Skip to content

Instantly share code, notes, and snippets.

Avatar

Rupert Bates rupertbates

View GitHub Profile
@rupertbates
rupertbates / intellij-eslint-js-formatting.xml
Created Sep 8, 2017
ES6 Linter compliant editor formatting config for IntelliJ
View intellij-eslint-js-formatting.xml
<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" />
View sapphire-and-steel.sc
//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 Sep 4, 2015
Use jq to return only football matches scheduled for Feb 2016
View select-football-matches-in-feb-2006.sh
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 Feb 6, 2015
Retrieve all 5 star album reviews from the Guardian content api
View get-music-reviews-final.sh
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)'
View five-star-music-reviews.json
{
"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",
View music-reviews-length.sh
[.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}|select(.starRating > 3)]|length
View music-reviews-converted-filtered.sh
.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}|select(.starRating > 3)
View music-reviews-converted.json
{
"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",
View music-reviews-numeric-rating.sh
.response.results[]|{webTitle, starRating:(.fields.starRating|tonumber)}
View music-reviews-results.json
{
"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",