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 / addFieldToMongoRecords.js
Created December 19, 2012 10:27
Add a field to all records in a Mongo collection
db.registration.update({},{$set : { "receiveNewsAlerts" : true}} , true, true);
@rupertbates
rupertbates / git log not master
Created December 14, 2012 11:31
Find all commits in <branch> which are not in master and mention an Android bug number
git log <branch> --not master --oneline | grep AND-
@rupertbates
rupertbates / Remove .DS_Store files from git
Created November 22, 2012 15:18
Remove .DS_Store files from git
find . -name .DS_Store -print0 | xargs -0 git rm --ignore-unmatch
@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 / gist:277153
Created January 14, 2010 13:21
Open Platform blog code snippets
//Get all users over the ages of 18
var adults = users.Where(u => u.Age > 18);
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<log4net>
<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="../../logs/Log4Net.log"/>
<appendToFile value="false"/>
public string TestReturn(int i)
{
return "hello hello hello";
}
@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