Skip to content

Instantly share code, notes, and snippets.

@Steven-Chan
Last active March 11, 2021 04:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Steven-Chan/08fe0878b6ecab22bdfa00dae803ac46 to your computer and use it in GitHub Desktop.
Save Steven-Chan/08fe0878b6ecab22bdfa00dae803ac46 to your computer and use it in GitHub Desktop.
Everything

sh

Run cmd with env file

env $(cat .env | xargs) ${CMD}

GPG

decrypt data in cmd

cat | base64 -D | echo $(gpg2 -d)

git

delete merged branches

# local
git branch --merged | egrep -v "(^\*|main|staging)" | xargs git branch -d

# remote
git branch -r --merged | egrep -v "(^\*|main|staging)" | egrep stevenchan/ | sed 's/stevenchan\///' | xargs -n 1 -P 5 git push --delete stevenchan

docker

build a new image in terminal

cat | docker build -t ${IMAGE_NAME} -

run with docker image, mounting current dir

docker run -it --rm -v "$PWD":/usr/src/myapp -w /usr/src/myapp ${IMAGE_NAME} bash

serve static files

alias with-docker='docker run --rm -v "$PWD":/usr/src/app -w /usr/src/app'
with-docker -p 8080:8080 tjmehta/node-http-server http-server ${PATH} -p 8080

copy files from container to local

docker cp ${container_id}:${path_in_container} ${local_path}

kubernetes

Cheat sheet: https://kubernetes.io/docs/user-guide/kubectl-cheatsheet/

HTML/CSS

Flexbox

A Complete Guide to Flexbox

Zero-width space

https://stackoverflow.com/questions/26972529/is-there-a-html-character-that-is-blank-including-no-whitespace-on-all-browser

<span>&#8203;</span>

Custom font css

Upload ttf, and download css with other font format https://onlinefontconverter.com/

Javascript

code to ast

http://esprima.org/demo/parse.html

Sublime Text

Clear caches when stuck in reload dialog

rm ~/Library/Application\ Support/Sublime\ Text\ 3/Local/Auto\ Save\ Session.sublime_session
rm ~/Library/Application\ Support/Sublime\ Text\ 3/Local/Session.sublime_session

Fake mail server

https://mailtrap.io

AWS

SES + ACM cert + CloudFront

http://abyssluke.hatenablog.com/entry/2016/05/31/194946

SES mail receiving setup

http://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-verification.html

Gradle

dependency with git

https://jitpack.io/

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
dependencies {
    compile 'com.github.SkygearIO:skygear-SDK-Android:master-SNAPSHOT'
}

Python

Virtual env

virtualenv -p python3.6 env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment