<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Talk Unafraid &#187; api</title>
	<atom:link href="http://www.talkunafraid.co.uk/tag/api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.talkunafraid.co.uk</link>
	<description>The (occasionally coherent) ramblings of a geek</description>
	<lastBuildDate>Sat, 07 Jan 2012 22:24:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The importance of APIs in broadcast</title>
		<link>http://www.talkunafraid.co.uk/2011/01/the-importance-of-apis-in-broadcast/</link>
		<comments>http://www.talkunafraid.co.uk/2011/01/the-importance-of-apis-in-broadcast/#comments</comments>
		<pubDate>Fri, 07 Jan 2011 07:17:32 +0000</pubDate>
		<dc:creator>James Harrison</dc:creator>
				<category><![CDATA[Code Snippets and Examples]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Radio]]></category>
		<category><![CDATA[Servers and Software]]></category>
		<category><![CDATA[am]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[commentary]]></category>
		<category><![CDATA[dab]]></category>
		<category><![CDATA[fm]]></category>
		<category><![CDATA[metadata]]></category>
		<category><![CDATA[myriad]]></category>
		<category><![CDATA[radio]]></category>
		<category><![CDATA[rambling]]></category>
		<category><![CDATA[rds]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[tcpip]]></category>

		<guid isPermaLink="false">http://www.talkunafraid.co.uk/?p=1221</guid>
		<description><![CDATA[We use a program called Myriad for all our broadcast automation, asset management and general playout purposes. It&#8217;s made by a company called P Squared, who are a very able and friendly bunch of people and who make ultimately a fairly decent product. However, as with anything these days, a single app isn&#8217;t sufficient no [...]]]></description>
			<content:encoded><![CDATA[<p>We use a program called Myriad for all our broadcast automation, asset management and general playout purposes. It&#8217;s made by a company called P Squared, who are a very able and friendly bunch of people and who make ultimately a fairly decent product.</p>
<p>However, as with anything these days, a single app isn&#8217;t sufficient no matter how good the app is. The expectation to end users is that everything should play together nicely and you should be able to get data from A into B with a minimum of fuss. And as a developer, you clearly want to enable this- it means your app has more happy users, and if your app is commercial that translates to more cash. If you make a really, really good API then you can end up with a veritable ecosystem around your app; other companies pouring money into development, all supporting your business. So APIs are good for business.</p>
<p>But more importantly APIs are good for consumers. If you&#8217;re listening on your DAB radio or (in our case soon, with any luck) an RDS equipped FM radio, you want some metadata. Who are the presenters you&#8217;re listening to? What&#8217;s this song? Listening online? Then you want the song title. This is all pretty basic stuff we&#8217;ve come to expect thanks to media players on computers. If you&#8217;re a big company like the BBC you just adjust your tools and systems to support the APIs you need, or specify them in your requirements to outside vendors and get them to add support. But what about the little guys?</p>
<p>P Squared have made a good step in the right direction as of their last major release of Myriad; they added a TCP/IP interface that lets you query Myriad for some basic variables. Through a fairly bodged-together little set of scripts we can get data out of Myriad like what song is playing now, and what&#8217;s coming up. But it&#8217;s still awkward.</p>
<p>So I whipped up a little Sinatra webapp that does the appropriate little dance to act as a gateway to that awkward TCP/IP gateway from the land of HTTP. Everything speaks HTTP, or can be prodded to speak HTTP quite easily. It&#8217;s far and away the best tool for interacting between applications, since it&#8217;s well understood and simple to understand. Now I can have a script poke Myriad and our website&#8217;s API, combine the two, and suddenly all our metadata can be updated: &#8220;There Will Be Cake with James Harrison: Around The World (Radio Edit) &#8211; Daft Punk&#8221;. And while there&#8217;s absolutely no need to tell people the name of that particular song, we&#8217;re still adding a lot of value by providing more interactivity to our listeners through updated content. And hell, it&#8217;s just more professional. Click through for the scripts.<span id="more-1221"></span></p>
<p><script src="https://gist.github.com/769210.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkunafraid.co.uk/2011/01/the-importance-of-apis-in-broadcast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More on PoliticsPosters</title>
		<link>http://www.talkunafraid.co.uk/2010/04/more-on-politicsposters/</link>
		<comments>http://www.talkunafraid.co.uk/2010/04/more-on-politicsposters/#comments</comments>
		<pubDate>Tue, 13 Apr 2010 02:02:33 +0000</pubDate>
		<dc:creator>James Harrison</dc:creator>
				<category><![CDATA[Code Snippets and Examples]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Servers and Software]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[lessons]]></category>
		<category><![CDATA[linode]]></category>
		<category><![CDATA[openrightsgroup]]></category>
		<category><![CDATA[pdf]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[prawn]]></category>
		<category><![CDATA[publicwhip]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[theyworkforyou]]></category>

		<guid isPermaLink="false">http://www.talkunafraid.co.uk/?p=852</guid>
		<description><![CDATA[Okay, so day one of that site is over, with some lessons learned and some serious improvements made! About 11AM, just as I was trundling along the M25 on my way to Egham, TheyWorkForYou made a change to their API method, getMP, which PoliticsPosters uses to find your MP from your postcode (or at least [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so day one of that site is over, with some lessons learned and some serious improvements made!</p>
<p>About 11AM, just as I was trundling along the M25 on my way to Egham, <a href="http://theyworkforyou.com">TheyWorkForYou</a> made a change to their API method, getMP, which <a href="http://politicsposters.co.uk">PoliticsPosters</a> uses to find your MP from your postcode (or at least did- more on that in a tick). Basically since our MPs aren&#8217;t technically our MPs, the method started to return nothing, a case I hadn&#8217;t considered. Fortunately they provided the always_return option, so when I got back from a successful day in Egham at around 7PM, I quickly fixed that.</p>
<p>Next bug: In any election, constituency boundaries are likely to change. In this one, we got plenty. My lookup had previously been this:</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1">mp = <span class="re2">PoliticsPosters::API</span>.<span class="me1">twfy</span>.<span class="me1">mp</span><span class="br0">&#40;</span><span class="re3">:postcode</span><span class="sy0">=&amp;gt;</span>params<span class="br0">&#91;</span><span class="re3">:postcode</span><span class="br0">&#93;</span>, <span class="re3">:always_return</span><span class="sy0">=&amp;gt;</span>true<span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>Trouble is, this doesn&#8217;t work if your boundary has changed (and thus your last MP has changed). To do that, we need to use the getConstituency call with the new &#8216;future&#8217; flag.</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1">constituency = <span class="re2">PoliticsPosters::API</span>.<span class="me1">twfy</span>.<span class="me1">constituency</span><span class="br0">&#40;</span><span class="re3">:postcode</span><span class="sy0">=&amp;gt;</span>params<span class="br0">&#91;</span><span class="re3">:postcode</span><span class="br0">&#93;</span>, <span class="re3">:future</span><span class="sy0">=&amp;gt;</span><span class="nu0">1</span><span class="br0">&#41;</span></div>
</li>
<li class="li1">
<div class="de1">mp = <span class="re2">PoliticsPosters::API</span>.<span class="me1">twfy</span>.<span class="me1">mp</span><span class="br0">&#40;</span><span class="re3">:constituency</span><span class="sy0">=&amp;gt;</span>constituency.<span class="me1">name</span>, <span class="re3">:always_return</span><span class="sy0">=&amp;gt;</span>true<span class="br0">&#41;</span></div>
</li>
</ol>
</div>
<p>And now we&#8217;re good! Easily fixed, overall, and it removed the two biggest problems. The other problems are a little trickier. One remains- handling of special characters in MP names. There&#8217;s a few MPs with circumflexes and the like in their name, which is fine if you have a language/framework/tools that support UTF8 encoding (which Ruby/Sinatra/Prawn does). But the font I&#8217;d chosen, <a href="http://www.theleagueofmoveabletype.com/fonts/4-chunk">Chunk</a>, didn&#8217;t have any of the characters it needed to render. This remains an issue, and my current planned work-around is to degrade to another font for pages and posters that handle those names. I&#8217;ll sort that out tomorrow, though- this post is, after all, being put together at 3AM, and I have to sleep sometime.<a href="http://assets.talkunafraid.co.uk/2010/04/posters1.png" rel="lightbox[852]"><img class="alignright size-thumbnail wp-image-851" title="Posters for Witney" src="http://assets.talkunafraid.co.uk/2010/04/posters1-150x150.png" alt="" width="150" height="150" /></a></p>
<p>The only other thing people wanted was more posters. I have been happy to oblige. I combined the PublicWhip policy feed provided through TheyWorkForYou, wrote a tiny scraper to get the titles off the PublicWhip site (since there&#8217;s no API for that I&#8217;m aware of), stuffed it together in PostgreSQL through DataMapper, and now I can do something like this:</p>
<div class="geshi no ruby">
<ol>
<li class="li1">
<div class="de1"><span class="re2">PoliticsPosters::MP</span>.<span class="me1">first</span><span class="br0">&#40;</span><span class="re3">:full_name</span><span class="sy0">=&amp;gt;</span><span class="st0">&#39;David Cameron&#39;</span><span class="br0">&#41;</span>.<span class="me1">policies</span> <span class="co1">#=&amp;gt; [&amp;lt;#PoliticsPosters::MPPolicy policy_id=4 distance=0.05 etc&amp;gt;]</span></div>
</li>
</ol>
</div>
<p>Which is very, very neat, and means that developing stuff is very easy. I dug around in the source code for TheyWorkForYou and pulled out their code for rendering PublicWhip data to get the same policy IDs and descriptions, wrote some methods to scale color and size, and stuffed it all together to produce the new and updated constituency page as well as new posters- one for all policies, and one for each individual policy. The individual policy posters are rendered on demand, whereas the common constituency ones are rendered on the first view of a constituency page.</p>
<p>The Linode VPS has been handling the load without even noticing. Despite the site being inoperative most of the day, it got 10,000 hits from nearly 4,000 unique users, who downloaded nearly 2,000 posters. Not bad for a first day.</p>
<p>Tomorrow I hope to sort out UTF8 character handling and maybe even get around to publishing the source code to the site if I have a spare moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkunafraid.co.uk/2010/04/more-on-politicsposters/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Welcome to Pandora</title>
		<link>http://www.talkunafraid.co.uk/2010/01/welcome-to-pandora/</link>
		<comments>http://www.talkunafraid.co.uk/2010/01/welcome-to-pandora/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 01:30:32 +0000</pubDate>
		<dc:creator>James Harrison</dc:creator>
				<category><![CDATA[MMMetrics]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[EVE]]></category>
		<category><![CDATA[eve metrics]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[servers]]></category>
		<category><![CDATA[stuffisawesome]]></category>

		<guid isPermaLink="false">http://www.talkunafraid.co.uk/?p=649</guid>
		<description><![CDATA[We&#8217;ve successfully moved all sites, email, DNS, and everything else on our old server, Highpoint, to our brand new machine, Pandora.  This has entailed a lot more downtime than we&#8217;d anticipated; this has mostly been due to lack of preparation on my part, a glorious DNS cock-up and the added complexity of having Highpoint&#8217;s backhaul [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;ve successfully moved all sites, email, DNS, and everything else on our old server, Highpoint, to our brand new machine, Pandora.  This has entailed a lot more downtime than we&#8217;d anticipated; this has mostly been due to lack of preparation on my part, a glorious DNS cock-up and the added complexity of having Highpoint&#8217;s backhaul fail three times as we tried to move across all the data.</p>
<p>In total it was a fairly mammoth operation by our standards; we transferred in excess of 100 gigabytes of data between the servers over the course of 12 hours, shifted over 20 websites and 3 major webapps, and got everything up and running again in under a day once we&#8217;d moved it all to the new box. The downtime has been annoying and I&#8217;ve certainly learned some lessons for next time, but here&#8217;s the flipside&#8230;</p>
<p>We&#8217;re now running on a much, much roomier machine. We&#8217;ve not got the environment perfectly set up and we&#8217;ll no doubt spend the next week tuning everything, adjusting things till they&#8217;re just right and fixing bugs, as well as adjusting and rewriting chunks of applications to make use of the extended caching capabilities of our new environment. We&#8217;re already using this to great effect in the EVE Metrics APIs but we can make better use of caching throughout our apps.</p>
<p>Once we&#8217;ve gotten settled in, we should be performing much better and more reliably than previously. We&#8217;ve already seen huge performance gains on our database (we can process more than twice as many uploads per second, for example) and we hope to have things even faster soon.</p>
<p>Of course, to achieve this I have been running on more or less an empty tank as far as sleep is concerned and working things in around my life at university, which has been interesting. Still, we&#8217;re at the point now where it&#8217;s more or less stable and everything basically works, so now I&#8217;m going to grab a few hours of sleep before lectures tomorrow, before a long long lie-in on Saturday. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.talkunafraid.co.uk/2010/01/welcome-to-pandora/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

