Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Chilton chilts

View GitHub Profile
@chilts
chilts / alexa.js
Created Oct 30, 2013
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
View alexa.js
var request = require('request');
var unzip = require('unzip');
var csv2 = require('csv2');
request.get('http://s3.amazonaws.com/alexa-static/top-1m.csv.zip')
.pipe(unzip.Parse())
.on('entry', function (entry) {
entry.pipe(csv2()).on('data', console.log);
})
;
@brianc
brianc / gist:5547726
Created May 9, 2013
a transaction with node-postgres - this is how _I_ write code which uses node-postgres. YMMV.
View gist:5547726
//this is an example of how you might run a transaction
//in postgres with node. This example has as little
//abstraction as possible. In your app you'll
//likely want to build a layer on top to ease some of the
//callback management and reduce code duplication
var log = require('logged')(__filename);
var pg = require('pg');