Skip to content

Instantly share code, notes, and snippets.

View robin's full-sized avatar
🏔️

Lu Yibin robin

🏔️
View GitHub Profile
#import <Cocoa/Cocoa.h>
@interface NSMutableArray (variadicMethodExample)
- (void) appendObjects:(id) firstObject, ...; // This method takes a nil-terminated list of objects.
@end
@implementation NSMutableArray (variadicMethodExample)
set mailserver smtp.gmail.com port 587
username "email@domain.tld" password "password"
using tlsv1
with timeout 30 seconds
parse_git_branch() {
RSLT=''
GIT_BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/^* //'`
if [ "$GIT_BRANCH" ]
then
GIT_STATUS=`git status 2> /dev/null | grep 'working directory clean'`
CLR='2'
if [ "$GIT_STATUS" ]
then
CLR='2'
JAVA_OPTS="${JAVA_OPTS} -Xms1024m -Xmx2048m -XX:MaxPermSize=256m -server"; export JAVA_OPTS;
@robin
robin / gist:190972
Created September 22, 2009 10:19
compress on mac
ditto -ck --rsrc --keepParent myFolder myFolder.zip
@robin
robin / sl_gems_update.rb
Created September 9, 2009 12:45 — forked from mattetti/sl_gems_update.rb
SL gems update
#!/usr/bin/env ruby
puts "looking for the gems to upgrade..."
gem_info = Struct.new(:name, :version)
to_reinstall = []
Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path|
path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/
name, version = $1, $2
bundle_info = `file path`
to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/
end
require 'rubygems'
require 'patron'
require 'json'
COUCH = Patron::Session.new
COUCH.timeout = 120
COUCH.base_url = "http://localhost:5984"
COUCH.headers['User-Agent'] = 'ruby/mattetti'
AMOUNT_RECORDS = 8000
$COUCH_ID = 0
@robin
robin / work around question mark bug in srt
Created April 27, 2009 13:26
work around question mark in cc
sed -n "s/^\([^0-9].*\)$/\1 /g" *.srt
NSObject *scroller = [webView.subviews objectAtIndex:0];
[scroller performSelector:@selector(setScrollingEnabled:) withObject:NO];
@robin
robin / httpdump
Created April 4, 2009 00:42 — forked from peterc/httpdump
# Monitor HTTP requests being made from your machine with a one-liner..
# Replace "en1" below with your network interface's name (usually en0 or en1)
sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*"
# OR.. to be able to use as "httpdump" from anywhere, drop this into ~/.bash_profile:
# (again replace "en1" with correct network interface name)
alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E "Host\: .*|GET \/.*""
# All the above tested only on OS X.