<?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>Coderholic &#187; programming</title>
	<atom:link href="http://www.coderholic.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coderholic.com</link>
	<description>Addicted to Development</description>
	<lastBuildDate>Tue, 31 Aug 2010 09:19:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>JavaScript: The Good Parts</title>
		<link>http://www.coderholic.com/javascript-the-good-parts/</link>
		<comments>http://www.coderholic.com/javascript-the-good-parts/#comments</comments>
		<pubDate>Sun, 18 Jul 2010 10:44:37 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=745</guid>
		<description><![CDATA[I&#8217;ve been a huge fan of Douglas Crockford and his articles about JavaScript for a long time. I often point people to his The World&#8217;s Most Misunderstood Programming Language article when I hear them complaining about the language. It&#8217;s taken me a couple of years to get around to reading his book, JavaScript: The Good [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://crockford.com/goodparts.gif" style="float: left; border: 1px solid grey; margin-right: 10px;"/> I&#8217;ve been a huge fan of Douglas Crockford and his <a href="http://javascript.crockford.com/">articles about JavaScript</a> for a long time. I often point people to his <a href="http://javascript.crockford.com/javascript.html">The World&#8217;s Most Misunderstood Programming Language</a> article when I hear them complaining about the language. It&#8217;s taken me a couple of years to get around to reading his book, <a href="http://www.amazon.co.uk/gp/product/0596517742?ie=UTF8&#038;tag=dowlingmeuk-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0596517742">JavaScript: The Good Parts</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=dowlingmeuk-21&#038;l=as2&#038;o=2&#038;a=0596517742" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, but it exceeded all of my expectations.</p>
<p>Being an avid reader of his online stuff, and having watched various <a href="http://www.youtube.com/results?search_query=crockford+javascript&#038;aq=f">talks of his</a> I knew the book would be well written and informative, but I thought it&#8217;d probably just repeat much of what I&#8217;d already read, without providing much new information or insights. To a certain extent this was true, the book does reiterate what&#8217;s said in many of his online articles and talks, but the book is absolutely amazing for a different reason: <strong>The code examples</strong>.</p>
<p>The book is extremely succinct. There&#8217;s no padding, and very little dialog to join one section to the next. There is a common thread thoughout the book though, and that&#8217;s the code. Examples of good coding practices are repeated, and functions written in earlier chapters are often reused in later ones. So although the book appears to be presenting one feature at a time with a small code example you&#8217;re actually building up more and more complex javascript applications, and the book ends with a full JSON parser!</p>
<p>Crockford&#8217;s coding style seems to match his writing style: succinct and to the point. There&#8217;s some really great code in the book, that I think even non-JavaScript developers could appreciate. Here&#8217;s my favourite, from the chapter on regular expressions:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> parse_url <span style="color: #339933;">=</span> <span style="color: #009966; font-style: italic;">/^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([^?#]*))?(?:\?([^#]*))?(?:#(.*))?$/</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'http://www.ora.com:80/goodparts?q#fragment'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> parse_url.<span style="color: #660066;">exec</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> names <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'url'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'scheme'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'slash'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'host'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'port'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'path'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'query'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'hash'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> blanks <span style="color: #339933;">=</span> <span style="color: #3366CC;">'       '</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> names.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i <span style="color: #339933;">+=</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    document.<span style="color: #660066;">writeln</span><span style="color: #009900;">&#40;</span>names<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">':'</span> <span style="color: #339933;">+</span> blanks.<span style="color: #660066;">substring</span><span style="color: #009900;">&#40;</span>names<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> result<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Which outputs:</p>

<div class="wp_syntax"><div class="code"><pre class="none" style="font-family:monospace;">url:    http://www.ora.com:80/goodparts?q#fragment
scheme: http
slash:  //
host:   www.ora.com
port:   80
path:   goodparts
query:  q
hash:   fragment</pre></div></div>

<p>I also love the explanations Crockford gives as to why he avoids using certain parts of JavaScript, and limits himself to a &#8220;good&#8221; subset of the language. He doesn&#8217;t simply say &#8220;This is bad and you shouldn&#8217;t use it&#8221;, it&#8217;s usually accompanied by a story about a time when Crockford had used that feature and got caught out, which is much more compelling.</p>
<p>I think it&#8217;s fair to say that <a href="http://www.amazon.co.uk/gp/product/0596517742?ie=UTF8&#038;tag=dowlingmeuk-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0596517742">JavaScript: The Good Parts</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=dowlingmeuk-21&#038;l=as2&#038;o=2&#038;a=0596517742" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> is one of my favourite programming books: It&#8217;s succinct, packed full of great code examples and best practices for writing maintainable and bug free code. It&#8217;s a fantastic JavaScript reference, but much of what the book talks about is relevant to programming in general. Highly recommended!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/javascript-the-good-parts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How we built a startup in 54 hours</title>
		<link>http://www.coderholic.com/how-we-built-a-startup-in-54-hours/</link>
		<comments>http://www.coderholic.com/how-we-built-a-startup-in-54-hours/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 11:03:15 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[startups]]></category>
		<category><![CDATA[#swlondon]]></category>
		<category><![CDATA[date parsing]]></category>
		<category><![CDATA[london]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[tweevents]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=703</guid>
		<description><![CDATA[Last weekend I attended the London Startup Weekend, a 54 hour event hosted at the IBM building on London&#8217;s Southbank. It was a fantastic event. I met loads of great people, had a lot of fun, and successfully launched a new website! Arianna, Pedro and Debbie have already written up great summaries of the event, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/weefz/4671279887/"><img border=0 style="float: right;" src="http://farm5.static.flickr.com/4036/4671279887_fe5d2b332f.jpg"/></a>Last weekend I attended the <a href="http://london.startupweekend.org/">London Startup Weekend</a>, a 54 hour event hosted at the IBM building on London&#8217;s Southbank. It was a fantastic event. I met loads of great people, had a lot of fun, and successfully launched a new website! <a href="http://arianna.posterous.com/my-thoughts-on-startup-weekend-london-swlondo">Arianna</a>, <a href="http://www.pedrosantos.me/08/some-thoughts-on-london-startupweekend-and-rags2riches">Pedro</a> and <a href="http://weefz.wordpress.com/2010/06/09/startup-weekend-london-writeup/">Debbie</a> have already written up great summaries of the event, so instead I&#8217;ll be focusing on how our team managed to build and launch our project, automatic event management for twitter.</p>
<p>After forming a group most of Friday evening and Saturday morning was spent discussing ideas around the original pitch of twitter calendar integration. We discussed a whole range of ideas including an event broker service, calendar availability widgets, and a twitter/google calendar mashup. It took until lunch time on Saturday to finalise our idea. We&#8217;d settled on a a service that would automatically work out the date of an event mentioned in a tweet and keep track of these events. There were now only 36 hours left!</p>
<p>I got straight to work on the code, using Django. I knew we&#8217;d need to pull in tweets and then analyse the dates. Using the <a href="http://code.google.com/p/python-twitter/">python-twitter</a> library I wrote a <a href="http://docs.djangoproject.com/en/dev/howto/custom-management-commands/">management command</a> to pull in all tweets containing some specific hashtags every minute.</p>
<p>The next stage was to work out a date from the tweets. A <a href="http://stackoverflow.com/questions/1495487/is-there-any-python-library-for-parsing-dates-and-times-from-a-natural-language">Stack Overflow question</a> suggested two options, <a href="http://code.google.com/p/parsedatetime/">parsedatetime</a> library, and some <a href="http://pyparsing.wikispaces.com/UnderDevelopment#toc0">pyparsing example code</a>. I tried the parsedatetime library first, and it gave some fairly good results right away. It wasn&#8217;t so good at more complicated dates though. I tried the pyparsing example, but unless given just the date string (eg. &#8220;Next week&#8221; instead of &#8220;See you next week&#8221;) failed to work out a date at all. I did briefly investigate using the <a href="http://www.nltk.org/">NLTK</a> to extract the date from a tweet, but worried about running out of time I gave up on investigating further and stuck with parsedatetime.</p>
<p>While I&#8217;d been busy programming <a href="http://twitter.com/guillaumedeM">Guillume</a> had come up with a great name for our service: tweevents. He&#8217;d then set about registering the domain name, setting up a <a href="http://twitter.com/tweevents_">twitter acccount</a> and <a href="http://www.facebook.com/pages/Tweevents/133447103335113?ref=ts">facebook fan page</a>. Once we had the name sorted I setup an online logo competition offering $25 to the winner, and an hour later we had our logo.</p>
<p><img src="http://www.tweevents.com/media/images/logo.png"/></p>
<p><a href="http://twitter.com/gtichy">Gabriel</a> worked hard overnight to produce some HTML/CSS for the site, so on Sunday morning I worked on integrating that into the Django project. We worked on adding features to the website, such as links to add events to your google calendar, hCalendar markup, and the ability to filter events by twitter username, and the rest of the day was spent putting a presentation together.</p>
<div style="width:425px" id="__ss_4487514"><object id="__sse4487514" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=tweevents4-100613083816-phpapp01&#038;stripped_title=tweevents" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse4487514" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=tweevents4-100613083816-phpapp01&#038;stripped_title=tweevents" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></div>
<p>So <a href="http://www.tweevents.com">tweevents</a> is now up and running. Within 54 hours we&#8217;d gone from a rough idea into a working website. The presentation we gave gives some details about what&#8217;s next from the business side, but there&#8217;s also some things I&#8217;d like to get done on the development side. Most importantly improved date parsing. I plan to give the <a href="http://labix.org/python-dateutil">python-dateutil</a> library a try, and failing that go back to look into NLTK in more detail. Guillume&#8217;s also working hard on improving the library we&#8217;re already using. Should none of the Python options work I&#8217;ve also come across some great date parsing libraries for other languges, such as <a href="http://www.rubyinside.com/chronic-natural-date-parsing-for-ruby-229.html">Chronic</a> for Ruby and <a href="http://www.datejs.com/">Datejs</a> for Javascript. A Rails or Node.js rewrite might be on the cards! There are also features that we could add, such as Facebook event creation, or filtering the list of events to just your twitter followers, or people you follow.</p>
<p>A huge thanks to <a href="http://twitter.com/damiensaunders">Damien</a>, <a href="http://twitter.com/digbyj">James</a> and <a href="http://twitter.com/peignoir">Franck</a> who organised and helped out at the event, and made it all so much fun. Of course, tweevents wouldn&#8217;t be much without the rest of the <a href="http://www.tweevents.com/about/">team</a>. Thanks also to my girlfriend, who was left on her own with our 2 month old daughter for the entire weekend!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/how-we-built-a-startup-in-54-hours/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FireEagle OAuth and Python2.5 Woes</title>
		<link>http://www.coderholic.com/fireeagle-oauth-and-python2-5-woes/</link>
		<comments>http://www.coderholic.com/fireeagle-oauth-and-python2-5-woes/#comments</comments>
		<pubDate>Tue, 18 May 2010 20:34:10 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[python]]></category>
		<category><![CDATA[oauth fireeagle python yahoo]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=691</guid>
		<description><![CDATA[Back in February I started work on integrating Yahoo&#8217;s FireEagle location service into Geomium and I ran into a problems with Python 2.5. Using Steve Marshall&#8217;s Python library the included test.py script was working perfectly with Python2.6, but when running with Python2.5 I&#8217;d get back an &#8220;Invalid OAuth signature error&#8221;. I posted the problem to [...]]]></description>
			<content:encoded><![CDATA[<p>Back in February I started work on integrating Yahoo&#8217;s <a href="http://fireeagle.yahoo.net/">FireEagle</a> location service into <a href="http://geomium.com">Geomium</a> and I ran into a problems with Python 2.5. Using <a href="http://github.com/SteveMarshall/fire-eagle-python-binding">Steve Marshall&#8217;s Python library</a> the included test.py script was working perfectly with Python2.6, but when running with Python2.5 I&#8217;d get back an &#8220;Invalid OAuth signature error&#8221;.</p>
<p>I posted the problem to the <a href="http://groups.google.com/group/oauth/browse_thread/thread/67fc9ca1e8fd750a/0953b6d5a3fd4b84?hl=en%CE%B9b6d5a3fd4b84&#038;pli=1">OAuth user group</a> but didn&#8217;t get any response. I got in touch with Yahoo. After quite a bit of back and forth we finally figured out the problem, which I&#8217;m posting here to try and save others from months of frustration!</p>
<p>The Yahoo guys noticed that with Python2.5 the HTTP host header was being sent through as as &#8220;fireeagle.yahooapis.com:443&#8243;, whereas 2.6 sends &#8220;fireeagle.yahooapis.com&#8221;. The inclusion of the port results in an invalid OAuth signature, because the signature is generated assuming the port isn&#8217;t included. I dug into the Python2.5 httplib code and came across this:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"> <span style="color: #ff4500;">813</span>    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">self</span>.<span style="color: black;">port</span> == HTTP_PORT:
 <span style="color: #ff4500;">814</span>        <span style="color: #008000;">self</span>.<span style="color: black;">putheader</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Host'</span>, host_enc<span style="color: black;">&#41;</span>
 <span style="color: #ff4500;">815</span>    <span style="color: #ff7700;font-weight:bold;">else</span>:
 <span style="color: #ff4500;">816</span>        <span style="color: #008000;">self</span>.<span style="color: black;">putheader</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'Host'</span>, <span style="color: #483d8b;">&quot;%s:%s&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>host_enc, <span style="color: #008000;">self</span>.<span style="color: black;">port</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>In Python 2.6 the comparison on line 813 is done with self.default_port instead of HTTP_PORT, which prevents the port from being added with HTTPS requests. I noticed that later on in the code that if you pass in your own host header it prevents one being created for you:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"> <span style="color: #ff4500;">875</span>     <span style="color: #ff7700;font-weight:bold;">def</span> _send_request<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, method, url, body, headers<span style="color: black;">&#41;</span>:
 <span style="color: #ff4500;">876</span>         <span style="color: #808080; font-style: italic;"># honour explicitly requested Host: and Accept-Encoding headers</span>
 <span style="color: #ff4500;">877</span>         header_names = <span style="color: #008000;">dict</span>.<span style="color: black;">fromkeys</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span>k.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> k <span style="color: #ff7700;font-weight:bold;">in</span> headers<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
 <span style="color: #ff4500;">878</span>         skips = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
 <span style="color: #ff4500;">879</span>         <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #483d8b;">'host'</span> <span style="color: #ff7700;font-weight:bold;">in</span> header_names:
 <span style="color: #ff4500;">880</span>             skips<span style="color: black;">&#91;</span><span style="color: #483d8b;">'skip_host'</span><span style="color: black;">&#93;</span> = <span style="color: #ff4500;">1</span></pre></div></div>

<p>So the fix turns out to be really simple &#8211; explicitly set the http header. That&#8217;s exactly what I&#8217;ve done in my <a href="http://github.com/coderholic/fire-eagle-python-binding/">fork of the fireeagle library</a> (<a href="http://github.com/coderholic/fire-eagle-python-binding/commit/5586db6e984826bbda2b0f12144caab5a7d9a3de">see the fix</a>). I&#8217;ve also sent a push request, so hopefully this fix will make it back into the original library. Thanks to Arnab Nandi and Anand S from Yahoo for helping to debug things their end.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/fireeagle-oauth-and-python2-5-woes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PyWebShot &#8211; Generate website thumbnails using Python</title>
		<link>http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/</link>
		<comments>http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 17:24:27 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[python gtkmozembed screenshot pywebshot webkit2png]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=643</guid>
		<description><![CDATA[There have been lots of links to automatic website thumbnail generators on sites like reddit and hacker news today, including webkit2png and CutyCapt. Well it just so happens that a few weeks ago I wrote my own website thumbnail generator, and today I got around to putting it on GitHub. The code is based on [...]]]></description>
			<content:encoded><![CDATA[<p>There have been lots of links to automatic website thumbnail generators on sites like reddit and hacker news today, including <a href="http://www.paulhammond.org/webkit2png/">webkit2png</a> and <a href="http://cutycapt.sourceforge.net/">CutyCapt</a>. Well it just so happens that a few weeks ago I wrote my own website thumbnail generator, and today I got around to putting it on <a href="http://github.com/coderholic/PyWebShot">GitHub</a>.</p>
<p>The code is based on Matt Biddulph&#8217;s <a href="http://burtonini.com/computing/screenshot-tng.py">screenshot-tng</a> script, but heavily modified to be more user friendly and provide more options. It uses embedded mozilla for rendering, and therefore requires the <a href="http://www.mozilla.org/unix/gtk-embedding.html">python-gtkmozembed</a> package.</p>
<p>You can specify a resolution to take the screenshot at, and also a resolution for the thumbnail. When generating the thumbnail the aspect ratio will be preserved. You can also specify a delay, so that the screenshot is only taken so many seconds after loading the page. Here&#8217;s an example of running PyWebShot with 3 URLs, and the resulting images:</p>
<pre>
$ ./pywebshot.py -t 500x250 http://www.coderholic.com http://geomium.com/update/598/ http://jobs.plasis.co.uk
Loading http://www.coderholic.com... saved as www.coderholic.com.png
Loading http://geomium.com/update/598/... saved as geomium.com.update.598..png
Loading http://jobs.plasis.co.uk... saved as jobs.plasis.co.uk.png
</pre>
<p><img src="http://www.coderholic.com/wp-content/uploads/coderholic.com_.png"/></p>
<p><img src="http://www.coderholic.com/wp-content/uploads/geomium.com_.update.598..png"/></p>
<p><img src="http://www.coderholic.com/wp-content/uploads/jobs.plasis.co_.uk_.png"/></p>
<p>It you have a huge list of URLs you&#8217;d like to generate screenshots for you can put them all into a file and generate images for them all with the following command:</p>
<pre>
$ cat urls.txt | xargs ./pywebshot.py
</pre>
<p>For more details and the source code see the <a href="http://github.com/coderholic/PyWebShot">PyWebShot project page</a> on GitHub.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/pywebshot-generate-website-thumbnails-using-python/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Clojure: 12 New Programming Languages Update 1</title>
		<link>http://www.coderholic.com/clojure-12-new-programming-languages-update-1/</link>
		<comments>http://www.coderholic.com/clojure-12-new-programming-languages-update-1/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 10:25:08 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[scripts]]></category>
		<category><![CDATA[12in12]]></category>
		<category><![CDATA[clojure]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=588</guid>
		<description><![CDATA[At the start of the year I announced that I was setting myself the challenge of learning 12 new programming languages during 2010. That works out at a language a month, so seeing as it&#8217;s almost the end of March you might expect me to be wrapping up my third language. Unfortunately that isn&#8217;t the [...]]]></description>
			<content:encoded><![CDATA[<p>At the start of the year I announced that I was setting myself the challenge of learning <a href="http://www.coderholic.com/12-new-programming-languages-in-12-months/">12 new programming languages during 2010</a>. That works out at a language a month, so seeing as it&#8217;s almost the end of March you might expect me to be wrapping up my third language. Unfortunately that isn&#8217;t the case. I&#8217;m just about to move on to my second. I&#8217;m still optimistic I can achieve the target of 12 new languages this year though, so expect future updates to be more regular.</p>
<p><strong>Getting Starting with Clojure</strong></p>
<p>Getting up and running with Clojure was made easy to to the wealth of documentation. There&#8217;s a great <a href="http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started">getting started guide</a>, and a guide specifically for <a href="http://riddell.us/ClojureOnUbuntu.html">Clojure on Ubuntu</a>. In terms of programming environment there&#8217;s a round up of <a href="http://www.bestinclass.dk/index.php/2010/03/clojure-ides-the-grand-tour-getting-started/">Clojure IDEs</a>. I stuck to Vim, but I didn&#8217;t take it as far as <a href="http://writequit.org/blog/?p=386">this guide</a>, which describes turning Vim into a fairly comprehensive Clojure IDE. </p>
<p>Clojure has a <a href="http://clojure.org/repl_and_main">REPL</a>, which I always find makes learning a new language easier. When you want to find something out just type it in a see what the result is! The default REPL doesn&#8217;t support arrow navigation or pressing up to run previous commands though, so it can be a little frustrating. There are guides on <a href="http://en.wikibooks.org/wiki/Clojure_Programming/Getting_Started#Enhancing_Clojure_REPL_with_JLine">enhacing the REPL</a> with this functionality.</p>
<p>One of the first things I did was put together the following shell script which either runs the specified Clojure script, or gives you a REPL if no script was specified.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #007800;">CLOJURE_JAR</span>=<span style="color: #ff0000;">&quot;/opt/clojure-1.1.0/clojure.jar&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span> 
        java <span style="color: #660033;">-jar</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${CLOJURE_JAR}</span>&quot;</span> 
<span style="color: #000000; font-weight: bold;">else</span>
        java <span style="color: #660033;">-jar</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${CLOJURE_JAR}</span>&quot;</span> <span style="color: #ff0000;">&quot;$@&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<p><strong>Writing Code</strong></p>
<p>I decided to write a port scanner in Clojure, which would introduce me to command line argument handling, the network API, and parallelization. </p>
<p>One of the great things about Clojure is that despite being such a new language there is so much example code available on the web. I was able to find a <a href="http://travis-whitton.blogspot.com/2009/07/network-sweeping-with-clojure.html">Clojure network scanner</a> by Travis Whitton which detailed all of the network related code I&#8217;d need to my port scanner. Travis uses <a href="http://clojure.org/agents">Clojure&#8217;s agents</a> for parallelization, which is something else I borrowed from his script. I was amazed at how easy it was to parallelize the lookups. So much simpler than threading. If there is only one thing I take away from Clojure it&#8217;ll be its interesting approaches to parallelization.</p>
<p>So without further ado here is my Clojure port scanner:</p>

<div class="wp_syntax"><div class="code"><pre class="scheme" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>import '<span style="color: #66cc66;">&#40;</span>java.io IOException<span style="color: #66cc66;">&#41;</span>
        '<span style="color: #66cc66;">&#40;</span>java.net Socket<span style="color: #66cc66;">&#41;</span>
        '<span style="color: #66cc66;">&#40;</span>java.net InetSocketAddress<span style="color: #66cc66;">&#41;</span>
        '<span style="color: #66cc66;">&#40;</span>java.net SocketTimeoutException<span style="color: #66cc66;">&#41;</span>
        '<span style="color: #66cc66;">&#40;</span>java.net UnknownHostException<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">==</span> <span style="color: #66cc66;">&#40;</span>count <span style="color: #66cc66;">*</span>command<span style="color: #66cc66;">-</span>line<span style="color: #66cc66;">-</span>args<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>def hostname <span style="color: #66cc66;">&#40;</span>first <span style="color: #66cc66;">*</span>command<span style="color: #66cc66;">-</span>line<span style="color: #66cc66;">-</span>args<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span>
    <span style="color: #66cc66;">&#40;</span>println <span style="color: #ff0000;">&quot;Usage: scanner &amp;lt;hostname&amp;gt;&quot;</span><span style="color: #66cc66;">&#41;</span>
        <span style="color: #66cc66;">&#40;</span>System<span style="color: #66cc66;">/</span>exit <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>defn port<span style="color: #66cc66;">-</span>open? <span style="color: #66cc66;">&#91;</span>hostname port timeout<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span> <span style="color: #66cc66;">&#91;</span>sock<span style="color: #66cc66;">-</span>addr <span style="color: #66cc66;">&#40;</span>InetSocketAddress. hostname port<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
    <span style="color: #66cc66;">&#40;</span>try
     <span style="color: #66cc66;">&#40;</span>with<span style="color: #66cc66;">-</span>open <span style="color: #66cc66;">&#91;</span>sock <span style="color: #66cc66;">&#40;</span>Socket.<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
       <span style="color: #66cc66;">&#40;</span>. sock connect sock<span style="color: #66cc66;">-</span>addr timeout<span style="color: #66cc66;">&#41;</span>
       port<span style="color: #66cc66;">&#41;</span>
     <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">catch</span> IOException <span style="color: #b1b100;">e</span> false<span style="color: #66cc66;">&#41;</span>
     <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">catch</span> SocketTimeoutException <span style="color: #b1b100;">e</span> false<span style="color: #66cc66;">&#41;</span>
     <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">catch</span> UnknownHostException <span style="color: #b1b100;">e</span> false<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
     	<span style="color: #66cc66;">&lt;</span>li<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&#40;</span>defn host<span style="color: #66cc66;">-</span>port<span style="color: #66cc66;">-</span>open? <span style="color: #66cc66;">&#91;</span>port<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span>port<span style="color: #66cc66;">-</span>open? hostname port <span style="color: #cc66cc;">5000</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>def port<span style="color: #66cc66;">-</span><span style="color: #b1b100;">list</span> <span style="color: #66cc66;">&#40;</span>range <span style="color: #cc66cc;">1</span> <span style="color: #cc66cc;">1024</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>def agents <span style="color: #66cc66;">&#40;</span>for <span style="color: #66cc66;">&#91;</span>port port<span style="color: #66cc66;">-</span><span style="color: #b1b100;">list</span><span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#40;</span>agent port<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>println <span style="color: #66cc66;">&#40;</span>str <span style="color: #ff0000;">&quot;Scanning &quot;</span> hostname <span style="color: #ff0000;">&quot;...&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>doseq <span style="color: #66cc66;">&#91;</span>agent agents<span style="color: #66cc66;">&#93;</span>
  <span style="color: #66cc66;">&#40;</span>send<span style="color: #66cc66;">-</span>off agent host<span style="color: #66cc66;">-</span>port<span style="color: #66cc66;">-</span>open?<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>apply await agents<span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>doseq <span style="color: #66cc66;">&#91;</span>port <span style="color: #66cc66;">&#40;</span>filter deref agents<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span>
       <span style="color: #66cc66;">&#40;</span>println <span style="color: #66cc66;">&#40;</span>str @port <span style="color: #ff0000;">&quot; is open&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>shutdown<span style="color: #66cc66;">-</span>agents<span style="color: #66cc66;">&#41;</span></pre></div></div>

<p>I&#8217;m sure it is far from an idiomatic solution, so any suggestions for improvement are welcome. Running the scanner with my bash script gives the following output:</p>
<pre>
$ ./clj.sh scanner
Usage: scanner &lt;hostname&gt;

$ ./clj.sh scanner github.com
Scanning github.com...
22 is open
80 is open
443 is open
</pre>
<p><strong>What&#8217;s next?</strong></p>
<p>I&#8217;ve barely scratched the surface of Clojure, but I&#8217;ve certainly become more aware of some of the concepts and idioms used by the language, which is what I was hoping for. I&#8217;ll be looking for more projects in the future where I can make use of it. For now though I need to move on to another language as part of my challenge. As I&#8217;m running behind I plan to go with one that I don&#8217;t think will be too unfamiliar, either Go or Fantom. I&#8217;ll keep you posted!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/clojure-12-new-programming-languages-update-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Recommended reading from Coders at Work</title>
		<link>http://www.coderholic.com/recommended-reading-from-coders-at-work/</link>
		<comments>http://www.coderholic.com/recommended-reading-from-coders-at-work/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 21:53:22 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[books]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=529</guid>
		<description><![CDATA[I really enjoyed reading Peter Siebel&#8217;s Coders at Work, in which he interviews many prominent developers including Donald Knuth, Ken Thompson and Peter Norvig. A question that gets asked to the majority of the developers is what programming books do they recommend. I&#8217;ve complied some of their suggestions into the following list: The Art of [...]]]></description>
			<content:encoded><![CDATA[<p>I really enjoyed reading Peter Siebel&#8217;s <a href="http://www.amazon.co.uk/gp/product/1430219483?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1430219483">Coders at Work</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=1430219483" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" />, in which he interviews many prominent developers including Donald Knuth, Ken Thompson and Peter Norvig. A question that gets asked to the majority of the developers is what programming books do they recommend. I&#8217;ve complied some of their suggestions into the following list:</p>
<p><a href="http://www.amazon.co.uk/gp/product/0201485419?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0201485419"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/41c-uUIgtyL._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=dowlingmeuk-21&#038;l=as2&#038;o=2&#038;a=0201485419" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/0201485419?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0201485419">The Art of Computer Programming</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0201485419" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>TAOCP is mentioned throughout Coders at Work. Some of the developers had read it all the way through, and really got stuck into the maths. Others, such as Doug Crockford had only used the book as a reference. Almost everybody agreed that this book should be on your shelf though.<br />
<br style="clear: left;"/></p>
<p><a href="http://www.amazon.co.uk/gp/product/0201657880?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0201657880"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/41ETT7KQRRL._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0201657880" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/0201657880?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0201657880">Programming Pearls</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0201657880" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>A book about good programming practice with examples in C, this classic has stood the test of time.<br />
<br style="clear: left;"/></p>
<p><a href="http://www.amazon.co.uk/gp/product/0596510047?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0596510047"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/41A3tFaEK-L._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0596510047" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/0596510047?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0596510047">Beautiful Code</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0596510047" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>The tagline for this book is &#8220;Leading Programmers Explain How They Think&#8221;. The book contains lots of example code, and descriptions and commentary from the code&#8217;s author. While this book is only recommended once in Coders at Work, almost all of the interviewees stress the importance of reading code, and this book can help with that.<br />
<br style="clear: left;"/></p>
<p><a href="http://www.amazon.co.uk/gp/product/0262510871?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0262510871"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/41VPCK8QCXL._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0262510871" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/0262510871?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0262510871">Structure and Interpretation of Computer Programs</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0262510871" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>SICP is recommended several times in the book. It&#8217;s supposed to be a very in depth book, it looks at programming from a functional perspective, using Scheme. Zawinski says despite being &#8220;Lispy&#8221;, it provides a great introduction to programming without teaching a language.<br />
<br style="clear: left;"/></p>
<p><a href="http://www.amazon.co.uk/gp/product/0521663504?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0521663504"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/410CKVZM2EL._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0521663504" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/0521663504?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0521663504">Purely Functional Data Structures</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0521663504" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>Describes data structures from a functional programming point of view, rather than the more common imperative perspective (such as Java and C++ data structure books).<br />
<br style="clear: left;"/></p>
<p><a href="http://www.amazon.co.uk/gp/product/1558607013?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1558607013"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/41D4RKA43XL._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=1558607013" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/1558607013?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1558607013">Higher Order Perl</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=1558607013" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>Brad Fitzpatrick recommends this book, which is about functional programming techniques in Perl. The reviews on Amazon seem to suggest this this is an excellent programming book, and should even be interesting for non-Perl developers.<br />
<br style="clear: left;"/></p>
<p><a href="http://www.amazon.co.uk/gp/product/0735619670?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0735619670"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/51hDvTy1LlL._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0735619670" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/0735619670?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0735619670">Code Complete</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0735619670" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>Jamie Zawinski describes this as &#8220;the book you wish your idiot coworker had read&#8221;. It goes through the whole development lifecyle, including design, desbugging, testing and refactoring.<br />
<br style="clear: left;"/></p>
<p><a href="http://www.amazon.co.uk/gp/product/020161586X?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=020161586X"><img style="float: left; margin-right:10px; margin-bottom: 10px;" border="0" src="http://ecx.images-amazon.com/images/I/41DGMPF6FJL._SL110_.jpg"></a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=020161586X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><b><a href="http://www.amazon.co.uk/gp/product/020161586X?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=020161586X">The Practice of Programming</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=020161586X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /><br />
</b>Co-authored by one of the creators of the C programming language, this book aims to teach you good programming practices to help you write faster and more maintainable code.<br />
<br style="clear: left;"/></p>
<p>The list above is just a sample of some of the books recommended in Coders at Work. The Joshua Block interview also mentions lots of interesting Computer Science papers. </p>
<p>The interviews are really great. Most aren&#8217;t particularly technical, but it is interesting to read about how these well-known programmers work, and to get some insight into some of the projects they&#8217;ve worked on. <a href="http://www.amazon.co.uk/gp/product/1430219483?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=1430219483">Coders at Work</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=1430219483" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> is well worth a read.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/recommended-reading-from-coders-at-work/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>12 New Programming Languages in 12 Months</title>
		<link>http://www.coderholic.com/12-new-programming-languages-in-12-months/</link>
		<comments>http://www.coderholic.com/12-new-programming-languages-in-12-months/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 00:37:07 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=519</guid>
		<description><![CDATA[I&#8217;ve decided to set myself the challenge of learning a new programming language every month in 2010. That&#8217;s 12 languages in total. With only a month on each new language I&#8217;m not going to be able to go into much depth, but I&#8217;m hoping to at least pick up some interesting techniques and new ways [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve decided to set myself the challenge of learning a new programming language every month in 2010. That&#8217;s 12 languages in total. With only a month on each new language I&#8217;m not going to be able to go into much depth, but I&#8217;m hoping to at least pick up some interesting techniques and new ways of thinking that I might be able to apply to my every day programming with my usual languages (which happen to be Java, Python, PHP and JavaScript). Who knows, I might even become a convert of one of these languages and wonder how I&#8217;ve been able to use anything else all these years! Here are the languages I&#8217;m hoping to tackle:</p>
<p><strong>Clojure</strong></p>
<p><a href="http://clojure.org/">Clojure</a> is a Lisp dialect for the JVM. I&#8217;ve done some reading on Clojure and had a play with the REPL, so this year I&#8217;m finally going to get round to writing some code with it. From what I&#8217;ve seen so far it looks quite powerful, and the integration with the Java libraries seems to work nicely.</p>
<p><strong>Factor</strong></p>
<p><a href="http://www.factorcode.org/">Factor</a> is a concatenative programming language, meaning it uses a stack instead of named variables to pass data around. Seems like a strange concept to me. This will definitely be an interesting one!</p>
<p><strong>Go</strong></p>
<p>Google announed their <a href="http://golang.org/">Go language</a> in late 2009, describing it as a cross between C++ and Python. It was co-created by by Ken Thompson, who also co-created Unix and worked on the C programming language.</p>
<p><strong>Haskell</strong></p>
<p><a href="http://haskell.org/">Haskell</a> is a purely functional strongly typed language. It also uses lazy evaluation. It&#8217;s got a bit of a reputation for being difficult, but I&#8217;m hoping I&#8217;ll at least be able to pick up some of the main concepts and put a few small programs together.</p>
<p><strong>Erlang</strong></p>
<p><a href="http://ftp.sunet.se/pub/lang/erlang/">Erlang</a> is a concurrent programming language designed for fault tolerant real time applications. I&#8217;m looking forward to learning how Erlang deals with concurrency.</p>
<p><strong>Scheme</strong></p>
<p>I did some <a href="http://en.wikipedia.org/wiki/Scheme_%28programming_language%29">Scheme</a>, a Lisp dialect, while at university. I haven&#8217;t really touched it since though, so I&#8217;m planning to revisit it and maybe dig a little deeper. I&#8217;m thinking about trying <a href="http://www.amazon.co.uk/gp/product/0262560992?ie=UTF8&#038;tag=coderholic-21&#038;linkCode=as2&#038;camp=1634&#038;creative=19450&#038;creativeASIN=0262560992">The Little Schemer</a><img src="http://www.assoc-amazon.co.uk/e/ir?t=coderholic-21&#038;l=as2&#038;o=2&#038;a=0262560992" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /> book, or perhaps the online <a href="http://www.ccs.neu.edu/home/dorai/t-y-scheme/t-y-scheme.html">fixnum days</a> tutorial.</p>
<p><strong>Fantom</strong></p>
<p>Previously called Fan, <a href="http://fantom.org/">Fantom</a> claims to be portable across the JVM, .NET CLR, and JavaScript in the browser! It&#8217;s on object oriented language with C like syntax, so there shouldn&#8217;t be a huge learning curve here. It seems to have some very interesting features though, so I&#8217;m looking forward to trying it out.</p>
<p><strong>Scala</strong></p>
<p>Another JVM language,<a href="http://www.scala-lang.org/"> Scala</a> is a strongly typed language that &#8220;smoothly integrates features of object-oriented and functional languages&#8221;.</p>
<p><strong>OCaml</strong></p>
<p><a href="http://caml.inria.fr/ocaml/">Objective Caml</a> is a statically typed, object-oriented and functional. I&#8217;m sure I&#8217;ll pick up some new techniques and ideas from this language.</p>
<p><strong>Ruby</strong></p>
<p><a href="http://www.ruby-lang.org/en/">Ruby</a> is a scripting language similar in many ways to Python. I&#8217;ve never looked at it in any detail before because I always thought it was too similar to Python. I&#8217;d like to learn it mainly to give the <a href="http://rubyonrails.org/">Rails</a> web framework a try and to see how it compares to <a href="http://www.coderholic.com/8-reasons-why-you-should-try-django/">Django</a>.</p>
<p><strong>Lua</strong></p>
<p>A small and portable scripting language, <a href="http://www.lua.org/">Lua</a> is very popular in the game programming world where it is often used for the scripting of complex 3D engines.</p>
<p><strong>Prolog</strong></p>
<p>I did a little bit of <a href="http://en.wikipedia.org/wiki/Prolog">Prolog</a> at University and I remember being blown away by it. It&#8217;s a declarative logic programming language, often used in the field of AI.</p>
<p>It&#8217;s going to be a tough challenge, learning 12 new languages in 12 months. But hopefully this time next year I&#8217;ll have picked up some interesting techniques, and have a few extra tools in my programmer&#8217;s toolbox. I&#8217;ll be blogging about my progress throughout the year, posting my thoughts on these languages along with any code that I come up with. If you&#8217;re interested in the updates then you can <a href="http://feeds.feedburner.com/coderholic">subscribe</a> to get them automatically. If you&#8217;ve got any comments about any of the languages or about the challenge in general then I&#8217;d love to hear them!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/12-new-programming-languages-in-12-months/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>8 Reasons Why You Should Try Django</title>
		<link>http://www.coderholic.com/8-reasons-why-you-should-try-django/</link>
		<comments>http://www.coderholic.com/8-reasons-why-you-should-try-django/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 22:14:36 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web dev]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=336</guid>
		<description><![CDATA[I have been using Python for quite a few years, but mostly for writing one off sysadmin scripts, command line utilities, and of course PyRadio. Most of my web development work has been done with PHP. The language gets a lot of bad press, some deserved and some not so much. I&#8217;ve had my own [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-505 aligncenter" title="django" src="http://www.coderholic.com/wp-content/uploads/django1.png" alt="django" width="500" height="228" /></p>
<p>I have been using Python for quite a few years, but mostly for writing one off sysadmin scripts, command line utilities, and of course <a href="http://www.coderholic.com/pyradio">PyRadio</a>. Most of my web development work has been done with PHP. The language gets a lot of bad press, some deserved and some not so much. I&#8217;ve had my own <a href="http://www.coderholic.com/beware-phps-split/">gripes</a>, but all-in-all I&#8217;ve been fairly happy with PHP.</p>
<p>Several months ago, though, I thought I&#8217;d give <a href="http://www.djangoproject.com/">Django</a> a try, a python based web framework. I was completely blown away!  Compared to the PHP frameworks I&#8217;d worked with, such as <a href="http://cakephp.org/">Cake</a>, it was just so much more of a pleasure to work with. So here are 8 reasons why you should give Django a try yourself if you haven&#8217;t already. You won&#8217;t be disappointed!</p>
<p><strong>1. Great Documentation</strong></p>
<p>The Django documentation is well written, extremely comprehensive, and up to date. The <a href="http://docs.djangoproject.com/en/">official documentation</a> contains details API references, loads of relevant examples, and tutorials for those getting started. If that isn&#8217;t enough there&#8217;s also a whole <a href="http://www.djangobook.com/">book</a> that&#8217;s available for free online.</p>
<p><strong>2. It&#8217;s Python</strong></p>
<p>The fact that it&#8217;s Python is a huge plus point for me. It&#8217;s a great language that doesn&#8217;t suffer from many of the well documented inconsistencies that PHP does, and includes some nice features such as decorators and first-class functions. Going back to PHP you soon start to miss the little things, such as the ability to assign <a href="http://diveintopython.org/native_data_types/declaring_variables.html#odbchelper.multiassign">multiple values at once</a>, and the simplicity of <a href="http://diveintopython.org/native_data_types/lists.html#odbchelper.list.slice">slicing lists</a>.</p>
<p><strong>3. The ORM</strong></p>
<p>Django&#8217;s object relational mapper completely abstracts away the database, meaning you don&#8217;t need to worry about your database schema or constructing SQL queries. If you&#8217;re using to writing SQL queries then the <a href="http://docs.djangoproject.com/en/dev/ref/models/querysets/">QuerySet</a> API takes a little getting used to, but it&#8217;s really worth the effort. Projects like <a href="http://south.aeracode.org/">South</a> make the ORM even more powerful, allowing you to make schema changes and data migrations automatically.</p>
<p><strong>4. Built in Development Server</strong></p>
<p>Where PHP really shines is on its ease of deployment. Setting up a local development server can be a bit of a pain though, especially if you&#8217;re working on several different sites. Django comes with a built in development server though, so you can be up and running within minutes! From your project&#8217;s root directory you just do</p>
<pre>./manage.py runserver</pre>
<p>and access your django website from http://localhost:8000 &#8211; awesome!</p>
<p><strong>5. The Admin Interface</strong></p>
<p>Django&#8217;s built-in admin interface is practically a full blown CMS, allowing you to add, delete or update your data. It&#8217;s pretty much all automatic, but it&#8217;s also fairly configuration. See the <a href="http://docs.djangoproject.com/en/dev/intro/tutorial02/">documentation</a> to see what it can do!</p>
<p><strong>6. Reusable Applications</strong></p>
<p>Django projects are broken up into &#8220;applications&#8221;, and there are lots of existing reusable applications that you can use for your own projects, such as those for <a href="http://code.google.com/p/django-registration/">user registration</a>, <a href="http://github.com/flashingpumpkin/django-socialregistration">facebook integration</a>, <a href="http://github.com/nathanborror/django-basic-apps">blogging</a>, and <a href="http://github.com/search?langOverride=&amp;language=&amp;q=django&amp;repo=&amp;start_value=2&amp;type=Repositories&amp;x=13&amp;y=19">many many more</a>.</p>
<p>Existing applications are great, but the whole project/application distinction also forces you to think about your own project structure and therefore more likely to make reusable components that you can use in more of your own projects, or even share for others to use.</p>
<p><strong>7</strong><strong>. Templates</strong></p>
<p>I&#8217;ve always been a bit dubious about the merits of PHP template engines such as Smarty. The Django template layer is great though. The inheritance model works well, and the restrictive language really forces you to have a very clean separation of presentation and logic.</p>
<p><strong>8</strong><strong>. Forms</strong></p>
<p>I usually find dealing with user input one of the most boring parts of web development. It takes time to get it right, and its repetitive. The Django Form API really simplifies things. You can define your form class, include and validation rules, and simply add a few lines to your template and few lines to your view and you&#8217;re done!</p>
<hr/>
<p>So those are my 8 reasons why you should give django a go. If you&#8217;re already a django user let me know if you have any points to add!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/8-reasons-why-you-should-try-django/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Recursively Drawing Trees with JavaScript and Canvas</title>
		<link>http://www.coderholic.com/recursively-drawing-trees-with-javascript-and-canvas/</link>
		<comments>http://www.coderholic.com/recursively-drawing-trees-with-javascript-and-canvas/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 21:27:25 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=448</guid>
		<description><![CDATA[I have written an article titled Graphics Programming with Canvas for the upcoming December 2009 edition of JSMag. One of the examples I came up with for the article was a recursive tree drawing algorithm. I had quite a bit of fun tweaking different values and seeing what sort of tree would be produced. After [...]]]></description>
			<content:encoded><![CDATA[<p>I have written an article titled <em>Graphics Programming with Canvas</em> for the upcoming December 2009 edition of <a href="http://www.jsmag.com">JSMag</a>. One of the examples I came up with for the article was a recursive tree drawing algorithm. I had quite a bit of fun tweaking different values and seeing what sort of tree would be produced. After a while it got a bit boring changing a value, saving the JavaScript and then refreshing the page, so with the help of jQuery UI I came up with an <a href="http://www.coderholic.com/demo/tree/">interactive version</a>. Below are a couple of tree images I&#8217;ve generated with the tool:</p>
<p><img src="http://www.coderholic.com/wp-content/uploads/tree4.png" alt="tree" title="tree" width="300" height="350" class="alignnone size-full wp-image-452" style="border: 1px solid grey; float: left; margin-right: 5px;" /></p>
<p><img src="http://www.coderholic.com/wp-content/uploads/tree1.png" alt="tree" title="tree" width="300" height="350" class="alignnone size-full wp-image-452" style="border: 1px solid grey; float: left;"/></p>
<p><br style="clear: left;"/></p>
<p>You can view the page source to see what&#8217;s going on behind the scenes, but for full details check out the December edition of JSMag. Give it a try for yourself, <a href="http://www.coderholic.com/demo/tree/">generate your own tree</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/recursively-drawing-trees-with-javascript-and-canvas/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Faking late static binding in PHP</title>
		<link>http://www.coderholic.com/faking-late-static-binding-in-php/</link>
		<comments>http://www.coderholic.com/faking-late-static-binding-in-php/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 21:41:25 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.coderholic.com/?p=328</guid>
		<description><![CDATA[PHP 5.3 brings lots of long awaited features to the language, including closures, late static binding and namespaces. Unfortunately 5.3 still isn&#8217;t widely available, so some of us are stuck with older version of the language that lack these great new features. One feature I miss all the time is late static binding, or LSB. [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 5.3 brings lots of long awaited features to the language, including closures, <a href="http://php.net/manual/en/language.oop5.late-static-bindings.php">late static binding</a> and namespaces. Unfortunately 5.3 still isn&#8217;t widely available, so some of us are stuck with older version of the language that lack these great new features.</p>
<p>One feature I miss all the time is late static binding, or LSB. The lack of LSB means that you can&#8217;t tell tell which class in your class hierarchy was invoked when calling a static method. Here&#8217;s a simple example:</p>
<pre name="code" class="php">
class class0 {
  public static function getName() {
      echo __CLASS__ . "\n";
  }
}

class class1 extends class0 {}

class class2 extends class1 {}

class0::getName(); // -> "class0"
class1::getName(); // -> "class0"
class2::getName(); // -> "class0"
</pre>
<p>Notice that all three method calls output &#8220;class0&#8243;, the name of the base class. There is no way to tell which class the static method was called on, and in some situations that is information we need to know. </p>
<p>So what can we do? One obvious solution is to re-implement the method in every subclass. This doesn&#8217;t pose much of a problem for a method as simple as the one in our example, but in reality our method is likely to be much more complex, and implementing it in every subclass will lead to lots of duplication. If we ever need to make changes to the method then changes will need to be made to every subclass too. Not fun!</p>
<p>And alternative solution is to have every subclass invoke the parent method, passing in the class name (or whatever variable we&#8217;re interested in). It requires only a couple of extra lines per subclass, rather than repeating the whole method. Any changes now only need to be made in one place. Here&#8217;s the code:</p>
<pre name="code" class="php">
class class0 {
  public static function getName($class = __CLASS__) {
      echo "$class\n";
  }
}

class class1 extends class0 {
  public static function getName($class = __CLASS__) {
      return parent::getName($class);
  }
}

class class2 extends class1 {
  public static function getName($class = __CLASS__) {
      return parent::getName($class);
  }
}

class0::getName(); // -> "class0"
class1::getName(); // -> "class1"
class2::getName(); // -> "class2"
</pre>
<p>In PHP5.3 we can use the new <a href="http://php.net/manual/en/function.get-called-class.php">get_called_class()</a>, so the code becomes much cleaner:</p>
<pre name="code" class="php">
class class0 {
  public static function getName() {
      echo get_called_class() . "\n";
  }
}

class class1 extends class0 {}

class class2 extends class1 {}

class0::getName(); // -> "class0"
class1::getName(); // -> "class1"
class2::getName(); // -> "class2"
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coderholic.com/faking-late-static-binding-in-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
