Skip to content

Instantly share code, notes, and snippets.

View AndreasMadsen's full-sized avatar

Andreas Madsen AndreasMadsen

View GitHub Profile
Andreass-MacBook-Pro:node Andreas$ sudo dtruss node child/deamon.js
head: 7880
SYSCALL(args) = return
getpid(0x0, 0x0, 0x0) = 7880 0
__sysctl(0xC00387AC, 0x3, 0xC00387A8) = 0 0
issetugid(0xC00387AC, 0x3, 0xC00387A8) = 0 0
csops(0x0, 0x0, 0xC003881C) = 0 0
shared_region_check_np(0xC00367A0, 0x0, 0xC003881C) = 0 0
stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0xC00379F0, 0xC003881C) = 0 0
open("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0x0, 0x0) = 3 0
Andreass-MacBook-Pro:node Andreas$ sudo dtruss -f node child/deamon.js
Password:
head: 480
PID/THRD SYSCALL(args) = return
480/0x3bbd: getpid(0x0, 0x0, 0x0) = 480 0
480/0x3bbd: __sysctl(0xC00077AC, 0x3, 0xC00077A8) = 0 0
480/0x3bbd: issetugid(0xC00077AC, 0x3, 0xC00077A8) = 0 0
480/0x3bbd: csops(0x0, 0x0, 0xC000781C) = 0 0
480/0x3bbd: shared_region_check_np(0xC00057A0, 0x0, 0xC000781C) = 0 0
480/0x3bbd: stat64("/usr/lib/dtrace/libdtrace_dyld.dylib\0", 0xC00069F0, 0xC000781C) = 0 0
@AndreasMadsen
AndreasMadsen / log.txt
Created February 5, 2012 12:12
#2698 strace on linux
This file has been truncated, but you can view the full file.
2307 execve("/usr/local/bin/node", ["node", "child/deamon.js"], [/* 21 vars */]) = 0
2307 brk(0) = 0x1a7f000
2307 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
2307 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f22f81f9000
2307 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
2307 open("/etc/ld.so.cache", O_RDONLY) = 3
2307 fstat(3, {st_mode=S_IFREG|0644, st_size=58473, ...}) = 0
2307 mmap(NULL, 58473, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f22f81ea000
2307 close(3) = 0
2307 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
@AndreasMadsen
AndreasMadsen / result.txt
Created February 5, 2012 19:08
test signals
{ SIGUSR2: { died: true, message: 'exit emitted' },
SIGUSR1: { died: false, message: 'not emitted' },
SIGINFO:
{ died: false,
message: 'signal not supported' },
SIGWINCH: { died: false, message: 'not emitted' },
SIGPROF: { died: true, message: 'exit emitted' },
SIGVTALRM: { died: true, message: 'exit emitted' },
SIGXFSZ: { died: true, message: 'exit emitted' },
SIGXCPU: { died: true, message: 'exit emitted' },
@AndreasMadsen
AndreasMadsen / proxy.js
Created February 15, 2012 17:07
proxy draft
var http = require('http');
http.createServer(function (req, res) {
req.pause();
var newReq = modifyRequest(req);
var proxy_req = http.request(newReq, function (proxy_res) {
req.resume();
req.pipe(proxy_req); //we miss trailer headers here
proxy_res.pipe(res); //we miss all headers here
});
}).listen(80, "127.0.0.1");
@AndreasMadsen
AndreasMadsen / log.txt
Created March 30, 2012 13:10
eio test on linux
andreas@ubuntu:~/GitHub/node$ make test
make -C out BUILDTYPE=Release
make[1]: Entering directory `/home/andreas/GitHub/node/out'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/andreas/GitHub/node/out'
ln -fs out/Release/node node
python tools/test.py --mode=release simple message
=== release test-eio-race ===
Path: simple/test-eio-race
trying to kill event loop ...
@AndreasMadsen
AndreasMadsen / mac.txt
Created March 31, 2012 09:39
test fork-socket
Andreass-MacBook-Pro:node Andreas$ 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-http-full-response ===
Path: simple/test-http-full-response
assert.js:104
throw new assert.AssertionError({
^
@AndreasMadsen
AndreasMadsen / spawn.js
Created April 12, 2012 12:18
immortal example
var net = require('net');
var immortal = require('immortal');
var spawn = function(id, callback) {
var socket = net.connect('/tmp/monitor.sock');
console.log(id, 'start');
socket.on('error', function(error) {
if (error.code !== 'ENOENT') throw error;
@AndreasMadsen
AndreasMadsen / gist:2693051
Created May 14, 2012 10:04
base64 shim [atob, btoa]
// Source: http://code.google.com/p/gflot/source/browse/trunk/flot/base64.js?r=153
/* Copyright (C) 1999 Masanao Izumo <iz@onicos.co.jp>
* Version: 1.0
* LastModified: Dec 25 1999
* This library is free. You can redistribute it and/or modify it.
*/
/*
* Interfaces:
@AndreasMadsen
AndreasMadsen / File processor.md
Created May 16, 2012 07:30
File converter module (piccolo project)

#File processor

Submodule to piccolo

The propuse is to create an abstraction for reading and processing static files. The source code of the static files should be in read and then be processed and copied to write so they don't have to be processed, even after an application crash. In order to know if the files has been changed since the even after an application crash crash, an map object between fs.Stat.modefied and the jsonFile.modefied will be stored.

  var module = require("module");
  
  var convert = module({