Skip to content

Instantly share code, notes, and snippets.

View othiym23's full-sized avatar
💭
what is this thing you call, "architecture"

Forrest L Norvell othiym23

💭
what is this thing you call, "architecture"
  • Ellation / Crunchyroll / VRV
  • San Francisco
View GitHub Profile
@othiym23
othiym23 / gist:4075562
Created November 14, 2012 23:23 — forked from CrabBot/gist:4075399
node.js domain fail
'use strict';
var domain = require('domain')
, fs = require('fs')
, trycatch = require('trycatch')
;
function thirdPartyFoo(callback) {
var d1 = domain.create();
d1.on('error', function(err) {
@othiym23
othiym23 / excerpt.js
Created December 1, 2012 00:01
mocha is not your friend if you want to test uncaughtException handlers
before(function (done) {
/**
* Mocha is extremely zealous about trapping errors, and runs each test
* in a try / catch block. To get the exception to propagate out to the
* domain's uncaughtException handler, we need to put the test in an
* asynchronous context and break out of the mocha jail.
*/
process.nextTick(function () {
// disable mocha's error handler
mochaHandler = process.listeners('uncaughtException').pop();
function f(){var a=arguments,l=a.length/2,o='';for(var i=0;i<l;i++)o+=String.fromCharCode(a[i]|a[i+l]);return o}
// =f(6,15,2,2,5,3,4,0,12,0,14,15,2,6,5,12,12,64,96,112,112,96,112,112,32,64,32,64,96,112,112,96,96,96)
@othiym23
othiym23 / wrap.js
Last active December 10, 2015 14:28 — forked from beaugunderson/wrap.js
var original = cb;
cb = function wrapper() {
var args = arguments;
process.nextTick(original.apply.bind(this, this, args));
};
@othiym23
othiym23 / bnb.js
Last active December 10, 2015 15:29 — forked from anonymous/bnb.js
function BadNewsBears() {
var a = 0;
Object.defineProperty(this, 'inc',
{get : function () { return a++; },
enumerable : true});
Object.defineProperty(this, 'wtf',
{get : function () {
var b = (this.inc, this.inc, this.inc);
return b;
},
var x = 'global';
function test() {
var x = 'local';
("eval",eval)("console.log(x)");
}
test();
function confusing(bool) {
if (bool) {
function nested() {
console.log("yes");
}
}
else {
function nested() {
console.log("no")
}
function lessConfusin(bool) {
var nested;
if (bool) {
nested = function () {
console.log("yes");
}
}
else {
nested = function () {
console.log("no")
function alsoUnconfusing(bool) {
function nested() {
if (bool) {
console.log("yes");
}
else {
console.log("no");
}
}
'use strict';
function generate(parent, name) {
var node = new parent.constructor();
Object.defineProperty(parent, name, {
enumerable : true,
configurable : false,
writable : false,
value : node