Skip to content

Instantly share code, notes, and snippets.

View njh's full-sized avatar

Nicholas Humfrey njh

View GitHub Profile
@njh
njh / xmpp-list-nodes.rb
Created July 14, 2011 14:51
Script to display the available pubsub nodes on the BBC push feeds server
#!/usr/bin/ruby
require 'rubygems'
require 'xmpp4r'
require 'xmpp4r/pubsub'
require 'xmpp4r/pubsub/helper/nodebrowser.rb'
require 'pp'
HOST = 'push.bbc.co.uk'
# Use Fink (if available)
test -r /sw/bin/init.sh && . /sw/bin/init.sh
# In Mac OS X, what network location is set?
if [ -f "/usr/sbin/scselect" ]; then
export LOCATION=$(/usr/sbin/scselect 2>&1 | perl -ne 'if (m/^\s+\*\s+(\S+)\s+\((.+)\)$/) { print "$2\n"; }')
echo "Network Location: $LOCATION"
fi
@njh
njh / musicbrainz-twitter.sql
Created September 8, 2011 21:31
Twitter accounts in MusicBrainz
COPY (SELECT artist.gid, artist_name.name, url.url FROM url
JOIN l_artist_url ON (url.id = l_artist_url.entity1)
JOIN artist ON (artist.id = l_artist_url.entity0)
JOIN artist_name ON (artist_name.id = artist.name)
WHERE url LIKE '%twitter.com%') TO STDOUT WITH CSV;
891abb2e-0156-411b-bf60-f4104e71ddfa,SMiLE.dk,http://twitter.com/smiledkmusic
aead4c74-d7e1-4960-8cec-bacb86617924,Triobelisk,http://twitter.com/triobelisk
89bf7e7f-34ef-4d91-a4f2-4f2bfe8c5c67,Freeze The Atlantic,http://twitter.com/fta_band
@njh
njh / sunrise.rb
Created September 11, 2011 22:45
Ruby Code to calculate sunrise and sunset times where I live
#!/usr/bin/env ruby
require 'rubygems'
require 'solareventcalculator'
solar = SolarEventCalculator.new(Date.today, BigDecimal.new('51.563'), BigDecimal.new('-0.499'))
puts "Sunrise: #{solar.compute_utc_civil_sunrise.getlocal}"
puts "Sunset: #{solar.compute_utc_civil_sunset.getlocal}"
@njh
njh / sd.ttl
Created October 12, 2011 08:39
RedStore Service Description
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sd: <http://www.w3.org/ns/sparql-service-description#> .
@prefix format: <http://www.w3.org/ns/formats/> .
@prefix void: <http://rdfs.org/ns/void#> .
format:N-Triples
a format:Format ;
rdfs:comment "N-Triples" ;
@njh
njh / gist:1381093
Created November 20, 2011 22:52
4store trace
$ curl -v -T test.nt -H "Content-Type: text/plain" http://localhost:9000/data/test.rdf
* About to connect() to localhost port 9000 (#0)
* Trying 128.0.0.1... connected
* Connected to localhost (127.0.0.1) port 9000 (#0)
> PUT /data/test.rdf HTTP/1.1
> User-Agent: curl/7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8r zlib/1.2.3
> Host: localhost:9000
> Accept: */*
> Content-Type: text/plain
> Content-Length: 197
<?php
/**
* Store and retrieve data from a SPARQL 1.1 Graph Store
*
* This example adds a triple containing the current time into
* a local graph store. It then fetches the whole graph out
* and displays the contents.
*
* Note that you will a graph store, for example RedStore,
* running on your local machine in order to test this example.
@njh
njh / flash_led.ino
Created January 15, 2012 19:11
Hello World for Nanode
#define NANODE_LED_PIN 6
void setup() {
pinMode(NANODE_LED_PIN, OUTPUT);
Serial.begin(9600);
Serial.println("Hello World!");
}
@njh
njh / gist:1704559
Created January 30, 2012 14:07
A list of artists in MusicBrainz that the BBC has edited the name of
+--------------------------------------+----------------------------------------+
| gid | bbc_name |
+--------------------------------------+----------------------------------------+
| 9c22e6c5-56a0-4559-b017-5b4e305141a2 | Abdel Halim Hafez |
| fcff7228-c196-4fa8-84b5-b6252389be27 | Abram Levental |
| b215b03a-8e0b-48ca-b832-bbbd0db504f0 | Akiko Yano |
| b1f170dd-cd12-4148-90f2-1e58aa5400f1 | Aleksandr Grechaninov |
| 5390b083-ab88-4a2e-838e-ea5e76f923ea | Alexander Alexandrovich Alyabiev |
| fb04a1ef-e32c-410e-8fc5-bd81d6b057ce | Alexander Arkhangelsky |
| 560b5e65-8d53-41b4-9913-83368f4721a0 | Alexander Borodin |
@njh
njh / gist:1704822
Created January 30, 2012 14:53
Mapping from BBC Music Review to MusicBrainz release identifier
+-----------------------------------------+--------------------------------------+
| bbc_url | release_gid |
+-----------------------------------------+--------------------------------------+
| http://www.bbc.co.uk/music/reviews/q9xm | 1e0e0bc1-6da4-46f7-9e71-a593c755fca6 |
| http://www.bbc.co.uk/music/reviews/jf9x | b3dc682f-c7b1-4987-8f19-42db8c846675 |
| http://www.bbc.co.uk/music/reviews/2n8c | 16c1c861-2cc0-4b3c-840b-07010993831a |
| http://www.bbc.co.uk/music/reviews/963n | 67520d07-4fd8-467e-bbf9-7cceeb1b1a4c |
| http://www.bbc.co.uk/music/reviews/vzf9 | bcac578a-8845-4937-826c-753a21cabcdd |
| http://www.bbc.co.uk/music/reviews/w3n8 | de695059-168a-45f9-8265-af2f2e0a1143 |