This file contains hidden or 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
#include <sys/xattr.h> | |
/// Set a flag that the files shouldn't be backuped to iCloud. | |
+ (void)addSkipBackupAttributeToFile:(NSString *)filePath { | |
u_int8_t b = 1; | |
setxattr([filePath fileSystemRepresentation], "com.apple.MobileBackup", &b, 1, 0, 0); | |
} | |
/// Returns the legacy storage path, used when the com.apple.MobileBackup file attribute is not available. | |
+ (NSString *)legacyStoragePath { |
This file contains hidden or 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 "CCPageBox2dBase.h" | |
@implementation CCPageBox2dBase | |
@synthesize levelHelperName = _levelHelperName; | |
- (void)setupWorld { | |
b2Vec2 gravity = b2Vec2(0.0f, 0.0f); | |
bool doSleep = false; | |
_world = new b2World(b2Vec2(0,0), doSleep); |
This file contains hidden or 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)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration { | |
/* Basic setup to translate the tile to gravity */ | |
b2Vec2 gravity(-acceleration.y * 15, acceleration.x *15); | |
_world->SetGravity(gravity); | |
/* First lets figure out the angle to which the iPad is tilted*/ | |
float angle = atan2(acceleration.x, -acceleration.y); | |
This file contains hidden or 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
// | |
// HelloWorldLayer.mm | |
// | |
// Created by Nathan Clark on 10/13/11. | |
// Copyright self 2011. All rights reserved. | |
// | |
// Import the interfaces | |
#import "HelloWorldLayer.h" |
This file contains hidden or 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
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; | |
[gregorian autorelease]; | |
NSCalendarUnit unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit; | |
NSDateComponents *component =[gregorian components:unitFlags fromDate:[[NSDate date] addTimeInterval: -86400.0]]; | |
[component setHour:0]; //12a.m. | |
[component setMinute:0]; | |
[component setSecond:1]; | |
NSDate *yestedayAtMidnight = [gregorian dateFromComponents:component]; |
This file contains hidden or 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 <Foundation/Foundation.h> | |
#import <CoreData/CoreData.h> | |
@class Assignment; | |
@interface Chore : NSManagedObject | |
@property (nonatomic, retain) NSString * name; | |
@property (nonatomic, retain) NSNumber * doMonday; | |
@property (nonatomic, retain) NSNumber * doSunday; |
This file contains hidden or 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)displayValidationError:(NSError *)anError { | |
NSLog(@"error domain, %@",[anError domain]); | |
if (anError && [[anError domain] isEqualToString:@"NSCocoaErrorDomain"]) { | |
NSArray *errors = nil; | |
// multiple errors? | |
if ([anError code] == NSValidationMultipleErrorsError) { | |
errors = [[anError userInfo] objectForKey:NSDetailedErrorsKey]; | |
} else { | |
errors = [NSArray arrayWithObject:anError]; |
This file contains hidden or 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
NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:2]; | |
NSDictionary *innerDict; | |
NSString *name; | |
NSDate *dob; | |
NSArray *scores; | |
scores = [NSArray arrayWithObjects:[NSNumber numberWithInt:6], | |
[NSNumber numberWithFloat:4.6], | |
[NSNumber numberWithLong:6.0000034], | |
nil]; |
This file contains hidden or 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
namespace :utils do | |
desc "Echos log rotate configs" | |
task :rotate => :environment do | |
puts <<EOD | |
<<<<<<<<<<<<Begin | |
# Rotate Rails application logs | |
#{Rails.root}/log/*.log { | |
daily | |
missingok | |
rotate 7 |
This file contains hidden or 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
def tip(msg); puts; puts msg; puts "-"*100; end | |
# | |
# 30 Ruby 1.9 Tips, Tricks & Features: | |
# http://www.igvita.com/2011/02/03/new-ruby-19-features-tips-tricks/ | |
# | |
tip "Upgrading to Ruby 1.9 is simple: rvm install 1.9.2 && rvm --default 1.9.2" | |
tip "Ruby 1.9 supports named captures in regular expressions!" |