Skip to content

Instantly share code, notes, and snippets.

View hongkongkiwi's full-sized avatar
🤓

Andy hongkongkiwi

🤓
View GitHub Profile
@hongkongkiwi
hongkongkiwi / stuns
Last active August 29, 2015 14:05 — forked from zziuni/stuns
Public STUN servers
# A list of available STUN server.
stun.l.google.com:19302
stun1.l.google.com:19302
stun2.l.google.com:19302
stun3.l.google.com:19302
stun4.l.google.com:19302
stun.ekiga.net
stun.ideasip.com
stun.iptel.org
#!/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://github.com/mongodb/mongo-c-driver.git
cd mongo-c-driver
./build/mci.sh --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
hongkongkiwi / redis-ip-update.sh
Last active January 9, 2017 08:31
Update Redis Config file with Private IP Address
#!/bin/bash
IP_ADDRESS=`ifconfig eth1 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`
sed -i "s/bind 127.0.0.1/bind ${IP_ADDRESS} 127.0.0.1/g" /etc/redis/redis.conf
@hongkongkiwi
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
#!/bin/bash
### BEGIN INIT INFO
# 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
### END INIT INFO
@hongkongkiwi
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 http://sourceforge.net/projects/filebot/files/filebot/HEAD/FileBot.jar/download -O /usr/share/filebot/FileBot.jar
sudo bash -c "cat <<EOT > /usr/share/filebot/bin/filebot.sh
#!/bin/sh
java -Dunixfs=false -DuseGVFS=false -DuseExtendedFileAttributes=false -Dfile.encoding=UTF-8 -Dsun.net.client.defaultConnectTimeout=10000 -Dsun.net.client.defaultReadTimeout=60000 -Dapplication.deployment=ipkg -Dapplication.analytics=true -Duser.home=/usr/share/filebot/data -Dapplication.dir=/usr/share/filebot/data -Djava.io.tmpdir=/usr/share/filebot/data/temp -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 \"\\\$@\"
EOT"
@hongkongkiwi
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.
#!/bin/bash
#
# AUTHOR: Andy Savage <andy@savage.hk>
# GITHUB: https://gist.github.com/hongkongkiwi/cfef6910c5c644eaebc9
# 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.
#
KEY_DIR="$HOME/signify-keys"
@hongkongkiwi
hongkongkiwi / fastest-server.sh
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.
#!/bin/bash
# INSTRUCTIONS
# After generating the OpenVPN server certificates, download and unzip then run this script in the same directory.
# Don't forget to chmod +x fastest-server.sh after downloading
#
# To test all servers with UK in the name
# sudo ./fastest-server.sh UK
# To test all servers with USA in the name
# sudo ./fastest-server.sh USA
@hongkongkiwi
hongkongkiwi / nz-routes.ovpn
Last active January 13, 2016 17:05
OpenVPN Routes
# Do not pull default route
route-nopull
@hongkongkiwi
hongkongkiwi / logout-user
Last active January 13, 2016 12:41
Simple bash script to logout a user from the terminal.
#!/bin/bash
USERNAME=$1
if [[ "$USERNAME" == "" ]]; then
echo "ERROR: No username specified!"
echo "USAGE: $0 <username>"
exit 1
fi