Skip to content

Instantly share code, notes, and snippets.

@mmalecki
mmalecki / file.js
Created September 15, 2012 19:17
How `module._extensions` works
var module = require('module');
module._extensions['.ext'] = function (module, filepath) {
module.exports = 42;
};
console.dir(require('./whatever.ext'));
function getLine(offset) {
var stack = new Error().stack.split('\n'),
line = stack[(offset || 1) + 1].split(':');
return parseInt(line[line.length - 2], 10);
}
global.__defineGetter__('__LINE__', function () {
return getLine(2);
});
@mmalecki
mmalecki / zero-downtime.js
Created May 24, 2012 12:29
Quick and dirty zero-downtime process restart
var http = require('http'),
fork = require('child_process').fork;
var serverHandle, server;
function log(l) {
console.log(process.pid + ': ' + l);
}
process.on('SIGUSR2', function () {
var fs = require('fs');
fs.readFile('file', function (ಠ_ಠ, data) {
if (ಠ_ಠ) {
console.log("Node does not approve");
}
});
@mmalecki
mmalecki / gist:2070387
Created March 18, 2012 10:24
OH #nodejitsu
13:20 < Nexxy> mmalecki, I experienced OC spray today!
13:21 <+mmalecki> Nexxy: why would you even
13:21 < Nexxy> I wanted to make sure it worked
13:22 < Nexxy> it... it works.
13:22 <+mmalecki> what.
13:22 < Nexxy> I bought OC spray for my waifu and I and I read that you should test them to make sure they work
13:22 < Nexxy> so I did.
13:22 < Nexxy> and they do.
13:22 < Nexxy> really well.
13:23 < Nexxy> so well I had to take a nap after I was done choking
@mmalecki
mmalecki / package.json
Created March 12, 2012 13:16
private packages on nodejitsu
{
"name": "super-secretz",
"dependencies": {
"secretz": "git+ssh://git@github.com:secretz/secretz.git"
},
"bundleDependencies": [ "secretz" ]
}
GNU gdb (GDB) Fedora (7.2-52.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /mnt/Data/Maciej/Programowanie/src/node-g/node...done.
[maciej@PC04 node-g]$ gdb --args ./node deps/npm/cli.js
GNU gdb (GDB) Fedora (7.2-52.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
[maciej@PC04 node]$ gdb --args ./node deps/npm/cli.js
GNU gdb (GDB) Fedora (7.2-52.fc14)
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
@mmalecki
mmalecki / gist:1845715
Created February 16, 2012 15:41
node@ce485791db5507d160cbc204b8a58e770ac60a50 test results, Mac OS X
[maciej@pc07 node (master)]$ make test
make -C out BUILDTYPE=Release
make[1]: Nothing to be done for `all'.
ln -fs out/Release/node node
python tools/test.py --mode=release simple message
=== release test-fs-watch ===
Path: simple/test-fs-watch
Command: out/Release/node /Users/maciej/dev/JavaScript/node/test/simple/test-fs-watch.js
--- TIMEOUT ---
=== release test-http-full-response ===