Skip to content

Instantly share code, notes, and snippets.

View chbeer's full-sized avatar

Christian Beer chbeer

View GitHub Profile
@chbeer
chbeer / gist:1312967
Created October 25, 2011 14:42
performFetchAndUpdateTableView: that performs a fetch request on NSFetchedResultsController and updates table view
// ONLY WORKS WITH ONE SECTION!!
- (BOOL) performFetchAndUpdateTableView:(NSError **)error
{
NSArray *objectsBefore = [self.fetchedResultsController.fetchedObjects retain];
BOOL result = [self.fetchedResultsController performFetch:error];
if (result) {
NSArray *objectsAfter = self.fetchedResultsController.fetchedObjects;
@chbeer
chbeer / gist:1385714
Created November 22, 2011 13:56
Small Apple Script that creates a mail with UUID of device
do shell script "system_profiler SPHardwareDataType | grep 'Hardware UUID:'"
set uuid to text ((offset of ":" in result) + 2) thru -1 of result
tell application "Mail"
set theNewMessage to make new outgoing message with properties {subject:"Mac App Beta - My UUID", content:uuid, visible:true}
tell theNewMessage
make new to recipient at end of to recipients with properties {address:"[email protected]"}
end tell
end tell
@chbeer
chbeer / gist:1612240
Created January 14, 2012 17:46
iPad logs when it doesn't finish deleting iCloud account.
========================
ASL is here to serve you
>
Jan 14 17:31:24 unknown configd[45] <Error>: WiFi:[348251484.774721]: bootstrap_look_up of WiFiManager server failed
Jan 14 17:31:24 unknown kernel[0] <Debug>: AppleBCMWLANChipManager::withBus(): BCM4329 revision B1
Jan 14 17:31:24 unknown kernel[0] <Debug>: AppleMultitouchZ2SPI: downloaded 47160 bytes of firmware data ("0x0146.bin") in 154ms.
Jan 14 17:31:24 unknown kernel[0] <Debug>: AppleBCMWLANChipManagerSdio4329::downloadFirmware(): start
Jan 14 17:31:24 unknown kernel[0] <Debug>: Loading syscfg.
@chbeer
chbeer / NSDate ISO methods
Created June 10, 2013 09:33
Methods to create and parse ISO date strings without NSDateFormatter.
NSDate *CBCBDateFromISOString(NSString *iso)
{
struct tm tm;
time_t t;
if (iso.length == 10) {
strptime([iso cStringUsingEncoding:NSUTF8StringEncoding], "%Y-%m-%d", &tm);
tm.tm_isdst = -1;
tm.tm_sec = 0;
@chbeer
chbeer / gist:5802954
Created June 18, 2013 05:58
Short example how I setup the synchronisation for iCloud sync with TICoreDataSync
- (void) registerSyncManager
{
if (self.applicationSyncManager) return;
TICDSLogVerbosity logVerbosity = [[NSUserDefaults standardUserDefaults] integerForKey:kIVTICDSLogVerbosity];
[TICDSLog setVerbosity:logVerbosity];
if (![self hasLocalDatabase]) {
@chbeer
chbeer / other c flags
Last active December 21, 2015 17:18
My current "other c flags" setting for get a good amount of warnings and turn the most important/dangerous warnings into errors.
-Wall
-Wno-deprecated-declarations
-Werror=incompatible-pointer-types
-Werror=arc-retain-cycles
-Werror=implicit-function-declaration
-Werror=return-type
-Werror=format
-Werror=mismatched-parameter-types
-Werror=tautological-constant-out-of-range-compare
@chbeer
chbeer / storeWindowImageToFile
Last active December 23, 2015 17:29
Stores a screenshot of a window to disk as PNG
@implementation NSWindow (JSTalk)
- (BOOL) storeWindowImageToFile:(NSString*)fileName
{
CGWindowID windowID = (CGWindowID)[self windowNumber];
CGWindowImageOption imageOptions = kCGWindowImageDefault;
CGWindowListOption singleWindowListOptions = kCGWindowListOptionIncludingWindow;
CGRect imageBounds = CGRectNull;
CGImageRef windowImage = CGWindowListCreateImage(imageBounds, singleWindowListOptions, windowID, imageOptions);
@chbeer
chbeer / AnimateUILabelTextColor
Created October 2, 2013 09:36
How to animate changing the textColor of a UILabel
[UIView transitionWithView:nameLabel
duration:0.25
options:UIViewAnimationOptionTransitionCrossDissolve
animations:^{
[nameLabel setTextColor:textColor];
}
completion:nil];
@chbeer
chbeer / simCap_startRecording.scpt
Created November 7, 2013 11:04
AppleScript that sends keystrokes to SimCap.app to start recording of the iOS Simulator screen
-- Uses System Events' keystrokes to start a recording in SimCap.app
tell application "SimCap"
activate
delay 0.5
tell application "System Events"
tell process "SimCap"
keystroke "r" using {command down}
end tell
@chbeer
chbeer / simCap_stopRecordingAndSave.scpt
Created November 7, 2013 11:06
AppleScript that sends keystrokes to SimCap.app to stop a running recording and to save the movie to temp.mov
-- Uses System Events' keystrokes to start a recording in SimCap.app
-- SimCap: http://www.jaml.co.uk/simcap/
tell application "SimCap"
activate
tell application "System Events"
tell process "SimCap"
keystroke "r" using {command down}
delay 1.0
keystroke "s" using {command down}