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
// Adds a 'fitTextToWidth' function. Which essentially accepts a String and | |
// an Number (int) parameters. The String is a long string of text (i.e. | |
// dialoge in a RPG) and adds '\n' characters throughout the String. | |
// | |
// The placement of '\n' characters is determined by the second param, which | |
// should be the maximum width of a single line of text. | |
// | |
// Depends on Prototype's Language extensions ($w, Enumberable, etc.). Meant | |
// to be used with my Simple Game Framework. |
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
// If no exception is passed into 'getScriptName', it will only | |
// retrieve the URL of the script where 'getScriptName' is defined. | |
// In order to get the URL of a different script file, you must | |
// pass an exception generated in this script file to 'getScriptName'. | |
try { | |
(0)(); | |
} catch(ex) { | |
getScriptName(ex, onScriptNameKnown); | |
} |
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
webfont.DomHelper.prototype.setCssStyle = function(styleNode, body) { | |
if (styleNode.styleSheet) { | |
styleNode.styleSheet.cssText = body; | |
} else { | |
styleNode.appendChild(this.document_.createTextNode(body)); | |
} | |
return styleNode; | |
} | |
/** |
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'); | |
var r = http.createClient(80, 'pri.kts-af.net'); | |
var request = r.request('GET', '/redir/index.pls?esid=cb07887ce881c6164c3ae52a58c55361&url_no=1&client_id=7&uid=68efed4d03ec7e45fd3978262c107180&clicksrc=xml', { | |
'Host': 'pri.kts-af.net' | |
}); | |
request.on('response', function (response) { | |
console.log('STATUS: ' + response.statusCode); | |
}); |
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 port = 8080; | |
require('net').createServer(function(stream) { | |
var id = Date.now(); | |
var filename = stream.remoteAddress + '.' + id + '.dump'; | |
var dumpStream = require('fs').createWriteStream(filename); | |
dumpStream.on('close', function() { | |
console.error('File "' + filename + '" closed'); | |
}); | |
stream.on('timeout', function() { | |
console.error('Closing connection id ' + id + ', due to inactivity (timeout after 5 seconds)'); |
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 spawn = require('child_process').spawn; | |
var http = require('http'); | |
http.createServer(function (request, response) { | |
response.writeHead(200, { | |
'Content-Type': 'text/plain', | |
'Connection':'close', | |
'Transfer-Encoding':'identity' // 'chunked' can't be used unfortunately | |
// since the child_process won't know how |
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
#! /bin/bash | |
# | |
# Program : iphone4.2-node-configure | |
# Authors : Nathan Rajlich ([email protected]) | |
# Michael Aaron Safyan ([email protected]) | |
# Synopsis : This program runs the "configure" script for Node.js. | |
# An install prefix of "/opt/iphone-4.2/" is used. | |
unset CPATH |
OlderNewer