Skip to content

Instantly share code, notes, and snippets.

View aseemk's full-sized avatar

Aseem Kishore aseemk

View GitHub Profile
@aseemk
aseemk / stack.md
Created November 21, 2011 02:19
Neo4j relationship not found error stack trace

HTTP ERROR 500

Problem accessing /db/data/ext/CypherPlugin/graphdb/execute_query. Reason:

    Relationship[17659] not found.

Caused by:

@aseemk
aseemk / 1-app.js
Created October 14, 2011 12:27
Weird/wrong order of execution when require()-ing things in Node v0.4.5
console.log(Date.now() + ' requiring coffee-script...');
require('coffee-script');
console.log(Date.now() + ' requiring streamline...');
require('streamline');
console.log(Date.now() + ' requiring custom...');
require('./custom');
@aseemk
aseemk / 1-input_.coffee
Created September 8, 2011 17:03
Streamline bug: order of precedence w/ comma operator
thing =
if id = input.id
Thing.getById id, _
else
url = adjustURL input.url
Thing.getByURL url, _
@aseemk
aseemk / response.json
Created August 25, 2011 20:55
Proposed subgraph representation for Neo4j
{
"adjacencies": {
"node/1": {
"node/2": "rel/1",
"node/3": "rel/2"
},
"node/2": {
"node/4": "rel/3"
},
"node/3": {
@aseemk
aseemk / 1-partial.html
Created August 24, 2011 17:34
Profiling partial rendering in Express
<% # XXX PROFILING %>
<% begin = Date.now() %>
<!-- ... -->
<% # XXX PROFILING %>
<% time = Date.now() - begin %>
<% console.log "partial for thing @#{@thing.id} rendered in #{time} ms" %>
@aseemk
aseemk / arguments_.js
Created August 10, 2011 22:08
Streamline bug: Function::apply(this, arguments) not handled
// arguments_.js
// Tests Streamline's ability to handle `arguments` objects which contain a
// Streamline (underscore) callback parameter.
var THIS = 'context';
var COOKIE = 'cookie'
var innerHasExited = false;
var outerHasExited = false;
@aseemk
aseemk / FollowEvent.js
Created August 10, 2011 17:26
Streamline bug: more duplicate executions?
var __global = typeof global !== 'undefined' ? global : window;
function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); try { return fn(null, result); } catch (ex) { return __propagate(_, ex); } } }
function __future(fn, args, i){ var done, err, result; var cb = function(e, r){ done = true; err = e, result = r; }; args = Array.prototype.slice.call(args); args[i] = function(e, r){ cb(e, r); }; fn.apply(this, args); return function(_){ if (done) _.call(this, err, result); else cb = _.bind(this); } .bind(this); }
function __nt(_, fn){ var i = 0; var cb = __cb(_, fn); var safeCb = function(){ try { cb(); } catch (ex) { __propagate(cb, ex); } }; if (typeof process != "undefined" && typeof process.nextTick == "function") return function(){ if (++i % 20 == 0) process.nextTick(safeCb); else cb(); }; else return function(){ if (++i % 20 == 0) setTimeout(safeCb); else cb(); }; }
function __propagate(_, err){ try { _(err); } catch (ex) { __trap
@aseemk
aseemk / ifs_.coffee
Created August 10, 2011 01:12
Streamline bug: nested switch statements somehow mess up sync flow
# async simulation helper:
async = (_) ->
setTimeout _, 500
# assume we're dealing with a status change event
type = 'event'
kind = 'statusChange'
# assume we initially have no user or target
user = null
@aseemk
aseemk / register.js
Created August 10, 2011 00:31
Streamline bug? A piece of code is somehow called twice.
var __global = typeof global !== 'undefined' ? global : window;
function __cb(_, fn){ var ctx = __global.__context; return function(err, result){ __global.__context = ctx; if (err) return _(err); try { return fn(null, result); } catch (ex) { return __propagate(_, ex); } } }
function __future(fn, args, i){ var done, err, result; var cb = function(e, r){ done = true; err = e, result = r; }; args = Array.prototype.slice.call(args); args[i] = function(e, r){ cb(e, r); }; fn.apply(this, args); return function(_){ if (done) _.call(this, err, result); else cb = _.bind(this); } .bind(this); }
function __propagate(_, err){ try { _(err); } catch (ex) { __trap(ex); } }
function __trap(err){ if (err) { if (__global.__context && __global.__context.errorHandler) __global.__context.errorHandler(err); else console.error("UNCAUGHT EXCEPTION: " + err.message + "\n" + err.stack); } }
/* 1 */ this.register = function __1(user, thing, oldStatus, newStatus, _) {
if (!_) {
return __future.call(thi
@aseemk
aseemk / express.md
Created July 17, 2011 19:54
Express monkey-patch to properly use Node callback convention; thus supports Streamline