<?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>I Am Seb &#187; programming</title>
	<atom:link href="http://iamseb.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://iamseb.com</link>
	<description>Characterisations, Hypotheses, Predictions and Experiments.</description>
	<lastBuildDate>Fri, 16 Jul 2010 00:00:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PyPlants — Now with added dimensions</title>
		<link>http://iamseb.com/seb/2009/11/pyplants-now-with-added-dimensions/</link>
		<comments>http://iamseb.com/seb/2009/11/pyplants-now-with-added-dimensions/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 01:58:49 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[ideas]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[pyplants]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=134</guid>
		<description><![CDATA[PyPlants has come on in leaps and bounds over the past few days (well, evenings), and now from its new home as PyPlants on bitbucket sports a completely rewritten rendering backend which is more modular, should be really easy to plug into, and now supports POV-Ray out of the box. What’s that you say? A [...]]]></description>
			<content:encoded><![CDATA[<p>PyPlants has come on in leaps and bounds over the past few days (well, evenings), and now from its new home as <a href="http://bitbucket.org/iamseb/pyplants/">PyPlants on bitbucket</a> sports a completely rewritten rendering backend which is more modular, should be really easy to plug into, and now supports <a href="http://www.povray.org/">POV-Ray</a> out of the box.</p>
<p>What’s that you say? A 3-D ray-tracer? Yes indeed, as promised in <a href="http://iamseb.com/seb/2009/11/procedural-plants-in-python-2/">the second part of this series of development diaries</a>, I’ve now finished work on an update that turns this:</p>
<pre class="brush: python">("A", "I+[A+O]--&gt;&gt;[--L]I[++L]-[AO]++AO")
("I", "FS[&gt;&gt;&amp;&amp;L][&gt;&gt;^^L]FS")
("S", "SFS")
("L", "['{+f-ff-f+|+f-ff-f}]")
("O", "[&amp;&amp;&amp;C`&gt;W&gt;&gt;&gt;&gt;W&gt;&gt;&gt;&gt;W&gt;&gt;&gt;&gt;W&gt;&gt;&gt;&gt;W]")
("C", "FF")
("W", "[`^F][{&amp;&amp;&amp;&amp;-f+f|-f+f}]")</pre>
<p>Into this:</p>
<div id="attachment_135" class="wp-caption alignnone" style="width: 310px"><img class="size-medium wp-image-135" title="Olive Bush" src="http://iamseb.com/wp-content/uploads/2009/11/olive_bush-300x195.png" alt="olive_bush" width="300" height="195" /><p class="wp-caption-text">Rendering of an olive bush from pyplants povray renderer</p></div>
<p>Unfortunately it’s now 2am, so the write-up will have to wait for the weekend. Do feel free to grab the code and have a poke around. You’ll obviously need povray, pygame, and pycairo installed, but everything else should work with python’s included batteries.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2009/11/pyplants-now-with-added-dimensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Procedural Plants in Python — Part 2</title>
		<link>http://iamseb.com/seb/2009/11/procedural-plants-in-python-2/</link>
		<comments>http://iamseb.com/seb/2009/11/procedural-plants-in-python-2/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 00:43:00 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[geekery]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=114</guid>
		<description><![CDATA[In the previous part of this article we looked at the background to L-Systems, and how they could be used for describing self-similar biological systems. In this part we’ll look at a sample implementation of a very basic 2D L-System in Python, together with a basic PNG renderer using PyCairo. This is an implementation of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://iamseb.com/seb/2009/11/procedural-plants-in-python-1/">In the previous part of this article we looked at the background to L-Systems</a>, and how they could be used for describing self-similar biological systems. In this part we’ll look at a sample implementation of a very basic 2D L-System in Python, together with <a href="http://www.cairographics.org/pycairo/">a basic PNG renderer using PyCairo</a>.</p>
<p>This is an implementation of a deterministic, context-less L-System, which given the same initial conditions will always produce the same results. Whilst this won’t produce very naturalistic results for our plant system, it’s a useful first step to produce results like this:</p>
<p><img class="alignnone size-medium wp-image-117" title="Test render of a D0 L-System" src="http://iamseb.com/wp-content/uploads/2009/11/test1-300x300.png" alt="Test render of a D0 L-System" width="300" height="300" /></p>
<p>First, we’ll define some 2D operations:</p>
<ul>
<li>F: Move forward LINE_LENGTH, drawing a line.</li>
<li>+: Rotate clockwise THETA degrees.</li>
<li>-: Rotate anti-clockwise THETA degrees.</li>
<li>[: Push the current position and rotation onto a stack</li>
<li>]: Pop the current position and rotation off the stack</li>
</ul>
<p>PyCairo is a great library for vector drawing operations and very well suited to the drawing operations we’ll be using. To use PyCairo, you simply declare a drawing surface (in this case a cairo.ImageSurface), and pass that to a context. All drawing operations will then happen on this context.</p>
<p>This sample implementation is <a href="http://pastebin.com/f66c734b2">also available on pastebin</a>.</p>
<pre class="brush: python"># this code is an improved version of the l-system
# sample code originally distributed with pycairo.
# originally Copyright 2003 Jesse Andrews (jdandr2 at uky.edu)
# this version Copyright 2009 Seb Potter (iamseb at iamseb.com)
# licensed under GPL

import logging
import cairo

# setup logging to just print to stdout.
# python's logging module is significantly
# better than using print for debugging
LOG_FILENAME = '/dev/stdout'
logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)

class Lindenmayer:
    """
    A class to represent L-Systems and render them using cairo
    """
    def __init__( self ):
        self.width = self.height = 500 # use a 500 pixel square image
        self.prod = {'[':'[','F':'F',']':']','+':'+','-':'-'} # the identity products
        self.start_pos = (self.width*0.5, self.height) # we translate to the middle bottom of the image to start
        self.start_angle = 180 # we rotate through 180 degrees to draw upwards - cairo's origin is top-left
        self.theta = 90 # the rotation angle in degrees
        self.stack = [] # this will be the stack for storing translation and orientation tuples
        self.str = 'f' # the starting string, or 'axiom'

        self.line_length = 5 # how far we move forward on each step
        self.line_width = 2 # just controls the rendered width of the line
        self.logger = logging.getLogger("flower.draw.lindenmayer") # use logging to print debugging
        self.logger.setLevel(logging.DEBUG)

    def addProd(self, let, prod):
        """
        Add a production to the ordered list of productions to apply to the current string.
        """
        self.prod[let]=prod

    def iterate(self, iterations=1):
        """
        Iterate over the list of productions and apply them to the string, in a loop.
        The end result is the final transformed string.
        """
        for i in xrange(iterations):
            self.str = ''.join([ self.prod[l] for l in self.str])

        self.logger.info("String is: %s" % self.str)

    def line(self, ctx, len):
        ctx.rel_line_to( 0, len )

    def rotate(self, ctx, deg):
        ctx.rotate( 2*3.141592653589793*deg/360.0  )

    def draw(self, colour):
        """Render the string representation of the L-System"""
        self.logger.info(colour)

        # create a cairo drawing context from the provided surface.
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.width, self.height)
        ctx = cairo.Context(surface)

        # first we'll create a nice white rectangle as our background
        ctx.rectangle(0, 0, self.width, self.height)
        ctx.set_source_rgb(1, 1, 1)
        ctx.fill()

        # set the line colour, width, and make sure that cairo knows how close
        # lines should be to join them
        ctx.set_source_rgb(*colour)
        ctx.set_line_width(self.line_width)
        ctx.set_tolerance(0.1)
        ctx.set_line_join(cairo.LINE_JOIN_BEVEL)

        # start drawing a path, move to our start point, and rotate to
        # the starting angle
        ctx.new_path()
        ctx.move_to(*self.start_pos)
        self.logger.debug("Initial position: %s, %s" % ctx.get_current_point())
        self.rotate(ctx, self.start_angle)

        # this is the very simple way we iterate over the final string
        # and perform a drawing operation for each symbol in the string
        for c in self.str:
            if c == 'F':
                # move forward
                self.logger.debug("f: draw a line of %s" % self.line_length)
                self.line(ctx, self.line_length)
            if c == '+':
                # rotate clockwise
                self.logger.debug("+: rotate %s" % self.theta)
                self.rotate(ctx, self.theta)
            if c == '-':
                # rotate anti-clockwise
                self.logger.debug("-: rotate -%s" % self.theta)
                self.rotate(ctx, -self.theta)
            if c == '[':
                # push the transform and orientation onto the stack
                m = ctx.get_matrix()
                p = ctx.get_current_point()
                self.logger.debug("[: push the matrix %s onto the stack" % m)
                self.stack.append((p, m))
            if c == ']':
                # restore the transform and orientation from the stack
                p, m = self.stack.pop()
                self.logger.debug("]: pop the matrix %s off the stack" % m)
                ctx.set_matrix(m)
                ctx.move_to(*p)

        # now draw the path created as a stroke on the context
        ctx.stroke()

        # write this to a png
        surface.write_to_png("test.png")
        self.logger.info("Wrote test.png")

def main():

    colour = (0, 0.3, 0)

    # setup the initial parameters for this l-system
    lin = Lindenmayer()
    lin.start_angle = 205
    lin.start_pos = (lin.width*0.25, lin.height)
    lin.str = 'X'
    lin.addProd('X', 'F[+X]F[-X]+X')
    lin.addProd('F', 'FF')
    lin.theta = 20

    # generate the final string
    lin.iterate(iterations=5)

    # render the string using pycairo
    lin.draw(colour)

if __name__ == '__main__':
    main()</pre>
<p>In the third part of this series we’ll look at more realistic approaches to describing plant systems, including introduction of randomness through Stochastic L-Systems, and ways to create more plant-like features including leaves and flowers.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2009/11/procedural-plants-in-python-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Procedural Plants in Python — Part 1</title>
		<link>http://iamseb.com/seb/2009/11/procedural-plants-in-python-1/</link>
		<comments>http://iamseb.com/seb/2009/11/procedural-plants-in-python-1/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 22:17:13 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[geekery]]></category>
		<category><![CDATA[graphics]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=107</guid>
		<description><![CDATA[For a fledgling project idea, I’ve recently needed to work out how to draw plants procedurally, and of course Python is my language of choice for some rapid prototyping. Whilst some richly-featured professional applications exist for generating flora in a procedural fashion for high-end rendering, there are precious few systems available for the kind of [...]]]></description>
			<content:encoded><![CDATA[<p>For a fledgling project idea, I’ve recently needed to work out how to draw plants procedurally, and of course Python is my language of choice for some rapid prototyping. Whilst some richly-featured professional applications exist for generating flora in a procedural fashion for high-end rendering, there are precious few systems available for the kind of bulk task that I require.</p>
<p>At first the task of generating plants might seem like a massive endeavour. The various permutations of stem widths, lengths, branch frequency, colour variation, leaf size, shape, frequency and mind-boggling. And that’s not even considering the problem space represented by flowers.</p>
<p>Fortunately, the problem of representing self-similar biological development is one that attracted Aristid Lindenmayer, who in 1968 introduced <a href="http://en.wikipedia.org/wiki/L-system">L-Systems</a>:</p>
<blockquote><p>… as a theoretical framework for studying the development of simple multicellular organisms, and subsequently applied to investigate higher plants and plant organs. After the incorporation of geometric features, plant models expressed using L-systems became detailed enough to allow the use of computer graphics for realistic visualization of plant structures and developmental processes.</p></blockquote>
<p>(Lindenmayer’s book <a href="http://algorithmicbotany.org/papers/#abop">The Algorithmic Beauty of Plants</a> is no longer in print, but is available for free in PDF.)</p>
<p>L-Systems are remarkably powerful, simple systems that express the development of a formal grammar through a parallel rewriting process. In effect, you start with a string that represents certain graphical operations, and a set of rules for rewriting the string. You iterate over the string a certain number of times, and are left with a final product.</p>
<p>For example in a 2D system, the symbol F represents drawing a straight line in a forward direction, the symbol + represents rotating left, and — represents rotating right. If you start with the string “F”, and a rule that says “(F → F+F−F−F+F)”, then you’d see the following iterations:</p>
<ol>
<li>F+F-F-F+F</li>
<li>F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F</li>
<li>F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F+ F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F– F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F– F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F+ F+F-F-F+F+F+F-F-F+F-F+F-F-F+F-F+F-F-F+F+F+F-F-F+F</li>
</ol>
<p>If you then plot those rules using a unit vector length and an angle of 90 degrees, you end up with the following iterations:</p>
<ol>
<li><img title="Koch Square 1" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/18/Square_koch_1.svg/40px-Square_koch_1.svg.png" alt="Single iteration of a Koch Square" width="40" height="20" /></li>
<li><img title="Koch Square 2" src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Square_koch_2.svg/100px-Square_koch_2.svg.png" alt="Second iteration of a Koch Square" width="100" height="50" /></li>
<li><img title="Koch Square 3" src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Square_koch_3.svg/280px-Square_koch_3.svg.png" alt="Third iteration of a Koch Square" width="280" height="140" /></li>
</ol>
<p>There are several more symbols that can be applied to the graphical operations, including pushing the current position and orientation onto a stack and popping it off again, rotations in 3D, and operations to define closed polygons and moving through colour and size lookup tables.</p>
<p>The most basic type of L-System is the deterministic context-less system, D0L, where each operation is independent and will always produce the same output. The Koch Square above is one of the most simplistic examples, but with a couple of variations much more complex patterns arise:</p>
<ul>
<li>Start: “X”</li>
<li>Rule 1: “(X → F-[[X]+X]+F[+FX]-X)”</li>
<li>Rule 2: “(F → FF)”</li>
<li>Angle: 25 degrees</li>
<li>Iterations: 5</li>
<li><img class="alignnone size-full wp-image-110" title="Sample 1" src="http://iamseb.com/wp-content/uploads/2009/11/sample1.gif" alt="Sample 1" width="200" height="189" /></li>
</ul>
<p><a href="http://iamseb.com/seb/2009/11/procedural-plants-in-python-2/">In Part 2 we’ll look at a first approach to implementing L-Systems in Python</a>, and a rudimentary renderer for 2D systems using <a href="http://www.cairographics.org/pycairo/">PyCairo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2009/11/procedural-plants-in-python-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ten Things I’ve Learned in a Start-Up</title>
		<link>http://iamseb.com/seb/2009/11/ten-things-i-learned-in-a-startup/</link>
		<comments>http://iamseb.com/seb/2009/11/ten-things-i-learned-in-a-startup/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 10:25:50 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=127</guid>
		<description><![CDATA[Ten things I’ve learned as a developer at WooMe: Be clear what your direction is. Identify your key proposition and focus on it. Don’t get distracted by unrelated features — somebody else is probably already doing those better than you. Be merciless with features that don’t cut it. No matter how much you like it, [...]]]></description>
			<content:encoded><![CDATA[<p>Ten things I’ve learned as a developer at WooMe:</p>
<ol>
<li><strong>Be clear what your direction is.</strong> Identify your key proposition and focus on it. Don’t get distracted by unrelated features — somebody else is probably already doing those better than you.</li>
<li><strong>Be merciless with features that don’t cut it.</strong> No matter how much you like it, if your audience doesn’t like it, either change it or kill it fast. Wasting time on your personal pet project when there’s no clear demand for it is time you should be spending on features users want.</li>
<li><strong>Use what’s already there rather than inventing your own.</strong> Need a message queue? Video processing? Load balancer? Email distribution? Payment system? Use something that already exists rather than waste time you should be spending on feature development.</li>
<li><strong>Quick and dirty is better than late to market.</strong> At the rate this industry moves, capturing your audience’s attention first is more important than having a well-engineered solution. For the most part, users don’t care about your code quality, as long as it works.</li>
<li><strong>Don’t optimise until you need to.</strong> Sure, you may end up chasing your tail for a bit when you need to scale, but until you hit that point you’re wasting valuable time that should be spent on feature development.</li>
<li><strong>Scaling is most often a data problem.</strong> When you do need to optimise, scaling won’t be about the performance of your application. Scaling web applications horizontally is easy. Scaling databases vertically is expensive. Scaling databases horizontally is very, very hard. Don’t worry about what web application framework you use, worry about what database you put behind it.</li>
<li><strong>Abstraction is great, as long as you understand what you’re abstracting.</strong> This has been a constant pain with Django’s ORM. Yes, it’s a powerful and useful abstraction, but without a solid understanding of what the database is doing behind it, it’s easy to get into very deep trouble, very quickly.</li>
<li><strong>Log everything.</strong> Nothing is harder than trying to find problems on a live environment without detailed logging.</li>
<li><strong>Storage is cheap.</strong> It’s better to store everything than to throw away data. You never know when you might need something.</li>
<li><strong>Communication is critical.</strong> Not just outside your organisation, but within it. Tell people what you’re doing, frequently. Ask them what they’re doing just as often. Not only do ideas percolate through this process much more effectively, but when things go wrong, clear and frequent communication will stop them from getting worse.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2009/11/ten-things-i-learned-in-a-startup/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Tactile Computing</title>
		<link>http://iamseb.com/seb/2009/02/tactile-computing/</link>
		<comments>http://iamseb.com/seb/2009/02/tactile-computing/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 23:07:46 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[ideas]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[science]]></category>
		<category><![CDATA[computing]]></category>
		<category><![CDATA[talks]]></category>
		<category><![CDATA[TED]]></category>
		<category><![CDATA[tubed]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=83</guid>
		<description><![CDATA[Every now and then someone at TED presents a technology or an idea that’s so utterly amazing, or ridiculously simple that it can’t help but change the world. David Merrill shows off an MIT project called Siftables in this talk, and even though I’ve been messing around with computing for 25 years my jaw is [...]]]></description>
			<content:encoded><![CDATA[<p>Every now and then someone at TED presents a technology or an idea that’s so utterly amazing, or ridiculously simple that it can’t help but change the world. David Merrill shows off an MIT project called Siftables in this talk, and even though I’ve been messing around with computing for 25 years my jaw is still dragging along the floor. Check it out.</p>
<p><object width="446" height="326"><param name="movie" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf"></param><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent"></param><param name="bgColor" value="#ffffff"></param><param name="flashvars" value="vu=http://video.ted.com/talks/embed/DavidMerrill_2009-embed_high.flv&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/DavidMerrill-2009.embed_thumbnail.jpg&#038;vw=432&#038;vh=240&#038;ap=0&#038;ti=457" /><embed src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" pluginspace="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" bgColor="#ffffff" width="446" height="326" allowFullScreen="true" flashvars="vu=http://video.ted.com/talks/embed/DavidMerrill_2009-embed_high.flv&#038;su=http://images.ted.com/images/ted/tedindex/embed-posters/DavidMerrill-2009.embed_thumbnail.jpg&#038;vw=432&#038;vh=240&#038;ap=0&#038;ti=457"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2009/02/tactile-computing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bingo We Can Believe In</title>
		<link>http://iamseb.com/seb/2008/11/bingo-we-can-believe-in/</link>
		<comments>http://iamseb.com/seb/2008/11/bingo-we-can-believe-in/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 21:34:31 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[politics]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[barack obama]]></category>
		<category><![CDATA[bingo]]></category>
		<category><![CDATA[drinking games]]></category>
		<category><![CDATA[election]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=73</guid>
		<description><![CDATA[Alcohol and politics are two things that should rarely mix, but once in a blue moon there’s cause to throw caution to the wind and get a little crazy. One such occasion is tomorrow night, when the US electorate takes to the polls and — with a little luck — elects Barack Obama their next [...]]]></description>
			<content:encoded><![CDATA[<p>Alcohol and politics are two things that should rarely mix, but once in a blue moon there’s cause to throw caution to the wind and get a little crazy.</p>
<p>One such occasion is tomorrow night, when the US electorate takes to the polls and — with a little luck — elects Barack Obama their next President.</p>
<p>There are all sorts of reasons why this is such an important election, both in terms of America’s current standing within the world community, and a number of imminent domestic problems that the next President will find himself dealing with probably before he’s even inaugurated.</p>
<p>That’s perhaps a post or two for another time; once the results are in and the residents of Awesome Manor have either celebrated or commiserated until they drop.</p>
<p>For now, I simply offer my humble contribution to the election festivities. I call it “<a href="http://www.bingowecanbelievein.com">Bingo We Can Believe In</a>”.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2008/11/bingo-we-can-believe-in/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django Decorator for View Rate Limits</title>
		<link>http://iamseb.com/seb/2008/09/django-decorator-for-view-rate-limits/</link>
		<comments>http://iamseb.com/seb/2008/09/django-decorator-for-view-rate-limits/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 02:05:18 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=56</guid>
		<description><![CDATA[This is a handy little snippet that allows you to set rate limits for views in Django.]]></description>
			<content:encoded><![CDATA[<p>This is a handy little <a href="http://www.djangosnippets.org/snippets/1083/">snippet that allows you to set rate limits for views</a> in Django.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2008/09/django-decorator-for-view-rate-limits/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes From a Small Internet</title>
		<link>http://iamseb.com/seb/2008/04/notes-from-a-small-internet/</link>
		<comments>http://iamseb.com/seb/2008/04/notes-from-a-small-internet/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 21:35:51 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=51</guid>
		<description><![CDATA[Beautiful Soup is a great little Python module that will read just about any HTML page and give you back a structured parsed tree. It’s awesome because you can pass it just about any mangled markup — I’ve never known it to choke on anything. For some web service consumers I’ve had to write over [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.crummy.com/software/BeautifulSoup/">Beautiful Soup is a great little Python module</a> that will read just about any HTML page and give you back a structured parsed tree. It’s awesome because you can pass it just about any mangled markup — I’ve never known it to choke on anything. For some web service consumers I’ve had to write over the years Beautiful Soup has saved me many, many hours of slogging through crappy HTML parsing. Great software deserves appreciation.</p>
<p>Whilst browsing my good friend Rachel’s website I happened to notice that her brother <a href="http://www.crummy.com">Leonard</a> wrote Beautiful Soup. He also wrote <a href="http://www.amazon.co.uk/gp/product/0596529260">RESTful Web Services</a>, which is part of my (recently pruned) dead tree collection, and which I’d heartily recommend to anyone who has to work with REST web services. The Django examples were especially useful!</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2008/04/notes-from-a-small-internet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google’s AppEngine Beat Me To It</title>
		<link>http://iamseb.com/seb/2008/04/googles-appengine-beat-me-to-it/</link>
		<comments>http://iamseb.com/seb/2008/04/googles-appengine-beat-me-to-it/#comments</comments>
		<pubDate>Thu, 10 Apr 2008 16:35:48 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://iamseb.com/?p=50</guid>
		<description><![CDATA[Recently I’ve been putting some time into writing a database adapter for Django that uses Amazon’s S3 and SimpleDB services as a storage layer, whilst trying to retain as much of Django’s QuerySet functional layer as possible. The general goal is to provide a storage back-end for Django that isn’t dependent on the traditional vertically-scaling [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I’ve been putting some time into writing a database adapter for <a href="http://djangoproject.com">Django</a> that uses Amazon’s <a href="http://www.amazon.com/S3-AWS-home-page-Money/b/ref=sc_fe_l_2?ie=UTF8&amp;node=16427261">S3</a> and <a href="http://www.amazon.com/SimpleDB-AWS-Service-Pricing/b/ref=sc_fe_l_2?ie=UTF8&amp;node=342335011">SimpleDB</a> services as a storage layer, whilst trying to retain as much of Django’s QuerySet functional layer as possible. The general goal is to provide a storage back-end for Django that isn’t dependent on the traditional vertically-scaling database server, but can scale horizontally in the same way as the <a href="http://www.amazon.com/EC2-AWS-Service-Pricing/b/ref=sc_fe_l_2?ie=UTF8&amp;node=201590011">EC2</a> computing cloud does. My eventual goal being the ability to deploy Django in the cloud with no external dependencies. Just throw out a Django machine image, deploy your app’s code and config, and you have a scaling solution that takes minutes rather than days or weeks.</p>
<p>It’s a non-trivial exercise that is both stimulating and frustrating in equal measure, and progress has been steady, if not exactly rapid. It’s worth it to me though, as the ability to roll out scaling infrastructure is dramatically hampered by the database layer.</p>
<p>Imagine my delight then to find that Google have launched <a href="http://code.google.com/appengine/">AppEngine</a>, their own cloud-based web application system. It’s Python without any messy machine-based libraries, uses <a href="http://www.wsgi.org/wsgi">WSGI</a> so you can use pretty much any Python web app, and with <a href="http://labs.google.com/papers/gfs.html">GFS</a> for a distributed file storage and <a href="http://labs.google.com/papers/bigtable.html">BigTable</a> as a data persistence layer. Google even throws in Django 0.96.1 with instructions on how to use their storage layers by doing away with Django’s own model  (more on this later).</p>
<p>There’s a lot of <a href="http://www.b-list.org/weblog/2008/apr/08/batteries-sold-separately/">whining about how Google’s solution cripples Python</a> (which is crazy when you look at how trivial it is to refactor code to use Google’s supplied alternatives), and locks you into their solution. I suspect that this is mostly from people who have never even contemplated building an application that needs to really scale, and are therefore still thinking in terms services provided by the underlying OS. That’s a big problem for scaling, because disk, IO, threads, sockets, etc are finite resources that are hardware-bound. Abstracting access to these things is tough. Most scaling solutions these days are about providing multiple hardware instances, but unfortunately that only solves the hardware problem. Building an app that scales transparently over multiple hardware instances is a huge challenge in comparison to procuring more servers.</p>
<p>Google’s approach is to do away with the concept of hardware entirely. That means a change of mindset towards every request being an atomic operation. Persistence occurs (correctly) in your persistence layer and not in transient storage available to an instance of your application. Google have provided extensive Python libraries and API calls to enable applications to take advantage of this, but it seems that a fairly vocal group aren’t interested unless their applications work on AppEngine without any additional effort. Considering the paradigm shift that AppEngine represents (from machine-centric programming to distributed programming) it’s not unreasonable to expect some small effort to be required. Especially when you take into account that AppEngine is currently in a very limited trial phase.</p>
<p>I’m extremely optimistic that Google’s approach will work well for a number of reasons. As an application programmer I spend huge amounts of time working around hardware and platform limitations that I should be spending on core functional areas. If Google can provide a solution that means I never have to worry about specific hardware problems ever again, I doubt I’ll look back.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2008/04/googles-appengine-beat-me-to-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPlayer Flash — Embedded (with a little work)</title>
		<link>http://iamseb.com/seb/2007/12/iplayer-flash-embedded-with-a-little-work/</link>
		<comments>http://iamseb.com/seb/2007/12/iplayer-flash-embedded-with-a-little-work/#comments</comments>
		<pubDate>Fri, 14 Dec 2007 19:28:32 +0000</pubDate>
		<dc:creator>seb</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[bbc]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[geekery]]></category>
		<category><![CDATA[iPlayer]]></category>
		<category><![CDATA[tubed]]></category>

		<guid isPermaLink="false">http://iamseb.com/seb/2007/12/iplayer-flash-embedded-with-a-little-work/</guid>
		<description><![CDATA[The BBC has just released Flash streaming for iPlayer’s 7 Day Catch-Up feature. This is just about the best news to come out of the fiasco that is iPlayer, and for those of us unwilling or unable to install the bandwidth-destroying Kontiki client it’s the only way we can get our on-demand BBC programming. Unfortunately, [...]]]></description>
			<content:encoded><![CDATA[<p>The BBC has just released Flash streaming for iPlayer’s 7 Day Catch-Up feature. This is just about the best news to come out of the fiasco that is iPlayer, and for those of us unwilling or unable to install the bandwidth-destroying Kontiki client it’s the only way we can get our on-demand BBC programming.</p>
<p>Unfortunately, the BBC only makes the streams available on their site. I checked the iPlayer terms and conditions, and there’s nothing stopping remote embedding, it’s just a technical hurdle.</p>
<p>Fortunately, the internet eats technical hurdles for breakfast.</p>
<p>So, in the half hour before I go out to the pub, I’ve knocked together a little WordPress plugin that will take an iPlayer URI, and embed the streaming video into your page for you.</p>
<p>Like so:</p>
<div id="iq4c52890e1eb19" class="iqbox iqiPlayer" style="width:512px;height:323px;">
<p><a href="http://www.bbc.co.uk/iplayer/page/item/b0079t3d.shtml">http://www.bbc.co.uk/iplayer/page/item/b0079t3d.shtml</a></p>
</div>
<p>Streaming full-screen Doctor Who on my website. Excuse me whilst I geek-out a moment, this is the coolest thing I’ve played with all week!</p>
<p>I’ll tidy up the code and release it to the community as soon as I get back from a night of drinking and dancing!</p>
]]></content:encoded>
			<wfw:commentRss>http://iamseb.com/seb/2007/12/iplayer-flash-embedded-with-a-little-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
