<?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>Russ Garrett</title>
	<atom:link href="http://russ.garrett.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://russ.garrett.co.uk</link>
	<description></description>
	<lastBuildDate>Mon, 11 Jan 2010 09:00:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Semi-Realtime Satellite Desktop Backgrounds</title>
		<link>http://russ.garrett.co.uk/2010/01/10/semi-realtime-satellite-desktop-backgrounds/</link>
		<comments>http://russ.garrett.co.uk/2010/01/10/semi-realtime-satellite-desktop-backgrounds/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 00:28:59 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Space]]></category>
		<category><![CDATA[modis]]></category>
		<category><![CDATA[nasa]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=142</guid>
		<description><![CDATA[A few days ago, a beautiful satellite photo of snow-covered Great Britain got quite a lot of press coverage (and garnered me a couple of hundred retweets). The image was taken with the snappily-named MODIS camera which flies aboard two NASA Earth Observation System satellites: Terra and Aqua.
Turns out these are pretty neat pieces of [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_146" class="wp-caption alignright" style="width: 240px"><a href="http://rapidfire.sci.gsfc.nasa.gov/gallery/?2010007-0107/GreatBritain.A2010007.1150.1km.jpg"><img class="size-full wp-image-146 " title="Snowy Great Britain" src="http://russ.garrett.co.uk/blog/wp-content/uploads/2010/01/modis-image.jpg" alt="Snowy Great Britain" width="230" height="298" /></a><p class="wp-caption-text">Snowy Great Britain</p></div>
<p>A few days ago, a beautiful satellite photo of snow-covered Great Britain got quite a lot of press coverage (and garnered me a couple of hundred retweets). The image was taken with the snappily-named <abbr title="Moderate-Resolution Imaging Spectroradiometer"><a href="http://en.wikipedia.org/wiki/MODIS">MODIS</a></abbr> camera which flies aboard two NASA Earth Observation System satellites: <a href="http://en.wikipedia.org/wiki/Terra_%28satellite%29">Terra</a> and <a href="http://en.wikipedia.org/wiki/Aqua_%28satellite%29">Aqua</a>.</p>
<p>Turns out these are pretty neat pieces of kit — they actually record images in 36 frequency bands ranging from blue to thermal infra-red. The two satellites are in a sun-synchronous polar orbit which means they each record an image of the whole earth every day: Terra in the morning and Aqua in the afternoon.</p>
<p>All the image data is collated and released into the public domain by NASA on several sites, but the most interesting outlet for the data is the semi-realtime site <a href="http://rapidfire.sci.gsfc.nasa.gov">here</a>.</p>
<p>It struck me that it would be pretty cool to have the most recent image on your desktop, updated twice a day. So I wrote a slightly hacky little script to do it. NASA provide <a href="http://rapidfire.sci.gsfc.nasa.gov/subsets/">georectified true-colour images</a> for a selection of regions, including most of Great Britain, so I&#8217;m just co-opting that. It does mean I don&#8217;t have a full image of GB, but my screens aren&#8217;t really the right aspect ratio for that anyway.</p>
<p><a href="http://www.flickr.com/photos/russss/4260277179/">Here&#8217;s an example</a> of the image it produces (for my dual 19&#8243; monitor setup at home).</p>
<p><a href="http://gist.github.com/273220">Here&#8217;s the script.</a><br />
<script src="http://gist.github.com/273220.js?file=modis-desktop.rb"></script></p>
<p>I&#8217;ve just learned that the MODIS satellites constantly <a href="http://modis.gsfc.nasa.gov/data/directbrod/">downlink their imagery</a> in the clear, so I think the next step is to build a receiver and grab the data directly ;).</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2010/01/10/semi-realtime-satellite-desktop-backgrounds/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Open Hardware and Top-Down Design</title>
		<link>http://russ.garrett.co.uk/2009/12/12/open-hardware-and-top-down-design/</link>
		<comments>http://russ.garrett.co.uk/2009/12/12/open-hardware-and-top-down-design/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 12:03:40 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Hackerspaces]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[40fires]]></category>
		<category><![CDATA[openhardware]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=126</guid>
		<description><![CDATA[A couple of weeks ago, I dropped by the Open Hardware Conference in my capacity as hackerspace founder and general interested hardware hacker. I&#8217;m a bit disappointed that I didn&#8217;t stay longer &#8212; I had to split my time with ScaleCamp &#8212; since there was a really interesting mix of people in attendance.
One of the [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of weeks ago, I dropped by the <a href="http://openhardware.eventbrite.com/">Open Hardware Conference</a> in my capacity as <a href="http://london.hackspace.org.uk">hackerspace founder</a> and general interested hardware hacker. I&#8217;m a bit disappointed that I didn&#8217;t stay longer &mdash; I had to split my time with <a href="http://www.scalecamp.org.uk/">ScaleCamp</a> &mdash; since there was a really interesting mix of people in attendance.</p>
<p>One of the companies present, and indeed sponsoring the event, was <a href="http://www.40fires.org/">40Fires</a>, who are taking on the audacious task of building an open source car. There was a lot of discussion about how to get more people involved with this project, especially considering that the CAD software used to design the car costs £20,000 per seat.</p>
<p>There was discussion about the best way to organize a community to build an open-source car. The Apache project was mentioned several times as an example of a project to emulate. The point was raised that most open source developers are &#8220;scratching their own itch&#8221; (which I don&#8217;t believe to be true &mdash; I suspect most open-source code written today is by people employed to do so).</p>
<p>The point which everyone missed (myself included) is that if you want to emulate the success of the open source software community, you can&#8217;t just decide how things will work in a top-down fashion. And these guys weren&#8217;t just talking about designing the <em>hardware</em> top-down, they were talking about designing the <em>community</em>. Open source hardware is sufficiently &mdash; radically &mdash; different from open source software that we can&#8217;t just copy the community patterns wholesale and hope they work &mdash; that&#8217;s not even a great idea for a software project. We have no idea of the best way to build an open hardware project of that size. It&#8217;s never been done before.</p>
<p>(Of course this isn&#8217;t even considering the engineering quality benefits that bottom-up design brings. See Richard Feynman&#8217;s brilliantly prescient <a href="http://science.ksc.nasa.gov/shuttle/missions/51-l/docs/rogers-commission/Appendix-F.txt">appendix</a> to the Challenger disaster report, comparing the design of the Space Shuttle&#8217;s software to the design of its hardware.)</p>
<p>Linus Torvalds didn&#8217;t write Linux in order to build an enterprise, server-class operating system. He started it as a toy project and the community built up around it. Open source software has evolved organically, with the tools used to build the software evolving with it. Crucially, as Richard Stallman would repeatedly remind you, Linux would have not even been born if it wasn&#8217;t for the open-source GNU toolchain used to build it. The toolchain completes the feedback loop which is essential for open source to thrive.</p>
<p>Attempting to build an open source car when we don&#8217;t have a capable open hardware toolchain is jumping the gun. That doesn&#8217;t just mean decent CAD software, although that&#8217;s certainly got to be a priority, but also open source manufacturing tools. The <a href="http://www.reprap.org">RepRap</a> and <a href="http://www.makerbot.com">associated commercial versions</a> are a great indication that this is really possible &mdash; now let&#8217;s see an open source milling machine.</p>
<p>So, let&#8217;s start building what we can build with our open source tools today. That feedback loop which fuels open source software, and the RepRap wants to bring to the world of hardware, is just starting to kick in. Our <a href="http://store.makerbot.com/cupcake-cnc/cupcake-cnc-basic.html">Makerbot Cupcake</a> is in the post, so <a href="http://london.hackspace.org.uk/">come join us</a>. It looks to be an exciting new decade.</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/12/12/open-hardware-and-top-down-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Starting a Non-Profit in the UK</title>
		<link>http://russ.garrett.co.uk/2009/10/25/starting-a-non-profit-in-the-uk/</link>
		<comments>http://russ.garrett.co.uk/2009/10/25/starting-a-non-profit-in-the-uk/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 23:33:44 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=114</guid>
		<description><![CDATA[Back in February, Jonty and I started the Hackspace Foundation to provide a legal structure for our efforts to create a hacker space in London. I&#8217;m going to try and document this process to make it a little less daunting for other organizations (and because people keep asking me). This is naturally very UK-specific.
Types of [...]]]></description>
			<content:encoded><![CDATA[<p>Back in February, <a href="http://jonty.co.uk">Jonty</a> and I started the <a href="http://hackspace.org.uk">Hackspace Foundation</a> to provide a legal structure for our efforts to create a <a href="http://www.hackerspaces.org">hacker space</a> in London. I&#8217;m going to try and document this process to make it a little less daunting for other organizations (and because people keep asking me). This is naturally very UK-specific.</p>
<h3>Types of Organization</h3>
<p>The Hackspace Foundation is a membership association &mdash; the company is controlled and run by its members. The easiest way to set one of these up is to start an unincorporated association, which is basically just a group of people who have registered a business name, with which you can create a bank account. This is the easiest way to go about creating an organizational structure (and <a href="http://www.oneclickor.gs">One Click Orgs</a> is making it even easier), but unincorporated associations can&#8217;t enter into contracts, and therefore can&#8217;t sign a lease or get a loan.</p>
<p>In order to be able to do that, you need an actual legal structure &mdash; a limited company. There are two types of private limited company: Limited by Share Capital and Limited by Guarantee. Limited by Share Capital is the structure most profit-making companies have. Companies Limited by Guarantee (CLG) are the other option, and that&#8217;s what we used with the Hackspace Foundation. Most non-profit companies, including charities, are CLGs. Instead of having shareholders, a CLG has members, all of whom are liable to contribute a nominal amount (£5 in our case) if the company goes under.</p>
<p>In addition to incorporating as a CLG, there are certain other actions that can be taken to make sure people won&#8217;t profit from a company. Doing this will not only reassure prospective members, but may also help with grants and taxes.</p>
<h3>A quick word about objects</h3>
<p>The objects of a company are the purpose under which it trades, and are recorded in the company&#8217;s Memorandum of Association. Trading outside of the objects of a company is illegal. Starting in October 2009, a company no longer needs to have objects, however restricting the objects of a company to educational non-profit aims may help with getting grants and reducing tax.</p>
<h3>Section 30 Companies</h3>
<p>A Section 30 company refers to a company incorporated in accordance with <a href="http://www.statutelaw.gov.uk/content.aspx?LegType=All+Legislation&#038;title=Companies+Act&#038;Year=1985&#038;searchEnacted=0&#038;extentMatchOnly=0&#038;confersPower=0&#038;blanketAmendment=0&#038;sortAlpha=0&#038;TYPE=QS&#038;PageNumber=1&#038;NavFrom=0&#038;parentActiveTextDocId=2975166&#038;ActiveTextDocId=2975207&#038;filesize=13297">section 30 of the Companies Act 1985</a>. This rather odd section refers to the ability to omit the word &#8220;Limited&#8221; from the company name. However, it also adds restrictions on the objects you can use:</p>
<blockquote><p>
(3)  Those requirements are that—<br />
(a) the objects of the company are (or, in the case of a company about to be registered, are to be) the promotion of commerce, art, science, education, religion, charity or any profession, and anything incidental or conducive to any of those objects; and<br />
(b) the company’s memorandum or articles—<br />
(i) require its profits (if any) or other income to be applied in promoting its objects,<br />
(ii) prohibit the payment of dividends to its members, and<br />
(iii) require all the assets which would otherwise be available to its members generally to be transferred on its winding up either to another body with objects similar to its own or to another body the objects of which are the promotion of charity and anything incidental or conducive thereto (whether or not the body is a member of the company).
</p></blockquote>
<p>Section 30 companies are also exempt from sending details of their members to Companies House, and so are ideal for membership associations. The Hackspace Foundation is incorporated as a Section 30 company.</p>
<h3>Community Interest Companies</h3>
<p><a href="http://en.wikipedia.org/wiki/Community_interest_company">Community Interest Companies</a> (CIC) are a relatively new innovation which takes the Section 30 idea a bit further. Converting a CLG into a CIC is a one-way process which adds a statutory &#8220;asset lock&#8221; to the company&#8217;s assets. The company can only transfer its assets to another body for less than their market value if that body is also a CIC. This differs from Section 30 because a company can convert themselves back to a standard CLG from a Section 30 company (although this still requires a vote of all the members).</p>
<p>We haven&#8217;t gone down the CIC route with the Hackspace Foundation because we&#8217;re not ready to make that much commitment to our community-only business model just yet. We were also concerned about finding a relevant CIC to donate any remaining proceeds to if the company was wound down.</p>
<h3>Charities</h3>
<p>For completeness, I&#8217;ll just mention a few things about charities. Obviously being a charity is a bonus because donations are tax-deductible. However, charities are required to have a public benefit, and we don&#8217;t believe that hacker spaces necessarily pass that test. (The rules are quite complex.) Additionally, charities are required to submit more complex audited accounts, which are more costly.</p>
<p>Hopefully this is helpful to someone. We registered the Hackspace Foundation with <a href="http://www.uk-plc.net/companyformation/">UKPLC</a> &mdash; they are cheap and very helpful, so I would definitely recommend them.</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/10/25/starting-a-non-profit-in-the-uk/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Help us Free London&#8217;s Data</title>
		<link>http://russ.garrett.co.uk/2009/10/25/help-us-free-londons-data/</link>
		<comments>http://russ.garrett.co.uk/2009/10/25/help-us-free-londons-data/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 16:49:49 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Data]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=111</guid>
		<description><![CDATA[Yesterday morning I went to Help us Free London&#8217;s Data on the top floor of City Hall. Organized by the GLA, it was intended to get feedback from the development community about their upcoming Datastore project, which is slated for launch in January 2010.
The people from the GLA admitted that they don&#8217;t produce that much [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday morning I went to <a href="http://freelondonsdata.eventbrite.com/">Help us Free London&#8217;s Data</a> on the top floor of City Hall. Organized by the <abbr title="Greater London Authority">GLA</abbr>, it was intended to get feedback from the development community about their upcoming Datastore project, which is slated for launch in January 2010.</p>
<p>The people from the GLA admitted that they don&#8217;t produce that much interesting data, and have limited influence over the authorities who do (like <abbr title="Transport for London">TfL</abbr> and the borough councils), so their plan is to set a precedent. I don&#8217;t agree that all the GLA&#8217;s data is boring &mdash; I think that transparency and accountability for our elected representatives is important, even if it isn&#8217;t as alluring to everyone as the elusive transport data.</p>
<p>Discussion was mainly about the mundane details of how to go about publishing the data. Thankfully pragmatism prevailed and the anticipated hour-long semantic web ontology discussion/flamewar didn&#8217;t materialize. </p>
<p>I was impressed by the amount of grassroots support open data appears to have within the GLA &mdash; there were representatives of several departments in attendance &mdash; and they definitely seem to be taking the right route by publishing data when they can. I&#8217;m really interested to see what they come up with in January.</p>
<p>My biggest annoyance was that they started at 10am on a Saturday. Hackers don&#8217;t do mornings, guys.</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/10/25/help-us-free-londons-data/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Letter to my MP about filesharing disconnection</title>
		<link>http://russ.garrett.co.uk/2009/10/23/letter-to-my-mp-about-filesharing-disconnection/</link>
		<comments>http://russ.garrett.co.uk/2009/10/23/letter-to-my-mp-about-filesharing-disconnection/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 10:25:10 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Politics]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=107</guid>
		<description><![CDATA[This is the letter I&#8217;ve sent to my MP, Emily Thornberry, about the government&#8217;s current plans to disconnect file-sharers. You should write to your MP too. It&#8217;s important.
I&#8217;ve put it up here because sometimes it&#8217;s nice to have something to base your letter on when contacting your MP. That said, please don&#8217;t copy and paste [...]]]></description>
			<content:encoded><![CDATA[<p>This is the letter I&#8217;ve sent to my MP, <a href="http://www.theyworkforyou.com/mp/emily_thornberry/islington_south_and_finsbury">Emily Thornberry</a>, about the government&#8217;s current <a href="http://www.openrightsgroup.org/campaigns/ask-your-mp-to-help-protect-our-freedoms-on-the-net">plans to disconnect file-sharers</a>. You should <a href="http://www.writetothem.com">write to your MP</a> too. It&#8217;s important.</p>
<p>I&#8217;ve put it up here because sometimes it&#8217;s nice to have something to base your letter on when contacting your MP. That said, <strong>please don&#8217;t copy and paste this</strong>, MPs want to hear that you&#8217;re a real person and not some mindless sheep. So write your own damn letter. This is mine.</p>
<blockquote><p>
Dear Mrs. Thornberry,</p>
<p>I&#8217;m writing to you to express my concern about the new Digital Britain proposals to disconnect internet users who are accused of violating copyright.</p>
<p>These plans amount to taking disproportionate action against internet users for a crime they have not been found guilty of committing. Internet access is a vital utility, and disconnecting users due to alleged copyright violation  would also cut off access to many other services, contrary to the government&#8217;s plans for universal access to broadband.</p>
<p>The recording industry is backing these heavy-handed tactics in preference to making their licensing rates more reasonable for small music streaming and download businesses. I believe the only viable way to effectively reduce music copyright infringement is to make music available on demand as a service. Services such as Spotify are doing this, but they are struggling to negotiate sensible rates from the music industry.</p>
<p>I&#8217;d appreciate it if you indicated your support for Tom Watson&#8217;s Early Day Motion 1997 which concerns these file-sharing plans.</p>
<p>Yours sincerely,</p>
<p>Russell Garrett</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/10/23/letter-to-my-mp-about-filesharing-disconnection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First person to make it happen wins everything</title>
		<link>http://russ.garrett.co.uk/2009/09/06/first-person-to-make-it-happen-wins-everything/</link>
		<comments>http://russ.garrett.co.uk/2009/09/06/first-person-to-make-it-happen-wins-everything/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 23:58:27 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[music]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=103</guid>
		<description><![CDATA[Lots of people ask me what the goal is.
The goal is for you to be able to play any song, anywhere you are, in CD quality, for less per month than the price of a cd. If you&#8217;re too cheap to pony up, then you can listen to ads instead, but no more than 10m [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Lots of people ask me what the goal is.</p>
<p>The goal is for you to be able to play any song, anywhere you are, in CD quality, for less per month than the price of a cd. If you&#8217;re too cheap to pony up, then you can listen to ads instead, but no more than 10m worth for every hour you listen. A light DRM in place is fine provided the technology exists to stream this anyplace you are. Who wants or needs downloads if you can just stream it whenever you want. Disks are so overrated. If the tech isn&#8217;t there do make that happen, then screw the DRM and let those that will pirate pirate and those that will pay pay. You&#8217;ll never get them to behave otherwise anyway.</p>
<p>That&#8217;s the goal. First person to make it happen wins everything.</p></blockquote>
<p>This quote was written by <a href="http://en.wikipedia.org/wiki/Tom_Pepper">Tom Pepper</a> at <a href="http://www.nullsoft.com/">Nullsoft</a> about a decade ago. <a href="https://www.spotify.com/en/mobile/overview/">Today it became a reality</a> (give or take the ads part, in certain territories, terms and conditions apply&#8230;). </p>
<p>Now let&#8217;s see if they do actually win everything. They&#8217;ve got my tenner a month.</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/09/06/first-person-to-make-it-happen-wins-everything/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Aggregating boolean arrays in Postgres</title>
		<link>http://russ.garrett.co.uk/2009/08/26/aggregate-boolean-arrays-in-postgres/</link>
		<comments>http://russ.garrett.co.uk/2009/08/26/aggregate-boolean-arrays-in-postgres/#comments</comments>
		<pubDate>Wed, 26 Aug 2009 11:30:54 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=83</guid>
		<description><![CDATA[We use arrays of booleans &#8211; a non-standard Postgres feature &#8211; quite frequently for storing permissions and similar data. It&#8217;s an elegant way to denormalize potentially scary schemas, as long as your client libraries support them.
We needed a function to count the number of true values across a whole table&#8217;s worth of boolean arrays &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>We use arrays of booleans &#8211; a non-standard Postgres feature &#8211; quite frequently for storing permissions and similar data. It&#8217;s an elegant way to denormalize potentially scary schemas, as long as your client libraries support them.</p>
<p>We needed a function to count the number of true values across a whole table&#8217;s worth of boolean arrays &#8211; basically a histogram of how many true values in each array field. I thought it would be useful to share because I use PL/PgSQL so occasionally I always forget how to write it, and examples are useful.</p>
<p>Here&#8217;s the code:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> boolean_array_count<span style="color: #66cc66;">&#40;</span>INTEGER<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #993333; font-weight: bold;">BOOLEAN</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> 
RETURNS integer<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> <span style="color: #993333; font-weight: bold;">AS</span>
$BODY$
DECLARE
	r INTEGER<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;
	size INTEGER;
BEGIN
	<span style="color: #993333; font-weight: bold;">IF</span> $<span style="color: #cc66cc;">2</span> <span style="color: #993333; font-weight: bold;">IS</span> <span style="color: #993333; font-weight: bold;">NULL</span> THEN
		<span style="color: #993333; font-weight: bold;">RETURN</span> $<span style="color: #cc66cc;">1</span>;
	END <span style="color: #993333; font-weight: bold;">IF</span>;
	size :<span style="color: #66cc66;">=</span> max<span style="color: #66cc66;">&#40;</span>coalesce<span style="color: #66cc66;">&#40;</span>array_upper<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">,</span> array_upper<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #993333; font-weight: bold;">FOR</span> i <span style="color: #993333; font-weight: bold;">IN</span> 1<span style="color: #66cc66;">..</span>size LOOP
		<span style="color: #993333; font-weight: bold;">IF</span> $<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> true THEN
			r<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> coalesce<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #cc66cc;">1</span>;
		ELSE
			r<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">=</span> coalesce<span style="color: #66cc66;">&#40;</span>$<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
		END <span style="color: #993333; font-weight: bold;">IF</span>;
	END LOOP;
	<span style="color: #993333; font-weight: bold;">RETURN</span> r;
END;
$BODY$ 
<span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #ff0000;">'plpgsql'</span> VOLATILE;
&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> AGGREGATE boolean_array_count <span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">BOOLEAN</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#40;</span>
	SFUNC <span style="color: #66cc66;">=</span> boolean_array_count<span style="color: #66cc66;">,</span>
	STYPE <span style="color: #66cc66;">=</span> integer<span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>
<span style="color: #66cc66;">&#41;</span>;</pre></div></div>

<p>You also need an implementation of the inexplicably missing max(integer, integer) function:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">OR</span> <span style="color: #993333; font-weight: bold;">REPLACE</span> <span style="color: #993333; font-weight: bold;">FUNCTION</span> max<span style="color: #66cc66;">&#40;</span>integer<span style="color: #66cc66;">,</span> integer<span style="color: #66cc66;">&#41;</span> RETURNS integer <span style="color: #993333; font-weight: bold;">AS</span>
$BODY$
BEGIN
	<span style="color: #993333; font-weight: bold;">IF</span> $<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&gt;</span> $<span style="color: #cc66cc;">2</span> THEN
		<span style="color: #993333; font-weight: bold;">RETURN</span> $<span style="color: #cc66cc;">1</span>;
	END <span style="color: #993333; font-weight: bold;">IF</span>;
	<span style="color: #993333; font-weight: bold;">RETURN</span> $<span style="color: #cc66cc;">2</span>;
END;
$BODY$ <span style="color: #993333; font-weight: bold;">LANGUAGE</span> <span style="color: #ff0000;">'plpgsql'</span> IMMUTABLE STRICT SECURITY DEFINER;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/08/26/aggregate-boolean-arrays-in-postgres/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Leaving Last.fm</title>
		<link>http://russ.garrett.co.uk/2009/07/09/leaving-lastfm/</link>
		<comments>http://russ.garrett.co.uk/2009/07/09/leaving-lastfm/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 09:10:37 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Meta]]></category>
		<category><![CDATA[lastfm]]></category>
		<category><![CDATA[personal]]></category>
		<category><![CDATA[smarkets]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=73</guid>
		<description><![CDATA[Earlier this week, I handed in three months&#8217; notice &#8211; I&#8217;m leaving Last.fm at the beginning of October. It&#8217;s been more than six years since I started working on a small project called Audioscrobbler with RJ, and since the founders&#8217; leaving I&#8217;m now the longest-serving member of staff. It&#8217;s been massively fun and Last.fm is [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this week, I handed in three months&#8217; notice &#8211; I&#8217;m leaving Last.fm at the beginning of October. It&#8217;s been more than six years since I started working on a small project called Audioscrobbler with <a href="http://www.metabrew.com">RJ</a>, and since the <a href="http://blog.last.fm/2009/06/10/message-from-the-lastfm-founders-felix-rj-and-martin">founders&#8217; leaving</a> I&#8217;m now the longest-serving member of staff. It&#8217;s been massively fun and Last.fm is still an awesome place to work, but I think it&#8217;s time for a change.</p>
<p>That said, it&#8217;ll be nice not to work in a company which is constantly subject to perplexingly arbitrary rules and unrealistic royalties set by increasingly out-of-touch record labels. </p>
<p>It feels like a lot of my work in the last few years has been trying to prevent myself from being such a single point of failure. It&#8217;s quite a relief to be in a situation where I can finally leave. </p>
<p>As for what I&#8217;m doing next; I&#8217;m <a href="http://blog.smarkets.com/2009/07/13/smarkets-announces-the-addition-of-russ-garrett/">going to work</a> for <a href="http://www.smarkets.com">Smarkets</a> heading up tech operations. I think it&#8217;ll be quite a different challenge to Last.fm, and it&#8217;ll be great to work for a proper startup again. It should be fun.</p>
<p>(If you&#8217;re interested in coming to work for Last.fm, we have a <a href="http://www.last.fm/about/jobs#job_Linux+Sysadmin+(varying+levels)">couple of vacancies</a> in our ops department on a variety of levels.)</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/07/09/leaving-lastfm/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>When Economies Collide: Last.fm</title>
		<link>http://russ.garrett.co.uk/2009/04/21/when-economies-collide-lastfm/</link>
		<comments>http://russ.garrett.co.uk/2009/04/21/when-economies-collide-lastfm/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 14:51:50 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=63</guid>
		<description><![CDATA[I&#8217;ve been reading Larry Lessig&#8217;s book Remix over the last few days, and one thing which struck me is his comparison of sharing economies against commercial economies. A sharing economy is something such as friendship, love, Wikipedia, or Linux, where no money is exchanged; A commercial economy is where money is exchanged.
Lessig notes, with lots [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been reading <a href="http://www.lessig.org">Larry Lessig</a>&#8217;s book <a href="http://www.amazon.co.uk/gp/product/1408113473?ie=UTF8&amp;tag=russgarr-21&amp;linkCode=as2&amp;camp=1634&amp;creative=6738&amp;creativeASIN=1408113473">Remix</a> over the last few days, and one thing which struck me is his comparison of sharing economies against commercial economies. A sharing economy is something such as friendship, love, Wikipedia, or Linux, where no money is exchanged; A commercial economy is where money is exchanged.</p>
<p>Lessig notes, with lots of examples, that even attempting to compare a sharing economy with a commercial economy will end up in trouble. In sharing economies, &#8220;price is poisonous&#8221;:</p>
<blockquote><p>You have, or have had, or will have, lovers. That relationship exists within a complex, sharing economy. The statement &#8220;Wow, that was great. Have $500&#8243; isn&#8217;t gratitude in such relationships. It might be perversion, but if not matched by perversion on the other side, it will likely be terminal to the relationship. <em>[...]</em> Prostitution is sex within a commercial economy. Both sides seek the simplicity of cash.</p></blockquote>
<p>At this point, something rang true for me. Way back in 2004, RJ and I were working on Audioscrobbler, while Martin and Felix were working on Last.fm.</p>
<p>Audioscrobbler was naturally a sharing economy: you contributed your listening data, and in return you received recommendations for new music and people who shared your taste. Last.fm&#8217;s premise was to make a personalized radio station. This unashamedly exists in a commercial economy, even if the price was free for several years.</p>
<p>In 2005 we merged these two sites — both sites were doing almost the same thing — and last month the <a href="http://blog.last.fm/2009/03/24/lastfm-radio-announcement">shit hit the fan</a>. We had created some kind of hybrid commercial/sharing monster, supported for the time being by investment and ads. Now nobody has any money to throw at anything, so we have to ask for money in an economical way: only asking for money in places where it makes up for our ads shortfall.</p>
<p>Sure enough, when we went from apparently being a sharing economy to charging for the bits which cost us the money, all hell broke loose. Despite this, in the countries we are charging, we&#8217;re running the equivalent of the good old Audioscrobbler service, plus a music streaming service with an identical, country-specific, business model to Spotify.</p>
<p>I wonder how many other startups which seem like sharing economies are going to have the same problem as Last.fm: staying true to their users&#8217; impressions of the service and going under, or being forced to charge and potentially losing their users&#8217; trust.</p>
<p>You can&#8217;t win, sometimes.</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/04/21/when-economies-collide-lastfm/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Operations Monitoring, Retro Style</title>
		<link>http://russ.garrett.co.uk/2009/04/10/operations-monitoring-retro-style/</link>
		<comments>http://russ.garrett.co.uk/2009/04/10/operations-monitoring-retro-style/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 20:04:00 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[operations]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://russ.garrett.co.uk/?p=53</guid>
		<description><![CDATA[Although I work in the Operations room at Last.fm which has its fair share of monitoring screens, sometimes you&#8217;ll see me wishing for the good old days: when men were men and control rooms had hundreds of gauges, dials, and lights.
A while ago I decided to take a small step towards that reality, so I [...]]]></description>
			<content:encoded><![CDATA[<p>Although I work in the Operations room at Last.fm which has its fair share of monitoring screens, sometimes you&#8217;ll see me wishing for the good old days: when men were men and control rooms had hundreds of gauges, dials, and lights.</p>
<p>A while ago I decided to take a small step towards that reality, so I hit up eBay and picked up a variety of old-school Bakelite panel gauges (many of which didn&#8217;t work). Throw in an <a href="http://www.arduino.cc/">Arduino</a>, a maze of wires and some resistors, and I had myself a plan.<a href="http://www.flickr.com/photos/russss/2839390297/"><img class="alignright" style="margin: 10px;" title="Gauge Setup" src="http://farm4.static.flickr.com/3077/2839390297_93a65cba83.jpg?v=0" alt="Gauge Setup" width="244" height="182" /></a></p>
<p>I&#8217;ve now had this setup for a number of months, and I have to say it&#8217;s massively useful. The gauges show a variety of key metrics on how Last.fm&#8217;s architecture is performing within a couple of seconds of realtime. That&#8217;s a lot quicker than our main monitoring systems which tend to take between three and five minutes to notice something going awry. The gauges are easy to read at a glance, and I generally notice if something&#8217;s going horribly wrong because I can see the gauges twitch out of the corner of my eye.</p>
<p>If you&#8217;re interested, you can get hold of the (Ruby and Arduino)  code which powers the gauges <a href="http://github.com/russss/arduino-gauges">here on Github</a>, complete with a lame ASCII art diagram. When I get round to it, I&#8217;d like to get them mounted onto a nice wooden panel, possibly with some warning lights.</p>
<p>I&#8217;ve got a while to go before I can rival <a href="http://pridian.net/places/battersea/CRW_7811-12-13-14_Pano_SM.jpg">Battersea Control Room A</a>, though&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://russ.garrett.co.uk/2009/04/10/operations-monitoring-retro-style/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
