Skip to content

Instantly share code, notes, and snippets.

View KarlNosworthy's full-sized avatar

Karl Nosworthy KarlNosworthy

View GitHub Profile
@jrturton
jrturton / gist:89ce72a87e1b0661eccb
Created October 2, 2014 13:30
Removing a core data store
-(void)removeDataStoreAtURL:(NSURL*)url
{
// Need to remove anything matching the first part - there are also logging files alongside the SQLite file itself.
// Typical directory contents are:
// Name.sqlite, Name.sqlite-shm, Name.sqlite-wal
NSURL *folderURL = [url URLByDeletingLastPathComponent];
NSArray *contents = [[NSFileManager defaultManager] contentsOfDirectoryAtURL:folderURL includingPropertiesForKeys:nil options:0 error:nil];
@tsuyukimakoto
tsuyukimakoto / read_exif_data.swift
Created August 9, 2014 09:57
Read exif data from raw file.
import Foundation
import Cocoa
for arg in Process.arguments[1...Process.arguments.count - 1] {
let cgDataRef = CGImageSourceCreateWithURL(NSURL.URLWithString("file://\(arg)"), nil).takeUnretainedValue()
let imageDict:CFDictionaryRef = CGImageSourceCopyPropertiesAtIndex(cgDataRef, 0, nil).takeUnretainedValue()
println(imageDict)
}
@jrturton
jrturton / Get keyboard frame in local coordinates after receiving notification
Last active September 28, 2016 12:36
Getting the keyboard's frame in local coordinates
CGRect keyboardFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
keyboardFrame = [self.view.window convertRect:keyboardFrame fromWindow:nil];
keyboardFrame = [self.view convertRect:keyboardFrame fromView:nil];