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);
})
;
@chilts
chilts / dump.go
Created Sep 15, 2016
Dump entire BoltDB to stdout, including Nested Buckets
View dump.go
package main
import (
"fmt"
"log"
"strings"
"time"
"github.com/boltdb/bolt"
)
@chilts
chilts / gist:3687910
Created Sep 9, 2012 — forked from twhid/gist:2648062
grunt task to deploy JS files to S3 with awssum
View gist:3687910
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 Mar 28, 2019
Dump a BoltDB (zipped) to a Dir with a Timestamp
View gist:687ec1e8c5337213a7e1a5de2d3584ae
package main
// From : https://gist.github.com/chilts/687ec1e8c5337213a7e1a5de2d3584ae
import (
"compress/gzip"
"fmt"
"log"
"os"
"path"
@chilts
chilts / handlers.go
Last active Mar 8, 2017
Simple, re-usable handlers for standard tasks.
View handlers.go
package main
// https://gist.github.com/chilts/db1adfaddaae871b161d7eadab6b1278
import (
"bytes"
"html/template"
"log"
"net/http"
)
@chilts
chilts / ReadMe.md
Last active Oct 18, 2016
"How Dropbox securely stores your passwords" in terrible, insecure, horrible GoLang (GoLang is not terrible, my code is).
View ReadMe.md
@chilts
chilts / gist:7920015
Created Dec 11, 2013
Symmetrical comments
View gist:7920015
// I used to do this:
/*
*
* For long comments. This was in 1994.
*
*/
// Then I did this:
@chilts
chilts / paramify.js
Created Nov 4, 2013
Alternative proposal ... not backwards compatible
View paramify.js
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 Dec 26, 2015
Inconsistency in how whois.srs.net.nz works compared to whois.verisign-grs.com.
View README.md

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 Aug 26, 2013
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.
View speed-comparison.js
var t1, t2, t3;
var i;
const TOP = 1000000000;
var tsHex = '013c798f75ad';
var counterHex = '0000';
var pidHex = '1154';
var macHex = '984be1b8b104';
t1 = Date.now();