Skip to content

Instantly share code, notes, and snippets.

Makoto Saito mlsaito

Block or report user

Report or block mlsaito

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

kubectl multi-version brews

We need to run multiple versions of kubectl for compatibility with various clusters.

It's a bit easier to get and use multiple versions of kubectl using Homebrew than it is using Macports.

With brew, it's simple to:

  • Install a bunch of versions of kubectl (in the kubernetes-cli Formula)
  • Switch between them as needed
mlsaito /
Created Nov 5, 2018 — forked from Kartones/
PostgreSQL command line cheatsheet


Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
mlsaito /
Last active Aug 21, 2018
Git Cheatsheet

Fix Previous Commits

$ git commit --fixup=8a465186
$ git rebase -i --autosquash 8a465186~1

Cherry Picking

mlsaito /
Created Aug 14, 2018
SSH into ElastiCache - Redis

Create a tunnel on your local:

$ ssh -f -N -L6379:<your redis node endpoint>:6379 <your EC2 node that you use to connect to redis> -i "key.pem"

Connect to redis exposed on your local:

$ redis-cli -h -p 6379
mlsaito /
Last active Aug 21, 2018
kubectl Cheat Sheet

Get a list of currently running Pod names:

$ kubectl get pods -o go-template --template '{{range .items}}{{}}{{"\n"}}{{end}}'

SSH directly into a pod:

$ kubectl exec --namespace <namespace_name> -it <pod_name> -- bash
mlsaito /
Last active Jun 3, 2019
Specify SSL version (TLS 1.2) on HTTParty - a Ruby client library


Some vendors require you to call their API via TLS 1.2 and I don't see that much documentation on how to do this.

2 ways to make an HTTP request using HTTParty:

  1. Directly calling Class method.
# Notice the `ssl_version` option, to specify ssl version of the HTTP request
response = HTTParty.get('', ssl_version: :TLSv1_2)
mlsaito /
Last active Jun 18, 2018
cURL Cheatsheet

cURL with Basic Authorization:

$ cURL -X POST -H "Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l" https://localhost:3000

cURL with username and password (pretty much same with Basic Auth):

$ curl -X POST -H "Content-Type: application/json" \
     --user "usernameorclient_id:passwordorclient_secret" \
mlsaito /
Created Jun 16, 2018
Find and kill processes listening on a port

Find processes listening on a port:

$ lsof -i :3000

Kill process:

$ kill -9 <PID>
mlsaito / get_users_info.bash
Last active Jun 14, 2018
Execute Redis commands via Bash
View get_users_info.bash
#!/usr/bin/env bash
#! This will output info to `users_info.csv`
echo "Getting info from Redis. . ."
redis-cli ping
for i in {1..29885}; do
#! as of 2018, we can use this: EMAIL=$(command) instead
#! Reference:
mlsaito /
Last active Jun 14, 2018
Docker Cheatsheet

Remove any stopped containers and all unused images (not just dangling images):

$ docker system prune -a

Stop all docker processes:

$ docker stop $(docker ps -a -q)
You can’t perform that action at this time.