This file contains hidden or 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 setNestedJSON = function(on, path, value) { | |
if (!(path instanceof Array)) { | |
path = path.split('\.'); | |
} | |
if (path && path.length > 0) { | |
var current = on; | |
var key = null; | |
while((key = path.shift()) != null) { |
This file contains hidden or 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 requestCounter = 0; | |
var startedRequests = 0; | |
var endedRequests = 0; | |
http.createServer(function (request, response) { | |
request.number = requestCounter++; | |
console.log("#" + request.number + " started"); |
This file contains hidden or 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'); | |
http.createServer(function (req, res) { | |
// set up some routes | |
switch(req.url) { | |
case '/': | |
console.log("[501] " + req.method + " to " + req.url); | |
res.writeHead(501, "Not implemented", {'Content-Type': 'text/html'}); | |
res.end('<html><head><title>501 - Not implemented</title></head><body><h1>Not implemented!</h1></body></html>'); | |
break; |
This file contains hidden or 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 querystring = require('querystring'); | |
var utils = require('utils'); | |
http.createServer(function (req, res) { | |
switch(req.url) { | |
case '/': | |
res.writeHead(200, "OK", {'Content-Type': 'text/html'}); | |
res.write('<html><head><title>Example</title></head><body>'); | |
res.write('<form enctype="application/x-www-form-urlencoded" action="/formhandler" method="post">'); |
This file contains hidden or 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 qs = require('querystring'); | |
var query = "foo[name]=bar&foo[bar]=foobar"; | |
var res = qs.parse(query); | |
console.log(res.foo.foo); | |
console.log(res['foo']['bar']); |
This file contains hidden or 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 printMemoryUsage = function() { | |
var spawn = require('child_process').spawn, | |
getconf = spawn('getconf', ['PAGESIZE']); | |
getconf.stdout.on('data', function (data) { | |
var pageSize = parseInt(data, 10); | |
console.log('Page size: ' + pageSize); | |
var procOutput = spawn('cat', ['/proc/' + process.pid + '/status']); |
This file contains hidden or 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
/* | |
* syslog-server.js | |
* | |
* @version 0.1.0 | |
* @author Frank Grimm (http://frankgrimm.net) | |
* | |
*/ | |
exports.getServer = function(bind_port, bind_ip, callback) { |
This file contains hidden or 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
/* | |
* syslog-messages.js | |
* | |
* Encoding and decoding of CentOS syslog messages. | |
* | |
* @version: 0.1.0 | |
* @author Frank Grimm (http://frankgrimm.net) | |
* | |
*/ |
This file contains hidden or 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 Script = process.binding('evals').Script; | |
var stdin = process.openStdin(); | |
stdin.setEncoding('utf8'); | |
var scriptCode = ''; | |
stdin.on('data', function (chunk) { | |
scriptCode += chunk; | |
}); | |
stdin.on('end', function () { | |
Script.runInThisContext(scriptCode); |
This file contains hidden or 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
test-client-connect.js test-client-query.js | |
[root@speicher node-mysql]# node test/system/test-client-connect.js | |
{ length: 52 | |
, received: 52 | |
, number: 0 | |
, type: 0 | |
, protocolVersion: 10 | |
, serverVersion: '5.0.45' | |
, threadId: 132500 | |
, scrambleBuffer: <Buffer 66 3c 37 3d 6c 2b 2f 47 59 6b 2e 41 3c 48 35 70 56 3f 77 5b> |