aws s3 bucket create command for kops

$ aws s3api create-bucket --bucket ${CLUSTER_FULL_NAME}-state --region ap-northeast-1 --create-bucket-configuration LocationConstraint=ap-northeast-1

Encode to base64

$ echo -n "postgres" | base64

Add binary executable file to system path on Linux

# For example, kubectl
$ chmod +x ./kubectl
$ sudo mv ./kubectl /usr/local/bin/kubectl

Stop unicorn process

$ ps aux | grep 'unicorn' | awk '{print $2}' | xargs sudo kill -9

Add local SSH key to remote Authorized Keys

$ cat ~/.ssh/ | ssh -p your_port_num deploy@your_server_ip 'cat >> ~/.ssh/authorized_keys'

Rails - ActionView::Template::Error (Permission denied ...

sudo chgrp -R <USER> /path/to/rails/tmp
sudo chmod -R g+x /path/to/rails/tmp

Start python SimpleHTTPServer

$ echo "Hello, world!" > index.html
$ sudo python -m SimpleHTTPServer 80

Docker Pow Switch

# Stop PF and use Docker for Mac:
$ sudo pfctl -d
# Start PF and use Pow:
$ sudo pfctl -e

monitor network connections

sudo ss -ltp

MySQL import local file to DB

mysqlimport -u root -p --local <db_name> <file_name|table_name>

Download all url list in a file to a folder

cat file_url_list | xargs wget -P file_folder

Install Vim with brew

brew install vim --override-system-vim

Delete all docker containers && images

# Delete all containers
docker rm -f $(docker ps -a -q)
# Delete all images
docker rmi -f $(docker images -a -q)

Find the public IP address of the server

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Delete all *.swp files

find . -type f -name "*.swp" -delete

Stop rails server

kill -9 $(lsof -i tcp:3000 -t)