View upnp.js
/* 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: |
View 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:)?/, ''); | |
})); | |
}) | |
} |
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); |
View strict.js
"use strict"; | |
function test () { | |
console.log('hello?') | |
} | |
test() |
View play-codestream.js
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.') | |
}) |
View server.js
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') |
View obj-gc-test-fail.js
// run with "node --expose_gc" | |
var weak = require('weak') | |
, util = require('util') | |
var count = 0 | |
, countGc = 0 | |
function dec () { | |
count-- |
View foo.js
module.exports = foo; | |
require('./index.js')(); | |
function foo(){ | |
console.log('foo.js', Date.now() ); | |
} |
View Run.js
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) |
View bbs.js
/** | |
* Requires node v0.7.7 or greater. | |
* | |
* To connect: $ curl -sSNT. localhost:8000 | |
*/ | |
var http = require('http') | |
, repl = require('repl') | |
, buf0 = new Buffer([0]) |
OlderNewer