Skip to content

Instantly share code, notes, and snippets.

View robb's full-sized avatar

Robb Böhnke robb

View GitHub Profile
@hannestyden
hannestyden / ppjson.sh
Created April 18, 2012 14:07
New version of the old classic
ppjson () {
ruby -e "require 'json'; puts JSON.pretty_generate(JSON.parse(STDIN.read))"
}
@0xced
0xced / NSString.m
Created April 1, 2012 12:24
Reverse-engineered implementation of -[NSString isEqual:] and -[NSString isEqualToString:]
/*
* Most NSString instances will actually be __NSCFString instances, so here are both NSString and __NSCFString implementations.
* If you know how to create an NSString instance whose class is actually NSString please let me know.
* Other possible concrete subclasses of NSString are: NSConstantString, __NSCFConstantString, NSPathStore2, NSSimpleCString and __NSLocalizedString.
*/
// CoreFoundation.framework 635.19.0 (Mac OS X 10.7.3)
@implementation NSObject
- (BOOL) isNSString__
@jspahrsummers
jspahrsummers / gist:1670404
Created January 24, 2012 14:22
Macro for safer key-value coding
#define ObjectKeyPath(OBJECT, KEYPATH) \
((void)(NO && ((void)OBJECT.KEYPATH, NO)), @ # KEYPATH )
NSString *str = @"foobar";
NSLog(@"%@", [str valueForKey:ObjectKeyPath(str, length)]);
@hannestyden
hannestyden / post-checkout
Created October 28, 2010 11:26
Prints a random line from the bridge of Metallica's "Master of Puppets" when checking out the master branch.
#!/bin/sh
# .git/hooks/post-checkout
# chmod +x .git/hooks/post-checkout
if [ $(git symbolic-ref HEAD | cut -d '/' -f 3) == 'master' ]; then
lines[0]="Master, Master, where's the dreams that I've been after?"
lines[1]="Master, Master, you promised only lies"
lines[2]="Laughter, laughter, all I hear or see is laughter"
lines[3]="Laughter, laughter, laughing at my cries"
echo " ${lines[$((RANDOM%${#lines[*]}))]}";