Skip to content

Instantly share code, notes, and snippets.

View eric-robinson's full-sized avatar

Eric Robinson eric-robinson

View GitHub Profile
@eric-robinson
eric-robinson / NSUserDefaultsNSDateExtensions.swift
Created September 29, 2015 15:07
Add NSDate support to NSUserDefaults
import Foundation
// ISO Formatting
extension NSDate {
static func ISOStringFromDate(date: NSDate) -> String {
let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
dateFormatter.timeZone = NSTimeZone(abbreviation: "GMT")
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
@eric-robinson
eric-robinson / DefaultRefreshController.m
Created March 1, 2013 00:17
Demo of rendering bug in CKRefreshControl, replace contents of DefaultRefreshController in the RefreshControlDemo with contents of this gist.
// DefaultRefreshController.m
//
// Copyright (c) 2012 Instructure, Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@eric-robinson
eric-robinson / gist:1614732
Created January 15, 2012 06:36
Setup Core Data SQLite db for use with iCloud
//Some scattered methods for setting up iCloud storage of a SQLite Core Data managed database.
//define your ubiquity container id
-(NSString*)ubiquityContainerIdentifier {
//should match what is in your app's entitlement file
return [NSString stringWithFormat:@"%@.%@", @"<YOUR TEAM IDENTIFIER>", [[NSBundle mainBundle] bundleIdentifier]];
}
//where you're going to store your database
@eric-robinson
eric-robinson / gist:1593255
Created January 11, 2012 05:45
NSColor to CGColor
@interface NSColor(Additions)
- (CGColorRef)toCGColor;
@end
@implementation NSColor(Additions)
- (CGColorRef)toCGColor {
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
NSColor* selfCopy = [self colorUsingColorSpaceName:NSDeviceRGBColorSpace];
@eric-robinson
eric-robinson / gist:1593197
Created January 11, 2012 05:26
Hex string to NSColor
@interface NSString(ColorAdditions)
-(NSColor*)hexStringToNSColor;
@end
@implementation NSString(ColorAdditions)
-(NSColor *) hexStringToNSColor {
unsigned int c;
if ([self characterAtIndex:0] == '#') {