Skip to content

Instantly share code, notes, and snippets.

View ashfurrow's full-sized avatar

Ash Furrow ashfurrow

View GitHub Profile
@ashfurrow
ashfurrow / gist:5621791
Created May 21, 2013 17:51
ReactiveCocoa Chaining Example
RACSignal *intervalSignal = [RACSignal interval:1];
RACSignal *startedIntervalSignal = [intervalSignal startWith:[NSDate date]];
RACSignal *mappedIntervalSignal = [startedIntervalSignal map:^id(NSDate *value) {
NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:value];
return [NSString stringWithFormat:@"%d:%02d", dateComponents.minute, dateComponents.second];
}];
RAC(self.textField.text) = mappedIntervalSignal;
@ashfurrow
ashfurrow / gist:5621776
Last active December 17, 2015 14:08
ReactiveCocoa Chaining Example
RAC(self.textField.text) = [[[RACSignal interval:1] startWith:[NSDate date]] map:^id(NSDate *value) {
NSDateComponents *dateComponents = [[NSCalendar currentCalendar] components:NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:value];
return [NSString stringWithFormat:@"%d:%02d", dateComponents.minute, dateComponents.second];
}];
@ashfurrow
ashfurrow / gist:5569942
Last active December 17, 2015 06:59
Combining two signals.
[[RACSignal
combineLatest:@[self.firstNameField.rac_textSignal, self.lastNameField.rac_textSignal]
reduce:^(NSString *firstName, NSString *lastName){
return @(firstName.length > 0 && lastName.length > 0);
}] toProperty:@"enabled" onObject:self.button];
@ashfurrow
ashfurrow / gist:5569937
Last active December 17, 2015 06:59
Filtering a text field's signal
[[self.textField.rac_textSignal filter:^BOOL(NSString *value) {
return [value length] >= 3;
}] subscribeNext:^(NSString *value) {
NSLog(@"Text field has been updated: %@", value);
}];
@ashfurrow
ashfurrow / gist:5404679
Last active December 16, 2015 08:19
Subscribing to a text field's signal
[self.textField.rac_textSignal subscribeNext:^(NSString *value) {
NSLog(@"Text field has been updated: %@", value);
}];
#########################
# .gitignore file for Xcode4 / OS X Source projects
#
# Version 2.0
# For latest version, see: http://stackoverflow.com/questions/49478/git-ignore-file-for-xcode-projects
#
# 2013 updates:
# - fixed the broken "save personal Schemes"
#
# NB: if you are storing "built" products, this WILL NOT WORK,
self.gitHubCommand = [RACCommand command];
self.gitHubSignal = [self.gitHubCommand addSignalBlock:^RACSignal *(id value) {
RACReplaySubject *subject = [RACReplaySubject subject];
[engine teamsInOrganization:@"TeehanLax" withSuccess:^(id result) {
for (NSDictionary *team in result)
{
@ashfurrow
ashfurrow / gist:2431499
Created April 20, 2012 20:11
Photo Walk April 21st
  • Meet at 500px World HQ downstairs lobby at 4pm (317 Adelaide St. West)
  • Taxi up to DVP at http://g.co/maps/6hg84
  • Take amazing photos

Please tweet to @ashfurrow to confirm your attendance.

@ashfurrow
ashfurrow / gist:2140332
Created March 20, 2012 19:36
500px iOS Developer Job Description

iOS Developer

The 500px team is growing and we're looking for another iOS developer. You need to be able to work at 500px HQ at the corner of Peter and Adelaide in beautiful Toronto, Ontario.

Qualifications

  • Excellent communication skills
  • A history of shipping iOS software
  • Ability to write idiomatic Objective-C code
  • Deep understanding of Cocoa design patterns and API design
@ashfurrow
ashfurrow / gist:1935770
Created February 28, 2012 22:39
CIImage filter to invert image colours
CIImage* ciImage = [[CIImage alloc] initWithData:[drawnImage TIFFRepresentation]];
if ([drawnImage isFlipped])
{
CGRect cgRect = [ciImage extent];
CGAffineTransform transform;
transform = CGAffineTransformMakeTranslation(0.0,cgRect.size.height);
transform = CGAffineTransformScale(transform, 1.0, -1.0);
ciImage = [ciImage imageByApplyingTransform:transform];
}
CIFilter* filter = [CIFilter filterWithName:@"CIColorInvert"];