Skip to content

Instantly share code, notes, and snippets.

View alvinlai's full-sized avatar

Alvin Lai alvinlai

  • Mountain View, CA
View GitHub Profile
@alvinlai
alvinlai / Vagrantfile
Created September 24, 2013 14:48 — forked from zekus/Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.define :dokku do |dokku|
dokku.vm.box = "raring64"
dokku.vm.box_url = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box"
dokku.vm.network :private_network, ip: "192.168.33.10"
dokku.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
@alvinlai
alvinlai / gist:6405317
Created September 1, 2013 15:52
quickly go back up to a specific folder in a directory tree
function bd () {
OLDPWD=`pwd`
NEWPWD=`echo $OLDPWD | sed 's|\(.*/'$1'[^/]*/\).*|\1|'`
index=`echo $NEWPWD | awk '{ print index($1,"/'$1'"); }'`
if [ $index -eq 0 ] ; then
echo "No such occurrence."
else
echo $NEWPWD
cd "$NEWPWD"
fi
module ApplicationHelper
# ==== Examples
# glyph(:share_alt)
# # => <i class="icon-share-alt"></i>
# glyph(:lock, :white)
# # => <i class="icon-lock icon-white"></i>
def glyph(*names)
content_tag :i, nil, class: names.map{|name| "icon-#{name.to_s.gsub('_','-')}" }
end
@alvinlai
alvinlai / how-the-internet-began.md
Created June 28, 2013 21:57
How the internet began

In ancient Israel , it came to pass that a trader by the name of Abraham Com did take unto himself a young wife by the name of Dorothy.

Dot Com was a comely woman, broad of shoulder and long of leg. Indeed, she was often called Amazon Dot Com.

And she said unto Abraham, her husband, "Why dost thou travel so far from town to town with thy goods when thou canst trade without ever leaving thy tent?"

$ cat foo | col -b > foo2
export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h: \[\e[33m\]\w\[\e[0m\]\n\$ '
$stack, $draws = [], {}
def method_missing *args
return if args[0][/^to_/]
$stack << args.map { |a| a or $stack.pop }
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :<
end
class Array
def +@

Install Rails 3.1

gem install rails

generate new app, skipping Test::Unit file generation

rails new my_app -T

Set up Gemfile

@alvinlai
alvinlai / .tmux.conf
Created March 15, 2013 18:05
My tmux config, changes prefix key from C-b to C-t so it won't interfere with emacs bindings, enables mouse mode
# restart tmux by:
# $ tmux kill-server
unbind C-b
set -g prefix C-t
bind C-t send-prefix
set-option -g mouse-select-pane on
set-option -g mouse-select-window on
set-window-option -g mode-mouse on
#!/usr/bin/env bash
apt-get -y update
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline5-dev libyaml-dev
cd /tmp
wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p125.tar.gz
tar -xvzf ruby-1.9.3-p125.tar.gz
cd ruby-1.9.3-p125/
./configure --prefix=/usr/local
make
make install