This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:)?/, ''); | |
})); | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
function test () { | |
console.log('hello?') | |
} | |
test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Requires node v0.7.7 or greater. | |
* | |
* To connect: $ curl -sSNT. localhost:8000 | |
*/ | |
var http = require('http') | |
, repl = require('repl') | |
, buf0 = new Buffer([0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run with "node --expose_gc" | |
var weak = require('weak') | |
, util = require('util') | |
var count = 0 | |
, countGc = 0 | |
function dec () { | |
count-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = foo; | |
require('./index.js')(); | |
function foo(){ | |
console.log('foo.js', Date.now() ); | |
} |
OlderNewer