Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Rajlich TooTallNate

View GitHub Profile
@TooTallNate
TooTallNate / notification.js
Created May 6, 2011
Example of displaying a notification on an iPhone with 'node-iOS'
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);
@TooTallNate
TooTallNate / accelerometerCommandLineTest.m
Created May 12, 2011
An attempt at getting accelerometer data from a command-line program running on a jailbroken iDevice
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
@TooTallNate
TooTallNate / vib.c
Created Jun 4, 2011
Attempt at using the iOS private `GSEventVibrateForDuration` function... this doesn't seem to work...
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;
}
@TooTallNate
TooTallNate / .gitignore
Created Jul 9, 2011
low-level objc runtime apis
View .gitignore
*
!*.m
!Makefile
@TooTallNate
TooTallNate / objc.js
Created Jul 13, 2011
Experimentations with node-ffi
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
@TooTallNate
TooTallNate / NodObjC-2.js
Created Jul 15, 2011
Proposed NodObjC Message-Sending API
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);
@TooTallNate
TooTallNate / mixpanel.js
Created Aug 8, 2011
Mixpanel JS Lib, Beautified
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;
@TooTallNate
TooTallNate / metaweblog.js
Created Aug 10, 2011
A little helper Class to send MetaWeblog API requests.
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);