View notification.js
var iOS = require('iOS'); | |
iOS.createNotification({ | |
header: 'node-iOS Rocks!', | |
message: 'How much does running \'node\' on your iPhone rock?', | |
defaultButton: 'A lot!', | |
alternateButton: 'It rocks my socks' | |
}, function(err, res){ | |
if (err) throw err; | |
console.log(res); |
View accelerometerCommandLineTest.m
// To compile: | |
// gcc -o runLoop runLoop.m -framework Foundation -framework UIKit | |
#import <Foundation/Foundation.h> | |
#import <UIKit/UIKit.h> | |
@interface AccelerometerDelegate: NSObject<UIAccelerometerDelegate> { | |
} | |
@end |
View vib.c
// To compile: | |
// gcc -o vib vib.c -F/System/Library/PrivateFrameworks -framework GraphicsServices | |
#import <GraphicsServices/GSEvent.h> | |
int main() { | |
GSEventVibrateForDuration(3.5f); | |
return 0; | |
} |
View .gitignore
* | |
!*.m | |
!Makefile |
View objc.js
var ffi = require('node-ffi') | |
, objc = new ffi.Library(null, { | |
'objc_getClass': [ 'pointer', [ 'string' ] ] | |
, 'class_getName': [ 'string', [ 'pointer' ] ] | |
, 'sel_registerName': [ 'pointer', [ 'string' ] ] | |
, 'sel_getName': [ 'string', [ 'pointer' ] ] | |
, 'objc_msgSend': [ 'pointer', [ 'pointer', 'pointer' ] ] | |
}) | |
// The problem with libffi and C functions that accepts varargs is that we | |
// have to create new wrappers for each different argument and return value |
View NodObjC-2.js
var $ = require('NodObjC') | |
// First you need to "load" the Framework | |
$.import('Foundation') | |
// Make the 'NSMutableArray' constructor be global | |
var NSMutableArray = $.NSMutableArray | |
// Now let's create an NSMutableArray | |
, array = NSMutableArray('alloc')('init') |
View gist:1126682
require('datejs'); | |
console.error(Date.CultureInfo); |
View mixpanel.js
var MixpanelLib = function (j, n, m) { | |
function k(a, c, b) { | |
if (a.length) { | |
var e; | |
for (e = 0; e < a.length; e++) c.call(b || c, a[e], e) | |
} else if (typeof a == "object") for (e in a) Object.hasOwnProperty.call(a, e) && c.call(b || c, a[e], e) | |
} | |
function z(a, c) { | |
a.prototype = new c; | |
a.prototype.constructor = a; |
View metaweblog.js
var xmlrpc = require('xmlrpc') | |
, parse = require('url').parse | |
, slice = Array.prototype.slice | |
function MetaWeblog (url) { | |
var parsed = parse(url) | |
, client = xmlrpc.createClient({ | |
host: parsed.hostname | |
, path: parsed.pathname | |
, port: parsed.port || 80 |
View purple.js
var FFI = require("node-ffi"); | |
var CUSTOM_USER_DIRECTORY= "/Users/santiago/tmp"; | |
var Purple = new FFI.Library("/Users/santiago/tmp/lib/libpurple", { "purple_util_set_user_dir": [ "void", [ "string" ] ] }); | |
Purple.purple_util_set_user_dir(CUSTOM_USER_DIRECTORY); |