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);
})
;
@chilts
chilts / dump.go
Created September 15, 2016 19:53
Dump entire BoltDB to stdout, including Nested Buckets
package main
import (
"fmt"
"log"
"strings"
"time"
"github.com/boltdb/bolt"
)
@chilts
chilts / gist:3687910
Created September 9, 2012 23:29 — forked from twhid/gist:2648062
grunt task to deploy JS files to S3 with awssum
grunt.registerMultiTask('s3deploy', 'deploy to S3 using awssum', function () {
// dependencies
var awssum = require('awssum'),
fs = require('fs'),
path = require('path'),
aws = require('./settings').aws;
var amz = awssum.load('amazon/amazon'),
AmazonS3 = awssum.load('amazon/s3'),
s3 = new AmazonS3({
@chilts
chilts / gist:687ec1e8c5337213a7e1a5de2d3584ae
Last active March 28, 2019 14:51
Dump a BoltDB (zipped) to a Dir with a Timestamp
package main
// From : https://gist.github.com/chilts/687ec1e8c5337213a7e1a5de2d3584ae
import (
"compress/gzip"
"fmt"
"log"
"os"
"path"
@chilts
chilts / handlers.go
Last active March 8, 2017 04:40
Simple, re-usable handlers for standard tasks.
package main
// https://gist.github.com/chilts/db1adfaddaae871b161d7eadab6b1278
import (
"bytes"
"html/template"
"log"
"net/http"
)
@chilts
chilts / ReadMe.md
Last active October 18, 2016 21:03
"How Dropbox securely stores your passwords" in terrible, insecure, horrible GoLang (GoLang is not terrible, my code is).
@chilts
chilts / gist:7920015
Created December 11, 2013 22:54
Symmetrical comments
// I used to do this:
/*
*
* For long comments. This was in 1994.
*
*/
// Then I did this:
@chilts
chilts / paramify.js
Created November 4, 2013 05:13
Alternative proposal ... not backwards compatible
var http = require('http')
var paramify = require('paramify')
var router = paramify()
router.get('intro/:greeting', intro)
router.get('showtimes/:start/:end', showtimes)
router.default(notFound);
http.createServer(router).listen(1337, '127.0.0.1')
@chilts
chilts / README.md
Last active December 26, 2015 23:19
Inconsistency in how whois.srs.net.nz works compared to whois.verisign-grs.com.

It seems that typing domain example.com means "give me this domain only", but just saying "example.com" is a query for things with example.com in them.

With the SRS, if I type nodejs.geek.nz it returns the details as though it is a domain command like above, but typing domain nodejs.geek.nz gives 500 Invalid characters in query string.

i.e. either it is not recognised as a valid command or a valid query.

(Note: I'm going off what I see, I'm not sure what it should actually do.)

Does that help?

@chilts
chilts / speed-comparison.js
Created August 26, 2013 19:56
Gist to compare two ways of creating the string for flake (https://npmjs.org/package/flake) IDs. I suspect the construction of the array far outweighs the construction of the string.
var t1, t2, t3;
var i;
const TOP = 1000000000;
var tsHex = '013c798f75ad';
var counterHex = '0000';
var pidHex = '1154';
var macHex = '984be1b8b104';
t1 = Date.now();