Skip to content

Instantly share code, notes, and snippets.

View Kevinwlee's full-sized avatar

Kevin Lee Kevinwlee

View GitHub Profile
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Register your app
[ContextHub registerWithAppId:@"823b8648-YOUR-UUID-a653-748d4fff9128"];
return YES;
}
platform :ios, '7.0'
pod 'ContextHub', :git => 'https://github.com/contexthub/contexthub-ios-sdk', :branch=>'master'
@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;
}
Device.tag('sand_creek').where("created_at < ?", Date.today ).each { |d| d.destroy }
@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];
@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 / color for hex
Created March 2, 2012 15:25
UIColor with String Hex
- (UIColor *)colorForHexColor:(id)hexColor{
if (hexColor == [NSNull null]) {
return [UIColor blackColor];
} else {
NSScanner *scanner2 = [NSScanner scannerWithString:hexColor];
unsigned int hex;
[scanner2 scanHexInt:&hex];
return UIColorFromRGB(hex);
}
}
@Kevinwlee
Kevinwlee / JSON
Created March 2, 2012 13:48
Getting Date/Time from .NET api
{
"Latitude": 31.550837,
"Longitude": -97.116265,
"Description": "Drop dirties by 1pm in the laundry cart near front desk.",
"Weekday": 3,
"StartTime": "/Date(1329535556148)/",
"EndTime": "/Date(1329535556148)/",
"Dorms": [
"South Russell"
],
@Kevinwlee
Kevinwlee / AQTestController.m
Created November 15, 2011 03:31
KIF Framework After
#import "AQTestController.h"
#import "KIFTestScenario.h"
#import "KIFTestScenario+AQAdditions.h"
@implementation AQTestController
- (void)initializeScenarios {
[self addScenario:[KIFTestScenario scenarioToOpenAndCloseTheLogin]];
[self addScenario:[KIFTestScenario scenarioToOpenAndCloseTheCreateActivityScreen]];
[self addScenario:[KIFTestScenario scenarioToEnterTextIntoTheWhereBox]];
@Kevinwlee
Kevinwlee / AQTestController.h
Created November 15, 2011 03:25
KIF Framework Before
#import <Foundation/Foundation.h>
#import "KIFTestController.h"
@interface AQTestController : KIFTestController
@end