Skip to content

Instantly share code, notes, and snippets.

John Clayton johnclayton

View GitHub Profile
@johnclayton
johnclayton / QSandbox
Last active Dec 19, 2015
A convenient wrapper around the sandbox for OSX and iOS apps
View QSandbox
@implementation QSandbox
+ (NSString *) documentsDirectory {
return [self directoryInUserSearchPath:NSDocumentDirectory];
}
+ (NSString *) applicationSupportDirectory {
return [self directoryInUserSearchPath:NSApplicationSupportDirectory];
}
View gist:5646870
- (NSString *) MD5Hash {
const char *cStr = [self UTF8String];
unsigned char result[CC_MD5_DIGEST_LENGTH];
CC_MD5( cStr, (CC_LONG)strlen(cStr), result );
NSMutableString *hash = [[NSMutableString alloc] initWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for (int i = 0; i < 16; i++) {
[hash appendFormat: @"%02x", result[i]];
}
View gist:5190399
+ (NSString *)nibName {
return [self className];
}
+ (id) loadFromNib {
return [self loadFromNibWithOwner:self];
}
+ (id) loadFromNibWithOwner:(id)owner {
NSArray *theObjects = [[NSBundle mainBundle] loadNibNamed:[self nibName] owner:owner options:nil];
@johnclayton
johnclayton / gist:4468810
Created Jan 6, 2013
NSArray first element convenience
View gist:4468810
@interface NSArray (FSQFoundation)
- (id) firstObject; ///< @returns the first object if there is one, or nil.
@end
@implementation NSArray (FSQFoundation)
- (id) firstObject {
if (self.count < 1) {
@johnclayton
johnclayton / gist:4468789
Created Jan 6, 2013
NSString empty checks
View gist:4468789
@interface NSString (FSQFoundation)
+ (BOOL) isEmpty:(NSString *)string;
+ (BOOL) isNotEmpty:(NSString *)string;
@end
@implementation NSString (FSQFoundation)
+ (BOOL) isEmpty:(NSString *)string {
View gist:2228502
- (UITextField *) textField {
UITextField *textField = nil;
for (id subview in [self subviews]) {
if ([subview isKindOfClass:[UITextField class]]) {
textField = (UITextField *)subview;
break;
}
}
return textField;
}
@johnclayton
johnclayton / FSQOpenStruct.h
Created Feb 22, 2012
An implementation of Ruby's OStruct in Objective C
View FSQOpenStruct.h
//
// FSQOpenStruct.h
// FivesquareKit
//
// Created by John Clayton on 2/5/12.
// Copyright (c) 2012 Fivesquare Software, LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
View welcome.md

Welcome to Drift!

Drift is an always-already versioned, cloud-backed text editor. You can use it to take notes, and save them in the GitHub cloud.

Your gists are always saved locally, and any changes you make will get pushed to GitHub's servers.

To name a gist, touch its name in the toolbar.

You can use the share button at the top-right to copy a link to one of your gists, or view it on the web in Safari.

View gist:537356
[DEBUG] - LNPaymentCertificateSyncAgent.m:69 -[LNPaymentCertificateSyncAgent shouldSyncNow] - LNPaymentCertificateSyncAgent: LNSyncAgentStrategyDelegate - shouldSyncNow (NO)
[TRACE] - SMWebServiceRequest.m:335 -[SMWebServiceRequest configureURLRequest:] - Cookies for URL tap/endpoint/restv1/member -- https://ash1api.ticketmaster.com : (
)
[TRACE] - SMWebServiceRequest.m:336 -[SMWebServiceRequest configureURLRequest:] - All cookies: (
"<NSHTTPCookie version:0 name:@\"JSESSIONID\" value:@\"448C8D57E3A4CA39CC1B7393D894D85D\" expiresDate:@\"(null)\" created:@\"303897572.000000\" sessionOnly:TRUE domain:@\"ash1api.ticketmaster.com\" path:@\"/tap\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>",
"<NSHTTPCookie version:0 name:@\"BID\" value:@\"xEW2EokI6XdEiU8SG4QbPY3PGbgucu3b8mstr0_fbAvYajvBKupwcLg4pTEpL8hWJxxH-wpZrehrpkd6ZnSn\" expiresDate:@\"2037-12-31 16:00:01 -0800\" created:@\"303897556.000000\" sessionOnly:FALSE domain:@\".ticketmaster.com\" path:@\"/\" secure:FALSE comment:@\"(n
View gist:537350
[TRACE] - SMWebServiceRequest.m:335 -[SMWebServiceRequest configureURLRequest:] - Cookies for URL tap/endpoint/restv1/certificate -- https://ash1api.ticketmaster.com : (
)
[TRACE] - SMWebServiceRequest.m:336 -[SMWebServiceRequest configureURLRequest:] - All cookies: (
"<NSHTTPCookie version:0 name:@\"JSESSIONID\" value:@\"5DFD1967F3F5B179F2C20E3B05B7608E\" expiresDate:@\"(null)\" created:@\"303897263.000000\" sessionOnly:TRUE domain:@\"ash1api.ticketmaster.com\" path:@\"/tap\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>",
"<NSHTTPCookie version:0 name:@\"TAPCID\" value:@\"ash1-1282204457\" expiresDate:@\"(null)\" created:@\"303897258.000000\" sessionOnly:TRUE domain:@\"ash1api.ticketmaster.com\" path:@\"/tap\" secure:FALSE comment:@\"(null)\" commentURL:@\"(null)\" portList:[]>",
"<NSHTTPCookie version:0 name:@\"BID\" value:@\"9l7alBBUVuaQbExIomCRui6MrAkR8aSxJjQ0XscqJVFZj-d6YuIyL2cVoRjYQK6vZ2yRBgKZjMu3BkrGxAz2\" expiresDate:@\"2037-12-31 16:00:01 -0800\" created:@\"3038972
You can’t perform that action at this time.