Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env node
var fs = require('fs');
var _ = require('underscore');
fs.readFile('area.json',function(err,data) {
var a = JSON.parse(data);
console.log(a.length);
var b = _.map(a,function(row) {
var o = new Object();
o.area = row.at4;
#!/usr/bin/env node
var util = require( "util" );
// Create a linked-list and reverse it.
// This is just a rough bit of code to solve the problem.
// If I had more time I would maybe try a different algorithm
// where I switch the pointer as I walk to the end.
// Also I may change the members to be private.
util.puts( "Make a list and print it out!" );
@jesslilly
jesslilly / google-chart.html
Created January 23, 2014 15:44
Convert data used for an ngGrid (Array of same-key objects) to something that will work for a google-chart focusing on the data attribute. It would be good to refactor this code to simply take an input array and convert to google-chart format. Call groupBy externally instead.
var ngGridObj = [ {
"entity" : {
'date' : '2013-09-23 23:23:23',
'amt' : 4.5,
'name' : 'Mike'
}
}, {
"entity" : {
'date' : '2013-09-26 23:23:23',
'amt' : 6.5,
@jesslilly
jesslilly / groupBy.js
Last active January 4, 2016 03:58
Function to group an array of x,y data. Useful for charting. Requires underscore.js.
/**
* @method
* @public
* @description Take an array of objects and convert to an array of pairs whose
* xCol are grouped and yCol values are aggregated somehow. If
* grouping by day or month, dates must be in ZULU format strings!
* Original implementation returned an object with keys = xCol and
* values = yCol. It worked great but js maps(objects) cannot be
* sorted!
* @param {array}
@jesslilly
jesslilly / logaxParserSpec.js
Created January 14, 2014 13:48
Parameterized jasmine test for your logax parser. https://github.com/jesslilly/logax. This is a really good idea to make sure that minor changes to your parser don't break your JSON output. Thanks to https://gist.github.com/basti1302/5051200 for the parameterized test gist. This test is in javascript, not coffeescript. This is a template. You wi…
var fs = require('fs');
var exec = require('child_process').exec, child;
// Inputs
var inputDir = './developer/test/unit/data/input/';
var expectedDir = './developer/test/unit/data/expected/';
var outputDir = './developer/test/unit/data/output/';
var parserA = './server/load-it/logax-a-parser.js';
var parserB = './server/load-it/logax-b-parser.js';
var inputFiles = new Array(3);