Skip to content

Instantly share code, notes, and snippets.

function parse_git_branch {
[ -d .git ] || return 1
git_status="$(git status 2> /dev/null)"
branch_pattern="^# On branch ([^${IFS}]*)"
remote_pattern="# Your branch is (.*) of"
diverge_pattern="# Your branch and (.*) have diverged"
if [[ ! ${git_status}} =~ "working directory clean" ]]; then
state="*"
fi
# add an else if or two here if you want to get more specific
static Singleton *singleton = nil;
+ (Singleton *) sharedService {
@synchronized(self) {
if (singleton == nil) {
[[self alloc] init]; // assignment not done here
}
}
return singleton;
}
These constants are used to choose the version of OpenGL ES that a rendering context provides.
typedef NSUInteger EAGLRenderingAPI;
enum
{
kEAGLRenderingAPIOpenGLES1 = 1
kEAGLRenderingAPIOpenGLES2 = 2
};
$lipo libTapjoyConnectDeviceConnect.a libTapjoyConnectSimulatorConnect.a -create -output libTapjoyConnect.a
#import <Foundation/Foundation.h>
int main() {
CGFloat version = [@"4.2.1" floatValue];
NSLog(@"version: %f", version);
}
O2Machina:~ karl$ gcc main.m -o test -framework Foundation
O2Machina:~ karl$ ./test
CGFloat CGContextShadowOrientationYMultiplier() {
static CGFloat sharedMultiplier__ = 0.0;
if (sharedMultiplier__ == 0.0) {
NSString *version = [UIDevice currentDevice].systemVersion;
sharedMultiplier__ = ([version compare:@"3.2"] == NSOrderedAscending) ? 1.0f : -1.0f;
}
return sharedMultiplier__;
}
#!/bin/sh
if [ -d "$BUILT_PRODUCTS_DIR/${PRODUCT_NAME}.app/foo.bundle" ]; then
rm -rf "$BUILT_PRODUCTS_DIR/${PRODUCT_NAME}.app/foo.bundle"
fi
if [ -d "$BUILT_PRODUCTS_DIR/foo.bundle" ]; then
cp -r "$BUILT_PRODUCTS_DIR/foo.bundle" "$BUILT_PRODUCTS_DIR/${PRODUCT_NAME}.app/"
fi
@augustjoki
augustjoki / Log.txt
Created May 10, 2011 19:58 — forked from evadne/Log.txt
Shared instances for all
2011-05-11 03:25:07.462 GlobalSingletonSupportTest[63618:1803] irSharedInstance instance NSObject 15f980, 181511 ns
2011-05-11 03:25:07.465 GlobalSingletonSupportTest[63618:5303] irSharedInstance instance NSObject 15f980, 614 ns
2011-05-11 03:25:07.465 GlobalSingletonSupportTest[63618:5403] irSharedInstance instance NSObject 15f980, 584 ns
2011-05-11 03:25:07.464 GlobalSingletonSupportTest[63618:a0f] irSharedInstance instance NSObject 15f980, 1546 ns
2011-05-11 03:25:07.466 GlobalSingletonSupportTest[63618:a0f] irSharedInstance instance NSObject 15f980, 1545 ns
@augustjoki
augustjoki / gist:969755
Created May 13, 2011 00:50
UITableViewCell reuse identifier
+ (NSString *)reuseIdentifier {
static NSString *reuseIdentifier;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
reuseIdentifier = [NSStringFromClass(self) retain];
});
return reuseIdentifier;
}
@augustjoki
augustjoki / gist:1119391
Created August 2, 2011 01:14
Kill implicit animations
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue
forKey:kCATransactionDisableActions];
[aLayer removeFromSuperlayer];
[CATransaction commit];