Skip to content

Instantly share code, notes, and snippets.

View hongkongkiwi's full-sized avatar

Andy hongkongkiwi

View GitHub Profile
hongkongkiwi / stuns
Last active August 29, 2015 14:05 — forked from zziuni/stuns
Public STUN servers
# A list of available STUN server.
#!/usr/bin/env bash
sudo apt-get install gcc dpkg-dev cdbs automake autoconf libtool make libssl-dev libsasl2-dev git python-lxml pkg-config
git clone git://
cd mongo-c-driver
./build/ --notest --enable-ssl
cd ..
sudo dpkg --install libmongoc-*.deb libbson-*.deb
var moment = require('moment'),
crypto = require('crypto');
function getICEServerJSON(username) {
var ttl = 86400;
var expiry = moment().add(ttl, 'seconds').unix();
var usernameToken = expiry + ":" + username;
var secret = "mysupersecret";
var nonce = crypto.createHmac("sha1", secret).update(usernameToken).digest("base64");
hongkongkiwi /
Last active January 9, 2017 08:31
Update Redis Config file with Private IP Address
IP_ADDRESS=`ifconfig eth1 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v ''`
sed -i "s/bind ${IP_ADDRESS}" /etc/redis/redis.conf
hongkongkiwi / forever-init.d
Created November 17, 2014 09:56
Forever Init.d script which can be used with NVM and can also easily install itself on boot
# Provides: YOUR_NAME_HERE
# Required-Start: $local_fs $remote_fs $network $syslog $named
# Required-Stop: $local_fs $remote_fs $network $syslog $named
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop the forever nodejs application
hongkongkiwi / filebot-on-odroid
Last active March 25, 2016 19:32 — forked from Nerten/filebot-on-odroid
Installing filebot on odroid
sudo apt-get -y install openjdk-8-jre-headless mediainfo libchromaprint-tools
#Bug in ca-certificates-java
sudo /var/lib/dpkg/info/ca-certificates-java.postinst configure
sudo mkdir -p /usr/share/filebot/bin
sudo mkdir -p /usr/share/filebot/data
sudo wget -O /usr/share/filebot/FileBot.jar
sudo bash -c "cat <<EOT > /usr/share/filebot/bin/
java -Dunixfs=false -DuseGVFS=false -DuseExtendedFileAttributes=false -Dfile.encoding=UTF-8 -Dapplication.deployment=ipkg -Duser.home=/usr/share/filebot/data -Dapplication.dir=/usr/share/filebot/data -Djna.library.path=/usr/share/filebot -Djava.library.path=/usr/share/filebot -Dnet.sourceforge.filebot.AcoustID.fpcalc=/usr/bin/fpcalc -jar -Xmx400M /usr/share/filebot/FileBot.jar \"\\\$@\"
hongkongkiwi / sign-openwrt-packages
Last active November 7, 2017 04:20
Little script to sign OpenWRT packages after running a build. I used this because I couldn't figure out how to do it automatically when using the SDK.
# AUTHOR: Andy Savage <>
# PURPOSE: After building one or more packages in OpenWRT this script signs them with a key file
# this can then be easily used in opkg to verify signatures.
hongkongkiwi /
Last active January 13, 2016 09:39
Bash script to test a list of Astrill Servers and returns the one with the best ping. Currently only works for the TCP servers (I am open to a way to test UDP servers). Only tested on OSX, should work fine on linux too.
# After generating the OpenVPN server certificates, download and unzip then run this script in the same directory.
# Don't forget to chmod +x after downloading
# To test all servers with UK in the name
# sudo ./ UK
# To test all servers with USA in the name
# sudo ./ USA
hongkongkiwi / nz-routes.ovpn
Last active January 13, 2016 17:05
OpenVPN Routes
# Do not pull default route
hongkongkiwi / logout-user
Last active January 13, 2016 12:41
Simple bash script to logout a user from the terminal.
if [[ "$USERNAME" == "" ]]; then
echo "ERROR: No username specified!"
echo "USAGE: $0 <username>"
exit 1