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 / cls.js
Last active August 29, 2015 13:57 — forked from hayes/cls.js
View cls.js
var cls = require('continuation-local-storage')
, concat = require('concat-stream')
, http = require('http')
var foo = cls.createNamespace('foo')
foo.run(function () {
http.createServer(function(req, res) {
req.pipe(concat(done))
View need-to-time.js
function task1(){
// some logic
}
function task2(){
task1();
// other logic
}
gulp.task('task1', task1);
@othiym23
othiym23 / _notes.md
Last active December 27, 2015 08:18 — forked from dazld/_notes.md
View _notes.md

The script populates a few keys in redis (assuming it is running), and once that is complete, calls a series of tests trying to get them.

Each test stores a key in cls, and compares the key it is given when calling the get function with the one in CLS, before and after invoking GET on the redis client, failing if they are not the same.

Ther are two versions of the get function

  • Straight up callback
  • Promise based with Q

Regardless of whether hiredis is present in the project, am getting errors as follows.

View run.out
HTTP: outgoing message end.
sending 104857600
HTTP: AGENT incoming response!
HTTP: AGENT isHeadResponse false
200
{"date":"Fri, 04 Oct 2013 01:12:40 GMT","connection":"keep-alive","transfer-encoding":"chunked"}
chunk received: 65527 (total 65527)
chunk received: 65536 (total 131063)
chunk received: 65536 (total 196599)
chunk received: 65536 (total 262135)
View async-n-net-server.js
var net = require('net');
var domain = require('domain');
var expected = 0, caught = 0;
process.on('exit', function () {
assert(expected === caught);
console.log('ok expected', expected, 'caught', caught);
});
var d = domain.create();
View async-n-net-server.js
var domain = require('domain');
var key = process.addAsyncListener(domain.____xXx__secret___asyncListener);
var d = domain.create();
d.on('error', ...);
d.run(function () {
var server = net.createServer(...);
});
@othiym23
othiym23 / index.js
Last active December 22, 2015 17:18 — forked from dazld/index.js
View index.js
var Router = require('./router');
var ns = require('./namespace-module');
var router = new Router();
router.initialize();
var NUM_TESTS = 10;
var spawnAsync = function (i) {
View ugly-scope-export.js
var slice = [].slice;
function exportscope() {
var args = slice.call(arguments);
for (var i = 0; i < args.length; i++) this.exports[args[i]] = eval(args[i]);
}
var a = 1, b = 2, c = 3;
// super-ugly
View callbackvflow.js
'use strict';
(function () {
var myfile;
function readFileCallback(err, val) {
if (err) throw err;
myfile=val;
@othiym23
othiym23 / promised.js
Last active December 12, 2015 07:38 — forked from medikoo/promised.js
View promised.js
MultiInstaller.prototype.forEach = function (visitor, callback) {
var qVisitor = Q.nfbind(visitor, null)
, qInstall = Q.nfbind(install)
;
var target = this.target;
var prefix = this.prefix;
function process(versions, index, result) {
if (!versions[index]) return result;