Skip to content

Instantly share code, notes, and snippets.

View rupertbates's full-sized avatar

Rupert Bates rupertbates

  • Guardian News and Media
  • London
View GitHub Profile
@rupertbates
rupertbates / intellij-eslint-js-formatting.xml
Created September 8, 2017 11:11
ES6 Linter compliant editor formatting config for IntelliJ
<code_scheme name="Default (1)">
<option name="OTHER_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="8" />
<option name="TAB_SIZE" value="2" />
<option name="USE_TAB_CHARACTER" value="false" />
<option name="SMART_TABS" value="false" />
<option name="LABEL_INDENT_SIZE" value="0" />
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
//This script fixes the naming on some video files which were numbered wrong - The last file 2x8 was actually the first
//and all the others were one down from where they should be (2x1 was actually the second 2x2 etc.)
//I have run it on the second series (2xX) but none of the others
import ammonite.ops._
val dir = home/'Movies/"Sapphire and Steel (1979-82 ITV)"
//get a list of the files in a particular series
val seriesNumber = 2
@rupertbates
rupertbates / select-football-matches-in-feb-2006.sh
Created September 4, 2015 13:53
Use jq to return only football matches scheduled for Feb 2016
curl -s "http://football.mobile-apps.guardianapis.com/football/competitions/100/matches" | jq '.[]|select(.kickOff|strptime("%Y-%m-%dT%H:%M:%SZ")|.[0] == 2016 and .[1] == 1)'
@rupertbates
rupertbates / get-music-reviews-final.sh
Created February 6, 2015 11:35
Retrieve all 5 star album reviews from the Guardian content api
URL="http://content.guardianapis.com/search?api-key=test&show-fields=starRating&page-size=100&tag=tone/albumreview,tone/reviews&from-date=2015-01-03&to-date=2015-02-03"
curl -s $URL | jq '.response.results[]|select(.fields.starRating != null)|{webTitle, url: .webUrl, starRating: (.fields.starRating|tonumber)}|select(.starRating == 5)'
{
"webTitle": "Napalm Death: Apex Predator – Easy Meat review – grindcore masters on top form",
"starRating": 5
},
{
"webTitle": "Mozart: Piano Sonatas K280 and 332; Chopin: 24 Preludes, etc CD review – overflowing with vitality",
"starRating": 5
},
{
"webTitle": "Bob Dylan: Shadows in the Night review – an unalloyed pleasure",
[.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}|select(.starRating > 3)]|length
.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}|select(.starRating > 3)
{
"webTitle": "Bob Dylan: Shadows in the Night review – pre-rock songs imbued with romantic regret",
"starRating": 4
}
{
"webTitle": "Arias for Domenico Gizzi review – just an echo of a true castrato",
"starRating": 3
}
{
"webTitle": "Liszt: Piano Sonata, Dante Sonata, Petrarch Sonnets review – Angela Hewitt is masterful and compelling",
.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}
{
"webTitle": "Beck Goldsmith: Lustre & Curve review – a polite howl of pain",
"webPublicationDate": "2015-01-08T21:30:19Z",
"sectionId": "music",
"id": "music/2015/jan/08/beck-goldsmith-lustre-and-curve-review-polite-howl-of-pain",
"fields": {
"starRating": "3"
},
"webUrl": "http://www.theguardian.com/music/2015/jan/08/beck-goldsmith-lustre-and-curve-review-polite-howl-of-pain",
"apiUrl": "http://content.guardianapis.com/music/2015/jan/08/beck-goldsmith-lustre-and-curve-review-polite-howl-of-pain",