Skip to content

Instantly share code, notes, and snippets.

View liangzan's full-sized avatar

Wong Liang Zan liangzan

View GitHub Profile
@liangzan
liangzan / gist:2390681
Created April 15, 2012 07:11
require profiler line
var profiler = require('notifymode-client').Profiler;
@liangzan
liangzan / gist:2390682
Created April 15, 2012 07:12
profile line
var pio = profiler.profile(io);
@liangzan
liangzan / org-mode-line-wrap.el
Created June 16, 2012 03:33
emacs org mode line wrapping
;; add this to your emacs.d
;; wraps the lines in org-mode
(setq org-startup-truncated nil)
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 / 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;
@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 / 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 / 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 / fail2ban_configuration.md
Last active January 2, 2016 19:09
Configuration for fail2ban

First install Fail2ban.

sudo apt-get install fail2ban

Then edit the configuration file at /etc/fail2ban/jail.conf

We are only showing the changed sections.

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
module Main where
import Keys (oneDriveKey)
import Network.OAuth.OAuth2
import Control.Monad (liftM)
import Data.Aeson (FromJSON)