Skip to content

Instantly share code, notes, and snippets.

View ZackMcBride's full-sized avatar

Zack McBride ZackMcBride

  • Reddit
  • New York City
View GitHub Profile
@ZackMcBride
ZackMcBride / signatureCapture.m
Created October 16, 2013 20:08
Simple signature capture functionality for iOS. Comes with methods to output as either string of coords or image.
- (void)pan:(UIPanGestureRecognizer *)pan {
CGPoint currentPoint = [pan locationInView:self];
CGPoint midPoint = midpoint(previousPoint, currentPoint);
if (pan.state == UIGestureRecognizerStateBegan) {
[path moveToPoint:currentPoint];
currentPath = [NSMutableArray arrayWithObject:[NSValue valueWithCGPoint:currentPoint]];
} else if (pan.state == UIGestureRecognizerStateChanged) {
[path addQuadCurveToPoint:midPoint controlPoint:previousPoint];
[currentPath addObject:[NSValue valueWithCGPoint:midPoint]];
@ZackMcBride
ZackMcBride / Outbox.m
Created October 16, 2013 20:26
Asynchronous, scheduled outbox thread. This snippet was used for a bespoke project where they required phones to be syncing up constantly with their API. This allows for all requests to be queued on the device and synced up at a later date when there is connectivity.
// This method acts as an entry point for the outbox service thread, it will create an additional thread in a continuous loop for the outbox services
- (void)startAndObserveOutboxThread {
// Only carry out the rest of the method if this isn't the main thread and there isn't a locationServiceObserverThread already running
if ([NSThread isMainThread] || outboxServiceObserverThread != nil) {
return;
}
outboxServiceObserverThread = [NSThread currentThread];
@ZackMcBride
ZackMcBride / LocationService.m
Created October 22, 2013 10:47
I recently had a problem using the CLRegion functionality where if the app was launched while within a Geofence, the didEnterRegion delegate method didn't get called. I created this little method to check for that.
- (BOOL)insideRegion:(CLRegion *)region location:(CLLocationManager *)manager {
if([region containsCoordinate:manager.location.coordinate]){
return true;
}
return false;
}

Keybase proof

I hereby claim:

  • I am zackmcbride on github.
  • I am zackm (https://keybase.io/zackm) on keybase.
  • I have a public key ASDRg-9p5ec8MQqqVVaFoBQZ_OYRoaRTY17R0BVDte-IcAo

To claim this, I am signing this object: