This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef TINY_PROFILER | |
#define TINY_PROFILER 1 | |
// Tiny Profiler is a lightweight tool for tracking and logging multiple tasks. I use it to | |
// see which parts of my OpenGL scene graph take the longest to render. | |
// | |
// Because logging is relatively expensive, the TinyProfilerLog() function only logs every | |
// nth time it is called, where n is TINY_PROFILER_LOG_INTERVAL. Set this to 1 to log every time. | |
// | |
// TINY_PROFILER_COUNT is the maximum number of active profilers. There is no bounds-checking, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "Common.h" | |
@interface AnimatedFloat : NSObject | |
{ | |
float _startValue; | |
NSTimeInterval _startTime; | |
BOOL _hasStarted; | |
float _endValue; | |
NSTimeInterval _endTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "NSObject+Blocks.h" | |
@interface CADisplayLink (Blocks) | |
+(CADisplayLink*)displayLinkWithBlock:(simpleBlock)block; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i = 0; | |
for(NSString* key in keys) | |
{ | |
//do stuff here with key and i | |
i++; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define BLOCK(name, return, ...) return(^name)(__VA_ARGS__) | |
#define BLOCKTYPE(return, ...) return(^)(__VA_ARGS__) | |
// Example Usage: | |
// To declare a block inside a function/method: | |
// | |
// BLOCK(foo, int, BOOL) = ^(BOOL bar) { return bar ? 4 : 3; } | |
// | |
// NSLog(@"%d", foo(NO)); // "3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bundleVersion=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" Tyche-Info.plist) | |
buildNumber=$(/usr/libexec/PlistBuddy -c "Print DDBuildNumber" Tyche-Info.plist) | |
buildNumber=$(($buildNumber + 1)) | |
/usr/libexec/PlistBuddy -c "Set :DDBuildNumber $buildNumber" Tyche-Info.plist | |
/usr/local/git/bin/git add . | |
/usr/local/git/bin/git commit -m "Version $bundleVersion.$buildNumber" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "Common.h" | |
@interface AnimatedFloat : NSObject | |
@property (nonatomic, assign) GLfloat startValue; | |
@property (nonatomic, assign) NSTimeInterval startTime; | |
@property (nonatomic, assign) GLfloat endValue; | |
@property (nonatomic, assign) NSTimeInterval endTime; | |
@property (nonatomic, assign) AnimationCurve curve; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(void)authenticateWithEmail:(NSString*)email password:(NSString*)password retries:(int)retries andThen:(BasicBlock)work | |
{ | |
NSString* urlString = @"https://www.google.com/accounts/ClientLogin"; | |
NSMutableDictionary* requestParameters = [NSMutableDictionary dictionary]; | |
[requestParameters setObject:email forKey:@"Email"]; | |
[requestParameters setObject:password forKey:@"Passwd"]; | |
[NSURLConnection postToUrlString:urlString withParameters:requestParameters completionBlock:^(NSData* data, NSURLResponse* response, NSError* error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface NSArray (BlockEnumerationTest) | |
-(void)enumerateObjectsUsingBlockType1:(void (^)(id, NSUInteger, BOOL *))block; | |
-(void)enumerateObjectsUsingBlockType2:(void (^)(id, NSUInteger, BOOL *))block; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+(NSData*)dataForPOSTWithDictionary:(NSDictionary *)dictionary boundary:(NSString *)boundary | |
{ | |
NSMutableData* postBodyData = [NSMutableData data]; | |
for(NSString* key in dictionary) | |
{ | |
id value = [dictionary valueForKey:key]; | |
if([value isKindOfClass:[NSData class]]) | |
{ |
OlderNewer