Skip to content

Instantly share code, notes, and snippets.

View chilts's full-sized avatar

Andrew Chilton chilts

View GitHub Profile
@chilts
chilts / alexa.js
Created October 30, 2013 09:27
Getting the Alexa top 1 million sites directly from the server, unzipping it, parsing the csv and getting each line as an array.
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 14:19
a transaction with node-postgres - this is how _I_ write code which uses node-postgres. YMMV.
//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');