Skip to content

Instantly share code, notes, and snippets.

View seanwolter's full-sized avatar

Sean Wolter seanwolter

View GitHub Profile
@seanwolter
seanwolter / gist:d5b17fb5f6019b04b763
Last active August 29, 2015 14:22
how Vokal's iOS team evaluates candidates
At Vokal our engineering interview process is pretty simple. Before we get emotionally attached
to any candidate we meet with them for two coding challenges. Candidates solve these contrived
coding conundrums with members of our team. During the challenge candidates are encouraged to
check documentation, google for help, and talk to their proctor. The exercise is not about
brain teasers, but how candidates work with people to solve a novel problem. Most of our
challenges require manipulating basic data structures. The work is completed in a collaborative
text editor. Often the most difficult part for candidates is working without autocomplete.
We've often asked ourselves what we want from candidates in these programming exercises. In short,
we're trying our best to notice the idiosyncrasies of a good engineer. There are small things like,
@seanwolter
seanwolter / gist:4033122
Created November 7, 2012 17:34
get the last word in a line UITextField
UITextPosition *firstRowStart = self.myTextView.beginningOfDocument;
UITextPosition *firstRowEnd = [self.myTextView.tokenizer positionFromPosition:firstRowStart
toBoundary:UITextGranularityLine
inDirection:UITextLayoutDirectionRight];
NSString *lastWord = nil;
while (!lastWord) {
UITextRange *range = [self.myTextView.tokenizer rangeEnclosingPosition:firstRowEnd
withGranularity:UITextGranularityWord
@seanwolter
seanwolter / gist:4033240
Created November 7, 2012 17:56
crappy loop to get the last word of each line in a UITextView
- (NSArray *)lastWordOfEachLine
{
NSMutableArray *wordArray = [@[] mutableCopy];
UITextPosition *firstRowStart = self.myTextView.beginningOfDocument;
UITextPosition *rowEnd = [self.myTextView.tokenizer positionFromPosition:firstRowStart
toBoundary:UITextGranularityLine
inDirection:UITextLayoutDirectionRight];
BOOL done = NO;
@seanwolter
seanwolter / gist:4033585
Created November 7, 2012 18:50
convert a RFC3339 string to an NSDate you can use dateFromRFC3339String
+ (NSDate *)dateFromRFC3339String:(NSString *)dateString
{
NSDate *date = nil;
if (dateString) {
NSDateFormatter *dateFormatter = [self internetDateTimeFormatter];
NSString *RFC3339String = [[NSString stringWithString:dateString] uppercaseString];
RFC3339String = [RFC3339String stringByReplacingOccurrencesOfString:@"Z" withString:@"-0000"];
if (RFC3339String.length > 20) {
RFC3339String = [RFC3339String stringByReplacingOccurrencesOfString:@":"
@seanwolter
seanwolter / gist:4548690
Last active December 11, 2015 04:58
EXIF handling methods in a photo model object
- (void)attachMetadata
{
DLog(@"EXIF data is %@",self.exifData);
[self.exifData setObject:@1 forKey:@"Orientation"];
NSData *jpeg = UIImageJPEGRepresentation(self.image, 1);
CGImageSourceRef sourceRef = CGImageSourceCreateWithData((__bridge CFDataRef)jpeg, NULL);
NSMutableData *dest_data = [NSMutableData data];
CFStringRef UTI = CGImageSourceGetType(sourceRef);
CGImageDestinationRef destination = CGImageDestinationCreateWithData((__bridge CFMutableDataRef)dest_data,UTI,1,NULL);
@seanwolter
seanwolter / gist:4549216
Created January 16, 2013 17:56
NSOperation queue very basic example
// MyOperation.h
@interface MyOperation : NSOperation
@end
// MyOperation.m
@implementation MyOperation
- (void)main {
if ([self isCancelled]) {
NSLog(@"** operation cancelled **");
@seanwolter
seanwolter / prefix.pch
Last active December 13, 2015 17:29 — forked from MattFoley/gist:4945666
#define screenHeight() ([UIScreen mainScreen].bounds.size.height)
#define isPhoneFive() (screenHeight() == 568)
#define isOS6() ([[[UIDevice currentDevice] systemVersion]intValue] > 5.2)
#define UIInterfaceIdiomIsPad() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
/*
* SenTestingKit does not wait for blocks to finish by default so your test would simply complete
* as successful. You need to use a semaphore and keep the run loop going in order for the test
* to properly run.
*/
- (void)testGetSpots {
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
CLLocation location = [[CLLocation alloc] initWithLatitude:70.0 longitude:50.0];
[Spot spotsWithURLString:@"/spots" near:location parameters:[NSDictionary dictionaryWithObject:@"128" forKey:@"per_page"] block:^(NSArray *records) {
//sample assert
@seanwolter
seanwolter / gist:5214606
Last active December 15, 2015 06:09
set a button's background image in interface builder then stretch it in code
- (void)awakeFromNib
{
[self strechImageForControlState:UIControlStateNormal];
[self strechImageForControlState:UIControlStateDisabled];
[self strechImageForControlState:UIControlStateHighlighted];
[self strechImageForControlState:UIControlStateSelected];
}
- (void)strechImageForControlState:(UIControlState)controlState
{
NSMutableArray *objects = [@[] mutableCopy];
NSObject *someObject = [NSObject new];
objects[objects.count] = object;