Git Product home page Git Product logo

lazy-bash's Introduction

lazy-bash

Lazy bash belong here

TODO

Random topics

Kill port ower

Kill testrpc that use 8545

lsof -t -i tcp:8545 | xargs kill

Multiple line .env

DO_OPTION=$(cat <<EOF
'{
  "name": "My-Droplet",
  "region": "nyc2",
  "size": "512mb",
  "image": "ubuntu-14-04-x64"
}'
EOF)

To see macOS power consumtion

system_profiler SPPowerDataType

Read .env

# Create some .env
echo "FOO=123" > .env

# Use it
source .env; echo $FOO

Creating a self-signed ssl cert

# Create cert.key and cert.pem for a certificate that is valid for the next 10 years.
openssl req -x509 -newkey rsa:4086 \
-keyout key.pem -out cert.pem \
-days 3650 -nodes -sha256

Output to file

  • > or 1> Redirects stdout to file.
  • 2> Redirects stderr to file.
  • &> Redirects stdout and stderr to file.
  • /dev/null is a blackhole.
  • echo $'export NVM_DIR="$HOME/.nvm"\n. "/usr/local/opt/nvm/nvm.sh"' >> ~/.bash_profile

Add SSH to server

# Config
export [email protected]
export SSH_PUBKEY=~/.ssh/id_rsa.pub

# Add
ssh $SERVER sh -c "'cat >> .ssh/authorized_keys'" < $SSH_PUBKEY

# Verify
ssh $SERVER cat .ssh/authorized_keys

Fix Host key verification failed.

To fix WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

ssh-keygen -R YOUR_HOST_IP_OR_DOMAIN

Replacement

Repace $FOO with BAR

src='Hello $FOO'
match='$FOO'
repl='BAR'
echo ${src/$match/$repl}
# Hello BAR

Replace template file with ENV

# Create template
echo "Hello {{FOO}}" > foo.conf.tmpl

# Replace {{FOO}} with FOO variable and output to new foo.conf file 
sed -e "s|{{FOO}}|$FOO|g" foo.conf.tmpl > foo.conf

# Multiple replacement
sed -e "s|{{FOO}}|$FOO|g;s|{{BAR}}|$BAR|g" foo.conf.tmpl > foo.conf

lazy-bash's People

Contributors

katopz avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.