Skip to content

Instantly share code, notes, and snippets.

View terrywang's full-sized avatar

Terry Wang terrywang

View GitHub Profile

Keybase proof

I hereby claim:

  • I am terrywang on github.
  • I am terrywang (https://keybase.io/terrywang) on keybase.
  • I have a public key whose fingerprint is CB3E C2DC AD18 0C78 731E C034 00D8 3189 AB6C 9CA3

To claim this, I am signing this object:

@terrywang
terrywang / dumpAccountImage.sh
Last active March 26, 2017 10:04
Extract / dump Mac OS X user account picture using dscl (Directory Service command line utility) and convert (hexdump into binary) it to to a JPEG file. NOTE: The resolution can vary depending on the original size of the photo and what version of the operating system you're using when it is saved.
dscl . -read /Users/username JPEGPhoto | tail -1 | xxd -r -p > /path/to/accountImage.jpg
@terrywang
terrywang / jdk.sh
Last active March 27, 2019 05:33
Oracle JDK Download Script, the magic cookie comes from oab-java6 ;-) It **ONLY** works for latest Oracle JDK 7 and 8 update releases.
#!/bin/bash
# --------------------------------------
#
# Title: Oracle JDK Download Script
# Author: Terry Wang
# Email: i (at) terry (dot) im
# Homepage: http://terry.im
# File: jdk.sh
# Created: 28 August, 2013
#
@terrywang
terrywang / Berkshelf
Last active October 25, 2019 23:20
Vagrantfile sample for Vagrant, the following plugins are required: vagrant-berkshelf, vagrant-omnibus, vagrant-proxyconf, vagrant-vbguest, vagrant-proxyconf. Berksfile defines cookbooks and their dependencies. Run berks install to install cookbooks and dependencies.
site :opscode
cookbook 'nginx', '~> 2.4.4'
@terrywang
terrywang / gist:50230273cf93d24eae363ab36584150b
Created August 29, 2020 12:07
terrywang@github keys.pub
BEGIN MESSAGE.
kb9gwzCN54guTDZ nRzTyPdnlMNA3qX NsJya3Xx0fUvqrX Vd90YV82h6Y7GJF
sumxMqfA9HmjTij JlQ2T8y8HjaTCKq 6Xr2MZHgg6Sdxkm kC9iG2QUd2xL5A8
Xos3qZmbvQqWVLB WyGeiAPgJWM8t0K LkygSwAlkXDHrTJ QbGfAXkSywRXkTZ
CNpuUkfztYMa2Jo hZIjTbpdxMb4cIj 3E2iO29HFxl.
END MESSAGE.
@terrywang
terrywang / vimcasts.sh
Last active May 19, 2021 15:46
Vimcasts screencasts download bash one-liner - please support Drew Neil if possible e.g. buy Practical Vim ;-D
for (( i=1; i<=76; i++ )); do file=$(curl -s http://media.vimcasts.org/videos/$i/ | grep m4v | awk '{ print $5 }' | cut -d'>' -f2 | cut -d'<' -f1); url=http://media.vimcasts.org/videos/$i/$file; echo $url; wget -c -S -O "$c-$file" "$url"; done
@terrywang
terrywang / .tmux.conf
Last active January 26, 2022 12:26
~/.tmux.conf
# /home/terrywang/.tmux.conf
# Based on tmux book written by Brian P. Hogan
# c-a o to switch to another panel
# c-d to close shell
# c-a ! to close panel
# c-a w to list windows
# c-a " split pane horizontally
# c-a % split pane vertically
# Setting the prefix from C-b to C-a
@terrywang
terrywang / config
Last active February 1, 2022 09:03
~/.ssh/config behind firewall (ssh via HTTP proxy) and faster session creation by reusing already established connection
# User ssh configuration file ~/.ssh/config
# Gist https://gist.github.com/terrywang/3997931
# man ssh_config for more information
# Inspired by the blog post below to fight the NSA
# https://stribika.github.io/2015/01/04/secure-secure-shell.html
# Outside of the firewall, with HTTPS proxy
# Package connect-proxy is required.
# Amazon EC2
@terrywang
terrywang / ssh_config
Created March 6, 2022 22:42
Using AWS SSM for SSH Dynamic Forwarding so as to access services in private subnet
Host ssm-tatooine
ProxyCommand sh -c "aws ssm start-session --target <instance id> --region <region> --document-name AWS-StartPortForwardingSession --parameters '{\"portNumber\":[\"22\"],\"localPortNumber\":[\"22222\"]}'"
Host dynamic-forwarding
Hostname localhost
user terry
IdentityFile ~/.ssh/r2d2_ed25519
Port 22222
UserKnownHostsFile /dev/null
DynamicForward 1080
@terrywang
terrywang / nginx.conf
Created July 28, 2022 21:48
Nginx Configuration for Pi-hole
server {
listen 80 default_server;
# listen [::]:80 default_server;
root /var/www/html;
server_name _;
autoindex off;
index pihole/index.php index.php index.html index.htm;
error_page 404 pihole/index.php;