Skip to content

Instantly share code, notes, and snippets.


Terry Wang terrywang

View GitHub Profile
terrywang / gist:74d1617600dfc7c2fb4c6365c60b09db
Created Apr 10, 2021
Bash history HISTFILE deduplication while preserving order
View gist:74d1617600dfc7c2fb4c6365c60b09db
# backup HISTFILE
cp ~/.bash_history{,.bak}
# deduplicate
nl ~/.bash_history.bak | sort -k2,2 -k1,1nr | uniq -f1 | sort -k1,1n | cut -f2 > ~/.bash_history
View gist:50230273cf93d24eae363ab36584150b
kb9gwzCN54guTDZ nRzTyPdnlMNA3qX NsJya3Xx0fUvqrX Vd90YV82h6Y7GJF
sumxMqfA9HmjTij JlQ2T8y8HjaTCKq 6Xr2MZHgg6Sdxkm kC9iG2QUd2xL5A8
CNpuUkfztYMa2Jo hZIjTbpdxMb4cIj 3E2iO29HFxl.

Keybase proof

I hereby claim:

  • I am terrywang on github.
  • I am 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 / config
Last active Jul 16, 2020
Secure Enhanced ~/.ssh/config OpenSSH client per-user configuration file
View config
# User ssh configuration file ~/.ssh/config
# Gist
# man ssh_config for more information
# Inspired by the blog post below to fight the NSA
# Github needs diffie-hellman-group-exchange-sha1 some of the time but not always
# Host
# KexAlgorithms,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
terrywang /
Last active May 19, 2021
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$i/ | grep m4v | awk '{ print $5 }' | cut -d'>' -f2 | cut -d'<' -f1); url=$i/$file; echo $url; wget -c -S -O "$c-$file" "$url"; done
terrywang / nginx.conf
Last active May 10, 2021
nginx config file template for Fedora, Ubuntu, Debian and Arch Linux
View nginx.conf
# User and group used by worker processes
# ubuntu
# user www-data;
# fedora
user nginx;
# Ideally # of worker processes = # of CPUs or cores
# Set to auto to autodetect
# max_clients = worker_processes * worker_connections
worker_processes auto;
terrywang /
Created Feb 17, 2014
Java code backup ;-) To Compile: javac Usage: java Match <pattern> <text>
* The Match class implements Brute Force pattern matching.
* @author Terry Wang
* @version 0.2
public class Match {
/** variable to record the position of matching */
private static int position = 0;
terrywang / vcheck.c
Last active Aug 29, 2015
Check Linux VM hardware assisted virtualization type {Xen HVM,KVM,VMware}. Based on the C program written by
View vcheck.c
* Use CPUID opcode from EAX register to determine Linux VM Virtualization type {Xen HVM,KVM,VMware}
* Based on the c program written by ;-)
#include <stdio.h>
#include <string.h>
#define HYPERVISOR_INFO 0x40000000
#define CPUID(idx, eax, ebx, ecx, edx) \
terrywang / rsync.rb
Last active Nov 2, 2016
rsync Homebrew formula for OS X, with fileflags, crtimes and hfs-compression patches. May be merged to soon ;-)
View rsync.rb
require 'formula'
class Rsync < Formula
homepage ''
url ''
sha1 'eb58ab04bcb6293da76b83f58327c038b23fcba3'
depends_on :autoconf
def patches
terrywang / Berkshelf
Last active Oct 25, 2019
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.
View Berkshelf
site :opscode
cookbook 'nginx', '~> 2.4.4'