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
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
@chockenberry
chockenberry / gist:3628620
Created Sep 5, 2012
NSEvent+MouseClamped
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:5464387
// Names: HEAVY BLACK HEART <space> EXTRATERRESTRIAL ALIEN <space> FIRE <space> PILE OF POO
// 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
'❤ 👽 🔥 💩'
undefined
> var buf = new Buffer(str, 'utf8')
View gist:5469201
> var buf_ucs2 = new Buffer([0x35,0xD8,0x9c,0xDC])
undefined
> buf_ucs2.toString('ucs2')
'𝒜'
> var str = buf_ucs2.toString('ucs2')
undefined
> str
'𝒜'
> var buf_utf8 = new Buffer(str, 'utf8')
undefined
View Dev Center downtime
To: Phil Schiller <schiller@apple.com>
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
chockenberry / gist:11056920
Last active Mar 15, 2017
NSFont+SystemFont
View gist:11056920
//
// NSFont+SystemFont.h
// xScope
//
// Created by Craig Hockenberry on 4/17/14.
//
// Thanks to http://nshipster.com/method-swizzling/
#import <Cocoa/Cocoa.h>
@chockenberry
chockenberry / gist:11235824
Last active Aug 29, 2015
Pipe standard output to a running Cocoa app
View gist:11235824
1) Create a script named '~/bin/xscope':
#!/bin/sh
parameter=""
if [ -z "$1" ]; then
parameter=`cat /dev/stdin`
else
parameter="$1"
fi
View appcheck
#!/bin/sh
find=`find /Applications /Applications/Utilities -maxdepth 2 -name '*.app' -exec echo \{\} \;`
#echo $find
IFS=$'\n'
apps=($find)
total=${#apps[*]}
echo "Checking $total applications..."
echo "The following applications will break in Gatekeeper on 10.9.5 and Yosemite:"
count=0
View gist:85d10a83a924e415ece6
- (void)createStatusItems
{
const CGFloat itemLength = 22.0f;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if ([userDefaults boolForKey:generalStatusbarSingleItemKey]) {
// create a single status item with a menu to access tools
NSMenu *statusMenu = [[[NSMenu alloc] initWithTitle:@"Status"] autorelease];
@chockenberry
chockenberry / gist:055bd31f28f3bc5904ea
Last active Aug 29, 2015
LAST TIME I WAS IN A PLAY GROUND I GOT BUSTED
View gist:055bd31f28f3bc5904ea
typealias BOOLAEN = Bool
typealias LIKEON68K = UInt16
typealias LIKEONPENTIUM = UInt32
typealias STRING = String
typealias STRINGINDEX = String.Index
typealias BOOL = Bool
typealias UNICODESCALER = UnicodeScalar
typealias GONADS = String
typealias NUMBERSWITHDOTS = Double
You can’t perform that action at this time.