Skip to content

Instantly share code, notes, and snippets.

View TooTallNate's full-sized avatar

Nathan Rajlich TooTallNate

View GitHub Profile
@TooTallNate
TooTallNate / AudioToolbox.bridgesupport
Created September 1, 2011 21:44
The BridgeSupport file for iOS from the AudioToolbox framework (from iOS SDK 4.3)
<?xml version='1.0'?>
<!DOCTYPE signatures SYSTEM "file://localhost/System/Library/DTDs/BridgeSupport.dtd">
<signatures version='1.0'>
<depends_on path='/System/Library/Frameworks/Accelerate.framework'/>
<struct name='AUNodeConnection' type='{AudioUnitNodeConnection=&quot;sourceNode&quot;i&quot;sourceOutputNumber&quot;I&quot;destNode&quot;i&quot;destInputNumber&quot;I}'/>
<struct name='AUNodeInteraction' type='{AUNodeInteraction=&quot;nodeInteractionType&quot;I&quot;nodeInteraction&quot;(?=&quot;connection&quot;{AudioUnitNodeConnection=&quot;sourceNode&quot;i&quot;sourceOutputNumber&quot;I&quot;destNode&quot;i&quot;destInputNumber&quot;I}&quot;inputCallback&quot;{AUNodeRenderCallback=&quot;destNode&quot;i&quot;destInputNumber&quot;I&quot;cback&quot;{AURenderCallbackStruct=&quot;inputProc&quot;^?&quot;inputProcRefCon&quot;^v}})}'/>
<struct name='AUNodeRenderCallback' type='{AUNodeRenderCallback=&quot;destNode&quot;i&quot;destInputNumber&quot;I&quot;cback&quot;{AURenderCallbackStruct=&quot;inputProc&quot;^?&quo
module.exports = function (a, b) {
return a + b
}
@TooTallNate
TooTallNate / cocoa-hello-world.js
Created September 5, 2011 03:37
Creating a Cocoa GUI window with NodObjC
var $ = require('./')
$.import('Foundation')
$.import('Cocoa')
var pool = $.NSAutoreleasePool('alloc')('init')
var app = $.NSApplication('sharedApplication')
var style = $.NSClosableWindowMask | $.NSResizableWindowMask
| $.NSTexturedBackgroundWindowMask | $.NSTitledWindowMask
| $.NSMiniaturizableWindowMask
@TooTallNate
TooTallNate / cocoa-hello-world2.js
Created September 8, 2011 17:07
Creating a Cocoa GUI window with NodObjC, with a proper Menu, dock icon, and NSApplicationDelegate.
// This example adapted from Matt Gallagher's "Minimalist Cocoa Programming"
// blog article:
// http://cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
var $ = require('NodObjC')
$.import('Cocoa')
var pool = $.NSAutoreleasePool('alloc')('init')
, app = $.NSApplication('sharedApplication')
Handle<Value> Pointer::PutObject(const Arguments& args)
{
HandleScope scope;
Pointer *self = ObjectWrap::Unwrap<Pointer>(args.This());
unsigned char *ptr = self->GetPointer();
if (args.Length() >= 1) {
Local<Value> obj = args[0];
*((unsigned char **)ptr) = reinterpret_cast<unsigned char*>(new Persistent<Value>(obj));
var ffi = require('./')
, assert = require('assert')
var p = new ffi.Pointer(1024)
, orig = p.seek(0)
var put1 = { test: { equality: true } }
, put2 = { test2: 'does this work?' }
p.putObject(put1, true)
@TooTallNate
TooTallNate / process.title-fail.js
Created September 22, 2011 20:39
Node's `process.title` handling being inconsistent with Cocoa's
var $ = require('NodObjC')
$.import('Foundation')
var pool = $.NSAutoreleasePool('alloc')('init')
var pi = $.NSProcessInfo('processInfo')
// Initial
console.log('Initial:')
console.log('process.title: %s', process.title)
console.log('pi("processName"): %s', pi('processName'))
@TooTallNate
TooTallNate / mobiledevice.js
Created September 23, 2011 00:42
half-attempt at using the MobileDevice framework with NodObjC
var $ = require('NodObjC')
, ffi = require('node-ffi')
$.import('MobileDevice')
function callback (info, foo) {
console.log('inside callback!')
}
// Get a function pointer to the callback function above
@TooTallNate
TooTallNate / weakmap.js
Created September 23, 2011 22:08
Creating a barebones WeakMap with node-weak (String keys only)
var weak = require('weak')
// This is our weakmap; a regular JS Object
var map = {}
// This is the object we wanna store a weak reference to
var anObj = { foo: 'bar' }
, key = 'anObj'
// Create a weak reference and store it in the map.
@TooTallNate
TooTallNate / Run.js
Created September 27, 2011 21:04 — forked from bored-engineer/Run.js
MobileDevice NodObjC basic example.
var $ = require('NodObjC')
$.import('MobileDevice');
$.import('CoreFoundation')
// Callback function that's invoked when a device is plugged in
function callback (info, foo) {
try {
console.log('inside callback!')
var i = new $.am_device_notification_callback_info(info)