Skip to content

Instantly share code, notes, and snippets.

View Kevinwlee's full-sized avatar

Kevin Lee Kevinwlee

View GitHub Profile
@Kevinwlee
Kevinwlee / QTSomeClient.m
Created May 2, 2012 14:35
Love this Pattern for generating a single instance of an object
@implementation QTSomeClient
+ (QTSomeClient *)sharedClient {
static QTSomeClient *_sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [QTSomeClient new];
});
return _sharedClient;
@Kevinwlee
Kevinwlee / gist:3226002
Created August 1, 2012 11:31
Date stuff
- (NSString *)currentDateString {
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"d"];
NSString *day = [df stringFromDate:self.currentDate];
return day;
}
- (NSString *)currentMonthString {
NSDateFormatter *df = [[NSDateFormatter alloc] init];
[df setDateFormat:@"MMMM"];
NSString *day = [df stringFromDate:self.currentDate];
Device.tag('sand_creek').where("created_at < ?", Date.today ).each { |d| d.destroy }
@Kevinwlee
Kevinwlee / fence_in.js
Last active December 31, 2015 22:48
Carbon Context Functions
function (event, vault, push) {
var vault_id = event.payload.vault.vault_info.id;
var data=vault.find(vault_id);
data.office = event.data.fence.id;
vault.update(vault_id, data)
push.sendToTags(1, [event.data.fence.id], "office_employee_changed", false );
true;
}
platform :ios, '7.0'
pod 'ContextHub', :git => 'https://github.com/contexthub/contexthub-ios-sdk', :branch=>'master'
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Register your app
[ContextHub registerWithAppId:@"823b8648-YOUR-UUID-a653-748d4fff9128"];
return YES;
}
@Kevinwlee
Kevinwlee / CCHContextEventManagerDataSource
Created March 27, 2014 14:27
Sample of how to return data.
#pragma mark - CCHContextEventManagerDataSource
- (NSDictionary *)contextEventManager:(CCHContextEventManager *)eventManager payloadForEvent:(NSDictionary *)event {
return @{@"company":@"ChaiONE", @"project":@"ContextHub"};
}
@Kevinwlee
Kevinwlee / will post event
Last active August 29, 2015 13:57
CCHContextEventManagerDelegate
#pragma mark - CCHContextEventManagerDelegate
- (void)contextEventManager:(CCHContextEventManager *)eventManager willPostEvent:(NSDictionary *)event {
NSLog(@"WILL Post Event %@", event);
}
@Kevinwlee
Kevinwlee / did post event
Last active August 29, 2015 13:57
CCHContextEventManagerDelegate
#pragma mark - CCHContextEventManagerDelegate
- (void)contextEventManager:(CCHContextEventManager *)eventManager didPostEvent:(NSDictionary *)event {
NSLog(@"DID Post Event %@", event);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
[ContextHub application:application didReceiveRemoteNotification:userInfo completion:completionHandler];
}