Skip to content

Instantly share code, notes, and snippets.

Craig Hockenberry chockenberry

Block or report user

Report or block chockenberry

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
chockenberry / Debug.swift
Last active Oct 7, 2019
Debug and release logging in Swift that's reminiscent of NSLog()
View Debug.swift
// Debug.swift
// Created by Craig Hockenberry on 3/15/17.
// Usage:
// debugLog("reticulating splines") prints "2019-10-04 11:52:28 SplineReticulationManager: reticulationFunction reticulating splines"
// debugLog() prints "2019-10-04 11:52:28 SplineReticulationManager: reticulationFunction called"
// Add "DEBUG" to project or target's "Active Compilation Conditions" for Debug builds.
View GPU Statistics for iPulse
In the next version of iPulse, I'd like to show GPU statistics. Unfortunately, the format
for these statistics is vendor specfic (see the "Performance Statistics" dictionary below.)
In order to cover as many devices as possible, I'd like you to run the following commands
from your Terminal:
$ sysctl hw.model
$ ioreg -r -d 1 -w 0 -c "IOAccelerator"
You can help me read the results by putting them in a code block (triple backticks).
View Dev Center downtime
To: Phil Schiller <>
Subject: Dev Center downtime
Dear Phil,
As I'm sure you're aware, the Mac and iOS Dev Centers have been down for more than a day. This means developers can't:
• Discuss issues in the forums
• Read iOS7 and Mavericks documentation
• Watch WWDC videos
chockenberry /
Last active Jun 6, 2018
A simple shell script to turn the Finders desktop icons on and off
defaults read CreateDesktop > /dev/null 2>&1
if [ "$1" = "off" ]; then
if [ $enabled -eq 1 ]; then
defaults write CreateDesktop false
osascript -e 'tell application "Finder" to quit'
open -a Finder
chockenberry / gist:11056920
Last active Mar 15, 2017
View gist:11056920
// NSFont+SystemFont.h
// xScope
// Created by Craig Hockenberry on 4/17/14.
// Thanks to
#import <Cocoa/Cocoa.h>
View UIColor+RGB.m
// Created by Sean Heber on 4/12/12.
#import <UIKit/UIKit.h>
// If you work with a designer who specifies color in sRGB using 102,0,204, this category makes it simpler to instantiate
// a color with that specification: [UIColor colorWithRGB:102:0:204 alpha:1.0];
@interface UIColor (RGB)
// NOTE: If you're using the extended sRGB color space, you'll want to use something other than UInt8 :-)
+ (UIColor *)colorWithRGB:(UInt8)r :(UInt8)g :(UInt8)b alpha:(CGFloat)alpha;
View gist:5469201
> var buf_ucs2 = new Buffer([0x35,0xD8,0x9c,0xDC])
> buf_ucs2.toString('ucs2')
> var str = buf_ucs2.toString('ucs2')
> str
> var buf_utf8 = new Buffer(str, 'utf8')
View gist:5464387
// Unicode: U+2764 U+1F47D U+1F525 U+1F4A9
// UTF-8 E2 9D A4 F0 9F 91 BD F0 9F 94 A5 F0 9F 92 A9
> var str = '❤ 👽 🔥 💩'
> str
'❤ 👽 🔥 💩'
> var buf = new Buffer(str, 'utf8')
chockenberry / gist:3628620
Created Sep 5, 2012
View gist:3628620
// NSEvent+MouseClamped.h
// xScope
// Created by Craig Hockenberry on 7/25/12.
// Copyright (c) 2012 The Iconfactory. All rights reserved.
#import <Cocoa/Cocoa.h>
View gist:1260280
- (void)loadDefaultSettings
NSMutableDictionary *defaults = [NSMutableDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Default-Settings" ofType:@"plist"]];
// other setup...
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithDictionary:defaults]];
- (void)resetDefaultSettings
You can’t perform that action at this time.