Skip to content

Instantly share code, notes, and snippets.

View commuterjoy's full-sized avatar

Matt Chadburn commuterjoy

View GitHub Profile
var v = new VideoPlayer( { preroll: true } );
v.play('http://brightcove.vo.llnwd.net/v1/uds/pd/47628783001/201410/897/47628783001_3817208988001_Wonga-021014.mp4');
# join all the ft-next projects
heroku list --org financial-times --all | \
grep ft-next | \
cut -d ' ' -f 1 | \
xargs -I % echo "heroku join --app %" | \
/bin/sh
@commuterjoy
commuterjoy / gist:50c2d041464fd90eadc9
Created February 11, 2015 22:07
notes on app per branch
- Heroku apps aren't hosted on a ft.com domain so cookie reads fail - a pr
request router in fastly with an canary-next.ft.com CNAME?
- Some XHR requests fail (eg, __flags.json) as the app is only serving engels
routes.
- We shouldn't set NODE_ENV to production - adapt next-build-tools to do this.
- It takes 3 mins for the heroku box to be alive, which means it's hard to
point sauce labs at it in the same build - Talk to Heroku ??
- Need to truncate project, branch, build, time etc. in to a 30 character
length string.
- Destroying apps on the fly feels v. risky.
// Usage - node distribution.js | sort | uniq -c
var seedrandom = require('./seedrandom');
// Given a uniform set of even numbers, from 1 to 100k
var n = [];
for(var i=0; i<100000; i++) { if (i % 2 === 0) n.push(i); }
// Produce a set of evenly distributed set of seeded random numbers
@commuterjoy
commuterjoy / server.js
Last active August 29, 2015 14:11
async error inside a promise
'use strict';
require('es6-promise').polyfill();
var domain = require('domain');
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('ok')
@commuterjoy
commuterjoy / stream.js
Last active August 29, 2015 14:11
Stream model
// returns a rendered list of items
res.get(req, res, next) {
/**
* A stream object accepts an array of content id UUIDs or CAPI search strings
* and returns a blob of HTML representing the stream.
*
* The returned HTML is a sequence of article card components.
*/
@commuterjoy
commuterjoy / gist:72e8e63c81e80d87a403
Created November 12, 2014 21:42
Monitor changes in Clamo
echo 'date; curl -sg "http://clamo.ftdata.co.uk/api?request=[{%22action%22:%22search%22}]" | wc -c; sleep 5' | ruby -e "a=STDIN.read;(1..100000).each{puts a}" | /bin/sh
@commuterjoy
commuterjoy / gist:558bae8bbbe6f535feeb
Created September 30, 2014 12:07
Clamo timeout errors over 28, 29, 30 September
1 date=2014-09-28T03
1 date=2014-09-28T05
3 date=2014-09-28T09
1 date=2014-09-28T11
1 date=2014-09-28T12
2 date=2014-09-28T14
2 date=2014-09-28T15
1 date=2014-09-28T18
3 date=2014-09-28T20
6 date=2014-09-28T22
@commuterjoy
commuterjoy / gist:f0f61d6ea6ef3f124865
Last active August 29, 2015 14:05
benchmark of node proxy against code as of 18 Aug 2014
$ siege -t30s -c100 -A 'iPhone 4' http://localhost:5050/badger
Transactions: 3640 hits
Availability: 100.00 %
Elapsed time: 29.56 secs
Data transferred: 1.31 MB
Response time: 0.25 secs
Transaction rate: 123.14 trans/sec
Throughput: 0.04 MB/sec
Concurrency: 30.19
"?foo=1&bar=2&car=s&p&foo=hello"
.split('&')
.map(function (n) {
return n.indexOf('=') > 0 ? n : encodeURIComponent('&' + n);
})
.join('&')