Skip to content

Instantly share code, notes, and snippets.

View hwdsl2's full-sized avatar

Lin Song hwdsl2

View GitHub Profile
eagafonov /
Created March 14, 2016 12:33
[DigitalOcean] Simple script to route outgoing traffic through Floating IP
#!/bin/bash -x
set -e
shift || (echo "E: Destination IP is not provided. Aborting"; exit 1)
ANCHOR_GW=$(curl -s
m-ou-se / replace-debian-with-arch.txt
Last active October 22, 2023 12:16
Instructions to replace a live Debian installation with Arch
# Download latest archlinux bootstrap package, see
wget '*-x86_64.tar.gz'
# Make sure you'll have enough entropy for pacman-key later.
apt-get install haveged
# Install the arch bootstrap image in a tmpfs.
mount -t tmpfs none /mnt
cd /mnt
tar xvf ~/archlinux-bootstrap-*-x86_64.tar.gz --strip-components=1
BLOCKS=$(nslookup -q=TXT | awk -F "spf1 " '{print $2}' | sed -e "s/include:/\n/g" | sed -e "s/?all\"//g" | grep -v ^$)
echo "$BLOCKS" | while read block; do nslookup -q=TXT $block | awk -F "spf1 " '{print $2}' | sed -e "s/ip4:/\n/g" | sed -e "s/?all\"//g" |grep -v "^ip6:" | grep -v ^$; done ;
zqqf16 / IKEv2.mobileconfig
Last active February 28, 2023 22:57
strongSwan IKEv2 configurations for iOS without certificate
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
PurpleBooth /
Last active June 22, 2024 22:08
A template to make good

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.


4ft35t /
Last active March 8, 2016 07:43
ubuntu install modsecurity with nginx

fix APXS error

configure: error: couldn’t find APXS

ref1 ref2

n0531m /
Last active April 17, 2024 21:50
Google Cloud Platform : ip address range
# nslookup -q=TXT
for LINE in `dig txt +short | tr " " "\n" | grep include | cut -f 2 -d :`
for LINE2 in `dig txt $LINE +short | tr " " "\n" | grep include | cut -f 2 -d :`
darron / gist:811cf41a6ec3dbfcb97a
Created January 5, 2015 23:19
Get IP Ranges from EC2
# You need: curl, jq, and ipcalc to run this.
# You should already have cut, sort and uniq if you're on OS X or Linux.
RANGES=$(curl -s | jq .prefixes | jq '.[] | select(.region=="us-east-1")' | jq 'select(.service=="EC2")' | jq .ip_prefix | cut -d '"' -f 2 | sort | uniq)
for range in $RANGES
MIN=$(ipcalc -bn $range | grep "HostMin" | cut -d ':' -f 2)
othiym23 /
Created September 20, 2014 19:36
a safe way to upgrade all of your globally-installed npm packages
set -e
set -x
for package in $(npm -g outdated --parseable --depth=0 | cut -d: -f3)
npm -g install "$package"
pnommensen / gist:707b5519766ba45366dd
Last active February 18, 2024 21:52
Ghost CMS with NGINX for Maximum Performance

Full blog post can be found here:

Ghost is an open source platform for blogging founded by John O'Nolan and Hannah Wolfe. It's a node.js application and therefore works great in conjunction with nginx. This guide will will help you create a high performance nginx virtual host configuration for Ghost.

"Don't use #nodejs for static content" - @trevnorris. If #nginx isn't sitting in front of your node server, you're probably doing it wrong.

— Bryan Hughes (@nebrius) August 30, 2014
<script async src="//" charset="utf-8"></script>

The node.js application runs on a port on your server