Skip to content

Instantly share code, notes, and snippets.

View terrywang's full-sized avatar

Terry Wang terrywang

View GitHub Profile
@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;
}
}
@terrywang
terrywang / nginx.conf
Last active July 28, 2022 23:29
Nginx config file template for self-hosted personal site on Fedora, Ubuntu, Debian and Arch Linux
# 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
terrywang / config
Last active October 13, 2022 20:39
Secure Enhanced ~/.ssh/config OpenSSH client per-user configuration file
# 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
# Github needs diffie-hellman-group-exchange-sha1 some of the time but not always
# Host github.com
# KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1
@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 / .bashrc
Last active December 6, 2023 08:52
Bash 5.2.x dot files for Linux and macOS, extracted from Ubuntu which by default does NOT use $HOME/.bash_profile for interactive login shells.
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
# [ -z "$PS1" ] && return
case $- in
*i*) ;;
*) return;;
esac