Skip to content

Instantly share code, notes, and snippets.

View darknoon's full-sized avatar

Andrew Pouliot darknoon

View GitHub Profile
@darknoon
darknoon / OutlineView.m
Last active September 6, 2016 05:11
This is the simplest way I could figure out how to make a view-based NSOutlineView
@interface AppDelegate : NSObject <NSApplicationDelegate, NSOutlineViewDataSource, NSOutlineViewDelegate>
@end
@implementation AppDelegate {
NSWindow *_w;
NSDictionary *_data;
}
#ifndef DBG_MACH_CHUD
#define DBG_MACH_CHUD 0x0A
#define DBG_FUNC_START 1
#define DBG_FUNC_END 2
#define DBG_APPS 33
#define KDBG_CODE(Class, SubClass, code) (((Class & 0xff) << 24) | ((SubClass & 0xff) << 16) | ((code & 0x3fff) << 2))
#define APPSDBG_CODE(SubClass,code) KDBG_CODE(DBG_APPS, SubClass, code)
@darknoon
darknoon / gist:4482025
Created January 8, 2013 07:46
Safe KVC macro by Andrew Pouliot. In the public domain.
//o is an object type, k is the key on which to check validity
//returns a NSString constant of the relevant key
#define KVC(o, k) (0 && sizeof(o.k) ? @#k : @#k)
//Usage:
ObjectWithMethodCalledKeyName *object = ...;
[object addObserver:self forKeyPath:KVC(object, keyName) options:0 context:NULL];
@darknoon
darknoon / burst.vsh
Created June 17, 2011 18:34
Antialiased burst from color stripes
//Declare a 2D texture as a uniform variable
uniform sampler2D texture;
uniform float samples;
void main()
{
vec2 poissonDisk[8];
poissonDisk[0] = vec2(-0.613392, 0.617481);
@interface A : NSObject
- (void)doSomething;
@end
@implementation A
- (void)doSomething;
{