Skip to content

Instantly share code, notes, and snippets.

View commuterjoy's full-sized avatar

Matt Chadburn commuterjoy

View GitHub Profile
RewriteCond %{HTTP:X-Flagpole-Candy-ContentAPI} ^RED$
RewriteRule ^(.*)$ /outage-news/error503 [NS,L]
@commuterjoy
commuterjoy / gist:1996423
Created March 7, 2012 21:41
List of mobile browsers with a audience of over 10k users accessing bbc.co.uk/news
November 2011
-------------
Alcatel
Amazon Kindle Amazon Webkit 528.5
Amoi
Apple iOS Safari Webkit 534.4
Apple iOS iPad 3 Safari Webkit 531.2
Apple iOS iPad 4 Safari Webkit 533.1
Apple iOS iPhone Opera Mini 6
require 'json'
Before do
@random_token = rand(10000)
end
Then /^the page should be compressed$/ do
response = RestClient.get("#{host}/news?#{@random_token}", { :accept_encoding => 'gzip' })
response.headers[:content_encoding].should include 'gzip'
response.headers[:vary].should include 'Accept-Encoding'
@commuterjoy
commuterjoy / gist:2119146
Created March 19, 2012 16:56
News Story API
{
"results" : [ {
"body" : "<body xmlns=\"http://www.bbc.co.uk/asset\" xml:base=\"http://www.bbc.co.uk/article/6b819206-d657-3545-9be2-a73a6347f470\"><image id=\"57609805\" width=\"304\" height=\"171\" href=\"http://wwwpreview.test.newsonline.tc.nca.bbc.co.uk/media/images/57609000/jpg/_57609805_leicestermatfascione.jpg\"><caption>The council advised people to allow more time for travel into the city centre</caption><altText>London Road in Leicester</altText></image><paragraph role=\"introduction\">TRSETESTSETSETSETSETSEDrivers have been warned to expect delays on one of the main routes into Leicester city centre over the next few months due to roadworks.</paragraph><paragraph>Sections of London Road, Regent Road and University Road will be closed off between January and March to allow new heating pipes to be fitted.</paragraph><paragraph>The city council said the work would be carried out in three phases to minimise disruption.</paragraph><paragraph>Diversions are to be set up and several bus stops will
@commuterjoy
commuterjoy / gist:2163903
Created March 22, 2012 20:38
Do something a number of times
alias times='ruby -e "ARGV.first.to_i.times { system ARGV.last }"'
# Eg,
times 10 'curl -I -s www.bbc.co.uk/news/ | grep HTTP'
(thanks @andrewvos)
@commuterjoy
commuterjoy / gist:2719165
Created May 17, 2012 14:10
Installing Postgres with Rails - what I did

-- install

 brew install postgres
 sudo brew link postgresql

 wget http://download.osgeo.org/proj/proj-4.8.0.tar.gz
 gunzip proj-4.8.0.tar.gz 
 tar -xzvf proj-4.8.0.tar 
 ./configure 
mkdir -p weight/ && cd ./weight
wget --verbose -p -e robots=off -H -o /tmp/m.bbc.co.uk.log m.bbc.co.uk/news
tar -cvzf /tmp/m.bbc.co.uk *
du -h /tmp/m.bbc.co.uk
@commuterjoy
commuterjoy / gist:2823543
Created May 29, 2012 09:33
Extract details from a weird data format
# Written because I couldn't bear the thought of my mother cutting a pasting
# four hundred key-value pairs from a text file in to Excel.
# Usage: ruby extract.rb < data
class Person
attr_accessor :full_name, :first_name, :other_names, :name_tokens, :company, :email
def first_name
full_name.split(' ').first if full_name
require "GD"
class Screenshot
attr_accessor :frame, :width, :height, :pid, :rate, :quality, :token, :framesPerSourceImage, :programme, :workingCopy
#
def initialize(opts)
# rate at which frames have been extracts - Eg, 1 = 1 fp/s, 0.2 = 1 frame every 5s