Skip to content

Instantly share code, notes, and snippets.

View manchunlam's full-sized avatar

Man Chun Lam manchunlam

View GitHub Profile
@manchunlam
manchunlam / en_to_zzzz.rb
Last active September 28, 2015 04:38
Change en.yml to Zoidberg's language
test_subject = {
abc: "foo",
bar: {
fox: { we: "es" }
},
foo: {
foobar: {
barfoo: "en",
usa: "f yeah",
uk: { queen: "save" }
@manchunlam
manchunlam / unicorn.rb
Last active September 28, 2015 13:08
Sample Unicorn Configuration File
# _*_ coding: utf-8 _*_
require 'yaml'
require 'erb'
# source: http://d.hatena.ne.jp/milk1000cc/20100804/1280893810
# Use at least one worker per core if you're on a dedicated server,
# more will usually help for _short_ waits on databases/caches
worker_processes 4
@manchunlam
manchunlam / nginx.conf
Last active September 28, 2015 13:08
Sample Nginx Configuration for Unicorn
#user nobody;
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
pid /usr/local/etc/nginx/logs/nginx.pid;
@manchunlam
manchunlam / background_positioner.js
Created January 19, 2012 16:01
Tommy's Module Pattern 1
var BackgroundPositioner = (function(){
var xVal = 0,
yVal = 0;
var getCoords = function(){
return xVal + "px " + yVal + "px";
},
setCoords = function(coords){
xVal = parseInt(coords[0]);
@manchunlam
manchunlam / script_ruby.rb
Created March 16, 2012 15:20
Unix-function-like Ruby Script
#!/usr/bin/env ruby
require 'getoptlong'
version = "0.0.1" # used by the --version or -v option handler
extract_f = false # set to true when --extract or -e are used
extract_args = [] # stores the list of arguments of --extract or -e
remove_f = false # set to true when --remove or -r are used
remove_args = [] # stores the list of arguments of --remove or -r
@manchunlam
manchunlam / scalr.rb
Last active October 2, 2015 01:58
Script for Common Scalr Tasks
#!/usr/bin/env ruby
require 'getoptlong'
KNIFE_SSH_OPT = '-x deploy -i ~/.ssh/id_rsa -a ec2.public_hostname'
VERSION = "1.1.0"
@project = ""
@env = "staging"
@instance_type = ""
@error_only = true
@manchunlam
manchunlam / fsevent_rsync.rb
Created August 8, 2012 15:56
Fire rsync if Changes are Detected in Directory
# source: http://pastebin.com/viMSaRh3
# Invoke rsync when there are changes in the current directory
# 1. Change to project root, `cd /Users/joelam/Projects/tabs`
# 2. Initial rsync local to VM, `rsync -avzi -e ssh . deploy@joelam.dev.cloud.vitrue.com:/home/deploy/Projects/Vitrue/tabs/`
# 3. Please place this file in project_root (e.g. /Users/joelam/Projects/tabs/)
# 4. Run the script by `ruby fsevent_rsync.rb`
# 5. Modify any file in directory
# 6. rsync is executed, modified files are copied to VM
@manchunlam
manchunlam / .rsyncignore
Created August 15, 2012 17:12
Sample .rsyncignore
.git
**.swp
.bundle
.DS_Store
.rspec
.sass-cache
.rvmrc
db/*.sqlite3
log/*.log
tmp/*
@manchunlam
manchunlam / .rsynckeep
Created August 15, 2012 17:12
Sample .rsynckeep
tmp/pids
tmp/sockets
@manchunlam
manchunlam / README.md
Last active October 11, 2015 04:08
Tabs Manual Install

Welcome to Tabs

Steps to Setting up your Tabs Development Environment

1. Setup Mac

On OS X,

  1. Install XCode

    If you are using XCode 4 and above, please also install Command Line Tools by