Skip to content

Instantly share code, notes, and snippets.

View TooTallNate's full-sized avatar

Nathan Rajlich TooTallNate

View GitHub Profile
/* node UPNP port forwarding PoC
This is a simple way to forward ports on NAT routers with UPNP.
This is a not-for-production hack that I found useful when testing apps
on my home network behind ny NAT router.
-satori
usage:
@TooTallNate
TooTallNate / getip.js
Created October 17, 2010 20:39 — forked from isaacs/getip.js
var child_process = require("child_process");
function getIPs (cb) {
child_process.exec("ifconfig -a", function (er, o) {
if (er) return cb(er);
cb(null, o.match(/inet (?:addr:)?([0-9]{0,3}\.[0-9]{0,3}\.[0-9]{0,3}\.[0-9]{0,3})/g).map(function (i) {
return i.replace(/^inet (?:addr:)?/, '');
}));
})
}
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);
@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)
@TooTallNate
TooTallNate / strict.js
Created October 17, 2011 23:05 — forked from anonymous/gist:1294124
Testing if "use strict" requires functions to always return something...
"use strict";
function test () {
console.log('hello?')
}
test()
@TooTallNate
TooTallNate / bbs.js
Created March 16, 2012 22:42
Running a node.js REPL over `curl`
/**
* Requires node v0.7.7 or greater.
*
* To connect: $ curl -sSNT. localhost:8000
*/
var http = require('http')
, repl = require('repl')
, buf0 = new Buffer([0])
@TooTallNate
TooTallNate / play-codestream.js
Created April 3, 2012 18:56 — forked from sugyan/play-codestream.js
play codestre.am video on your terminal
var sio = require('socket.io-client')
, id = process.argv[2] || '3Y'
, socket = sio.connect('http://play.codestre.am/?id=' + id)
console.log('connecting...')
socket.on('connect', function () {
console.log('connected.')
})
@TooTallNate
TooTallNate / server.js
Created April 14, 2012 03:24 — forked from nicokaiser/server.js
node http request leak FIX!
var http = require('http')
, weak = require('weak')
function collectGET() { console.log('GET request collected by GC') }
function collectPOST() { console.log('POST request collected by GC') }
var server = http.createServer(function(req, res) {
if (req.method == 'GET') {
// GET
console.log('GET request')
// run with "node --expose_gc"
var weak = require('weak')
, util = require('util')
var count = 0
, countGc = 0
function dec () {
count--
@TooTallNate
TooTallNate / foo.js
Created August 15, 2012 22:34 — forked from mediaupstream/foo.js
Recursive require crashes node
module.exports = foo;
require('./index.js')();
function foo(){
console.log('foo.js', Date.now() );
}