Skip to content

Instantly share code, notes, and snippets.

View moustaki's full-sized avatar

Yves Raimond moustaki

View GitHub Profile
require 'rubygems'
require '4store-ruby'
require 'rdf/redland'
store = FourStore::Store.new 'https://server11.incubator.bbc.co.uk/sparql/', {
'certificate' => 'cert.ca',
'key' => 'cert.pem',
'soft-limit' => "-1"
}
require 'rubygems'
require 'sinatra'
require 'rqommend'
DEFAULT_OPTIONS = {
'certificate' => 'cert.ca',
'key' => 'cert.pem'
}
DEFAULT_ENDPOINT = 'https://server11.incubator.bbc.co.uk/sparql/'
// ==UserScript==
// @name /music recs
// @namespace http://moustaki.org/music-recs/
// @description Injects recommendations within /music
// @include http://www.bbc.co.uk/music/artists/*
// ==/UserScript==
var url = window.location.href;
artist_guid = url.split("artists\/")[1];
// ==UserScript==
// @name /music recs
// @namespace http://moustaki.org/music-recs/
// @description Injects recommendations within /music
// @include http://www.bbc.co.uk/music/artists/*
// ==/UserScript==
var url = window.location.href;
artist_guid = url.split("artists\/")[1];
#!/usr/bin/python
from pyechonest import artist, config
from ircbot import SingleServerIRCBot
from irclib import nm_to_n, nm_to_h, irc_lower, ip_numstr_to_quad, ip_quad_to_numstr
from random import *
import urllib2
import socket
import twitter
module RDFMapper
class << self
def to_rdf(obj)
mapping = obj.rdf_mapping
uri = obj.uri
data = "<#{uri}>\n" unless mapping.empty?
module RDFMapper
class << self
def to_rdf(obj)
mapping = obj.rdf_mapping
uri = obj.uri
data = "<#{uri}>\n" unless mapping.empty?
require 'rubygems'
require '4store-ruby'
query = ARGV[0]
class Array; def sum; inject( nil ) { |sum,x| sum ? sum+x : x }; end; end
class Array; def mean; sum / size; end; end
store = FourStore::Store.new 'http://kakapo.dcs.qmul.ac.uk/bbc/programmes/sparql/'
results = []
:- use_module(library('http/http_open')).
prove((A, B)) :-
A, B.
prove((A; B)) :-
A; B.
prove(H) :-
clause(H, B), !,
prove(B).
prove(Head) :- load(Head), Head.
When /^I am on (.+)$/ do |page_name|
begin
visit path_to(page_name)
rescue Mechanize::ResponseCodeError => e
$stderr.puts "ERROR: " + e.page.root.xpath('//pre[@id="message"]/text()').to_s
raise Mechanize::ResponseCodeError.new e.page
end
end