This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var through = require('through'); | |
var path = require('path'); | |
var ss = require('stream-stream'); | |
var avro = require('node-avro-io'); | |
var hdfs = require('webhdfs').createClient({ | |
host: '' // stuff goes here | |
}); | |
avrostream2('/log/ap/2014-04-01/01/ClientEvent', hdfs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// simple serial task queue. Calling .next multiple times just prompts a check | |
// if something is still inflight. Does not periodically check for added | |
// tasks in a period of inactivity | |
function SerialTaskQueue() { | |
var t = { | |
tasks: [] | |
, current: null | |
, next: function(){ | |
return t.current | |
|| (t.current = t.tasks.shift()) && t.current(function(){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var vash = require('vash'); | |
var str = '' | |
+ 'p {\n' | |
+ ' @if(model.can==\'123\') {' | |
+ ' float-offset: 3px;' | |
+ ' } else {' | |
+ ' float-offset: 6px;' | |
+ ' }' | |
+ '}'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var nlp = require('nlp_compromise') | |
var sentences = nlp.pos('Cats always follow the player'); | |
console.log(sentences); | |
sentences[0].tokens.forEach(function(part) { | |
console.log(part.pos.tag, part.pos.description, part.normalised, part.pos_reason) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var test = require('tape'); | |
require('tap-browser-color')(); | |
test('test', function(t) { | |
setTimeout(function() { | |
t.ok(true); | |
t.end(); | |
}, 2000) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tester = require('stream-tester'); | |
var t2 = require('through2'); | |
function dot() { | |
return t2.obj() | |
} | |
function key(k) { | |
return t2.obj(function(obj, _, cb) { | |
console.log('key ' + k + ' ' + (typeof obj) + JSON.stringify(obj)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var m = | |
[0, 1, 0, 0, | |
1, 0, 1, 1, | |
1, 0, 0, 1, | |
1, 0, 0, 1, | |
1, 0, 0, 1] | |
function next(m, cols) { | |
// up, right, down, left, up/left, up/right, down/right, down/left |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Having trouble recitfying descriptive yet short names, since | |
// there is a Component (data structure initializer), the instance | |
// of a component (component data) for an entity id, and an entity, | |
// which is simply an object with an `id` property (for now). | |
// Other constrains include trying to keep return types consistent | |
// (always receive an array, or always an object), and providing | |
// query interfaces so the underlying system can be optimized (as | |
// opposed to raw Objects where you just insert a string key). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function imageToCanvas(image, opt_cvs, cb) { | |
if (!cb) { cb = opt_cvs; } | |
var cvs = opt_cvs || document.createElement('canvas'); | |
var ctx = cvs.getContext('2d'); | |
cvs.width = image.width; | |
cvs.height = image.height; | |
ctx.drawImage(image, 0, 0); | |
cb(null, cvs); | |
} |