Skip to content

Instantly share code, notes, and snippets.

View metade's full-sized avatar

Patrick Sinclair metade

View GitHub Profile
<!--#config timefmt="%Y" --><!--#set var="time_year" value="${DATE_LOCAL}" -->
<!--#config timefmt="%j" --><!--#set var="time_day" value="${DATE_LOCAL}" -->
<!--#config timefmt="%H" --><!--#set var="time_hour" value="${DATE_LOCAL}" -->
<!--#config timefmt="%M" --><!--#set var="time_min" value="${DATE_LOCAL}" -->
<!--#func var="time_year_m" func="mult" value="${time_year}" value="525948" -->
<!--#func var="time_day_m" func="mult" value="${time_day}" value="1440" -->
<!--#func var="time_hour_m" func="mult" value="${time_hour}" value="60" -->
<!--#func var="time" func="add" value="${time_year_m}" value="${time_day_m}" value="${time_hour_m}" value="${time_min}"-->
<!--#config timefmt="%Y" --><!--#func var="modified_year" func="flastmod" virtual="/radio1/nowplaying/latest.sssi" -->
class Point
attr_accessor :x, :y
def initialize(x, y)
@x, @y = x, y
end
end
ENTRY_COUNT = 40
INCREMENT = 0.01
/:service/programmes/segments # n most played segments
/:service/programmes/segments/player # n most played segments available in iplayer
/:service/programmes/segments/latest # latest n segments
/programmes/:brand_pid/segments
/programmes/:brand_pid/segments/player
/programmes/:brand_pid/segments/latest
/:service/programmes/genres/music/:genre/segments
/:service/programmes/genres/music/:genre/segments/player
require 'rubygems'
require 'mysql'
sql = %[
select b.pid, b.title as brand_title, c.musicbrainz_gid as mbid, c.name as artist_name, count(DISTINCT se.id) as 'plays'
FROM contributors c
JOIN segments s ON s.primary_contributor_id = c.id
JOIN segment_events se ON se.segment_id = s.id
JOIN versions v ON se.version_id = v.id
JOIN broadcasts br ON v.id = br.version_id
require 'rubygems'
require 'bbc_standards'
require 'sqlite_cache'
require 'open-uri'
require 'rubigraph'
include Rubigraph
Rubigraph.init
class Crawler
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>bbc.introducing</groupId>
<artifactId>peel</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
<url>https://dev.bbc.co.uk/maven/sites/peel</url>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Feature</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Expires" content="-1" />
<meta http-equiv="Pragma" content="no-cache" />
require 'rubygems'
require 'hpricot'
require 'yaml'
task :convert_data do
doc = Hpricot(File.open('b00h752w.html'))
artists = (doc/'//a').map { |a| { :link =>a['href'], :name => a.inner_html, :offset => nil } }
File.open('data.yml', 'w') { |file| file.puts artists.to_yaml }
end
[{"imageURL": "http://we-need.org/sicamp/charts/786f939d2c82a86437f42df6607e9832.png", "count": 29, "needs": ["Doing everyday things", "Getting washed and dressed", "Moving about the house", "preparing meals", "eating", "Being with other people - family, friends, relationships ", "seeing and staying in touch with my family & friends ", "having someone to talk to ", "making friends ", "finding a life partner ", "Getting out and about ", "getting to work/shops/appointments/meetings ", "using public transport ", "sharing transport ", "Running my life ", "managing paper work ", "getting organised ", "Doing something useful ", "paid work ", "voluntary work ", "setting up a business ", "Education and learning ", "vocational courses ", "cultural studies ", "Holidays and Short Breaks ", "going on holiday ", "having a break for me and or my family ", "study break ", "retreat"], "label": "51.4985,-0.163669", "details": "<table>\n\n<td>Doing everyday things</td>\n<td>2</td>\n\n<td>Getting washed and dressed</td>\n<td>1<