Skip to content

Instantly share code, notes, and snippets.

View robin's full-sized avatar
🏔️

Lu Yibin robin

🏔️
View GitHub Profile
@robin
robin / gist:41659
Created December 30, 2008 16:36
cocoa http upload
NSString *filename = @"myfile.png";
NSString *boundary = @"----BOUNDARY_IS_I";
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@SERVER_POSTIMAGE_PATH_STR, [[UIDevice currentDevice] uniqueIdentifier] ]];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
[req setHTTPMethod:@"POST"];
@robin
robin / gist:62684
Created February 12, 2009 15:40
round corner uiimage
#import "ImageManipulator.h"
@implementation ImageManipulator
static void addRoundedRectToPath(CGContextRef context, CGRect rect, float ovalWidth, float ovalHeight)
{
float fw, fh;
if (ovalWidth == 0 || ovalHeight == 0) {
CGContextAddRect(context, rect);
return;

(This is the text of the keynote I gave at Startup Riot 2009. Will update when video becomes available.)

Hi everyone, I’m Chris Wanstrath, and I’m one of the co-founders of GitHub.

GitHub, if you haven’t heard of it, has been described as “Facebook for developers.” Which is great when talking about GitHub as a website, but not so great when describing GitHub as a business. In fact, I think we’re the polar opposite of Facebook as a business: we’re small, never took investment, and actually make money. Some have even called us successful.

Which I’ve always wondered about. Success is very vague, right? Probably even relative. How do you define it?

After thinking for a while I came up with two criteria. The first is profitability. We employ four people full time, one person part time, have thousands of paying customers, and are still growing. In fact, our rate of growth is increasing – which means January was our best month so far, and February is looking pretty damn good.

awk -F"\t" '{if ($11 != 0) print $3, $10, $11, $14}' $1 | sort | awk '/YOUR_APP_ID_HERE/ {amount += $2} END {print "YOUR_APP_NAME_HERE", amount, amount * YOUR_APP_PRICE_HERE}'
@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.
NSObject *scroller = [webView.subviews objectAtIndex:0];
[scroller performSelector:@selector(setScrollingEnabled:) withObject:NO];
@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
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 / 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
@robin
robin / gist:190972
Created September 22, 2009 10:19
compress on mac
ditto -ck --rsrc --keepParent myFolder myFolder.zip