Skip to content

Instantly share code, notes, and snippets.

View commuterjoy's full-sized avatar

Matt Chadburn commuterjoy

View GitHub Profile
@commuterjoy
commuterjoy / gist:2966561
Created June 21, 2012 15:48
Mocking AMD modules
// Idea that you can use the 'paths' property to swap in a mock AMD module
// during testing.
-- test/runner.html
23 var guardian = {
24 page: {
25 omnitureAccount: "guardiangu-fake"
26 },
27 js: {
@commuterjoy
commuterjoy / gist:2988744
Created June 25, 2012 13:51
Mobile devices hitting www.guardian.co.uk
Devices hitting www on 2012-06-22.
iOS
---
1 302 1.0 iPhone OS
405 302 2.1 iPhone OS
11 302 2.2.1 iPhone OS
25 302 3.0 iPhone OS
1 302 3.0.1 iPhone OS
@commuterjoy
commuterjoy / gist:3083562
Created July 10, 2012 14:18
Mobile devices hitting m.guardian.co.uk
Analysis of ~200k Android user-agent strings from 26 June 2012, accessing m.guardian.co.uk
# By version
39429 200 1.5 Android
685 200 1.6 Android
12 200 2.0 Android
6924 200 2.1 Android
25219 200 2.2 Android
632 200 2.2.1 Android
Modernizr.fontface true
Modernizr.audio true
Modernizr.video true
Modernizr.history true
Modernizr.svg false
Modernizr.canvas true
Modernizr.geolocation true
Modernizr.localstorage true
Modernizr.indexeddb false
@commuterjoy
commuterjoy / gist:3116199
Created July 15, 2012 10:29
Oyster card top-ups - 01-March-2012 to 15-July-2012
Mine on the left, my wife's on the right.
2012-07-12
2012-07-11
2012-07-10
2012-07-09
* 2012-07-08
2012-07-07 *
2012-07-06
* 2012-07-05
@commuterjoy
commuterjoy / gist:3166466
Created July 23, 2012 21:52
Guardian search terms

Events (in bold) described incoming searches to guardian.co.uk.

Theory:- users look for events by typing the key person or thing involved in to Google. Google suggests a bit of recent news.

  • Tour de France 2012, 140k
  • Discovery of Higgs Boson, 84k
  • Alan Turing’s 100th Birthday, 66k
  • Andy Murray reaches Wimbledon final, 59k
  • Chris Moyles resigns, 53k
  • Stone Roses reunion, 48k
@commuterjoy
commuterjoy / gist:3220725
Created July 31, 2012 21:25 — forked from madrobby/gist:3202087
Fallback to PNG if SVG is not supported
<!-- example for the http://retinafy.me ebook -->
<style>
div.rss {
background: url(rss.svg);
width: 32px;
height: 32px;
}
body.no-svg div.rss {
@commuterjoy
commuterjoy / server.rb
Created August 3, 2012 09:07
Override host header with HTMLUnit
import org.openqa.selenium._
import org.openqa.selenium.htmlunit._
import org.scalatest.matchers.ShouldMatchers
import org.scalatest.{ GivenWhenThen, FeatureSpec }
import test.`package`._
// instance of htmlunit with request header setting ability
class FixedHtmlUnitDriver extends HtmlUnitDriver {
def setHeader(name: String, value: String) = {
getWebClient().addRequestHeader(name, value)
-- job to group number of unique urls request per second
lines = load '12_ip-10-226-85-155.processed/part-r-00000' using PigStorage();
projected = foreach lines generate
REGEX_EXTRACT((chararray)$1, '(.*)\\.(.*)', 1) as time,
(chararray)$3 as url
;
group_by_url = group projected by (url, time);
@commuterjoy
commuterjoy / gist:3415362
Created August 21, 2012 13:23
pig - pages p/min
-- Job to count the number of logged requests p/min
record = load '12_ip-10-226-85-155.processed/part-r-00000' using PigStorage();
projected = foreach record generate
REGEX_EXTRACT((chararray)$1, '(.*)\\:(.*)', 1) as time
;
group_by_minute = group projected by (time);