Skip to content

Instantly share code, notes, and snippets.

View biti's full-sized avatar

liuzihua biti

View GitHub Profile
@biti
biti / haml_vs_erb_vs_erubis.rb
Created June 25, 2011 10:13
erb,erubis,haml的性能比较.结果:haml不靠谱
# encoding: utf-8
require 'rubygems'
require 'haml'
require 'erb'
require 'erubis'
notes = []
20.times { notes << {:title => "标题标题", :content => "内容,内容"} }
obj = {
@biti
biti / inject_sum_vs_normal_sum.rb
Created July 14, 2011 07:54
测试inject叠加
def benchmark(test_name)
start = Time.now
10000.times do
yield
end
seconds = Time.now - start
puts "%s time(s): %s" % [test_name, seconds]
end
@biti
biti / Capistrano tasks for starting unicorn.rb
Created September 7, 2011 03:26 — forked from vvalgis/Capistrano tasks for starting unicorn.rb
Capistrano tasks for starting unicorn
set :rails_env, :production
set :unicorn_binary, "/usr/bin/unicorn"
set :unicorn_config, "#{current_path}/config/unicorn.rb"
set :unicorn_pid, "#{current_path}/tmp/pids/unicorn.pid"
namespace :deploy do
task :start, :roles => :app, :except => { :no_release => true } do
run "cd #{current_path} && #{try_sudo} #{unicorn_binary} -c #{unicorn_config} -E #{rails_env} -D"
end
task :stop, :roles => :app, :except => { :no_release => true } do
@biti
biti / deploy.rb
Created September 11, 2011 02:47
自动部署脚本
# auto deploy script
# content: sync update all servers code, control unicorn servers and thin servers
# by liuzihua
default_environment["LC_CTYPE"] = "en_US.UTF-8"
# servers!
set :server1, "124.42.34.226"
set :server2, "124.42.34.238"
set :server3, "119.254.7.196"