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
@mlsaito
mlsaito / base64.txt
Last active May 22, 2018
Convert strings to Base64 encoding in MacOS using OpenSS
View base64.txt
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 / portfolio-setup.md
Last active Jun 15, 2018
Deploy Static Files to Google App Engine using Python (Always Free Tier!)
View portfolio-setup.md

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).
@mlsaito
mlsaito / docker-cheatsheet.md
Last active Jun 14, 2018
Docker Cheatsheet
View docker-cheatsheet.md

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 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: 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 Jun 16, 2018
Find and kill processes listening on a port
View find_and_kill.md

Find processes listening on a port:

$ lsof -i :3000

Kill process:

$ kill -9 <PID>
@mlsaito
mlsaito / curl_sheetsheet.md
Last active Jun 18, 2018
cURL Cheatsheet
View curl_sheetsheet.md

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 / ssl_version.md
Last active Jun 3, 2019
Specify SSL version (TLS 1.2) on HTTParty - a Ruby client library
View ssl_version.md

Implementation

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('http://api.stackexchange.com/2.2/questions?site=stackoverflow', ssl_version: :TLSv1_2)
@mlsaito
mlsaito / kubectl-cheatsheet.md
Last active Aug 21, 2018
kubectl Cheat Sheet
View kubectl-cheatsheet.md

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 <namespace_name> -it <pod_name> -- bash
@mlsaito
mlsaito / tunnel.md
Created Aug 14, 2018
SSH into ElastiCache - Redis
View tunnel.md

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 127.0.0.1 -p 6379
@mlsaito
mlsaito / cheatsheet.md
Last active Aug 21, 2018
Git Cheatsheet
View cheatsheet.md

Fix Previous Commits

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

Cherry Picking

You can’t perform that action at this time.