Skip to content

Instantly share code, notes, and snippets.

View liangzan's full-sized avatar

Wong Liang Zan liangzan

View GitHub Profile
#!/usr/bin/env bash
# leaves 5 copies of the standalone app
total_files=$(find -name '*.jar' -type f -print0 | xargs -0 ls -t | wc -l)
file_num_to_remove=`expr $total_files - 5`
find -name '*.jar' -type f -print0 | xargs -0 ls -t | tail -n $file_num_to_remove | xargs rm
@liangzan
liangzan / error.md
Created September 6, 2013 00:11
level 1 error

Internal Server Error

The server has either erred or is incapable of performing the requested operation.

Traceback (most recent call last):
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
@liangzan
liangzan / pg_users_chef_recipe.rb
Last active December 15, 2015 18:59
pg_users_chef_recipe.rb
include_recipe "postgresql::server"
node[:notifymode][:db_users].each do |user|
execute "create-database-user" do
exists = <<-EOH
sudo -u postgres psql -U postgres -c "select * from pg_user where usename='#{user[:name]}'" | grep -c #{user[:name]}
EOH
command "echo \"CREATE ROLE #{user[:name]} with CREATEDB LOGIN PASSWORD '#{user[:password]}'\" | sudo -u postgres psql -U postgres"
not_if exists
end
@liangzan
liangzan / .tmux.conf
Created October 25, 2012 02:26
tmux configuration
## term
set -g default-terminal "screen-256color"
set -g default-shell /bin/zsh
## tmux window titling for X
set -g set-titles on
set -g set-titles-string '#W [#S:#I]'
setw -g automatic-rename on
## msgs
@liangzan
liangzan / readdir_recursive.js
Created August 10, 2012 09:34
Read directories recursively with Node.js
var fs = require('fs')
, async = require('async')
, _ = require('underscore');
/**
* Utility - for functions that do not belong anywhere
*
* @namespace - utility
*/
var utility = exports;
<?php
/**
* Sample to use Courex XML Technical Guide
*
* How to use:
* Search for "//input" and fill in the data accordingly
*
* @author Tao Yueling <yueling@courex.com.sg>
* @copyright 2014 Courex Pte Ltd
* @version 1.0.0
require 'oauth'
require 'httparty'
require 'etsy'
url = "http://openapi.etsy.com/v2/users/__SELF__"
access_token = "ae84c7ab4ad4b970b1c7ec9ae13fe5"
access_secret = "54116787c5"
etsy_api_key = "akymywrst9yajht2a81756vd"
etsy_shared_secret = "fmj4dgt1lw"
user_id = "18053491"
@liangzan
liangzan / gist:2390682
Created April 15, 2012 07:12
profile line
var pio = profiler.profile(io);
@liangzan
liangzan / gist:2390681
Created April 15, 2012 07:11
require profiler line
var profiler = require('notifymode-client').Profiler;
@liangzan
liangzan / app.js
Created April 15, 2012 07:10
example socket.io app with notifymode profiler
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs');
var profiler = require('notifymode-client').Profiler;
app.listen(3000);
function handler (req, res) {
fs.readFile(__dirname + '/index.htm',