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 / 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 / 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
@hongkongkiwi
hongkongkiwi / nz-routes.ovpn
Last active January 13, 2016 17:05
OpenVPN Routes
# Do not pull default route
route-nopull
@hongkongkiwi
hongkongkiwi / download-trust-cert.sh
Last active January 24, 2016 17:28
This script downloads a public certificate from a remote server over SSH and then adds it to the local trust store.
#!/bin/bash
REMOTE_CRT="/etc/ssl/certs/squidCA.crt"
REMOTE_URL="root@192.168.20.1"
FILENAME=`basename "$REMOTE_CRT"`
LOCAL_CRT="/tmp/$FILENAME"
KEYCHAIN="$HOME/Library/Keychains/login.keychain"
# More information about this here:
# http://lists.apple.com/archives/macos-x-server/2008/Feb/msg00187.html
SECURITY_TYPE="trustAsRoot"
@hongkongkiwi
hongkongkiwi / mount_remote
Last active January 28, 2016 14:11
A nice friendly script for mounting a remote linux directory on demand.
#!/bin/bash
VOLUME_NAME="LinuxServer"
REMOTE_USER=`whoami`
REMOTE_SERVER="xx.xx.xx.xx"
MOUNT_DIR="$HOME/$VOLUME_NAME"
REMOTE_DIR="/home/$REMOTE_USER"
SSH_KEY="$HOME/.ssh/id_rsa"
TIMEOUT=5
@hongkongkiwi
hongkongkiwi / import-blacklist-categories.sh
Last active February 3, 2016 07:51
This is a simple script to import many (millions!) of entries from a blacklist file into redis. It first generates the file using redis mass import format, then it pipes that into redis for super fast importing.
#!/bin/bash
FILE="CATEGORIES"
REDIS_KEY="categories"
while read line; do
category=`echo "$line" | cut -f1 -d'-'`
description=`echo "$line" | cut -f2 -d'-'`
redis-cli hset "$REDIS_KEY" "$category" "$description"
done < "$FILE"
var request = require('request');
var url1 = 'http://vanamco.com/ghostlab/';
//var url = 'http://httpbin.org/get';
var proxyUrl = 'http://127.0.0.1:3128';
var proxiedRequest = request.defaults({'proxy': proxyUrl});
console.log('Making a test request to',url1);
proxiedRequest(url1, function (error, response, body) {