View QBird.js
app.config(['$qProvider', function($qProvider) {
// Tell Angular to create Bluebird promises instead of $q promises.
$qProvider.$get = function() {
function QBird(resolver) {
return new Promise(resolver);
QBird.defer = function() {
var deferred = {};
deferred.promise = new Promise(function(resolve, reject) {
View gist:c53e6b80bb3d0c89f9a2
matt@matt-dev ~> ~/node-binaries/nodejs-0.10.33
> e = new Error()
> Object.getOwnPropertyDescriptor(e, 'stack')
{ get: [Function],
set: [Function],
enumerable: false,
configurable: true }
> e.stack
'Error\n at repl:1:6\n at REPLServer.self.eval (repl.js:110:21)\n at Interface.<anonymous> (repl.js:239:12)\n at Interface.emit (events.js:95:17)\n at Interface._onLine (readline.js:202:10)\n at Interface._line (readline.js:531:8)\n at Interface._ttyWrite (readline.js:760:14)\n at ReadStream.onkeypress (readline.js:99:10)\n at ReadStream.emit (events.js:98:17)\n at emitKey (readline.js:1095:12)'
View node-gyp-output
matt@matt-dev ~/s/n/node-webkit-agent> node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@1.0.2
gyp info using node@0.12.0 | linux | x64
child_process: customFds option is deprecated, use stdio instead.
gyp info spawn python
gyp info spawn args [ '/usr/lib/node_modules/node-gyp/gyp/',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',

Demo for NodeJS preemption bugs via node::MakeCallback.


  • node 0.12.0 should be on your PATH
  • grab all the files from this gist into the same directory
  • node-gyp rebuild to compile into build/Release/preemptor.node
  • node demo to run the demo

For me, the demo output is


Keybase proof

I hereby claim:

  • I am metamatt on github.
  • I am metamatt ( on keybase.
  • I have a public key whose fingerprint is 6EBF C4F0 19C0 122A 168F 600E 0452 043E 5FC8 7E11

To claim this, I am signing this object:

View promise-chain.js
// find Q/$q implementation
var Q;
try {
$injector = angular.injector([ 'ng' ]);
Q = $injector.get('$q');
} catch (err) {
Q = require('q');
// helper function to attach handlers that show how promise is resolved
View debug node
  1. Check out node 0.10.33 source
  2. ./configure --without-snapshot --debug
  3. make
  4. copy/symlink out/Debug/node so it's the node binary on your path
  5. create a package.json with the following contents
  "dependencies": {
    "archiver": "0.13",
View Debug vs

If you build Node.js from source and want to try both the Debug and Relase configurations, and you notice that if you do

% ./configure --without-snapshot --debug
% make

you get both Debug and Release versions, and you think you can use them normally, think again:

View bigStrings.js
b1 = fs.readFileSync('/usr/bin/nodejs')
b2 = fs.readFileSync('/usr/bin/nodejs')
c1 = b1.toString(); 0
c2 = b2.toString(); 0
c1 === c2 // true!
View fast wake
magi@duality ~> sudo pmset -b standbydelay 43200
magi@duality ~> sudo pmset -c standby 0
magi@duality ~> pmset -g
Active Profiles:
Battery Power -1*
AC Power -1
Currently in use:
standbydelay 43200
standby 1
halfdim 1