Skip to content

Instantly share code, notes, and snippets.

View mlsaito's full-sized avatar

Makoto Saito mlsaito

View GitHub Profile
@mlsaito
mlsaito / base64.txt
Last active May 22, 2018 02:56
Convert strings to Base64 encoding in MacOS using OpenSS
Encoding to Base64:
$ echo 'mako@ringcaptcha.com:samplePassword' | openssl base64
> bWFrb0ByaW5nY2FwdGNoYS5jb206c2FtcGxlUGFzc3dvcmQK
Decoding from Base64:
$ echo 'bWFrb0ByaW5nY2FwdGNoYS5jb206c2FtcGxlUGFzc3dvcmQK' | openssl base64 -d
> mako@ringcaptcha.com:samplePassword
@mlsaito
mlsaito / docker-cheatsheet.md
Last active June 14, 2018 12:25
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)
@mlsaito
mlsaito / get_users_info.bash
Last active June 14, 2018 12:32
Execute Redis commands via 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: https://stackoverflow.com/questions/4651437/how-to-set-a-variable-to-the-output-of-a-command-in-bash
@mlsaito
mlsaito / find_and_kill.md
Created June 16, 2018 13:06
Find and kill processes listening on a port

Find processes listening on a port:

$ lsof -i :3000

Kill process:

$ kill -9 
@mlsaito
mlsaito / curl_sheetsheet.md
Last active June 18, 2018 07:55
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
mlsaito / cheatsheet.md
Last active August 21, 2018 03:39
Git Cheatsheet

Fix Previous Commits

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

Cherry Picking

@mlsaito
mlsaito / kubectl-cheatsheet.md
Last active August 21, 2018 12:43
kubectl Cheat Sheet

Get a list of currently running Pod names:

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

SSH directly into a pod:

$ kubectl exec --namespace  -it  -- bash
@mlsaito
mlsaito / postgres-cheatsheet.md
Created November 5, 2018 06:21 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

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
mlsaito / kubectl-multi-version-brews.md
Created June 10, 2019 01:41 — forked from rdump/kubectl-multi-version-brews.md
kubectl multi-version brews

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
mlsaito / portfolio-setup.md
Last active April 15, 2023 12:16
Deploy Static Files to Google App Engine using Python (Always Free Tier!)

Deploy Static Files to Google App Engine using Python (Always Free Tier!)

By default, GAE (Google App Engine) supports Python as one of their default run time, which is always free!

Advantages of deploying static site to Google App Engine:

  1. It's always free! Google Cloud Platform provides always-free-tier for standard environment - hence Python!
  2. Free, auto-renewing SSL cert for custom domains.
  3. Direct traffic to instance instead of routing it through cloudflare for free cert.
  4. Makes deployment easier in just one line (using gcloud CLI tool).