Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Chilton chilts

View GitHub Profile
View gist:9676982
test(
'/account/create with a variety of malformed email addresses',
function (t) {
var pwd = '123456'
// See: http://en.wikipedia.org/wiki/Email_address#Valid_email_addresses
var emails = [
'notAnEmailAddress',
'\n@example.com',
'me@hello world.com',
View gist:9676306
return Client.create(config.publicUrl, 'a+b+c@example.com', pwd)
.then(
function (c) {
return c.destroyAccount()
},
function (err) {
t.equal(err.errno, 101, 'unusual email is not invalid')
}
)
@chilts
chilts / npm-ls-after-npm-dedupe.txt
Last active Aug 29, 2015
npm ls inside fxa-content-server
View npm-ls-after-npm-dedupe.txt
fxa-content-server@0.0.5 /home/chilts/src/chilts-fxa-content-server
├── abbrev@1.0.4
├─┬ argparse@0.1.15
│ ├── underscore@1.4.4
│ └── underscore.string@2.3.3
├── aws-sign@0.3.0
├── aws-sign2@0.5.0 extraneous
├── bluebird@1.0.7
├─┬ bower@1.2.8
│ ├── archy@0.0.2
View gist:9263441
diff --git a/mailer.js b/mailer.js
index d5a46c6..5518639 100644
--- a/mailer.js
+++ b/mailer.js
@@ -67,6 +67,13 @@ module.exports = function (config, log) {
var p = P.defer()
var remaining = config.i18n.supportedLanguages.length * types.length;
+
+ function checkRemaining() {
@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 / 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 / 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();
@chilts
chilts / lock.js
Last active Dec 17, 2015
Lock API using Redis
View lock.js
var redis = require('redis');
var redlock = require('redlock');
var getLock2 = redlock({
client : client,
prefix : 'lock:', // optional
});
var getLock2 = redlock({
// same credentials as redis.createClient()