<?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>j4mie dot org &#187; Design &amp; Programming</title>
	<atom:link href="http://www.j4mie.org/category/design-programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.j4mie.org</link>
	<description></description>
	<lastBuildDate>Tue, 08 Jun 2010 22:10:25 +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>Idiorm &#8211; a simple ORM for PHP</title>
		<link>http://www.j4mie.org/2010/06/08/idiorm-a-simple-orm-for-php/</link>
		<comments>http://www.j4mie.org/2010/06/08/idiorm-a-simple-orm-for-php/#comments</comments>
		<pubDate>Tue, 08 Jun 2010 12:57:10 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=191</guid>
		<description><![CDATA[
Just a quick update on a little project I&#8217;ve been working on over the past few months. Idiorm is &#8220;a lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5,&#8221; and is released under a BSD license.
Idiorm on GitHub.
The starting point for Idiorm was the topic of my talk at BarCampBrighton last year: &#8220;Minimalism in [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://github.com/images/error/octocat_happy.gif"></p>
<p>Just a quick update on a little project I&#8217;ve been working on over the past few months. <a href="http://github.com/j4mie/idiorm">Idiorm</a> is &ldquo;a lightweight nearly-zero-configuration object-relational mapper and fluent query builder for PHP5,&rdquo; and is released under a BSD license.</p>
<p><a href="http://github.com/j4mie/idiorm">Idiorm on GitHub.</a></p>
<p>The starting point for Idiorm was the topic of my talk at BarCampBrighton last year: &ldquo;<a href="http://www.slideshare.net/j4mie/minimalism-in-web-development">Minimalism in Web Development</a>&rdquo;, the idea that for many purposes, simpler solutions are often preferable to complex ones.</p>
<p><span id="more-191"></span></p>
<p>Idiorm lets you start using an ORM in your application with almost no effort. No XML files, model classes, database introspection or code generation is required: You just need to tell the ORM how to connect to your database, and away you go.</p>
<p>The <a href="http://en.wikipedia.org/wiki/Fluent_interface">fluent interface</a> allows you to build most basic queries without writing any SQL, and gets out of the way when you need to do something more complex (both raw WHERE clauses and complete raw queries are supported). Once you have one or more instances of the ORM class (representing the rows in your database tables) you can access the data in them directly as properties of the objects (using PHP&#8217;s magic __get and __set methods internally), modify and save them, as well as delete them. For full documentation and lots of code samples, see the <a href="http://github.com/j4mie/idiorm#readme">README file</a>.</p>
<p>Obviously, such a simple project (the whole ORM class is only about 600 lines of code) would probably never be used in a huge, complex PHP application. The main drawback to using a generic ORM class instead of domain-specific model classes is that you can&#8217;t attach your own behaviour to the models. So the (extremely sensible) idea of placing most of your business logic in your models (<a href="http://weblog.jamisbuck.org/2006/10/18/skinny-controller-fat-model">Skinny Controller, Fat Model</a>) isn&#8217;t possible with Idiorm as-is.</p>
<p>I have three answers to this problem. The first is that many applications simply don&#8217;t need any business logic more complex than basic CRUD operations, for which Idiorm is perfect. Secondly, one clear use case for Idiorm is to clean up legacy applications which are littered with raw SQL statements, usually passed directly into some custom-written &ldquo;database abstraction&rdquo; class or set of functions. Here, the application is <em>already</em> a mess, and in the absence of a complete rewrite, integrating Idiorm can only make things better. Finally, there&#8217;s no reason why you couldn&#8217;t build a full model layer as a lightweight wrapper <em>on top</em> of Idiorm. This would probably take the form of a factory object which returns instances of the correct model class, using Idiorm to populate them with data. I have a rough-and-ready implementation of this idea on my laptop which I may release at some point, but it&#8217;s easy enough to build yourself. If you&#8217;re using PHP 5.3 (and so have access to late static binding), you could even code up a pretty nice implementation of the active record pattern around Idiorm.</p>
<p>So to summarise, Idiorm isn&#8217;t really intended to replace something like <a href="http://www.doctrine-project.org/">Doctrine</a> or <a href="http://www.propelorm.org/">Propel</a> (or <a href="http://ar.rubyonrails.org/">ActiveRecord</a>, or <a href="http://docs.djangoproject.com/en/dev/topics/db/">Django&#8217;s ORM</a>, or <a href="http://www.sqlalchemy.org">SQLAlchemy</a>, etc). It&#8217;s designed to be a quick and easy solution to database abstraction in small-to-medium sized applications. And let&#8217;s face it &#8211; most of us are building small-to-medium sized applications. We&#8217;re building bicycles, not space shuttles. If Doctrine is a rocket engine, Idiorm is a <a href="http://en.wikipedia.org/wiki/Bottom_bracket">bottom bracket</a>. But if all you want to do is get to the corner shop, a bicycle is a much quicker way to travel.</p>
<p>Finally, if you think you&#8217;d find Idiorm useful, please let me know. Fork the project, make suggestions using <a href="http://github.com/j4mie/idiorm/issues">GitHub&#8217;s Issues system</a> or just leave a comment on this post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2010/06/08/idiorm-a-simple-orm-for-php/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Maps and Parking Tickets</title>
		<link>http://www.j4mie.org/2009/08/23/maps-and-parking-tickets/</link>
		<comments>http://www.j4mie.org/2009/08/23/maps-and-parking-tickets/#comments</comments>
		<pubDate>Sun, 23 Aug 2009 11:49:53 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=145</guid>
		<description><![CDATA[
Over the last few months, I&#8217;ve been kicking around a couple of little spare-time projects, and I&#8217;ve finally got round to writing a blog post about them. Both are fairly simple, but each represents a stepping stone in my efforts to bootstrap my brain into understanding the architecture and design of web applications.


First, http://hereit.is, a [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.j4mie.org/wordpress/wp-content/uploads/2009/08/appscreens.jpg" alt="hereit.is and iwillpayyourparkingticket.com" title="appscreens" width="450" height="379" class="size-full wp-image-146" /></p>
<p>Over the last few months, I&#8217;ve been kicking around a couple of little spare-time projects, and I&#8217;ve finally got round to writing a blog post about them. Both are fairly simple, but each represents a stepping stone in my efforts to bootstrap my brain into understanding the architecture and design of web applications.</p>
<p><span id="more-145"></span></p>
<p><a href="http://hereit.is"><img src="http://www.j4mie.org/wordpress/wp-content/uploads/2009/08/hereitisbanner.png" alt="hereit.is logo" title="hereit.is logo" width="450" height="63" class="size-full wp-image-159" /></a></p>
<p>First, <a href="http://hereit.is">http://hereit.is</a>, a service for creating short urls for geographical locations. The idea is that you use the map on the homepage to find a location, and then create a short url to represent that location (such as <a href="http://hereit.is/brighton">http://hereit.is/brighton</a>). You can then share this url by email, on the phone, on Twitter, etc. When the recipient(s) of the link visits the url, they are shown a simple landing page containing the map, with a link to Google Maps from where they can plan routes, see satellite imagery, and so on.</p>
<p>Despite its simplicity, hereit.is is built using modern web application principles. It has an <a href="http://en.wikipedia.org/wiki/Model–view–controller">MVC architecture</a> and its design is quite closely based on that of <a href="http://www.djangoproject.com/">Django</a>. I decided to implement it in PHP (which I spend all day using at work), partly to prove to myself that it is at least <em>possible</em> to construct well-architected applications with this badly-assembled mess of a language. I now know that if I had used Django itself, the whole project would probably have taken me about half an hour &#8211; but the project itself wasn&#8217;t really the point. The point was to learn how frameworks are put together, and I have definitely succeeded at that.</p>
<p>I also wanted to get my head around <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a>, so hereit.is has simple API which you can use to create locations, and retrieve GeoJSON and KML representations of places. See the <a href="http://hereit.is/api.html">API documentation</a> for more information.</p>
<p>For the front-end design, I took advantage nifty CSS3 tricks, such as <a href="http://www.css3.info/preview/rounded-border/"><code>border-radius</code></a> and <a href="http://www.css3.info/preview/box-shadow/"><code>box-shadow</code></a>. The main page of the site uses no images at all in its design, the idea of which appeals to the minimalist in me (of course, the map itself uses images). Even the logo is a Unicode character, inserted into the heading text with the <a href="http://www.w3schools.com/CSS/CSS_pseudo_elements.asp"><code>:before</code> pseudo-element.</a></p>
<p>I was invited to give a talk about hereit.is at <a href="http://www.fivepoundapp.com/">£5 App</a>, the brilliant monthly-ish meeting organised by <a href="http://ianozsvald.com/">Ian Ozsvald</a> and <a href="http://www.psychicorigami.com/">John Montgomery</a>. I gave a fairly high-level overview of how hereit.is works, and the talk should be fairly accessible (I hope) to the less technical types. You can see the talk on Vimeo here: <a href="http://vimeo.com/5664789">http://vimeo.com/5664789</a></p>
<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=5664789&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=5664789&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/5664789">£5 App #18 &#8211; Jamie on HereIt.Is</a> from <a href="http://vimeo.com/user1893982">Ian Ozsvald</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><a href="http://www.iwillpayyourparkingticket.com"><img src="http://www.j4mie.org/wordpress/wp-content/uploads/2009/08/iwillpay.png" alt="i will pay your parking ticket logo" title="i will pay your parking ticket logo" width="450" height="46" class="size-full wp-image-161" /></a></p>
<p>The second project is <a href="http://www.iwillpayyourparkingticket.com">I Will Pay Your Parking Ticket</a>. This is the brainchild of my friend <a href="http://www.sebleedelisle.com">Seb Lee-Delisle</a>, who <a href="http://www.iwillpayyourparkingticket.com/help/">explains the idea much better himself</a>. </p>
<p>He asked me to help out with the server-side implementation, which we decided to do with <a href="http://www.djangoproject.com">Django</a>. It&#8217;s fairly straightforward for the most part, with one or two interesting details, such as the method we use to select which tweets to show on the homepage (simple randomness turned out to be quite inadequate), and the Twitter search API integration. Fortunately, you can see how it all works for yourself, because we decided to make the whole project open source. You can <a href="http://github.com/j4mie/parkingtickets">follow or fork it at Github</a>.</p>
<p>This experience has completely sold me on the benefits of <a href="http://www.djangoproject.com">Django</a>. At one stage, we more-or-less completely tore the application apart and rebuilt it from scratch in a few hours. There&#8217;s simply no way that would be possible with almost anything else. I&#8217;ve loved <a href="http://python.org/">Python</a> for years, so the ability to work on Web projects with it is fantastic.</p>
<p>Because of Seb&#8217;s rock-star status in the Flash world, and his thousand-plus followers on <a href="https://twitter.com/sebleedelisle">Twitter</a>, I Will Pay Your Parking Ticket has been pretty popular. We already have nearly six thousand votes in the database. Deciding whether or not random strangers deserve your sympathy is a strangely addictive experience, and a good way to waste your lunch hour.</p>
<p>Again, Seb gave a talk about the idea at <a href="http://www.fivepoundapp.com/">£5 App</a>, which you can see below:</p>
<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=6070867&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=6070867&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/6070867">£5 App #19 Seb and Jamie with I Will Pay Your Parking Ticket</a> from <a href="http://vimeo.com/user707645">IanProCastsCoUk</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>So, that&#8217;s a quick update on what I&#8217;ve been doing over the past few weeks. I&#8217;m trying to keep myself busy, with regular attendance at <a href="http://www.flashbrighton.org/">FlashBrighton</a> and other events, as well as getting involved with the brand-new <a href="http://www.buildbrighton.com">Brighton Hackerspace, BuildBrighton</a>. I also managed to grab a ticket for <a href="http://www.barcampbrighton.org/">BarCampBrighton 4</a> at the beginning of September. Hmm, I should probably decide what I&#8217;m going to talk about&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2009/08/23/maps-and-parking-tickets/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>BarCampLondon6</title>
		<link>http://www.j4mie.org/2009/03/30/barcamplondon6/</link>
		<comments>http://www.j4mie.org/2009/03/30/barcamplondon6/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 00:28:12 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Blog]]></category>
		<category><![CDATA[Life]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=143</guid>
		<description><![CDATA[
I spent the weekend at BarCampLondon6 at the offices of the Guardian near King&#8217;s Cross Station. I think my brain is too full of interesting things I&#8217;ve picked up over the last couple of days (not to mention too deprived of sleep) to actually process any of it into a coherent blog post, but you&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3607/3395764613_683ff530d3.jpg" alt="Space Invader" /></p>
<p>I spent the weekend at <a href="http://www.barcamplondon.org/">BarCampLondon6</a> at the offices of <a href="http://www.guardian.co.uk/">the Guardian</a> near King&#8217;s Cross Station. I think my brain is too full of interesting things I&#8217;ve picked up over the last couple of days (not to mention too deprived of sleep) to actually process any of it into a coherent blog post, but you&#8217;ll get an idea of my thoughts by looking at <a href="http://search.twitter.com/search?tag=barcamplondon6&#038;from=j4mie&#038;rpp=30">my posts on Twitter tagged #barcamplondon6</a>, and <a href="http://www.flickr.com/photos/j4mie/sets/72157616003993093/">my Flickr set from the event</a>. Thanks to the organisers for their hard work, and to all the people who took part.</p>
<p>My talk was about <a href="http://www.processing.org">Processing</a>. The photos below are by <a href="http://www.flickr.com/photos/37996583811@N01/">Rain Rabbit</a>.</p>
<p><span id="more-143"></span></p>
<p>Me:</p>
<p><a href="http://www.flickr.com/photos/37996583811@N01/3391746803/"><img src="http://farm4.static.flickr.com/3456/3391746803_379464a2d1_m.jpg" alt="My talk at barcamplondon6" /><br />
</a></p>
<p>The audience (yes, I probably should have picked a bigger room):</p>
<p><a href="http://www.flickr.com/photos/37996583811@N01/3392900990/"><img src="http://farm4.static.flickr.com/3653/3392900990_11300c68e4_m.jpg" alt="My talk at barcamplondon6" /></a></p>
<p>You can view the <a href="http://www.slideshare.net/j4mie/why-should-you-care-about-processing">slides on Slideshare</a>:</p>
<div style="width:425px;text-align:left" id="__ss_1218422"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/j4mie/why-should-you-care-about-processing?type=presentation" title="Why should you care about Processing?">Why should you care about Processing?</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=barcamplondon-090329165927-phpapp02&#038;stripped_title=why-should-you-care-about-processing" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=barcamplondon-090329165927-phpapp02&#038;stripped_title=why-should-you-care-about-processing" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/j4mie">Jamie Matthews</a>.</div>
</div>
<p>Finally, here&#8217;s one of me playing with <a href="http://code.google.com/p/tinkerit/wiki/Auduino">Auduino</a> an Arduino-based synthesiser created by Peter Knight from <a href="http://tinker.it">tinker.it</a>:</p>
<p><img src="http://farm4.static.flickr.com/3647/3394326615_103f894c6e.jpg" alt="Playing with Auduino" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2009/03/30/barcamplondon6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Conway&#8217;s Life in JavaScript</title>
		<link>http://www.j4mie.org/2009/01/27/conways-life-in-javascript/</link>
		<comments>http://www.j4mie.org/2009/01/27/conways-life-in-javascript/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 02:14:32 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Science]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=141</guid>
		<description><![CDATA[If you have a modern browser, have a go with my Game of Life implementation in JavaScript, using the HTML5 Canvas element: 

(click for the “live” version)

Feel free to leave a comment with your frame rate..
]]></description>
			<content:encoded><![CDATA[<p>If you have a modern browser, have a go with my <a href="http://en.wikipedia.org/wiki/Conway%27s_life">Game of Life</a> implementation in JavaScript, using the HTML5 <a href="http://en.wikipedia.org/wiki/Canvas_element">Canvas</a> element: </p>
<p><a href="http://www.j4mie.org/misc/canvas/"><img src="http://farm4.static.flickr.com/3404/3197824914_a421a587ba.jpg" alt="Game of Life in JavaScript " />
<p>(click for the “live” version)</p>
<p></a></p>
<p>Feel free to leave a comment with your frame rate..</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2009/01/27/conways-life-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Syntax Checking from gedit</title>
		<link>http://www.j4mie.org/2009/01/14/javascript-syntax-checking-from-gedit/</link>
		<comments>http://www.j4mie.org/2009/01/14/javascript-syntax-checking-from-gedit/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 14:12:06 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=140</guid>
		<description><![CDATA[JSLint is a tool for finding problems in JavaScript programs. Unfortunately, to use it, you need to paste your source code into a textarea on a website &#8211; less than ideal. This post will explain how to check your JavaScript directly from gedit.
It is based on these instructions for vim, combined with this method to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.jslint.com">JSLint</a> is a tool for finding problems in JavaScript programs. Unfortunately, to use it, you need to paste your source code into a textarea on a website &#8211; less than ideal. This post will explain how to check your JavaScript directly from <a href="projects.gnome.org/gedit/">gedit</a>.</p>
<p>It is based on <a href="http://mikecantelon.com/story/javascript-syntax-checking-vim">these instructions for vim</a>, combined with<a href="http://whereisandy.com/code/jslint/"> this method to allow piping text into JSLint from the standard input</a>.</p>
<p><img src="http://www.jslint.com/jslint.gif" alt="JSLint" /></p>
<p><span id="more-140"></span></p>
<p><strong>1. Install SpiderMonkey</strong><br />
See the <a href="http://developer.mozilla.org/en/SpiderMonkey_Build_Documentation">build instructions page</a> for installing on many different architectures, or<a href="http://mikecantelon.com/story/javascript-syntax-checking-vim"> these instructions</a> for quick installations on Ubuntu and CentOS 5.</p>
<p><strong>2. Download JSLint SpiderMonkey Hack Edition</strong><br />
Get <a href="http://whereisandy.com/code/jslint/jslint">this version of JSLint</a> which has been modified to allow piping code from the standard input. Save it somewhere in your home directory, say <code>/home/<em>username</em>/bin/js/jslinthack.js</code>. You&#8217;ll also need to make it executable by typing <code>chmod +x /home/<em>username</em>/bin/js/jslinthack.js</code></p>
<p><strong>3. Enable the External Tools plugin in gedit</strong><br />
Open gedit and click the Edit menu, then choose Preferences. Click the Plugins tab and tick to enable the Extenal Tools plugin.</p>
<p><strong>4. Set up the JSLint External Tool</strong><br />
In gedit, open the Tools menu and click External Tools. Click the New button and give your new tool the name JSLint. Give it a descriptive name like &#8220;Check JavaScript source code&#8221;. Give it an Accelerator if you wish (mine is Shift+Ctrl+j). Set the Command to the location at which you saved the hacked JSLint file, eg. <code>/home/<em>username</em>/bin/js/jslinthack.js</code>. Set Input to Current Document and set Output to Insert in Output Panel (you&#8217;ll need to have the Bottom Panel enabled in gedit&#8217;s View menu).</p>
<p><strong>5. Profit!</strong><br />
Open up a JavaScript source file, and either press your Accelarator keyboard shortcut, or go to Tools > JSLint. The results of the syntax check will be output in the bottom panel.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2009/01/14/javascript-syntax-checking-from-gedit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Cahors</title>
		<link>http://www.j4mie.org/2008/11/16/cahors/</link>
		<comments>http://www.j4mie.org/2008/11/16/cahors/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 00:07:41 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Electronics + Robotics]]></category>
		<category><![CDATA[Music]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=139</guid>
		<description><![CDATA[
A few months ago, I spent some time writing a MIDI sequencer for the Arduino. I finished the sequencer, wrote a couple of songs with it, and then got sucked into MSc thesis mode and had to abandon it. 
Well, I&#8217;ve finally got round to publishing it as an open source project on Google Code, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://code.google.com/p/cahors/"><img src="http://farm3.static.flickr.com/2140/2476034483_2ed50b8429_m.jpg" alt="Arduino MIDI shield" /></a></p>
<p>A few months ago, I spent some time writing a MIDI sequencer for the Arduino. I finished the sequencer, wrote a couple of songs with it, and then got sucked into MSc thesis mode and had to abandon it. </p>
<p>Well, I&#8217;ve finally got round to publishing it as an open source project on Google Code, so hopefully others will be able to have some fun with it. I&#8217;ve also written some documentation which will hopefully make it a little easier to get started creating music with it. I&#8217;ve named it ‘Cahors,’ which is a word I found in The Deeper Meaning of Liff. See the FAQ page on the Google Code side for a full explanation.</p>
<p><a href="http://code.google.com/p/cahors/">http://code.google.com/p/cahors/</a></p>
<p>You can hear the first full piece I wrote with Cahors on last.fm <a href="http://www.last.fm/music/hot+pink+brain">here</a>, or you can download the MP3 from the Google Code project page. I&#8217;ve not had a chance to go back and write and more music for it recently, but hopefully I&#8217;ll get back into that soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2008/11/16/cahors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to create realistic smoke effects with astronomical photos</title>
		<link>http://www.j4mie.org/2008/10/04/how-to-create-realistic-smoke-effects-with-astronomical-photos/</link>
		<comments>http://www.j4mie.org/2008/10/04/how-to-create-realistic-smoke-effects-with-astronomical-photos/#comments</comments>
		<pubDate>Sat, 04 Oct 2008 15:07:08 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=135</guid>
		<description><![CDATA[I was lucky enough to attend the Flash On The Beach conference in Brighton this week, and one of the highlights was Robert Hodgin of Flight404.com talking about his stunning work, including his famous Solar and Weird Fishes pieces. His Magnetosphere engine is now the default music visualiser in iTunes 8.
In passing, he mentioned that [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.j4mie.org/wordpress/wp-content/uploads/2008/10/smoke1.jpg" alt="" title="Smoke" width="250" class="alignright size-full wp-image-136" />I was lucky enough to attend the <a href="http://www.flashonthebeach.com/">Flash On The Beach</a> conference in Brighton this week, and one of the highlights was Robert Hodgin of <a href="http://www.flight404.com">Flight404.com</a> talking about his stunning work, including his famous <a href="http://vimeo.com/658158">Solar</a> and <a href="http://vimeo.com/935317">Weird Fishes</a> pieces. His Magnetosphere engine is now the default music visualiser in <a href="http://www.apple.com/itunes/whatsnew/">iTunes 8</a>.</p>
<p>In passing, he mentioned that his smoke effects were created using photographs of <a href="http://en.wikipedia.org/wiki/Nebula">nebulae</a>. He didn&#8217;t give any details about exactly how this works, but I thought it was such a good idea that I decided to have a go for myself.</p>
<p><span id="more-135"></span></p>
<p>The concept I came up with is simple: use a particle system to generate smoke-like behaviour, but instead of drawing each particle as a simple &#8220;blob,&#8221; draw an image of a nebula. The older the particle, the larger and more transparent the image. Fairly simple, but it creates remarkably realistic effects.</p>
<p>The particle system I used is based on the <a href="http://www.cs.princeton.edu/~traer/physics/">Traer physics library</a> (in fact, I used some of their sample code to create the smoke behaviour) but you could use any system you like.</p>
<p>The images I used are show below. I took pictures of nebulae I found via Google and cropped out the most interesting parts, then applied a circular gradient mask in Photoshop and saved the resulting image as a transparent PNG. The original PNG images are included in the ZIP file which is linked at the bottom of this post.</p>
<p><img src="http://www.j4mie.org/wordpress/wp-content/uploads/2008/10/all.jpg" alt="" title="Nebulae" width="450" height="450" class="aligncenter size-full wp-image-137" /></p>
<p>Here are a couple of videos showing the results from this process:</p>
<p>UPDATE: The videos have been moved to Vimeo, please see: <a href="http://www.vimeo.com/3166671">Smoke 1</a>, <a href="http://www.vimeo.com/3166712">Smoke 2</a>, <a href="http://www.vimeo.com/3166744">Smoke 3</a>.</p>
<p>The Processing source code for my simple example (along with the images used to create it) can be found in this ZIP file: <a href="http://www.j4mie.org/misc/processing/smoke.zip">smoke.zip</a>.  If you run this code, you&#8217;ll first see the particles drawn as red dots. If you press the &#8216;i&#8217; key, the images will be drawn. Pressing &#8216;p&#8217; hides the red dots. Finally, the &#8216;m&#8217; key toggles mouse following mode. Don&#8217;t forget, you&#8217;ll need the <a href="http://www.cs.princeton.edu/~traer/physics/">Traer physics library</a> for this to work. I used the OpenGL drawing mode because it considerably speeds up image drawing, but it will work using the default Processing renderer.</p>
<p>This is just a basic sketch of how the idea works, and as I said, I have no idea if this is exactly how Robert Hodgin does it. Either way, I think it looks pretty good.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2008/10/04/how-to-create-realistic-smoke-effects-with-astronomical-photos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>House of Cards</title>
		<link>http://www.j4mie.org/2008/07/22/house-of-cards/</link>
		<comments>http://www.j4mie.org/2008/07/22/house-of-cards/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 15:09:34 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=132</guid>
		<description><![CDATA[
UPDATE: Videos have been moved to Vimeo.
I just noticed that I got linked to from Create Digital Motion, a blog about digital video production and computer animation.  Cheers guys!  However, the post says that there is &#8220;more at [my] personal site&#8221; and.. well, there isn&#8217;t.  Or wasn&#8217;t, until now.
The post is about [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://farm4.static.flickr.com/3013/2676056415_062efe4679.jpg" alt="Still from Radiohead video" width = "450" /></p>
<p>UPDATE: Videos have been moved to <a href="http://www.vimeo.com/j4mie">Vimeo</a>.</p>
<p>I just noticed that I got <a href="http://createdigitalmotion.com/2008/07/21/first-radiohead-house-of-cards-videos-appearing-ben-fry-on-the-code/">linked to from Create Digital Motion</a>, a blog about digital video production and computer animation.  Cheers guys!  However, the post says that there is &#8220;more at [my] personal site&#8221; and.. well, there isn&#8217;t.  Or wasn&#8217;t, until now.</p>
<p>The post is about Radiohead&#8217;s &#8220;House of Cards&#8221; video which has been getting a lot of coverage on t&#8217;interwebs this week.  I&#8217;ll spare the technical details as you&#8217;re almost certainly familiar with them by now (if not, have a look at <a href="http://createdigitalmotion.com/2008/07/14/radiohead-makes-house-of-cards-video-with-3d-plotting-processing-gives-you-the-data/">this post</a>).  My two attempts (so far) are below, along with a little info about how they were made.  You can view both the videos in higher quality by clicking through to <span style="text-decoration:line-through;">YouTube</span> Vimeo.</p>
<p><span id="more-132"></span></p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2973927&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=2973927&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object><br /><a href="http://vimeo.com/2973927">House of Cards, Experiment One</a> from <a href="http://vimeo.com/j4mie">Jamie M</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>The first set of experiments is based on a really simple particle system.  The x, y and z co-ordinates of each point in the data cloud are turned into a particle, which is then &#8220;bounced&#8221; off a hard surface using very basic physics.  The position of each particle of each frame in the video is calculated the correct number of times to produce the animation effect.  By bouncing the particles at different angles relative to the &#8220;camera,&#8221; appearance of the bouncing particle cloud can be changed, creating some unusual visuals.  The next section of the video is created by duplicating each point three times, to create three versions of Thom&#8217;s head.  Finally, every particle is given a random velocity, creating an &#8220;explosion&#8221; effect which again is modelled as a large number of bouncing physical objects.</p>
<p><object width="400" height="302"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=2977649&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=2977649&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="302"></embed></object><br /><a href="http://vimeo.com/2977649">House of Cards, Experiment Two</a> from <a href="http://vimeo.com/j4mie">Jamie M</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>The second video is simpler: no physical simulation, just a set of lines.  Every point is connected to another point with a line.  The number of points slowly increases over the video, so Thom&#8217;s face slowly appears from randomness.</p>
<p>I&#8217;ve put some higher-quality stills from the videos on <a href="http://www.flickr.com/photos/j4mie/sets/72157606214314062/">my Flickr account</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2008/07/22/house-of-cards/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to get the dimensions of the dock with AppleScript in Mac OS X Leopard</title>
		<link>http://www.j4mie.org/2008/05/26/how-to-get-the-dimensions-of-the-dock/</link>
		<comments>http://www.j4mie.org/2008/05/26/how-to-get-the-dimensions-of-the-dock/#comments</comments>
		<pubDate>Mon, 26 May 2008 17:23:44 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/?p=130</guid>
		<description><![CDATA[This code snippet might be useful for anyone wanting to write a script to resize your application windows automatically to fit on your display.
Note: I&#8217;m fairly sure you need to enable UI scripting for this to work.

tell application &#34;System Events&#34; to tell process &#34;Dock&#34;
	   set dock_dimensions to size in list 1
	   [...]]]></description>
			<content:encoded><![CDATA[<p>This code snippet might be useful for anyone wanting to write a script to <a href="http://slaunchaman.wordpress.com/2008/05/20/resize-your-windows-automatically-for-different-resolutions/">resize your application windows automatically</a> to fit on your display.</p>
<p>Note: I&#8217;m fairly sure you need to <a href="http://www.apple.com/applescript/uiscripting/01.html">enable UI scripting</a> for this to work.</p>
<ol class="codelist">
<li class="tab0 odd"><code>tell application &quot;System Events&quot; to tell process &quot;Dock&quot;<br />
	   set dock_dimensions to size in list 1<br />
	   set dock_width to item 1 of dock_dimensions<br />
	   set dock_height to item 2 of dock_dimensions<br />
end tell</code></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2008/05/26/how-to-get-the-dimensions-of-the-dock/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>PyTwitFace: Twitter/Facebook mashup with Python</title>
		<link>http://www.j4mie.org/2008/04/13/pytwitface/</link>
		<comments>http://www.j4mie.org/2008/04/13/pytwitface/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 12:36:24 +0000</pubDate>
		<dc:creator>Jamie</dc:creator>
				<category><![CDATA[Design & Programming]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.j4mie.org/2008/04/13/pytwitface/</guid>
		<description><![CDATA[
I&#8217;ve recently started using Twitter, but its &#8220;What are you doing?&#8221; functionality does have some overlap with the Facebook &#8220;Status&#8220;.  It&#8217;d be nice to join these two things together, so that an update in one place would automatically update the other.

The current solutions to this (both the official Twitter Facebook app, and the unofficial [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.j4mie.org/wordpress/wp-content/uploads/2008/04/pytwitface.png' alt='PyTwitFace' /></p>
<p>I&#8217;ve recently started using <a href="http://www.twitter.com/j4mie">Twitter</a>, but its &#8220;What are you doing?&#8221; functionality does have some overlap with the Facebook &#8220;<a href="http://en.wikipedia.org/wiki/Facebook_features#Status">Status</a>&#8220;.  It&#8217;d be nice to join these two things together, so that an update in one place would automatically update the other.</p>
<p><span id="more-124"></span></p>
<p>The current solutions to this (both the official Twitter Facebook app, and the unofficial Twittersync app) allow you to import your Twitter updates into Facebook.  This is great for some people, but I&#8217;d rather not force all my none-geeky Facebook friends to put up with my geeky Twittering.</p>
<p>A better solution for me would be syncing from Facebook to Twitter.  Facebook publishes an RSS feed of your status updates, and <a href="http://twitterfeed.com/">Twitterfeed</a> can monitor feeds and post updates to Twitter.  Perfect.. except it seems to be a bit flaky (I was getting double posts to Twitter of all my Facebook updates).  It&#8217;s also lacking some customisation options which I&#8217;d like.</p>
<p>So.. if all else fails, <strong>do it yourself</strong>.  Below is <strong>PyTwitFace</strong>, a Python script which grabs your RSS feed from Facebook, checks whether your most recent update has been posted to Twitter, and if not, posts it.</p>
<p>You will need:</p>
<ul>
<li>The <a href="http://code.google.com/p/python-twitter/">python-twitter</a> library.</li>
<li>The <a href="http://www.feedparser.org/">Universal Feed Parser</a> library</li>
<li>The URL of your Facebook status RSS feed.  Instructions to find it <a href="http://internetducttape.com/2007/08/08/broadcast-facebook-status-rss-filter/">here</a>.</li>
</ul>
<p>This script doesn&#8217;t do any caching.  It checks your recent Twitter updates to see if your Facebook status has already been imported.  Twitter only publishes your twenty most recent Twitter updates via its API.  So, if you update your Facebook status, then post 20 updates to Twitter, your status will be copied over again (duplicated).  This isn&#8217;t a problem for me, but it may be for you.</p>
<p>The script does a bit of pre-processing of your Facebook status before posting it to Twitter.  It chops off the first word (which is your name), and then checks whether the the next word is in a list of verbs (mine includes &#8220;is&#8221; and &#8220;has&#8221;, but you can add your own).  It then appends &#8220;(from Facebook)&#8221; to the message.  This means that a Facebook status of:</p>
<p><em>Jamie is trying out PyTwitFace.</em></p>
<p>will appear on Twitter as..</p>
<p><em>Trying out PyTwitFace (from Facebook)</em></p>
<p>Here&#8217;s the code.  Don&#8217;t forget to have a look at it, and put in your Twitter username and password and your Facebook feed URL.</p>
<ol class="codelist">
<li class="tab0 odd"><code>import twitter, feedparser, socket</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code>#</code></li>
<li class="tab0 even"><code># SETTINGS</code></li>
<li class="tab0 odd"><code>#</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code>twitteruser = 'username'</code></li>
<li class="tab0 even"><code>twitterpassword = 'password'</code></li>
<li class="tab0 odd"><code>facebook_feed_address = &quot;Your full Facebook status feed URL&quot;</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># Will be appended to facebook status</code></li>
<li class="tab0 even"><code>to_append = &quot;(from Facebook)&quot;</code></li>
<li class="odd">&nbsp;</li>
<li class="tab0 even"><code># These words will be removed from the</code></li>
<li class="tab0 odd"><code># beginning of your status if present</code></li>
<li class="tab0 even"><code>prefixes = ['is', 'has']</code></li>
<li class="odd">&nbsp;</li>
<li class="even">&nbsp;</li>
<li class="odd">&nbsp;</li>
<li class="tab0 even"><code># Make sure the script doesn't hang if it can't get through to</code></li>
<li class="tab0 odd"><code># Twitter or Facebook (ie network is down).</code></li>
<li class="tab0 even"><code>timeout = 60 # seconds</code></li>
<li class="tab0 odd"><code>socket.setdefaulttimeout(timeout)</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code>#</code></li>
<li class="tab0 even"><code># FACEBOOK STUFF</code></li>
<li class="tab0 odd"><code>#</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># Get most recent facebook status.</code></li>
<li class="tab0 even"><code>feed = feedparser.parse(facebook_feed_address)</code></li>
<li class="tab0 odd"><code>most_recent_facebook = feed.entries[0].title</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># Convert facebook status string into a list of words</code></li>
<li class="tab0 even"><code>most_recent_facebook_words = most_recent_facebook.split()</code></li>
<li class="odd">&nbsp;</li>
<li class="tab0 even"><code># Get rid of name from start of string.</code></li>
<li class="tab0 odd"><code>del most_recent_facebook_words[0]</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># If next word is in verb list, remove it.</code></li>
<li class="tab0 even"><code>if most_recent_facebook_words[0] in prefixes:</code></li>
<li class="tab1 odd"><code>del most_recent_facebook_words[0]</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># Capitalise first word.</code></li>
<li class="tab0 even"><code>most_recent_facebook_words[0] = most_recent_facebook_words[0].title()</code></li>
<li class="odd">&nbsp;</li>
<li class="tab0 even"><code># Append selected string.</code></li>
<li class="tab0 odd"><code>most_recent_facebook_words.append(to_append)</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># Convert back into a string</code></li>
<li class="tab0 even"><code>most_recent_facebook = &quot; &quot;.join(most_recent_facebook_words)</code></li>
<li class="odd">&nbsp;</li>
<li class="tab0 even"><code>#</code></li>
<li class="tab0 odd"><code># TWITTER STUFF</code></li>
<li class="tab0 even"><code>#</code></li>
<li class="odd">&nbsp;</li>
<li class="tab0 even"><code># Set up API</code></li>
<li class="tab0 odd"><code>twitterapi = twitter.Api(username=twitteruser, password=twitterpassword)</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># Get list of statuses</code></li>
<li class="tab0 even"><code>twitter_statuses = twitterapi.GetUserTimeline(twitteruser)</code></li>
<li class="tab0 odd"><code>twitter_statuses_text = [s.text for s in twitter_statuses]</code></li>
<li class="even">&nbsp;</li>
<li class="tab0 odd"><code># Check if your current Facebook status</code></li>
<li class="tab0 even"><code># has already been posted to Twitter</code></li>
<li class="tab0 odd"><code>if not most_recent_facebook in twitter_statuses_text:</code></li>
<li class="tab1 even"><code># If not, post it!</code></li>
<li class="tab1 odd"><code>twitterapi.PostUpdate(most_recent_facebook)</code></li>
<li class="even">&nbsp;</li>
<li class="odd">&nbsp;</li>
</ol>
<p>You can either run this manually when you update your Facebook status (which may slightly defeat the object), or put it on a server and set up a cron job, or (like me) run it automatically every so often on your own computer.  I&#8217;m doing this using launchd in Mac OS X.  See my <a href="http://www.j4mie.org/2008/02/15/how-to-make-a-physical-gmail-notifier/">Physical Gmail Notifier</a> post for instructions of how to do this.</p>
<p>A final note: while I was writing this post, I came across <a href="http://www.designmeme.com/2008/04/03/twitterbook-2/">Twitterbook</a>, which does a similar thing with PHP.  It does seem to require manually visiting the script&#8217;s URL to work though, which isn&#8217;t ideal.  Try it out if you&#8217;re more of a PHP person.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.j4mie.org/2008/04/13/pytwitface/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
