Skip to content

Instantly share code, notes, and snippets.

View Zhengquan's full-sized avatar

Zhengquan Zhengquan

  • ThoughtWorks
  • Beijing
View GitHub Profile
@Zhengquan
Zhengquan / rb_workshop.rb
Created July 29, 2016 00:06
code snippet for ruby workshop
# Everything in Ruby is - Object
class People
attr_accessor :name, :gender, :race, :nationality
def initialize(name='', gender='', race='', nationality='')
@name = name
@gender = gender
@race = race
@nationality = nationality
@Zhengquan
Zhengquan / spec_helper.rb
Last active July 27, 2016 05:53 — forked from hartmantis/spec_helper.rb
ChefSpec stubs for testing a recipe in isolation with new syntax
module IncludeRecipeHelper
def global_stubs
# Don't worry about external cookbook dependencies
allow_any_instance_of(Chef::Cookbook::Metadata).to receive(:depends)
# Test each recipe in isolation, regardless of includes
@included_recipes = []
allow_any_instance_of(Chef::RunContext).to receive(:loaded_recipe?).and_return(false)
@Zhengquan
Zhengquan / instance_b_info.log
Last active March 23, 2016 07:54
Logs for EventStore instance B
[PID:05828:013 2016.03.22 09:08:42.948 INFO Application ] Exiting with exit code: 0.
Exit reason: Shutdown with exiting from process was requested.
[PID:05828:013 2016.03.22 09:08:42.917 INFO ClusterVNodeControll] ========== [10.10.13.102:2113] IS SHUT DOWN!!! SWEET DREAMS!!!
[PID:05828:009 2016.03.22 09:08:42.480 TRACE InMemoryBus ] SLOW BUS MSG [SubscriptionsBus]: BecomeShuttingDown - 62ms. Handler: SubscriptionsService.
[PID:05828:013 2016.03.22 09:08:42.449 INFO ClusterVNodeControll] ========== [10.10.13.102:2113] All Services Shutdown.
[PID:05828:013 2016.03.22 09:08:42.449 INFO ClusterVNodeControll] ========== [10.10.13.102:2113] Service 'Storage Chaser' has shut down.
[PID:05828:013 2016.03.22 09:08:42.433 INFO ClusterVNodeControll] ========== [10.10.13.102:2113] Service 'Master Replication Service' has shut down.
[PID:05828:013 2016.03.22 09:08:42.418 TRACE GossipServiceBase ] CLUSTER HAS CHANGED (TCP connection lost to [10.10.13.101:2116])
Old:
VND {625acf3f-d4cb-474f-b8f4-e3f1
@Zhengquan
Zhengquan / instance_c_info.log
Last active March 23, 2016 07:55
EventStore Instance C
[PID:1071684:030 2016.03.22 09:11:54.109 TRACE QueuedHandlerThreadP] SLOW QUEUE MSG [MonitoringQueue]: GetFreshStats - 327ms. Q: 10/18.
[PID:1071684:011 2016.03.22 09:11:54.093 DEBUG ClusterVNodeControll] There is NO MASTER or MASTER is DEAD according to GOSSIP. Starting new elections. MASTER: [InstanceId: {c532c941-4817-4064-92f4-92ddcdde98fe}, InternalTcp: 10.10.13.101:2111, InternalSecureTcp: 10.10.13.101:2116, ExternalTcp: 147.42.14.100:2112, ExternalSecureTcp: 147.42.14.100:2115, InternalHttp: 10.10.13.101:2113, ExternalHttp: 147.42.14.100:2114].
[PID:1071684:011 2016.03.22 09:11:54.093 DEBUG ClusterVNodeControll] There is NO MASTER or MASTER is DEAD according to GOSSIP. Starting new elections. MASTER: [InstanceId: {c532c941-4817-4064-92f4-92ddcdde98fe}, InternalTcp: 10.10.13.101:2111, InternalSecureTcp: 10.10.13.101:2116, ExternalTcp: 147.42.14.100:2112, ExternalSecureTcp: 147.42.14.100:2115, InternalHttp: 10.10.13.101:2113, ExternalHttp: 147.42.14.100:2114].
[PID:1071684:011 2016.03.22 09:11:54.093
@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
@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 / 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 / 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 / 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 / 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