Skip to content

Instantly share code, notes, and snippets.

View ivan-loh's full-sized avatar
🍌
Chilling

Ivan Loh ivan-loh

🍌
Chilling
View GitHub Profile
@ivan-loh
ivan-loh / install_java.sh
Last active August 29, 2015 14:07
install_java.sh
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections
sudo apt-get install oracle-java8-installer
sudo apt-get install git maven htop
@ivan-loh
ivan-loh / install_tokumx.sh
Created October 10, 2014 20:39
TokuMX 2.0.0 Community Edition for MongoDB, 64-bit Linux
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-key 505A7412
echo "deb [arch=amd64] http://s3.amazonaws.com/tokumx-debs $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/tokumx.list
sudo apt-get update
sudo apt-get install tokumx
sudo add-apt-repository -y ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install gcc make build-essential nodejs
@ivan-loh
ivan-loh / .bashrc_custom
Last active August 29, 2015 14:07
my osx .bashrc_custom
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/opt/go/libexec/bin
export PATH=$PATH:$GOPATH/bin
_type=$(uname -s)
# BSD Date
if [ "$_type" = "Darwin" ]; then
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
fi
@ivan-loh
ivan-loh / traverse.js
Last active August 29, 2015 14:07
function to go thru every single values in a json object
function traverse() {
var prop, addr, value,
doc = arguments['0'],
parent = arguments['1'],
func = arguments['2'];
if (typeof parent === "function") {
func = parent;
parent = undefined;
@ivan-loh
ivan-loh / install_nginx.sh
Created November 10, 2014 14:27
install_nginx.sh
sudo -s
nginx=stable # use nginx=development for latest development version
add-apt-repository ppa:nginx/$nginx
apt-get update
apt-get install nginx
@ivan-loh
ivan-loh / gist:0a3752d8857c29c20f9a
Created March 21, 2015 16:12
Getting 0.10.x versions of nodejs
#!/bin/bash
# Gettings 0.10.x versions of nodejs
brew tap homebrew/versions
brew search node
brew install node010
brew link --overwrite node010
@ivan-loh
ivan-loh / gist:1d3e6c61c9353c561471
Created May 5, 2015 18:23
MongoDB Aggregation equivalent of SQL SELECT COUNT(DISTINCT FieldName) FROM ColletionName
db.CollectionNameHere.aggregate([
{ $group: { _id: "$FieldNameHere"} },
{ $group: { _id: 1, count: { $sum: 1 } } }
], { allowDiskUse: true })
@ivan-loh
ivan-loh / gist:b5052c2bcbcf6a6b81f0
Created June 18, 2015 18:16
Decoding base64 encoding with command line
base64 --decode --input infilename --output outfilename
@ivan-loh
ivan-loh / eventbus.js
Created July 2, 2015 20:25
simple javascript event bus for handling lots of stuff
var EventBus = (function () {
var topics = {};
return {
subscribe: function (topic, listener) {
if (!topics[topic]) {
topics[topic] = [];
}
topics[topic].push(listener);
},