Skip to content

Instantly share code, notes, and snippets.

@amrox
amrox / SynthesizingDummyClass.h
Created June 4, 2011 18:06
SynthesizingDummyClass
#define SYNTHESIZE_DUMMY_CLASS(C) \
@interface Dummy_##C : NSObject \
@end \
@implementation Dummy_##C : NSObject \
@end
// don't do this
deviceToken = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""];
// do this
NSString* deviceTokenStr = [[[[deviceToken description]
stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
@amrox
amrox / gist:1124312
Created August 4, 2011 01:32
TEST_WAIT_UNTIL_TRUE
#define TEST_WAIT_UNTIL_TRUE_SLEEP_SECONDS (0.25)
#define TEST_WAIT_UNTIL_TRUE(expr) \
while( (expr) == NO ) [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:TEST_WAIT_UNTIL_TRUE_SLEEP_SECONDS]];
dispatch_async(_renderQueue, ^{
[exportSession exportAsynchronouslyWithCompletionHandler:^{
LOG_DEBUG( @"exported to %@", [exportSession.outputURL path] );
}];
});
TEST_WAIT_UNTIL_TRUE( (exportSession.status == AVAssetExportSessionStatusCancelled ||
exportSession.status == AVAssetExportSessionStatusFailed ||
exportSession.status == AVAssetExportSessionStatusCompleted) );
[exportSession exportAsynchronouslyWithCompletionHandler:^{
NSLog( @"exported to %@", [exportSession.outputURL path] );
}];
TEST_WAIT_UNTIL_TRUE( (exportSession.status == AVAssetExportSessionStatusCancelled ||
exportSession.status == AVAssetExportSessionStatusFailed ||
exportSession.status == AVAssetExportSessionStatusCompleted) );
STAssertTrue( exportSession.status == AVAssetExportSessionStatusCompleted, @"export failed" );
__block BOOL done = NO;
[userService updateUser:user
completionHandler:^(NSError* error) {
STAssertNil( error, @"error: %@", error );
done = YES;
}];
TEST_WAIT_UNTIL_TRUE(done);
@amrox
amrox / gist:1218473
Created September 15, 2011 03:43
It's shit like this, Python package management
$ sudo pip install jsonpretty
Downloading/unpacking jsonpretty
Downloading JSONPretty-1.0.0.tar.gz
Running setup.py egg_info for package jsonpretty
Requirement already satisfied (use --upgrade to upgrade): simplejson in /Library/Python/2.7/site-packages (from jsonpretty)
Installing collected packages: jsonpretty
Running setup.py install for jsonpretty
Installing jsonpretty script to /usr/local/bin
[amrox@gorbash:inception(master)]$ ./inception
Dreamer [Fischer], level [1], priority [19], policy [OTHER]
Dreamer [Cobb], level [1], priority [19], policy [OTHER]
Dreamer [Ariadne], level [1], priority [19], policy [OTHER]
Dreamer [Arthur], level [1], priority [19], policy [OTHER]
Dreamer [Eames], level [1], priority [19], policy [OTHER]
Dreamer [Yusuf], level [1], priority [19], policy [OTHER]
Dreamer [Saito], level [1], priority [19], policy [OTHER]
[Fischer] HIJACKED ! Open up my defense projections in my dream to the hijackers!
[Ariadne] sees Fischers defense projections at work in the dream at level [1]
$ xcodebuild -sdk iphonesimulator -scheme "Unit Tests" -configuration Debug build
Build settings from command line:
SDKROOT = iphonesimulator5.0
=== BUILD NATIVE TARGET MSAppKit OF PROJECT MSAppKit WITH CONFIGURATION Debug ===
Check dependencies
=== BUILD NATIVE TARGET MSAppKitTests OF PROJECT MSAppKit WITH CONFIGURATION Debug ===
Check dependencies
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildNumber</key>
<string>BUILD_NUMBER</string>
<key>CFBundleShortVersionString</key>
<string>MARKETING_VERSION</string>
<key>CFBundleVersion</key>
<string>VERSION</string>