Skip to content

Instantly share code, notes, and snippets.

View zhaocai's full-sized avatar
🤨
I may be slow to respond.

Zhao Cai zhaocai

🤨
I may be slow to respond.
View GitHub Profile
set nocompatible
let $VIMHOME = $HOME . '/.vim'
set runtimepath=$VIMRUNTIME,$VIMHOME,$VIMHOME/after
let g:bundle_home = expand($VIMHOME . '/bundle')
if has('vim_starting')
exec 'set runtimepath+=' . g:bundle_home . '/neobundle.vim/'
endif
# #!/usr/bin/ruby
# -- env -- [[[1 -------------------------------------------------------------
snippet shebang
abbr #!/usr/bin/env ruby
prev_word '^'
#!/usr/bin/env ${1:ruby}
# -*- coding: utf-8 -*-
${2}
{'Fb': {'word': 'Fb', 'options': {'word': 0, 'indent': 0, 'head': 0}, 'snip': 'Factory.build(:${1:factory})${2}', 'description': 'Factory.build(:${1:factory})${2}', 'action__path': '/Users/zhaocai/.vim/bundle/neco-snip/snip/ruby/factory_girl.snip', 'action__line': 24, 'menu_template': '[nsnip] Factory.build(:${1:factory})${2}', 'real_name': 'Fb', 'action__pattern': '^snippet\s\+Fb$', 'menu_abbr': 'Factory.build(:${1:factory})${2}'}, 'yD': {'word': 'yD', 'options': {'word': 0, 'indent': 0, 'head': 1}, 'snip': 'File.open(${1:TARGET}, "wb") { |f| YAML::dump(${2:object}, f)}', 'description': 'File.open(${1:TARGET}, "wb") { |f| YAML::dump(${2:object}, f)}', 'action__path': '/Users/zhaocai/.vim/bundle/neco-snip/snip/ruby/ruby.snip', 'action__line': 455, 'menu_template': '[nsnip] File.open(${1: }, "wb") { |f| YAML::dump(${2:object}, f)}', 'real_name': 'yamlDump', 'action__pattern': '^snippet\s\+yamlDump$', 'menu_abbr': 'File.open(${1: }, "wb") { |f| YAML::dump(${2:object}, f)}'}, 'Fd': {'word': 'Fd', 'options': {'wo

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@zhaocai
zhaocai / facets-margin.rb
Created April 5, 2013 07:18
`rb output margin
require 'facets'
x = %Q{
| This
| is
| margin controlled!
}.margin
puts x
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@zhaocai
zhaocai / Objective-C to MacRuby method translate
Created November 28, 2012 00:19 — forked from ryecroft/Objective-C to MacRuby method translate
Ruby script to translate Objective-C method calls into MacRuby
#!/usr/bin/env ruby
# Translates an objective C method call on the pasteboard,
# as copied from the docs, into MacRuby syntax, placing it
# back on the pasteboard.
# @example
# '+ (NSColor *)colorWithCalibratedRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha'
# => 'colorWithCalibratedRed(red, green:green, blue:blue, alpha:alpha)'
string = `pbpaste`
@zhaocai
zhaocai / vimshell_rc.vim
Created September 8, 2012 16:36
vim` quick eval current selected lines with vimshell interactive shell
command! -range Ieval :<line1>,<line2>call EvalScriptRegion()
vnoremap <silent> <CR> :Ieval<CR>
function! EvalScriptRegion() range
if has_key(g:vimshell_interactive_interpreter_commands, &ft)
exec a:firstline.','a:lastline.'VimShellSendString'
else
exec a:firstline.','a:lastline.'QuickRun'
endif
@zhaocai
zhaocai / colortrans.py
Created August 28, 2012 13:17 — forked from MicahElliott/colortrans.py
Convert values between RGB hex codes and xterm-256 color codes.
#! /usr/bin/env python
""" Convert values between RGB hex codes and xterm-256 color codes.
Nice long listing of all 256 colors and their codes. Useful for
developing console color themes, or even script output schemes.
Resources:
* http://en.wikipedia.org/wiki/8-bit_color
* http://en.wikipedia.org/wiki/ANSI_escape_code
@zhaocai
zhaocai / context.rb.diff
Created August 16, 2012 23:47
vdebug patch
diff --git a/rubylib/rdbgp/commands/context.rb b/rubylib/rdbgp/commands/context.rb
index 000869c..7a28b45 100644
--- a/rubylib/rdbgp/commands/context.rb
+++ b/rubylib/rdbgp/commands/context.rb
@@ -41,6 +41,7 @@ module Debugger
sc = @state.context
propInfo = processor.propInfo
stackDepth = get_adjusted_stack_depth(processor, stackDepth)
+ processor.logger.debug("Adjusted stack depth: " + stackDepth.to_s)
the_binding = sc.frame_binding(stackDepth)