<?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>mySociety &#187; Developers</title>
	<atom:link href="http://www.mysociety.org/category/developers/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mysociety.org</link>
	<description>Relentless user-focus on civic websites</description>
	<lastBuildDate>Thu, 09 Feb 2012 18:07:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Job Advert: Developers &#8211; Deadline 21st Feb</title>
		<link>http://www.mysociety.org/2010/12/08/job-advert-developers/</link>
		<comments>http://www.mysociety.org/2010/12/08/job-advert-developers/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 15:47:24 +0000</pubDate>
		<dc:creator>Tom Steinberg</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Job adverts]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=3774</guid>
		<description><![CDATA[How would you like to be a coder in an organisation that is as determined to make a difference in the world as it is to be a truly high quality, engineer-led software team? mySociety is that organisation. We’re a project of a registered charity, currently running award-winning civic and democratic websites like TheyWorkForYou.com and [...]]]></description>
			<content:encoded><![CDATA[<p>How would you like to be a coder in an organisation that is as determined to make a difference in the world as it is to be a truly high quality, engineer-led software team?</p>
<p>mySociety is that organisation. We’re a project of a registered charity, currently running award-winning civic and democratic websites like <a href="http://theyworkforyou.com">TheyWorkForYou.com</a> and <a href="http://fixmystreet.com">FixMyStreet.com</a>,  and we’re looking to grow our already-celebrated development team by several new members over the next six months.</p>
<p>We’re looking for people with at least two years experience (professional or keen amateur) in at least one of Python, Ruby, Perl, PHP, C++, Javascript or Adobe Flex, and who have ambitions to learn more languages in the future.</p>
<p>We’re looking for developers willing to commit to full or mostly-full time positions (no freelancers, sorry) and who are up for a career change that will see them stay with us for a little while. You’ll get to work with volunteers, mix commercial and charitable projects, and travel far and wide. Plus, you can work from wherever you live (in the UK), and we pay salaries from £28k to £50k depending on skills.</p>
<p>Most of all, we’re looking for coders who look at the services we have built so far and think “I wish I’d been on that project”. Projects you&#8217;ll likely be working on over the next few months include (but are not limited to):</p>
<ul>
<li>A/B testing and conversion tracking of our charitable sites</li>
<li>Commercial spinoffs from FixMyStreet</li>
<li>Mapumental</li>
<li>Enhancements to TheyWorkForYou and WhatDoTheyKnow</li>
<li>Commercial development for clients</li>
</ul>
<p>We’re looking to speak with possible candidates continually over the next few months, with a view to hiring two developers now and two more later in the year.  Please send us your CV if you&#8217;re interested &#8211; the address is <a href="mailto:hello@mysociety.org">hello@mysociety.org</a> and the subject line needs to be msjob6.  The first round closing date is 10am on Monday 21st February, but CVs received after this deadline will still be considered for the next round of hiring.</p>
<p>And if you’ve any questions, please post them in the comments below so we can share the answers.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2010/12/08/job-advert-developers/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>New features on MaPit</title>
		<link>http://www.mysociety.org/2010/10/06/new-features-on-mapit/</link>
		<comments>http://www.mysociety.org/2010/10/06/new-features-on-mapit/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 13:17:10 +0000</pubDate>
		<dc:creator>Matthew Somerville</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Launches]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=3715</guid>
		<description><![CDATA[li { margin-bottom: 1em; } We&#8217;ve added a variety of new features to our postcode and point administrative area database, MaPit, in the past month &#8211; new data (Super Output Areas and Crown dependency postcodes), new functionality (more geographic functions, council shortcuts, and JSONP callback), and most interestingly for most people, a way of browsing [...]]]></description>
			<content:encoded><![CDATA[<style type="text/css">li { margin-bottom: 1em; }</style>
<p>We&#8217;ve added a variety of new features to our postcode and point administrative area database, <a href="http://mapit.mysociety.org/">MaPit</a>, in the past month &#8211; new data (Super Output Areas and Crown dependency postcodes), new functionality (more geographic functions, council shortcuts, and JSONP callback), and most interestingly for most people, a way of browsing all the data on the site.</p>
<ul>
<li>Firstly, we have some <strong>new geographic functions</strong> to join touches &#8211; overlaps, covered, covers, and coverlaps. These do as you would expect, enabling you to see the areas that overlap, cover, or are covered by a particular area, optionally restricted to particular types of area. &#8216;coverlaps&#8217; returns the areas either overlapped or covered by a chosen area &#8211; this might be useful for questions such as &#8220;Tell me all the <a href="http://mapit.mysociety.org/area/2528/coverlaps.html?type=WMC">Parliamentary constituencies fully or partly within the boundary of Manchester City Council</a>&#8221; (three of those are entirely covered by the council, and two overlap another council, Salford or Trafford).</li>
<li>As you can see from that link, nearly everything on MaPit now has an <strong>HTML representation</strong> &#8211; just stick &#8220;.html&#8221; on the end of a JSON URI to see it. This makes it very easy to explore the data contained within MaPit, linking areas together and letting you view any area on Google Maps (e.g. <a href="http://mapit.mysociety.org/area/2600.html">Rutland Council</a> on <a href="http://maps.google.co.uk/maps?q=http://mapit.mysociety.org/area/2600.kml">a map</a>). It also means <a href="http://mapit.mysociety.org/postcode/SW1A1AA.html">every postcode has a page</a>.</li>
<li>From a discussion on our mailing list started by Paul Waring, we discovered that the NSPD &#8211; already used by us for Northern Ireland postcodes &#8211; also contains <strong>Crown dependency postcodes</strong> (the Channel Islands and the Isle of Man) &#8211; no location information is included, but it does mean that given something that looks like a Crown dependency postcode, we can now at least tell you if it&#8217;s a valid postcode or not for those areas.</li>
<li>Next, we now have all <strong>Lower and Middle Super Output Areas</strong> in the system; thanks go to our volunteer Anna for getting the CD and writing the import script. These are provided by ONS for small area statistics after the 2001 census, and it&#8217;s great that you can now trivially look up the SOA for a postcode, or see what SOAs are within a particular ward. Two areas are in MaPit for each LSOA and MSOA &#8211; one has a less accurate boundary than the other for quicker plotting, and we thought we might as well just load it all in. The licences on the CD (<a href="http://parlvid.mysociety.org:81/os/soa/Conditions_of_supply_of_Super_Output_Area_boundaries.pdf">Conditions of supply of SOA boundaries</a> and <a href="http://parlvid.mysociety.org:81/os/soa/Ordnance_Survey_Output_Area_Licence.pdf">Ordnance Survey Output Area Licence</a>) talk about a click-use licence, and a not very sraightforward OS licence covering only those SOAs that might share part of a boundary with Boundary-Line (whichever ones those are), but ONS now use the <a href="http://www.ons.gov.uk/copyright/">Open Government Licence</a>, Boundary-Line is included in <a href="http://www.ordnancesurvey.co.uk/oswebsite/opendata/">OS OpenData</a>, various councils have published their SOAs as open data (e.g. <a href="http://opendata.warwickshire.gov.uk/datasets/warwickshire-super-output-areas">Warwickshire</a>), and these areas should be publicly available under the same licences.</li>
<li>As the UK has a variety of different types of council, depending on where exactly you are, the postcode lookup now includes a <strong>shortcuts</strong> dictionary in its result, with two keys, &#8220;council&#8221; and &#8220;ward&#8221;. In one-tier areas, the values will simply by the IDs of that postcode&#8217;s council and ward (whether it&#8217;s a Metropolitan district, Unitary authority, London borough, or whatever); in two-tier areas, the values will again be dictionaries with keys &#8220;district&#8221; and &#8220;council&#8221;, pointing at the respective IDs. This should hopefully make lookups of councils easier.</li>
<li>Lastly, to enable use directly on other sites with JavaScript, MaPit now sends out an &#8220;Access-Control-Allow-Origin: *&#8221; header, and allows you to specify a <strong>JSON callback</strong> with a callback parameter (e.g. put &#8220;?callback=foo&#8221; at the end of your query to have the JSON results wrapped in a call to the foo() function). JSONP calls will always return a 200 response, to enable the JavaScript to access the contents &#8211; look for the &#8220;error&#8221; key to see if something went wrong.</li>
</ul>
<p>Phew! I hope you find this a useful resource for getting at administrative geographic data; please do let us know of any uses you make of the site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2010/10/06/new-features-on-mapit/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Outlook attachments now viewable in WhatDoTheyKnow</title>
		<link>http://www.mysociety.org/2010/03/15/outlook-attachments-now-viewable-in-whatdotheyknow/</link>
		<comments>http://www.mysociety.org/2010/03/15/outlook-attachments-now-viewable-in-whatdotheyknow/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 11:24:54 +0000</pubDate>
		<dc:creator>Francis Irving</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[WhatDoTheyKnow]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=3330</guid>
		<description><![CDATA[When a bit of government forwards or attaches emails using Outlook, they get sent using a special, strange Microsoft email format. Up until now, WhatDoTheyKnow couldn&#8217;t decode it. You&#8217;d just see a weird attachment on the response to your Freedom of Information request, and probably not be able to do anything with it. Peter Collingbourne [...]]]></description>
			<content:encoded><![CDATA[<p>When a bit of government forwards or attaches emails using Outlook, they get sent using a special, strange Microsoft email format. Up until now, WhatDoTheyKnow couldn&#8217;t decode it. You&#8217;d just see a weird attachment on the response to your Freedom of Information request, and probably not be able to do anything with it.</p>
<p><a href="http://www.pcc.me.uk/~peter/">Peter Collingbourne</a> got fed up with this, and luckily for us, he can code too. He <a href="http://github.com/mysociety/whatdotheyknow">forked our source code repository</a>, and <a href="http://git.pcc.me.uk/?p=~peter/whatdotheyknow.git;a=commit;h=9d1321cca685d4a25cdb615199ef464da3ba4d5d">made a nice patch</a> in his own copy of it.</p>
<p>He then told us about it, and I <a href="http://github.com/mysociety/whatdotheyknow/commit/7c5be5afbc8af5fa3ab504983e4f38c09c71e118">merged his changes</a> into the main WhatDoTheyKnow code, tested them out on my laptop, then made them live. It all work perfectly first time. Peter even added the new dependency on vpim to WhatDoTheyKnow <a href="http://github.com/mysociety/whatdotheyknow/commit/7c5be5afbc8af5fa3ab504983e4f38c09c71e118#diff-2">conf/packages</a>.</p>
<p>Now if you go to an Outlook attachment on WhatDoTheyKnow,<br />
<a href="http://www.whatdotheyknow.com/request/immediate_response_team_deployme#incoming-11901">such as this one</a> you&#8217;ll just see the files, and be able to download them, and view them as HTML as normal. They&#8217;ll also get indexed by the search (although I need to do a rebuild for that for it to work with old requests).</p>
<p>Thanks Peter!</p>
<p>If you want to have a go making an improvement to a mySociety site, you can get the code for most of them <a href="http://github.com/mysociety">from our github repositories</a>. For some sites, there&#8217;s an INSTALL.txt file explaining how to get a development environment set up. Let us know if you do anything &#8211; even incremental improvements to installation instructions are really useful. And new, useful, features like Peter&#8217;s are even more so.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2010/03/15/outlook-attachments-now-viewable-in-whatdotheyknow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What are the two sorts of Cloud infrastructure called?</title>
		<link>http://www.mysociety.org/2009/09/22/what-are-the-two-sorts-of-cloud-infrastructure-called/</link>
		<comments>http://www.mysociety.org/2009/09/22/what-are-the-two-sorts-of-cloud-infrastructure-called/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 10:42:45 +0000</pubDate>
		<dc:creator>Francis Irving</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Mapumental]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=3092</guid>
		<description><![CDATA[I&#8217;ve been doing lots of research around &#8220;cloud computing&#8221; recently, so we can change how Mapumental works and take it out of private beta. One thing that&#8217;s struck me is that there doesn&#8217;t seem to be a proper, industry standard name to distinguish what to me are two fundamentally different sorts of &#8220;cloud computing&#8221;. I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing lots of research around &#8220;cloud computing&#8221; recently, so we can change how <a href="http://mapumental.channel4.com/">Mapumental</a> works and take it out of private beta.</p>
<p>One thing that&#8217;s struck me is that there doesn&#8217;t seem to be a proper, industry standard name to distinguish what to me are two fundamentally different sorts of &#8220;cloud computing&#8221;. I&#8217;m focusing here entirely on cloud services for programmers (let&#8217;s leave what it means to end users or businesses for another day).</p>
<p>Here are my own names and descriptions of them:</p>
<p><strong>1) Cloud hardware server provision (Cloud HSP)<br />
</strong> Low level APIs for making and destroying (virtual) servers, and loading machine images onto them. e.g. Amazon Elastic Compute Cloud, Rackspace Cloud Servers,  Eucalyptus&#8217;s EC2 bits. Basically, what <a href="http://open.eucalyptus.com/wiki/API_v1.5">Eucalyptus v 1.5 can do</a> and what <a href="http://libcloud.org/">libcloud</a> should do. (By analogy,  this is the assembly language of cloud computing)</p>
<p><strong>2) Cloud developer service provision (Cloud DSP)</strong> A service that a developer accesses with one name and a simple API, and behind the scenes it scales for him, automatically. e.g. Amazon Queue Service, Rackspace Cloud Files. (By analogy, this layer is the C programming language of cloud computing)</p>
<p>[as an aside, Google AppEngine is an interesting one. It is definitely in the Cloud DSP category, but I think it is larger than that - it is a whole set of APIs all in that category. Something like Google DataStore is a single Cloud DSP, albeit one apparently only accessible within AppEngine apps]</p>
<p>It&#8217;s possible to use a Cloud HSP (assembly language), along with a bunch of your own software or open source software, to build new Cloud DSPs (C code). Right now this is pretty hard &#8211; even quite well known open source distributed datasbases like CouchDB still need scripting to even make them replicate. The code that makes and destroys servers and gives the service one name, needs manually stringing with quite new bits of wire (things like <a href="http://code.google.com/p/scalr/">scalr</a> and <a href="http://www.backhand.org/wackamole/">Wackamole</a>).</p>
<p>For this reason, I&#8217;m reluctant for mySociety to get into the &#8220;making our own Cloud DSP out of Cloud HSP&#8221; game. It feels to me like a suck of time, and like we wouldn&#8217;t be able to guarantee without lots of careful and expensive testing that it would scale. I&#8217;m more tempted to use the commercial Cloud DSP services where possible, even though they are proprietary. But use them via our own abstraction layer, so we can change as we need to. Of course, we have some C++ code (the public transport route finder), so will have to use the Cloud HSP API to get that going, perhaps with <a href="http://aws.amazon.com/autoscaling/">Amazon&#8217;s Auto Scaling</a>. But it can jolly well use AQS and S3 to talk to other services.</p>
<p>So, what do you think about the names Cloud HSP/DSP? Are there already existing names for the distinction that I&#8217;m making? Is it a useful distinction for you? Can you think of better names?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2009/09/22/what-are-the-two-sorts-of-cloud-infrastructure-called/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>WhatDoTheyKnow growing pains (and Ruby memory leaks)</title>
		<link>http://www.mysociety.org/2009/09/17/whatdotheyknow-growing-pains-and-ruby-memory-leaks/</link>
		<comments>http://www.mysociety.org/2009/09/17/whatdotheyknow-growing-pains-and-ruby-memory-leaks/#comments</comments>
		<pubDate>Thu, 17 Sep 2009 19:19:09 +0000</pubDate>
		<dc:creator>Francis Irving</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[WhatDoTheyKnow]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=2982</guid>
		<description><![CDATA[WhatDoTheyKnow keeps growing and growing, sucking people in from Google as its archive of maybe 8.5% of Freedom of Information requests gets more and more detailed. (Graph of number of FOI requests made using WhatDoTheyKnow over time; click for larger version) There&#8217;s round about 8Gb of unfettered Government data in the core database, plus a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.whatdotheyknow.com">WhatDoTheyKnow</a> keeps growing and growing, sucking people in from Google as its archive of <a href="http://www.mysociety.org/2009/07/16/what-percentage-of-foi-requests-are-made-using-whatdotheyknow/">maybe 8.5% of Freedom of Information requests</a> gets more and more detailed.</p>
<p><a href="http://www.whatdotheyknow.com/foi-live-creation.png"><img src="http://www.whatdotheyknow.com/foi-live-creation.png"alt="mapumental-early-architecture" title="mapumental-early-architecture" width="300" height="212" class="alignnone wp-image-2300" style="max-width: 36em; max-height: 25.67em" /></a><br />
<strong>(Graph of number of FOI requests made using WhatDoTheyKnow over time; click for larger version)</strong></p>
<p>There&#8217;s round about 8Gb of unfettered Government data in the core database, plus a whole bunch more for indexing and caching. For comparison, TheyWorkForYou  (which now <a href="http://www.google.co.uk/search?sourceid=chrome&#038;ie=UTF-8&#038;q=theyworkforyou+historic+hansard">goes back to 1935</a>) has 12Gb. And it&#8217;s catching up on traffic also &#8211; WhatDoTheyKnow has about half the number of visitors as TheyWorkForYou.</p>
<p>Unfortunately, this new found traffic has led to performance problems. You might have seen errors when using WhatDoTheyKnow in the last week or two. This post is firstly an apology for that. Thank you for your patience. Hopefully it is fixed now &#8211; do let us know if you get problems still. And secondly it is some techy stuff about debugging such problems in Ruby on Rails&#8230;</p>
<p>When WhatDoTheyKnow started failing, we did the obvious things to start with &#8211; moving the database to a separate server, and moving some other services off the same server, to give WDTK more room to breathe. It still kept breaking.</p>
<p>None of my server monitoring tools shed any very clear light as to the problem. I upgraded to the latest version of <a href="http://www.modrails.com/">Passenger</a>, the best Rails deployment tool I&#8217;ve seen yet. It&#8217;s pretty good, but still not mature enough for my liking. I was still getting the same problems with it, but reporting tools like passenger-memory-stats were really helpful.</p>
<p>Eventually I worked out that it was to do with memory use of the Rails processes. Individual ones would leap up to 1Gb, and never drop back down. If several did, the server (with 4Gb of RAM) would start swapping and grind to a halt. The world of Ruby and Rails memory monitoring software is patchwork at best, and in the end I found the simplest tools the most useful. Here&#8217;s some:</p>
<ul>
<li>I found some Rails processes were getting jammed, and not dieing even when I restarted Apache. I think in the end this was due to the Passenger spawning method, and our use of the <a href="http://xapian.org/">Xapian</a> Ruby module. Running Passenger in <tt>RailsSpawnMethod conservative</tt> mode made things much more robust.
</li>
<li><a href="http://mmonit.com/monit/">Monit</a>, which in a previous life had a job holding up vital structural pillars of buildings with duct tape, makes you feel dirty. Actually it is really useful. Given I couldn&#8217;t quickly fix the problem, Monit let me at least reduce the suffering for people trying to use the site meanwhile. Here&#8217;s the rule I used, which gives Apache a kick every time server memory use is too high. It was firing every 5 or 10 minutes&#8230;<br />
<blockquote><pre>check system localhost
    if memory > 3500 MB then exec "/usr/sbin/apache2ctl graceful"</pre>
</blockquote>
</li>
<li>I found <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/foi/lib/memory_profiler.rb">memory_profiler</a> on a <a href="http://scottstuff.net/blog/2006/08/17/memory-leak-profiling-with-rails">blog</a>. It helps you find the kind of memory leak where you unintentionally continue to reference an object you don&#8217;t use any more. With a specialist subject of string objects. This led to <a href="https://secure.mysociety.org/cvstrac/chngview?cn=16577">a fix</a> to do with declaring static arrays in classes vs. modules, which I still don&#8217;t really understand. But it wasn&#8217;t the cause of the big 1Gb memory munching, there were no large enough leaks of this sort.</li>
<li>The record_memory function in WDTK&#8217;s <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/foi/app/controllers/application.rb">application controller</a> came from <a href="http://www.codeweblog.com/rails-to-monitor-the-process-of-memory-leaks-skills/">another blog</a>. It&#8217;s handy as it shows you how much of the system memory in the Ruby process each request causes an increase by. With caveats, this was the best way for me to identify the most damaging requests (search results, and certain public body pages). And it also brought focus on the actual problem &#8211; the peak memory use <strong>during a request</strong>. That&#8217;s really important, because Ruby&#8217;s memory manager never returns memory to the operating system&#8230; The Gb leaps in memory use were because of temporary memory used during certain requests, which the Ruby memory manager then never frees later.</li>
<li>I made a <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/rblib/debug_helpers.rb">bunch of functions</a> culminating in <tt>allocated_string_size_around_gc</tt>. This was really useful in use with the &#8220;just add lots of print statements and fiddle&#8221; school of debugging. Not everyone&#8217;s favourite school, but if your test code can&#8217;t catch it, one I often end up using (it gets really involved rarely enough that it doesn&#8217;t seem worth setting up an interactive debugger). It led me to various peak memory savings, <a href="https://secure.mysociety.org/cvstrac/chngview?cn=16599">such as</a> calling &#8220;text.gsub!&#8221; rather than &#8220;text = text.gsub&#8221; while removing (email addresses and private information) from FOI request responses, which help quite a bit when dealing with multi-megabyte attachments.
</li>
<li>Finally, I used the overlooked debugging tool, and the one you should never rely on, being common sense. That is, common sense informed by days of careful use of all the other tools. In order to quickly show text extracts when searching, WDTK stores the extracted attachment text in the database. A few of these attachments are quite large, and led to 50Mb fields, often several of which were being loaded and processed in one page request. That this would cause a high peak of memory use all became just obvious to me some time yesterday. I checked that that was the case, and this morning, I <a href="https://secure.mysociety.org/cvstrac/chngview?cn=16618">changed it</a> to use the full text for indexing, but to at most keep 1Mb for use in snippets. So sometimes now you won&#8217;t get a good search extract for queries, but it is rare, and it will at least still return the right result.
</li>
</ul>
<p>I&#8217;ve more work to do, I think there are quite a few other quick wins, all of which are making the site faster too. I&#8217;m quite happy that WhatDoTheyKnow also has a bunch more test code as a result of all this.</p>
<p>On the other hand, what a disappointing disaster for open source languages beginning with P/R (as opposed to J). Yes, the help and tools were just about there to work it out, but would seem primitive if you&#8217;d used say Java&#8217;s <a href="http://www.eclipse.org/mat/about/screenshots.php">Memory Analyzer</a>. Indeed somebody over on StackOverflow <a href="http://stackoverflow.com/questions/161315/ruby-ruby-on-rails-memory-leak-detection">suggested</a> running your site in JRuby and using exactly that tool&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2009/09/17/whatdotheyknow-growing-pains-and-ruby-memory-leaks/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>How Mapumental works</title>
		<link>http://www.mysociety.org/2009/08/18/how-mapumental-works/</link>
		<comments>http://www.mysociety.org/2009/08/18/how-mapumental-works/#comments</comments>
		<pubDate>Tue, 18 Aug 2009 16:40:13 +0000</pubDate>
		<dc:creator>Francis Irving</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Mapumental]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=2304</guid>
		<description><![CDATA[Here is a diagram of how the backend of Mapumental works. Take it in the spirit that Chris Lightfoot set when he made a similar diagram for the No. 10 petitions site &#8211; although many such diagrams are useless, hopefully this one contains useful information. If you haven&#8217;t seen Mapumental yet, first take a look [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a diagram of how the backend of Mapumental works. Take it in the spirit <a href="http://www.mysociety.org/2006/12/08/under-the-bonnet/">that Chris Lightfoot set</a> when he made a similar diagram for the No. 10 petitions site &#8211; although many such diagrams are useless, hopefully this one contains useful information. </p>
<p>If you haven&#8217;t seen Mapumental yet, first <a href="http://mapumental.channel4.com/">take a look</a> at the video, and sign up for the private beta.</p>
<p><a href="http://www.mysociety.org/wp/wp-content/uploads/2009/08/mapumental-early-architecture.png"><img src="http://www.mysociety.org/wp/wp-content/uploads/2009/08/mapumental-early-architecture-300x212.png" alt="mapumental-early-architecture" title="mapumental-early-architecture" width="300" height="212" class="alignnone wp-image-2300" style="max-width: 36em; max-height: 25.67em" /></a><br />
<strong>(Click on the diagram for a large version)</strong></p>
<p>Below, I&#8217;ve explained what the main components are, and some interesting things about them.</p>
<p>Everything can, at least in theory, run on lots of servers. Currently we are only actually using one server for web requests, because of problems with HAProxy. We&#8217;re runnning isodaemons on two different servers.</p>
<p><strong>Basic web application</strong> &#8211; it started out as raw Python, but the more Matthew hacks on it the more Django libraries he pulls in. Soon it&#8217;ll be indistinguishable from a Django app. When someone enters a new postcode, it adds it to the work queue in the PostgreSQL database, then refreshes waiting for the job to be finished. Then it displays the flash application (made by Stamen), set up to load the appropriate tile layers.</p>
<p><strong>Tile server and cache</strong> &#8211; This uses the Python-based <a href="http://tilecache.org/">TileCache</a>, calling <a href="http://gdal.org/">Geospatial Data Abstraction Library</a> (GDAL) to help render the tiles from points. It was originally written by Stamen, and expanded by mySociety. GDAL isn&#8217;t perfect, it doesn&#8217;t have fancy enough algorithms for my liking. e.g. Using a median rather than a weighted mean.  </p>
<p><strong>Isodaemons</strong> &#8211; These are controlled by <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/bin/isodaemon.py">a Python script</a>, but the <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/cpplib/makeplan.h">bulk of the code</a> is custom written in C++. Slightly crazily, this can find the quickest route by public transport for each of 300,000 journeys from every station in the UK to a particular station, arriving at a particular time, in 10 to 30 seconds.</p>
<p>I had no idea how to do this, but luckily I live in Cambridge, UK. It&#8217;s a city fit to bursting with computer scientists. Many of the jobs are dull, and need little computing, never mind science &#8211; like <a href="http://www.autonomy.com/content/Autonomy/Careers/Graduates/index.en.html">writing interface layers for SQL server</a>. So if you have a real interesting problem it&#8217;s easy to get help!</p>
<p>The universal advice was to use <a href="http://www.cs.sunysb.edu/~skiena/combinatorica/animations/dijkstra.html">Dijkstra&#8217;s algorithm</a>, which needed a bit of adaptation to work efficiently over space-time, rather than just space. Normally it is used for planning routes round a map, but public transport isn&#8217;t like that, you have to arrive in time for each particular train, so time affects what journeys you can take.</p>
<p>I originally wrote it in Python, which was not only too slow, but used up far far too much RAM. It could never have loaded the whole dataset in.  However, the old Python code is still run by the test script, to double check the C++ code against. It is also still used to make the binary timetable files, see below.</p>
<p><strong>Travel times, 1 binary file / postcode</strong> &#8211; I briefly attempted to insert 300,000 rows into PostgreSQL for each postcode looked up, but it was obvious it wasn&#8217;t going to scale. Going back to basics, it now just saves the time taken to travel to each station in a simple binary file &#8211; two bytes for each station, 600k in total. The tile server then does random access lookups into that file, as it renders each tile. It only needs to look up the values for the stations it knows are on/near the tile.  </p>
<p><strong>There&#8217;s various other bits:</strong></p>
<ul>
<li> cron jobs for <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/bin/email-invites">sending out invites</a> </li>
<li> <a href="https://secure.mysociety.org/cvstrac/fileview?f=mysociety/iso/bin/do-nptdr.py&#038;v=1.35https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/bin/do-nptdr.py">converting timetable data</a> from ATCO-CIF to the binary format </li>
<li> <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/bin/populate-houseprices.py">loading static layer data</a> into the database </li>
<li> <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/bin/grab-uk-bounds-urls">precaching every tile</a> for static datasets </li>
<li> Squid and Apache and FastCGI both sit in front of the web applications </li>
<li> for speed, we cache the <a href="http://developers.cloudmade.com/projects/show/tiles">mapping background tiles</a> from Cloudmade </li>
<li> when zoomed out, there is code to <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/bin/cull_stations.py">cull which stations</a> are used to draw tiles </li>
<li> of course, a <a href="https://secure.mysociety.org/cvstrac/rlog?f=mysociety/iso/bin/test-run">bunch of test code</a> </li>
</ul>
<p>Thanks to everyone who helped make Mapumental, we couldn&#8217;t have done it without lots of clever people.</p>
<p>I realise the above is a sketchy overview, so please ask questions in the comments, and I&#8217;ll do my best to answer them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2009/08/18/how-mapumental-works/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>RIP Angie Martin 1974-2009</title>
		<link>http://www.mysociety.org/2009/07/20/rip-angie-ahl-1974-2009/</link>
		<comments>http://www.mysociety.org/2009/07/20/rip-angie-ahl-1974-2009/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 13:48:13 +0000</pubDate>
		<dc:creator>Tom Steinberg</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=1303</guid>
		<description><![CDATA[It is with overwhelming sadness that I write to tell our community that Angie Martin, mySociety&#8217;s fourth core developer, has died. She was taken from us by the cancer that she had been fighting since soon after we hired her less than two years ago. Possessed of an almost unbelievably upbeat personality, Angie brought not [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/tommymartin/3310044186/in/set-72157607391855997/"><img class="alignnone" src="http://farm4.static.flickr.com/3611/3310044186_cd36d7709a.jpg?v=0" alt="" width="500" height="282" /></a></p>
<p>It is with overwhelming sadness that I write to tell our community that Angie Martin, mySociety&#8217;s fourth core developer, has died. She was taken from us by the cancer that she had been fighting since soon after we hired her less than two years ago.</p>
<p>Possessed of an almost unbelievably upbeat personality, Angie brought not only her formidable Perl skills, but her blazing warmth of character to our team. In remission during our yearly retreat in January this year, she combined laughter with a typically tough line of questioning on ideas she thought insufficiently robust. With typical disgregard for cool, her CV noted that she was &#8220;known to enjoy wrangling regular expressions on a Sunday Morning&#8221;. She didn&#8217;t see any contradiction between being a successful woman and a geek, throwing herself wholeheartedly into the Mac-toting, perlmonger ethos. She even brought her husband Tommy with her, who became a significant volunteer.</p>
<p>Given her habit of plain speaking, it is pointless to pretend that Angie was able to make the contribution to mySociety&#8217;s users or codebase that she wanted to. What she achieved in terms of difficult coding during recovery from chemotherapy was incredible, breathtaking &#8211; but she wanted to change the world. It now falls to the rest of us, and our supporters, to live up to the expectations she embodied, to continue to push every day, using skills like those that she had to help people with everyday problems. We now have to ask &#8216;What would Angie do?&#8217;, as well as &#8216;What would <a href="http://www.mysociety.org/2007/03/05/rip-chris-lightfoot-1978-to-2007/">Chris</a> do?&#8217;. It is a lot to live up to.</p>
<p>She was a mySociety core developer: I hope that meant as much to her as it meant for me to have her as one of my coders.  Remember and Respect.</p>
<p><strong>Updated</strong>: Angie changed her surname upon getting married, a couple of months ago. I have just read she wanted to be remembered as Angie Martin, and so I have made that change. <a href="http://www.listsearch.com/Lasso/Thread/index.lasso?22581#249722">Read this tribute</a> on the Lasso list.</p>
<p><strong>Updated 21 7 2009:</strong> Tommy has just told me that those wishing to may memorial donations should send them to <a href="http://www.hospiceathome.co.uk/memdonations.htm">Hospice at Home</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2009/07/20/rip-angie-ahl-1974-2009/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8220;Politicians are using the internet to harness your bright ideas&#8221;</title>
		<link>http://www.mysociety.org/2008/09/07/politicians-are-using-the-internet-to-harness-your-bright-ideas/</link>
		<comments>http://www.mysociety.org/2008/09/07/politicians-are-using-the-internet-to-harness-your-bright-ideas/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 12:41:10 +0000</pubDate>
		<dc:creator>Francis Irving</dc:creator>
				<category><![CDATA[Developers]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=754</guid>
		<description><![CDATA[&#8220;People often say they could run Britain better than the political parties. A web-based revolution may give them the chance&#8221; Nice article in the Sunday Times today mentioning lots of our sites and others.]]></description>
			<content:encoded><![CDATA[<p>&#8220;People often say they could run Britain better than the political parties. A web-based revolution may give them the chance&#8221;</p>
<p>Nice <a href="http://technology.timesonline.co.uk/tol/news/tech_and_web/the_web/article4692454.ece">article in the Sunday Times</a> today mentioning lots of our sites and others.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2008/09/07/politicians-are-using-the-internet-to-harness-your-bright-ideas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Annotations just in today&#8230;</title>
		<link>http://www.mysociety.org/2008/09/01/annotations-just-in-today/</link>
		<comments>http://www.mysociety.org/2008/09/01/annotations-just-in-today/#comments</comments>
		<pubDate>Mon, 01 Sep 2008 12:37:38 +0000</pubDate>
		<dc:creator>Francis Irving</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[WhatDoTheyKnow]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/?p=738</guid>
		<description><![CDATA[It&#8217;s the first full working day for the new facility to annotate Freedom of Information (FOI) requests on WhatDoTheyKnow, and people have been hard at it. Mr Ormerod points out that private information isn&#8217;t necessarily so private if someone has died, so perhaps the exemption the MOD used shouldn&#8217;t apply. Trevor R Nunn has posted [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s the first full working day for the new facility to <a href="http://www.mysociety.org/wp/wp-admin/post.php?action=edit&#038;post=733">annotate Freedom of Information (FOI) requests</a> on WhatDoTheyKnow, and people have been hard at it.</p>
<p>Mr Ormerod <a href="http://www.whatdotheyknow.com/request/royal_navy_serial_numbers_1962#comment-47">points out</a> that private information isn&#8217;t necessarily so private if someone has died, so perhaps the exemption the MOD used shouldn&#8217;t apply.</p>
<p>Trevor R Nunn has posted three annotations (e.g. <a href="http://www.whatdotheyknow.com/request/status_of_play_area_opposite_lin#comment-44">this one</a>) to show that his three FOI requests are being treated as one. The annotations facility is great for handling edge cases like this, which don&#8217;t happen often enough to be worth explicitly adding to the code, but need some mention.</p>
<p>And finally Edward Betts has processed the list of post boxes retrieved by FOI into a more structured data format, and <a href="http://www.whatdotheyknow.com/request/location_of_every_post_box_that#comment-48">posted up a link to it</a>. Exactly the kind of collaboration I love to see!</p>
<p>And that&#8217;s just this morning!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2008/09/01/annotations-just-in-today/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>acts_as_xapian</title>
		<link>http://www.mysociety.org/2008/07/17/acts_as_xapian/</link>
		<comments>http://www.mysociety.org/2008/07/17/acts_as_xapian/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 23:19:34 +0000</pubDate>
		<dc:creator>Francis Irving</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Technical]]></category>
		<category><![CDATA[TheyWorkForYou]]></category>
		<category><![CDATA[WhatDoTheyKnow]]></category>

		<guid isPermaLink="false">http://www.mysociety.org/2008/07/17/acts_as_xapian/</guid>
		<description><![CDATA[One of the special pieces of magic in TheyWorkForYou is its email alerts, sending you mail whenever an MP says a word you care about in Parliament. Lots of sites these days have RSS, and lots have search, but surprisingly few offer search based email alerts. My Mum trades shares on the Internet, setting it [...]]]></description>
			<content:encoded><![CDATA[<p>One of the special pieces of magic in <a href="http://www.theyworkforyou.com">TheyWorkForYou</a> is its email alerts, sending you mail whenever an MP says a word you care about in Parliament. Lots of sites these days have RSS, and lots have search, but surprisingly few offer search based email alerts. My Mum trades shares on the Internet, setting it to automatically buy and sell at threshold values. But she doesn&#8217;t have an RSS reader. So, it&#8217;s important to have email alerts.</p>
<p>So naturally, when we made <a href="http://www.whatdotheyknow.com">WhatDoTheyKnow</a>, search and search based email alerts were pretty high up the list, to help people find new, interesting Freedom of Information requests. To implement this, I started out using acts_as_solr, which is a Ruby on Rails plugin for Solr, which is a REST based layer on top of the search engine Lucene.</p>
<p>I found acts_as_solr all just that bit too complicated. Particularly, when a feature (such as spelling correction) was missing, there were too many layers and too much XML for me to work out how to fix it. And I had lots of nasty code to make indexing offline &#8211; something I needed, as I want to safely store emails when they arrive, but then do the risky indexing of PDFs and Word documents later.</p>
<p>The last straw was when I found that acts_as_solr didn&#8217;t have collapsing (analogous to GROUP BY in SQL). So I decided to bite the bullet and implement my own <a href="http://github.com/frabcus/acts_as_xapian/wikis">acts_as_xapian</a>. Luckily there were already Xapian Ruby bindings, and also the fabulous <a href="http://lists.xapian.org/mailman/listinfo/xapian-discuss">Xapian email list</a> to help me out, and it only took a day or two to write it and deploy it on the live site.</p>
<p>If you&#8217;re using Rails and need full text search, I recommend you have a look at <a href="http://github.com/frabcus/acts_as_xapian/wikis">acts_as_xapian</a>. It&#8217;s easy to use, and has a diverse set of features. You can <a href="http://skillsmatter.com/podcast/ruby-on-rails/act-as-xapian">watch a video of me talking about WhatDoTheyKnow and acts_as_xapian</a> at the London Ruby User Group, last Monday.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mysociety.org/2008/07/17/acts_as_xapian/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

