Skip to content

Instantly share code, notes, and snippets.

View Zhengquan's full-sized avatar

Zhengquan Zhengquan

  • ThoughtWorks
  • Beijing
View GitHub Profile
@Zhengquan
Zhengquan / unicorn_init
Created November 10, 2011 13:51
A script to start unicorn at system boots
#! /bin/sh
# File: /etc/init.d/unicorn
prog="unicorn"
PATH=/usr/local/rvm/gems/ruby-1.9.2-p290/bin:/usr/local/rvm/gems/ruby-1.9.2-p290@global/bin:/usr/local/rvm/rubies/ruby-1.9.2-p290/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
DAEMON=`which unicorn_rails`
CONFIG_FILE=/var/www/magic/config/unicorn.rb
DAEMON_ARGS="$CONFIG_FILE"
APP_ROOT="/var/www/magic"
PID_FILE="$APP_ROOT/tmp/pids/unicorn.pid"
@Zhengquan
Zhengquan / resque_worker.markdown
Created February 3, 2012 16:33
resque_workers log file
*** got: (Job{statused} | SchedulerNotifyAccept | ["93772c701eb8012f0c9d723c91df8bf1", {}])
*** done: (Job{statused} | SchedulerNotifyAccept | ["93772c701eb8012f0c9d723c91df8bf1", {}])
*** got: (Job{statused} | SchedulerAcceptAnswer | ["937741001eb8012f0c9d723c91df8bf1", {}])
*** done: (Job{statused} | SchedulerAcceptAnswer | ["937741001eb8012f0c9d723c91df8bf1", {}])
*** Error reserving job: #
*** /prod/dev/magic/shared/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:170:in `rescue in read'
/prod/dev/magic/shared/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:161:in `read'
/prod/dev/magic/shared/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:46:in `block in call'
/prod/dev/magic/shared/bundle/ruby/1.9.1/gems/redis-2.2.2/lib/redis/client.rb:142:in `block (2 levels) in process'
@Zhengquan
Zhengquan / .tmux.conf
Created March 9, 2012 13:34
my .tmux.conf
set-option -g base-index 1
set-window-option -g mode-keys vi
set-option -g repeat-time 1000
set-option -g status-keys vi
set-option -g status-right "#(date +%H:%M' ')"
set-option -g status-right-length 10
set-option -g status-utf8 on
set-window-option -g utf8 on
@Zhengquan
Zhengquan / .vimrc
Created March 9, 2012 13:36
my vimrc
"Use Vim settings, rather then Vi settings (much better!).
"This must be first, because it changes other options as a side effect.
set nocompatible
"activate pathogen
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
"allow backspacing over everything in insert mode
set backspace=indent,eol,start
@Zhengquan
Zhengquan / data_export.txt
Created June 12, 2012 02:36
软妹子的福利
cid delist_time nick num_iid pic_url score post_fee price title volume  
1 1512 2012-6-12<span style='mso-spacerun:yes'> </span>15:34 全国老人机总代理 13466741306 http://img02.taobaocdn.com/bao/uploaded/i2/T1YqyCXoJZXXctv1sU_014357.jpg 14 0.01 100 关爱心GS88 大声 老年<span class=H>手机</span> 正品行货老人<span class=H>手机</span> 大字体大屏幕老人机 4835  
2 1512 2012-6-12<span style='mso-spacerun:yes'> </span>14:09 谷米科技 14458824581 http://img02.taobaocdn.com/bao/uploaded/i2/T1n9jXXeheXXahKRZ9_104443.jpg 13 0 100 老福多 F88 老人<span class=H>手机</span> 正品 行货 老年<span class=H>手机</span> 大字体 彩屏 老人机 5050  
3 1512 2012-6-15<span style='mso-spacerun:yes'> </span>10:37 诚亨通讯 16016896217 http://img02.taobaocdn.com/bao/uploaded/i2/T1SVu8XdXrXXbaYZA5_055214.jpg 12 0 848 Lenovo/联想 A750<span class=H>手机</span> 智能安卓 送1492话费 4.0纯净版 包邮顺丰 5783  
4 1512 2012-6-17<span style='mso-spacerun:yes'> </span>19:20 谷米科技 14025113760 http://img04.taobaocdn.com/bao/uploaded/i4/T1kSveXoVlXXbG_V3__105256.jpg 13 0.01 100 老人<span class=H>手机</span>正品行货 老人机 大字大屏 老年<span class=H>手机</sp
@Zhengquan
Zhengquan / profile.log
Created December 19, 2012 04:18
vim-profiling information
SCRIPT /Users/yangkit/.vim/janus/vim/langs/ruby/ftplugin/ruby.vim
Sourced 4 times
Total time: 0.010662
Self time: 0.010662
count total (s) self (s)
" Vim filetype plugin
" Language: Ruby
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" URL: https://github.com/vim-ruby/vim-ruby
@Zhengquan
Zhengquan / start_time.log
Created December 19, 2012 04:25
vim sart-time.log
times in msec
clock self+sourced self: sourced script
clock elapsed: other lines
000.024 000.024: --- VIM STARTING ---
000.266 000.242: Allocated generic buffers
000.643 000.377: locale set
000.701 000.058: GUI prepared
000.713 000.012: clipboard setup
000.736 000.023: window checked
@Zhengquan
Zhengquan / yield_and_instance_eval.rb
Last active December 27, 2015 05:49
There’s no reason that yield and instance_eval DSLs need to be mutually exclusive. Far from it! In Ruby we encourage options, and it’s actually quite easy to provide a way to yield OR instance_eval based on the block passed in:
class Page
attr_accessor :name
def initialize(&block)
if block_given?
if block.arity == 1
yield self
else
instance_eval(&block)
end
end
@Zhengquan
Zhengquan / integration-fixture.rb
Created December 19, 2014 17:32
demo to generate fixture data with factory_girl
require 'securerandom'
require 'factory_girl'
class Assignee
attr_accessor :first_name, :last_name
def to_s
"#{first_name} #{last_name}"
end
end
@Zhengquan
Zhengquan / instance_a_info.log
Last active March 23, 2016 11:59
Logs for EventStore instance A
[PID:07992:013 2016.03.22 09:10:58.165 TRACE GossipServiceBase ] CLUSTER HAS CHANGED (gossip received from [10.10.13.103:2113])
Old:
VND {625acf3f-d4cb-474f-b8f4-e3f1f71ccdac} <LIVE> [Slave, 10.10.13.103:2111, 10.10.13.103:2116, 147.42.14.102:2112, 147.42.14.102:2115, 10.10.13.103:2113, 147.42.14.102:2114] 88989307179/88989308153/88989308153/E264@88989095874:{4f60d64e-15af-4210-a061-670efc296af0} | 2016-03-22 09:10:57.059
VND {a4c1bdc0-2643-4512-b4b9-3a3d5c08cc4f} <DEAD> [Master, 10.10.13.102:2111, 10.10.13.102:2116, 147.42.14.101:2112, 147.42.14.101:2115, 10.10.13.102:2113, 147.42.14.101:2114] 88988811590/88988812753/88988812753/E257@88988805718:{16994d92-0059-494f-a5a7-80eff4f04316} | 2016-03-22 09:08:42.428
VND {c532c941-4817-4064-92f4-92ddcdde98fe} <LIVE> [Unknown, 10.10.13.101:2111, 10.10.13.101:2116, 147.42.14.100:2112, 147.42.14.100:2115, 10.10.13.101:2113, 147.42.14.100:2114] 88989307179/88989308257/88989308153/E264@88989095874:{4f60d64e-15af-4210-a061-670efc296af0} | 2016-03-22 09:10:57.868
New:
VN