Skip to content

Instantly share code, notes, and snippets.

View atnan's full-sized avatar

Nathan de Vries atnan

View GitHub Profile
#!/usr/bin/env bash
# Get a sample dictionary here:
# http://labs.kitiyo.com/files/t9.dic
umask 077
NUMN=/tmp/numn.$$
trap "exit 1" HUP INT PIPE QUIT TERM
trap "rm -f $DICTN $NUMN" EXIT
#import <Foundation/Foundation.h>
/*
$ gcc -x objective-c -Wno-import -lobjc -framework Foundation subclassing.m
$ ./a.out
-[FooThatCallsSelf initWithBar:]
-[SubFooThatCallsSelf init]
-[FooThatCallsSuper initWithBar:]
*/
#!/usr/bin/env bash
function serve() {
ruby -rwebrick <<-EOM
server = WEBrick::HTTPServer.new({
:Port => 1234,
:DocumentRoot => File.expand_path('$1'),
:MimeTypes => WEBrick::HTTPUtils::load_mime_types('/etc/apache2/mime.types')
})
trap("INT"){ server.shutdown }
#!/bin/bash
export CODESIGN_ALLOCATE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate
codesign -f -s "iPhone Developer" "$1.app"
/*
* NSObjectPropertyObservers.h
*
* Created by Nathan de Vries on 12/03/10.
* Copyright 2010 Nathan de Vries. All rights reserved.
*
*/
#define OBSERVE_CHANGES_FOR_PROPERTIES(...) \
\
static NSString * const AQPerThreadManagedObjectContext = @"AQPerThreadManagedObjectContext";
void StoreManagedObjectContextForCurrentThread( NSManagedObjectContext * context )
{
[[[NSThread currentThread] threadDictionary] setObject: context forKey: AQPerThreadManagedObjectContext];
}
NSManagedObjectContext * PerThreadManagedObjectContext( void )
{
NSManagedObjectContext * result = [[[NSThread currentThread] threadDictionary] objectForKey: AQPerThreadManagedObjectContext];
do shell script "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\" --enable-webgl & killall applet"
#/usr/bin/env bash
brewprefix="$( brew --prefix )"
rvmpath="$HOME/.rvm"
sources=(
"$brewprefix/etc/bash_completion"
"$brewprefix/Library/Contributions/brew_bash_completion.sh"
"$rvmpath/scripts/rvm"
"$rvmpath/scripts/completion"
# define ALog(format, ...) NSLog((@"%s [L%d] " format), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
# ifdef DEBUG
# define DLog(format, ...) ALog(format, ##__VA_ARGS__);
# else
# define DLog(...)
# endif
Check altitude...
http://ws.geonames.org/gtopo30JSON?lat=-33.92541457768646&lng=151.11934661865234&callback=loadJSON