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
protocol DelegateOwningType { | |
typealias DelegateType | |
var delegate : DelegateType { get set } | |
} | |
class DelegatedOperation <T : DelegateOwningType, TDelegate where T.DelegateType == TDelegate.Type>: NSOperation { | |
let authority : T | |
var delegate : TDelegate | |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'twitter' | |
require 'sqlite3' | |
client = Twitter::Streaming::Client.new do |config| | |
config.consumer_key = "..." | |
config.consumer_secret = "..." | |
config.access_token = "..." |
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
/*! This protocol is reserved for Contacts framework usage. */ | |
protocol CNKeyDescriptor : NSObjectProtocol, NSSecureCoding, NSCoding, NSCopying { | |
} | |
extension NSString : CNKeyDescriptor { | |
} | |
var keys : [CNKeyDescriptor] | |
keys.join([CNContactGivenNameKey, CNContactFamilyNameKey]) | |
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
@interface GradientView : UIView | |
@end | |
@implementation GradientView | |
+ (Class)layerClass { | |
return [CAGradientLayer class]; | |
} |
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
1. Thou shalt always use Key Value Observing | |
2. Thou shalt not block the main thread | |
3. Thou shalt compile with zero errors or warnings | |
4. Thou shalt use #pragma mark to separate code into groups based on related functionality |
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 <AppKit/AppKit.h> | |
int main(int argc, char **argv) { | |
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | |
NSString *sourceFile = [NSString stringWithCString:(const char *)argv[1] encoding:NSUTF8StringEncoding]; | |
NSData *fileData = [NSData dataWithContentsOfFile:[sourceFile stringByExpandingTildeInPath]]; | |
NSDictionary *plist = [NSPropertyListSerialization propertyListWithData:fileData options:0 format:NULL error:NULL]; | |
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
NSManagedObject *itemA = [NSEntityDescription insertNewObjectForEntityForName:@"Group" inManagedObjectContext:self.managedObjectContext]; | |
NSManagedObject *itemB = [NSEntityDescription insertNewObjectForEntityForName:@"Subgroup" inManagedObjectContext:self.managedObjectContext]; | |
NSManagedObject *itemC = [NSEntityDescription insertNewObjectForEntityForName:@"Folder" inManagedObjectContext:self.managedObjectContext]; | |
NSFetchRequest *aAndBFetch = [[NSFetchRequest alloc] initWithEntityName:@"Group"]; | |
NSFetchRequest *aAndCFetch = [[NSFetchRequest alloc] initWithEntityName:@"Group"]; | |
[aAndBFetch setIncludesSubentities:YES]; | |
[aAndCFetch setIncludesSubentities:YES]; | |
[aAndBFetch setPredicate:[NSPredicate predicateWithFormat:@"entity.name == \"Group\" OR entity.name == \"Subgroup\""]]; |
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
@implementation XXNavigationBar | |
- (void)layoutSubviews { | |
[super layoutSubviews]; | |
MPLog(@"navBar: %@", [self recursiveDescription]); | |
} | |
- (void)pushNavigationItem:(UINavigationItem *)item animated:(BOOL)animated { | |
MPLog(@"[%@:%p %@]:%@, %@", NSStringFromClass([self class]), self, NSStringFromSelector(_cmd), item, animated ? @"YES": @"NO"); |
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
Loading development environment (Rails 3.0.1) | |
>> Time.zone = "Mountain Time (US & Canada)" | |
>> start = Time.parse("2/9/11 12:30 PM") | |
=> Wed Feb 09 12:30:00 -0800 2011 | |
>> start.zone | |
=> "PST" | |
>> Time.zone | |
=> #<ActiveSupport::TimeZone:0x1020592b0 @utc_offset=nil, @current_period=nil, @name="Mountain Time (US & Canada)", @tzinfo=#<TZInfo::TimezoneProxy: America/Denver>> |
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
{ | |
"endTime" : "2/9/11 12:30 PM", | |
"id" : "1", | |
"location" : "Fandango", | |
"sessionEndTime" : "2/9/11 12:30 PM", | |
"sessionStartTime" : "2/9/11 9:30 AM", | |
"startTime" : "2/9/11 9:30 AM", | |
}, |
NewerOlder