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
@zhaocai
zhaocai / LeapHere.applescript
Created August 7, 2011 07:06
Droplets for Leap app developed by www.ironicsoftware.com
(*
Droplet for Leap.app which is something it should provide. This droplet serves three functions:
1. drop files/folders to tag in leap
2. open the current folder in leap if there is no selection
3.combine with alfred to make a global shortcut key to quick tag selection
Author: Zhao Cai
Notes:
1. Work with Finder Selection: Parameter to open is a list of alias references to the items you dropped. But Finder selection is a specifier for the applicatiaon Finder itself. Anyway, it has to be changed to the "drag'n'drop" format.
2.
Link:
@zhaocai
zhaocai / bash-stack.bash
Created November 9, 2011 02:04 — forked from tlrobinson/bash-stack.bash
Bash XML parser and stack, plus Gmail XML feed parsing example
#!/usr/bin/env bash
# Bash Stack
set -o errtrace
set -o errexit
set -o nounset
declare -a stack
@zhaocai
zhaocai / growlnotify.rb
Created August 4, 2012 06:35 — forked from ttscoff/growlnotify.rb
Seamless drop-in to turn existing growlnotify calls into Mountain Lion Notifications
#!/usr/bin/env ruby
# encoding: utf-8
# == Synopsis
# Requires the terminal-notifier gem ([sudo] gem install terminal-notifier)
# growlnotify wrapper to turn Growl alerts into Mountain Lion notifications
# Uses growlnotify option syntax to keep your old scripts working with the new shiny.
#
# If you use Growl via growlnotify in your shell scripting, this script
# will replace Growl's alerts with Mountain Lion notifications.
@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)
@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 / 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 / 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`
# 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 / facets-margin.rb
Created April 5, 2013 07:18
`rb output margin
require 'facets'
x = %Q{
| This
| is
| margin controlled!
}.margin
puts x

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname