Skip to content

Instantly share code, notes, and snippets.

View robb's full-sized avatar

Robb Böhnke robb

View GitHub Profile
@robb
robb / gist:5524258
Created May 6, 2013 09:49
Convenience macro for creating singletons and the like. Handy if you define a lot of fixture objects.
#define SHARED_INSTANCE(EXPR) \
^(){ \
static typeof((EXPR)) instance; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
instance = EXPR;\
});\
return instance;\
}()
@robb
robb / gist:4431330
Created January 2, 2013 00:43
OpenCL vectors with Clang
typedef float float3 __attribute__((ext_vector_type(3)));
- (void)test;
{
float3 a = {1, 2, 3};
a = 2.0f * a;
NSLog(@"%f %f %f", a.x, a.y, a.z);
}
@robb
robb / gist:2968975
Created June 21, 2012 22:22
macros and literals fail
STAssertEqualObjects(@[],
@[],
@"Works");
STAssertEqualObjects(@[@1],
@[@1],
@"Works");
STAssertEqualObjects(@[@1, @2, @3],
@[@1, @2, @3],
@robb
robb / numbers.md
Created April 23, 2012 16:46
Japanese Numbers Vocabulary

一 (one)

一  (いち) one
一つ (ひとつ) one thing
一時 (いちじ) one o'clock
一分 (いっぷん) one minute
一月 (いちがつ) January
一日 (いちにち) one day
一日 (ついたち) the 1st day of the month
一人 (ひとり) one person

@robb
robb / robbs-hacks.md
Created April 18, 2012 14:32
Music Hack Day Hacks

Music Hack Day Hacks I worked on

  • [Spinamp]
    Music Hack Day San Francisco – Feb 11, 2012
  • [Notorious Siri]
    Music Hack Day London – Dec 3, 2011
  • [6 Strings]
    Music Hack Day Montreal – Sep 24, 2011
  • SoundNebula
    Music Hack Day Berlin – May 28
'stereo':
size: {width: 23, height: 29}
'couch':
size: {width: 77, height: 34}
'computer':
size: {width: 19, height: 34}
spriteCount: 2
@robb
robb / NSColor+Hex.h
Created April 1, 2011 14:57
NSColor+Hex
//
// NSColor+Hex.h
// SoundCloud
//
// Created by Robert Böhnke on 4/1/11.
// Copyright 2011 Soundcloud Ltd. All rights reserved.
//
#import <Foundation/Foundation.h>
@robb
robb / Big Piano Hack.pde
Created September 5, 2010 21:20
Big Piano Hack
/* Music Hackday 2010
* Big Piano Hack
*/
const int LED_PIN = 13;
const byte CHANNEL = 0;
/* The pin numbers in chromatic order
*/
const int INPUT_PINS[] = {32, 30, 28, 26, 24, 22};
{
"name": "SBJson",
"version": "4.0.2",
"license": {
"type": "BSD",
"text": " Copyright (C) 2007-2015 Stig Brautaset. All rights reserved.\n\n Redistribution and use in source and binary forms, with or without\n modification, are permitted provided that the following conditions are met:\n\n * Redistributions of source code must retain the above copyright notice, this\n list of conditions and the following disclaimer.\n * Redistributions in binary form must reproduce the above copyright notice,\n this list of conditions and the following disclaimer in the documentation\n and/or other materials provided with the distribution.\n * Neither the name of the author nor the names of its contributors may be used\n to endorse or promote products derived from this software without specific\n prior written permission.\n\n THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT L
import Foundation
typealias JSONDictionary = [String: AnyObject]
/// Attempts to load a data from a given URL.
func loadData(URL: NSURL) -> Either<NSError, NSData> {
if let data = NSData(contentsOfURL: URL) {
return Either.Right(Box(data))
} else {
// In a real world scenario, we'd have a more useful error :-)