This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# .git/hooks/post-checkout | |
# chmod +x .git/hooks/post-checkout | |
if [ $(git symbolic-ref HEAD | cut -d '/' -f 3) == 'master' ]; then | |
lines[0]="Master, Master, where's the dreams that I've been after?" | |
lines[1]="Master, Master, you promised only lies" | |
lines[2]="Laughter, laughter, all I hear or see is laughter" | |
lines[3]="Laughter, laughter, laughing at my cries" | |
echo " ${lines[$((RANDOM%${#lines[*]}))]}"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define ObjectKeyPath(OBJECT, KEYPATH) \ | |
((void)(NO && ((void)OBJECT.KEYPATH, NO)), @ # KEYPATH ) | |
NSString *str = @"foobar"; | |
NSLog(@"%@", [str valueForKey:ObjectKeyPath(str, length)]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Most NSString instances will actually be __NSCFString instances, so here are both NSString and __NSCFString implementations. | |
* If you know how to create an NSString instance whose class is actually NSString please let me know. | |
* Other possible concrete subclasses of NSString are: NSConstantString, __NSCFConstantString, NSPathStore2, NSSimpleCString and __NSLocalizedString. | |
*/ | |
// CoreFoundation.framework 635.19.0 (Mac OS X 10.7.3) | |
@implementation NSObject | |
- (BOOL) isNSString__ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ppjson () { | |
ruby -e "require 'json'; puts JSON.pretty_generate(JSON.parse(STDIN.read))" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[[NSUserDefaultsController sharedUserDefaultsController] rac_subscribableForKeyPath:@"values.yourDefaultsKey" onObject:self] subscribeNext:(id x) { | |
// do the things | |
}]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSContainer+Subscripting.h | |
// | |
// Created by Markus Emrich on 10.08.12. | |
// Copyright 2012 nxtbgthng. All rights reserved. | |
// | |
#if !defined(__IPHONE_6_0) || __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_6_0 | |
#import "NSContainer+Subscripting.h" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <uuid/uuid.h> | |
#include <sys/types.h> | |
u_int64_t bits2uint64(unsigned char const bits[]) { | |
return ((u_int64_t)bits[0] << 56) | |
| ((u_int64_t)bits[1] << 48) | |
| ((u_int64_t)bits[2] << 40) | |
| ((u_int64_t)bits[3] << 32) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static NSInteger NSJSONReadingFuckNSNulls = (1UL << 3); | |
@implementation NSJSONSerialization (FuckNulls) | |
+ (void)load { | |
Method originalMethod = class_getClassMethod(self, @selector(JSONObjectWithData:options:error:)); | |
IMP swizzledImplementation = imp_implementationWithBlock([^id (id _self, NSData *_data, NSJSONReadingOptions _opt, NSError **_error){ | |
NSInputStream *stream = [NSInputStream inputStreamWithData:_data]; | |
[stream open]; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path as path | |
import string | |
import argparse | |
import glob | |
import re | |
def basename(filename): | |
base = filename | |
if filename.find('@2x') > 0: | |
base = filename[:filename.find('@2x')] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Close annoying notification windows that you can't Cmd+Tab to. | |
-- From: http://www.mentby.com/stockly-ed/window-watcher.html | |
tell application "System Events" | |
try | |
set unc to application process "UserNotificationCenter" | |
activate unc | |
set uncw to window 1 of unc | |
repeat with label in {"OK", "Close", "Ignore", "Cancel"} | |
try |
OlderNewer