This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'rubygems' | |
require 'haml' | |
require 'erb' | |
require 'erubis' | |
notes = [] | |
20.times { notes << {:title => "标题标题", :content => "内容,内容"} } | |
obj = { |