<rss version="2.0">
<channel>
    <title>www.subdimension.co.uk blog feed</title>
    <link>http://www.subdimension.co.uk/</link>
    <description/>
    <copyright>All rights reserved.</copyright>
    <language>en-GB</language>
    <lastBuildDate>Fri, 26 Apr 2013 19:06:31 GMT</lastBuildDate>
    <ttl>1440</ttl>
    
    <item>
        <title><![CDATA[Making Progress]]></title>
        
        <link>http://www.subdimension.co.uk/2013/04/26/Making_Progress.html</link>
        <guid>http://www.subdimension.co.uk/2013/04/26/Making_Progress.html</guid>
        
        <description><![CDATA[
        <p><img alt="Cadence Emilia" src="http://www.subdimension.co.uk/files/images/cadence.jpg" title="Cadence Emilia"></p>
<p>Things have been moving slowly in the last week on account of a new arrival in our house!</p>
<p>However, I have built the very basic skeleton of an RSS sync system that uses the <a href="http://www.feedafever.com/api">Fever API</a>. Here's a screenshot of <a href="http://reederapp.com/iphone/">Reeder</a> syncing with my test server (currently only subscribed to the feed for this website!)</p>
<p><img alt="mo.lecul.es syncing with Reeder" src="http://www.subdimension.co.uk/files/images/mo.lecul.es.png" title="mo.lecul.es syncing with Reeder"></p>
<p>The Fever API doesn't allow for editing feeds, so currently in order to add a new subscription to my account, I have to log onto the database server and manually add it, but it's a good start and I think I've got the hardest 2 parts done. Just the huge easy bit of building a webapp to manage it all to go!</p>
<p>I'm planning to enter Ludum Dare tomorrow, just to start easing myself back into coding, so I'll probably be writing a fair bit about that as I go.</p>
        ]]></description>
        <pubDate>Fri, 26 Apr 2013 19:06:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[RSS Sync and Google Reader]]></title>
        
        <link>http://www.subdimension.co.uk/2013/03/14/RSS_Sync_and_Google_Reader.html</link>
        <guid>http://www.subdimension.co.uk/2013/03/14/RSS_Sync_and_Google_Reader.html</guid>
        
        <description><![CDATA[
        <p>Google <a href="http://googlereader.blogspot.co.uk/2013/03/powering-down-google-reader.html">announced</a> yesterday that they are shuttering Reader. I'm rather sad about this since I use Reader and a number of apps that interface with it <strong>many</strong> times every day. It's the first tab I open when I start my browser.</p>
<p>Back in 2011 I wrote <a href="http://www.subdimension.co.uk/2011/11/18/RSS_Sync_Service.html">a post</a> about developing my own system. I've noticed that it's getting quite a few pageviews at the moment! I did indeed begin developing my own service, but it was a bit of a <a href="http://www.dev.gd/20130122-the-joys-of-having-a-forever-project.html">forever project</a> for me. I have a domain, a database and a skeleton api but nothing fully working; <strong>yet</strong>.</p>
<p>I'm going to switch priorities on this now and start building something that I would be happy to use myself in place of Google Reader.</p>
<p><em>Maybe</em> my forever project could become my <em>forever career</em></p>
        ]]></description>
        <pubDate>Thu, 14 Mar 2013 08:52:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[Pew! Pew!]]></title>
        
        <link>http://www.subdimension.co.uk/2013/03/11/Pew_Pew.html</link>
        <guid>http://www.subdimension.co.uk/2013/03/11/Pew_Pew.html</guid>
        
        <description><![CDATA[
        <p>I've really been enjoying noodling about learning HTML5 Canvas and JavaScript and whatnot, I have <a href="http://www.ludumdare.com/compo/">plans</a>!</p>
<p>A couple of weeks ago I started running <em>Computer Club</em> at the school I teach at. Last week we started playing around with a space shooter akin to Xenon 2* and its ilk.</p>
<p>The code is available on <a href="https://github.com/MalphasWats/SuperSpaceBattleYeah">GitHub</a> and you can also <a href="http://malphaswats.github.com/SuperSpaceBattleYeah/game.html">Play the Game</a>.</p>
<p>IMPORTANT NOTE: The graphics are intentionally crappy! The idea was to offend the kids' sensibilities so much that they made their own art!! (The game is rubbish because <em>making games is hard</em>)</p>
<p>* Cute fact, my brother and I called this "Exanon" for far longer than either of us care to admit when we were kids.</p>
        ]]></description>
        <pubDate>Mon, 11 Mar 2013 12:28:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[Static Blog - The New "Hello World"]]></title>
        
        <link>http://www.subdimension.co.uk/2013/03/05/Static_Blog__The_New_Hello_World.html</link>
        <guid>http://www.subdimension.co.uk/2013/03/05/Static_Blog__The_New_Hello_World.html</guid>
        
        <description><![CDATA[
        <p>I've been thinking about <a href="http://news.ycombinator.com/item?id=5262597">a comment I read</a> on an <a href="http://news.ycombinator.com/item?id=5262099">HN thread</a> introducing a static blogging engine someone had written.</p>
<p>It's difficult to tell the tone the line was written with:</p>
<blockquote>
<p>Are static site generators the new "hello world?"</p>
</blockquote>
<p>when reading anything on the internet, one's immediate reaction is usually that the person is criticising or disparaging, sometimes this is even without merit!</p>
<p>I kept thinking about it though. In <a href="http://www.subdimension.co.uk/2012/04/20/New_Project_pyDimension.html">April of 2012</a>, I re-wrote my PHP based static blog engine using Python; not because there was anything particularly wrong with the system I had already built and was using, but because I wanted to learn Python.</p>
<p><em>"Hello World"</em> is a deeply dissatisfying first step in learning a language. I remember sitting in the computer lab at my school, aged 13, entering into a BASIC prompt:</p>
<pre><code>10 PRINT "HELLO WORLD"
20 GOTO 10
</code></pre>
<p>and feeling very foolish when I had to ask someone how to make it stop on the unfamiliar machine I was using! Following that, I was left with the question "What now?"</p>
<p>The great thing about building a static blogging engine is that it touches on most of the fundamentally important aspects of creating a useful application:</p>
<ul>
<li>Reading and writing files</li>
<li>Capturing user input</li>
<li>Formatting Strings</li>
<li>Loop and other flow control</li>
<li>Arrays and other simple data structures</li>
<li>Incorporating external libraries</li>
</ul>
<p>You start off (ironically) creating a simple HelloWorld.txt entry and learn how to open the file and read in the contents. Then you start to think about outputting that as HTML, working in templating and markdown libraries, and writing it to a file. And so on.</p>
<p>It's clear from some of the other comments in that thread that some people believe that once there is a good solution for a given problem, there is no merit in creating more. I'd say that <a href="https://github.com/MalphasWats/electrostatic">my current static blogging engine</a> is a long way from the best option, but I enjoyed writing it and I learnt a lot by doing so.</p>
<p>Whilst I would recommend building one to anyone thinking of learning a new language, <em>nothing</em> compares to solving an <em>actual</em> problem you have right now.</p>
        ]]></description>
        <pubDate>Tue, 05 Mar 2013 12:42:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[Advertising]]></title>
        
        <link>http://www.subdimension.co.uk/2013/01/22/Advertising.html</link>
        <guid>http://www.subdimension.co.uk/2013/01/22/Advertising.html</guid>
        
        <description><![CDATA[
        <p>There are only really 2 ways to make money from writing on the internet:</p>
<ul>
<li>Paywall</li>
<li>Advertising</li>
</ul>
<p>The problem with a Paywall is that you really have to have a fairly large audience to start with. The problem with Advertising is that it's advertising.</p>
<p>Really though, there are others, these two are just the <em>obvious</em> ones.</p>
<p>In around February of 2011, I decided to take a slightly different direction with my online writing. Up until then I'd just written about whatever came to mind, which was usually a brief opinion on something that someone else had written. I was trying to emulate the blogs that I followed myself, but I'm not that strong a writer and I don't have access to the juicy inside information (or any information really). I was just adding to the echoes.</p>
<p>I started writing about my adventures in tech, explaining how I solved various coding-related problems. I was emulating a different set of blogs that I follow (of which there are fewer), but also the kinds of resources that I was using myself every day to solve the problems I would then write about.</p>
<p>My intention was to add value - where I had to cobble together 3 or 4 different blog or forum posts to find a solution, those that came after would find my single post that explained exactly how to do what needed to be done. If nothing else, I'm creating a resource for myself, so that when I come across the same problem next time, I can simply search my own blog.</p>
<p>A few of my posts seem to have served their purpose though, my <a href="http://www.subdimension.co.uk/2012/04/24/Deploying_Flask_to_Apache.html">Deploying Flask to Apache</a> post has nearly 400 hits at time of writing.</p>
<p>So far this year, I've noticed an increase in traffic of about 50% overall, so I decided to try an experiment. I've added Google Ads to the sidebar, just beneath the main navigation. It's not in the perfect place for maximum eyeballification, but it's there, and I'll be interested to see what happens with it.</p>
<p>Personally, I rarely, if ever click on ads, my brain has mostly learnt to filter them out so I don't think I'll get many pennies from this endeavour. It would be nice to make enough to pay for <a href="http://lovevps.com/">my hosting</a>, which is currently <em>very</em> cheap (no kickbacks, I feel nothing but positive about them!). I might experiment with writing some reviews of stuff I buy and including affiliate links, although again, I want to make sure I'm actually adding value somewhere.</p>
<p>I've enjoyed writing my blog far more since I switched to a more technical slant, and a brief look at my <a href="http://www.subdimension.co.uk/archive.html">post archive</a> suggests that I've been keeping it up for longer than ever before! It has had an interesting effect on my coding too - I find myself working on things in my spare time much more often, so that I can generate things to write about in my blog!</p>
<p>I shall give it a few months and report back with what I find.</p>
        ]]></description>
        <pubDate>Tue, 22 Jan 2013 12:34:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[Toggling field values in PostgreSQL]]></title>
        
        <link>http://www.subdimension.co.uk/2013/01/20/Toggling_field_values_in_PostgreSQL.html</link>
        <guid>http://www.subdimension.co.uk/2013/01/20/Toggling_field_values_in_PostgreSQL.html</guid>
        
        <description><![CDATA[
        <p>It's important to me that each time I do something new, I move forward with knowledge of the technologies I'm using.</p>
<p>This weekend I created <a href="https://github.com/MalphasWats/ticks">Ticks</a>, a super simple TODO list. I needed a way to toggle a task between complete and incomplete. This status is stored simply as a timestamp field. If the field is <code>NULL</code> then the task is incomplete, otherwise, it was completed on the date stored.</p>
<pre><code>UPDATE ticks
SET completed = 
    CASE
        WHEN completed IS NULL THEN CURRENT_TIMESTAMP
        ELSE NULL
    END
WHERE task_id=%s;
</code></pre>
<p>Nice and simple, with just 1 query.</p>
        ]]></description>
        <pubDate>Sun, 20 Jan 2013 22:26:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[New Design for 2013]]></title>
        
        <link>http://www.subdimension.co.uk/2013/01/17/New_Design_for_2013.html</link>
        <guid>http://www.subdimension.co.uk/2013/01/17/New_Design_for_2013.html</guid>
        
        <description><![CDATA[
        <p>My website has a new design this week. I liked the simplicity of my old design, but I felt a little constrained by it. The width made me feel pressured to only post long articles, I'd like to be able to post twitter-style updates from time-to-time and I felt that they would look lost. The new design gives everything its own little box and I think this gives me more flexibility. My intention is to make a few small tweaks to <a href="https://github.com/MalphasWats/electrostatic">my blogging engine</a> over the next week or so to facilitate different kinds of posts.</p>
<p>The design is not so much inspired by <a href="https://github.com/MalphasWats">my GitHub profile page</a> as it is a complete rip-off. I really like the layout, the sidebar with the avatar communicates the ownership of the writing here. I hope they don't mind too much. There are still a few little bugs to work out, so things might look a bit wonky whilst I work through them all. I'm not sure how the monospace font comes across, but I spend most of my free time looking at code, so again, I think it communicates a little of my personality.</p>
<p>In preparation for my new design, I was perusing the Internet Archive. I was trying to get a feel for the last couple of designs I'd had. Unfortunately, the Way Back Machine hadn't archived any of my old style sheets, so I just got text. What they had archived though was a batch of old blog posts that I no-longer had! I spent a few hours copying and pasting the content into text-files and those posts are now preserved here. Reading through a few of them I was struck by just how poor I was (still am?) at writing and how I really didn't know what to write about. I think I've found my voice a little more over the last year or so, writing about developing the things I make. I don't need to worry about awkward opinions looking strange 3 years from now. I leave the posts as they were, aside from a few notes about things that have disappeared since I wrote about them.</p>
<p>I've also noticed that a lot of my posts start in exactly the same way, which often sounds a bit odd, so I'm going to work on that this year! I found <a href="http://asserttrue.blogspot.co.uk/2013/01/how-to-write-opening-sentence.html">a few tips on opening sentences</a>, so I have somewhere to start!</p>
        ]]></description>
        <pubDate>Thu, 17 Jan 2013 09:16:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[Developing Games in Javascript]]></title>
        
        <link>http://www.subdimension.co.uk/2013/01/11/Developing_Games_in_Javascript.html</link>
        <guid>http://www.subdimension.co.uk/2013/01/11/Developing_Games_in_Javascript.html</guid>
        
        <description><![CDATA[
        <p>I was inspired by the <a href="http://www.ludumdare.com/compo/ludum-dare-25/?action=top&amp;cat=Overall">Ludum Dare</a> competition at the beginning of last month. I wanted to make a game!</p>
<p>Initially I started working in Python but sadly the current state of game libraries' OS X compatibility leaves plenty for another post. I thought I'd give Javascript a whirl.</p>
<p>There are <a href="https://gist.github.com/768272">many, many javascript game libraries</a>. I invented 3 criteria for choosing one in the end:</p>
<ol>
<li>Can I understand the code, armed with just my early-2000's knowledge of Javascript?</li>
<li>What's the documentation like?</li>
<li>How cool do the example games look?</li>
</ol>
<p>basically, #1 and #3 are inversely proportional and #2 is really hit-and-miss.</p>
<p><a href="https://github.com/ippa/jaws">JawsJs</a> ended up being my choice. It totally fulfilled #1, #2 was good enough that I could work out where to go next and #3 looked pitched at the sort of level I thought I could manage myself!</p>
<p>I found that I really enjoyed using it. It even became my first contributed repository on GitHub - I implemented A* pathfinding on TileMaps (which I'll probably write about soon).</p>
<p>My first game is still very much in progress, and it represents the absolute zenith of my artistic abilities, but I'm proud of it:</p>
<p><a href="http://www.subdimension.co.uk/games/Rouge/">Play 'Rouge' here</a>. It'll get better.</p>
        ]]></description>
        <pubDate>Fri, 11 Jan 2013 10:50:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[PostgreSQL triggers in plpython]]></title>
        
        <link>http://www.subdimension.co.uk/2012/12/19/PostgreSQL_triggers_in_plpython.html</link>
        <guid>http://www.subdimension.co.uk/2012/12/19/PostgreSQL_triggers_in_plpython.html</guid>
        
        <description><![CDATA[
        <p>I wanted to run a query that inserted rows into table B whenever a new row was added to table A.</p>
<p>The first step took quite some time. You have to start off by adding the procedural language you wish to use to the database you're working with. I'm happy with Python, so I chose <code>plpython</code>:</p>
<pre><code>$ psql

# CREATE LANGUAGE plpythonu;
</code></pre>
<p>but it didn't like that, I got an error:</p>
<pre><code>ERROR:  could not access file "$libdir/plpython": No such file or directory
</code></pre>
<p>Googling failed me! I couldn't find the answer anywhere. This time, a bit of "aptitude foo" came in useful (I'm running Ubuntu):</p>
<pre><code>$ aptitude search postgresql
</code></pre>
<p>there were a lot of results, but neatly nestled towards the bottom was:</p>
<pre><code>p   postgresql-plpython-8.4         - PL/Python procedural language for PostgreS
</code></pre>
<p>so I installed that:</p>
<pre><code>$ sudo aptitude install postgresql-plpython-8.4
</code></pre>
<p>back to <code>psql</code> and try creating the language again:</p>
<pre><code># CREATE LANGUAGE plpythonu;
CREATE LANGUAGE
</code></pre>
<p>success!</p>
<p>Next to create the function that I wanted to use in a trigger, I discovered a useful command in <code>psql</code>:</p>
<pre><code># \e
</code></pre>
<p>this pulls up the environment default editor to make writing queries a little less horrible!</p>
<pre><code>CREATE FUNCTION unread_trigger()
RETURNS TRIGGER
AS $$
qry = plpy.prepare("""INSERT INTO unread_messages
                      SELECT m.message_id, s.user_id
                      FROM messages m
                      JOIN conversation_subscriptions s
                        ON s.conversation_id = m.conversation_id
                      WHERE m.message_id = $1;""", ("INTEGER",))
res = plpy.execute(qry, (TD['new']['message_id'],))
$$ LANGUAGE plpythonu;
</code></pre>
<p>When you exit the editor and save the temporary file, <code>psql</code> executes the query. I'll explain what's going on here in a minute. Another useful command in <code>psql</code> lists the functions created:</p>
<pre><code># \df
</code></pre>
<p>The next step was to add the function as a trigger to my table:</p>
<pre><code># CREATE TRIGGER set_unread 
# AFTER INSERT ON messages 
# FOR EACH ROW EXECUTE PROCEDURE unread_trigger();
</code></pre>
<p>so, every time a row is inserted into the <code>messages</code> table, the <code>unread_trigger()</code> function is called and inserts a new row in the <code>unread_messages</code> table for each user that is subscribed to the conversation that message belongs to. In that function, there is a dictionary called <code>TD</code>, this dictionary holds the various values relevant to the event that triggered the function, it's documented in the <a href="http://www.postgresql.org/docs/8.4/static/plpython-trigger.html">PL/Python PostgreSQL docs</a>.</p>
<p>The <a href="http://www.postgresql.org/docs/8.4/static/plpython-database.html">PL/Python language includes a module that allows access to the database: <code>plpy</code></a>.</p>
<p>Finally, I didn't get the function right first time. I couldn't work out an easy way to modify a function, so I ended up <code>DROP</code>ping and re-<code>CREATE</code>ing it:</p>
<pre><code>DROP TRIGGER set_unread ON messages;
DROP FUNCTION unread_trigger();
</code></pre>
<p>EDIT: I just realised you can use <code>CREATE OR REPLACE FUNCTION ...</code> and it will change the function definition, instead of dropping and re-creating it every time!</p>
        ]]></description>
        <pubDate>Wed, 19 Dec 2012 20:43:00 GMT</pubDate>
    </item>
    
    <item>
        <title><![CDATA[PostgreSQL unicode]]></title>
        
        <link>http://www.subdimension.co.uk/2012/12/11/PostgreSQL_unicode.html</link>
        <guid>http://www.subdimension.co.uk/2012/12/11/PostgreSQL_unicode.html</guid>
        
        <description><![CDATA[
        <p>I was having trouble storing unicode strings in my postgresql database.</p>
<p>DISCLAIMER: I'm still really struggling with Unicode in Python, but I think I got a little closer to understanding today!</p>
<p>When I installed and configured PostgreSQL for the first time, the default setting for character set was <code>LATIN-1</code>, which is annoying. I kept running into problems saving bookmarks in <a href="https://github.com/MalphasWats/subMarks">subMarks</a> when the page titles had unicode characters in them (the <em>emdash</em> has a lot to answer for).</p>
<p>In order to fix this, I had to convert my database to <code>UTF-8</code>. You can't actually do this though, instead, you have to create a new database, and dump the data into it. Creating a new <code>UTF-8</code> database is fairly straightforward:</p>
<pre><code>$ createdb -E UTF8 -T template0 NEW_DB_NAME
</code></pre>
<p>I used <a href="http://www.turnkeylinux.org/blog/postgresql-latin1-utf8">some instructions I found for transferring the data</a>, however, I didn't drop the cluster and create a new one - I have other databases running and I really couldn't be bothered with all the hassle, I just created a new database and left the old one where it was. Basically, I did this:</p>
<pre><code>$ pg_dump --blobs --oids OLD_DB_NAME &gt; OLD_DB_NAME.latin1.sql
$ pg_dump --blobs --oids --encoding=UTF-8 OLD_DB_NAME &gt; OLD_DB_NAME.utf8.sql
</code></pre>
<p>then:</p>
<pre><code>psql --set ON_ERROR_STOP=on NEW_DB_NAME &lt; OLD_DB_NAME.utf8.sql
</code></pre>
<p>That all went fine, but the next step was causing me some serious problems: connecting to the database from my python web app.</p>
<p>Since I'm running PostgreSQL 8.4, I couldn't specify the <code>client_encoding</code> as part of the DSN, it needs a separate step:</p>
<pre><code>conn = psycopg2.connect(app.config['DSN'])
conn.set_client_encoding('UTF8')
</code></pre>
<p>But that isn't quite enough. <a href="http://stackoverflow.com/questions/10406135/unicodedecodeerror-ascii-codec-cant-decode-byte-0xd1-in-position-2-ordinal">UTF-8 is not Unicode</a> so Python was getting upset with the encoding of the strings it got from the database.</p>
<p>My Googlefu was strong at this point though, I discovered the missing piece in a <a href="https://code.djangoproject.com/ticket/5171">bug filing for Django</a>. Adding the line:</p>
<pre><code>psycopg2.extensions.register_type(psycopg2.extensions.UNICODE)
</code></pre>
<p>to the top of my database code did the job. You can view the code change in this <a href="https://github.com/MalphasWats/instruments/commit/3fb715946533e047c06104d22b9cc3bb02dad366">commit</a>.</p>
<p>This got me a little closer to finally <em>getting</em> Python Unicode!</p>
        ]]></description>
        <pubDate>Tue, 11 Dec 2012 22:04:00 GMT</pubDate>
    </item>
    
</channel>
</rss>