Skip to content

Instantly share code, notes, and snippets.

View terrywang's full-sized avatar

Terry Wang terrywang

View GitHub Profile
@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 / gist:74d1617600dfc7c2fb4c6365c60b09db
Last active November 30, 2023 02:47
Bash history HISTFILE deduplication while preserving order
# backup HISTFILE
cp ~/.bash_history{,.bak}
# deduplicate - deprecated
nl ~/.bash_history.bak | sort -k2,2 -k1,1nr | uniq -f1 | sort -k1,1n | cut -f2 > ~/.bash_history
# dedupelicate
cp ~/.bash_history{,.bak-$(date -I)}
tac $HISTFILE | awk '!x[$0]++' | tac | sponge $HISTFILE
@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;
@terrywang
terrywang / nginx.conf
Created July 28, 2022 23:28
Nginx config for log.terry.im
server {
listen 80;
# listen [::]:80 default ipv6only=on;
server_name log.terry.im;
# redirect all HTTP requests to HTTPS with a 301 Moved Permanently response
location / {
return 301 https://$host$request_uri;
}
}