Skip to content

Instantly share code, notes, and snippets.

View chockenberry's full-sized avatar

Craig Hockenberry chockenberry

View GitHub Profile
- (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 September 5, 2012 00:50
NSEvent+MouseClamped
//
// NSEvent+MouseClamped.h
// xScope
//
// Created by Craig Hockenberry on 7/25/12.
// Copyright (c) 2012 The Iconfactory. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@chockenberry
chockenberry / gist:5464387
Created April 26, 2013 00:45
Unicode trim
// 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')
@chockenberry
chockenberry / gist:5469201
Created April 26, 2013 18:09
Unicode trim 2
> 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
To: Phil Schiller <[email protected]>
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 October 22, 2020 19:23
NSFont+SystemFont
//
// 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 October 22, 2020 19:23
Pipe standard output to a running Cocoa app
1) Create a script named '~/bin/xscope':
#!/bin/sh
parameter=""
if [ -z "$1" ]; then
parameter=`cat /dev/stdin`
else
parameter="$1"
fi
#!/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
@chockenberry
chockenberry / gist:85d10a83a924e415ece6
Created October 31, 2014 18:07
xScope Status Items
- (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 October 22, 2020 19:24
LAST TIME I WAS IN A PLAY GROUND I GOT BUSTED
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