Skip to content

Instantly share code, notes, and snippets.

View jeffchao's full-sized avatar
:shipit:

Jeff Chao jeffchao

:shipit:
View GitHub Profile
@jeffchao
jeffchao / ssh-reverse-tunnel-bastion
Last active February 20, 2020 01:58
ssh reverse tunnel into bastion
ssh -t bastion -L localhost:port:remotehost:port
use jconsole, visualvm, zmc, etc.
-L [bind_address:]port:host:hostport
-L [bind_address:]port:remote_socket
-L local_socket:host:hostport
-L local_socket:remote_socket
Specifies that connections to the given TCP port or Unix socket on the local (client) host are to be forwarded to the given host and port, or Unix
socket, on the remote side. This works by allocating a socket to listen to either a TCP port on the local side, optionally bound to the specified
bind_address, or to a Unix socket. Whenever a connection is made to the local port or socket, the connection is forwarded over the secure channel,
@jeffchao
jeffchao / docker-mac.sh
Last active February 7, 2017 18:16
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
docker-machine start
eval $(docker-machine env default)
docker ps
@jeffchao
jeffchao / scales
Created July 25, 2014 21:41
Programming scale
The full scale (which is explained) is:
10 - Wrote the book on it (there must be a book)
9 - Could have written the book, but didn't.
8 - Deep understanding of corner cases and esoteric features.
7 - Understanding and (appropriate) usage of most lesser known features.
6 - Can develop large programs and deploy new systems from scratch.
5 - Can develop/deploy larger programs/systems using all basic (w/o book) and more esoteric features (some w/ book, some without)
4 - Can develop/deploy medium programs/systems using all basic (w/o book) and a few esoteric features (w/ book). Understands enough about internals to do nontrivial troubleshooting.
3 - Can utilize basic features without much help, manage a small installation competently.
@jeffchao
jeffchao / clustering_columns
Created April 8, 2014 01:02
Cassandra ordering cluster columns
CREATE TABLE employees (company varchar, name varchar, age int, role varchar, primary key (company, name, age)) with clustering order by (name desc, age asc);
@jeffchao
jeffchao / nginx.conf
Last active August 29, 2015 13:57
nginx + node + ssl config
upstream foo_backend {
server 127.0.0.1:8080;
}
server {
listen 443 ssl;
ssl_certificate /etc/nginx/ssl/foo.com.bundle.crt;
ssl_certificate_key /etc/nginx/ssl/foo.com.key;
ssl_ciphers RC4:HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
@jeffchao
jeffchao / revert
Created October 11, 2013 08:06
Revert git head back to last known specific commit. Typically useful on bad merges.
// Reset the index to the desired tree.
git reset <specific sha>
// Move the branch pointer back to the previous HEAD.
git reset --soft HEAD@{1}
git commit
git push origin master
@jeffchao
jeffchao / show-git-branch
Last active May 27, 2023 09:26
Show git branches ordered by latest commit. Also by name and date.
# By commit hash
git for-each-ref --sort=-committerdate refs/heads/
# By name, date.
git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(authorname) %(refname:short)'
@jeffchao
jeffchao / git-branch-checkout
Created May 23, 2013 17:16
Checking out an existing git branch and not getting a "merge commit" when pulling.
# Get a list of existing remote branches
git fetch origin
# Checkout the branch from that branch
git checkout -b branch_name origin/branch_name
git pull origin branch_name
git push origin branch_name # yields 'Everything up-to-date'
@jeffchao
jeffchao / fix-deploy
Created May 21, 2013 22:31
Deploying octopress to github pages but then it says "Everything up-to-date"
rm -rf _deploy
mkdir _deploy
cd _deploy
git init
git remote add origin [email protected]:username/username.github.io.git
git pull origin master
cd ..
bundle exec rake deploy
@jeffchao
jeffchao / injectable.spec.js
Created March 29, 2013 06:58
Basic implementation of Array.prototype.inject() in Ruby-like method in Javascript
Array.prototype.myinject = function () {
var obj = Object(this);
var base;
var callback;
if (arguments.length === 2) {
base = arguments[0];
callback = arguments[1];
} else if (arguments.length === 1) {
callback = arguments[0];