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
#!/bin/sh | |
# | |
# Check for ruby style errors | |
# https://gist.github.com/johnnyji/d1226c9467a51f7d8b39 | |
# Put this in .git/hooks/pre-commit | |
red='\033[0;31m' | |
green='\033[0;32m' | |
yellow='\033[0;33m' | |
NC='\033[0m' |
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 UIKit | |
class FullscreenPhotoViewController: UIViewController, UIScrollViewDelegate { | |
// MARK: - IBOutlets | |
@IBOutlet weak var scrollView: UIScrollView! | |
// MARK: - IBActions | |
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
tell application "iPhone Simulator" | |
activate | |
end tell | |
tell application "System Events" | |
tell process "iPhone Simulator" | |
tell menu bar 1 | |
tell menu bar item "iOs Simulator" | |
tell menu "iOs Simulator" | |
click menu item "Reset Content and Settings…" |
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
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar_background.png"] forBarMetrics:UIBarMetricsDefault]; | |
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackOpaque]; | |
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica-Bold" size:14], UITextAttributeFont, [UIColor colorWithWhite:0.25 alpha:1.0], UITextAttributeTextColor, [UIColor colorWithWhite:0.75 alpha:1.0], UITextAttributeTextShadowColor, [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset, nil]]; | |
[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:5.f forBarMetrics:UIBarMetricsDefault]; |
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
- (NSArray *)searchForContacts:(NSString *)searchString { | |
NSArray *searchWords = [searchString componentsSeparatedByString:@" "]; | |
NSMutableString *query = [NSMutableString stringWithString:selectColumnsClause]; | |
[query appendString:@"WHERE "]; | |
BOOL isFirst = YES; | |
NSMutableArray *arguments = [NSMutableArray array]; | |
for (NSString *word in searchWords) { | |
if ([word length] > 0) { | |
NSString *searchWord = [word lowercaseString]; |
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
[self.currentOrder loadForm]; | |
[self.currentOrder loadFieldControllers]; |
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 <Foundation/Foundation.h> | |
#import "NSObject+PropertySupport.h" | |
@interface PropertyCoder : NSObject <NSCoding> { | |
} | |
@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
- (void)testDateAdditions { | |
int daysAgoReversed = [[NSDate dateAtMidnightWithDaysAgo:900] numDaysAgo]; | |
STAssertTrue(daysAgoReversed == 900, @"date methods should be reversible, but 900 != %d", daysAgoReversed); | |
NSDate *tomorrow = [[NSDate date] dateByAddingDays:1]; | |
int tomorrowDaysAgo = [tomorrow numDaysAgo]; | |
STAssertTrue(tomorrowDaysAgo == -1, @"tomorrow should be negative one day ago, but it was %d, " | |
"and we think tomorrow is %f seconds from 1970", tomorrowDaysAgo, [tomorrow timeIntervalSince1970]); | |
NSDate *yesterday = [[NSDate date] dateByAddingDays:-1]; |
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
@implementation NSDate (PKDateUtils) | |
+ (NSDate *)dateAtMidnightWithDaysAgo:(int)numDaysAgo | |
{ | |
NSDate *today = [NSDate date]; | |
NSCalendar *gregorianCal = [[[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar] autorelease]; | |
NSDateComponents *todayComponents = [gregorianCal components:NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit fromDate:today]; | |
todayComponents.day -= numDaysAgo; | |
todayComponents.hour = 0; | |
todayComponents.minute = 0; |
NewerOlder