<?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>John McCollum &#187; web development</title>
	<atom:link href="http://johnmc.co/llum/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnmc.co/llum</link>
	<description>Muddling through since 1980</description>
	<lastBuildDate>Sat, 11 Sep 2010 11:59:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Nominations open in the Packt Open Source Awards 2010</title>
		<link>http://johnmc.co/llum/nominations-open-in-the-packt-open-source-awards-2010/</link>
		<comments>http://johnmc.co/llum/nominations-open-in-the-packt-open-source-awards-2010/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 21:11:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[open-source]]></category>

		<guid isPermaLink="false">http://johnmc.co/llum/?p=230</guid>
		<description><![CDATA[Nominations are available in the following categories: Open Source CMS Award Hall of Fame CMS Most Promising Open Source Project Open Source E-commerce Applications Open Source JavaScript Libraries Open Source Graphics Software You don&#8217;t have to vote in all categories; this year, I&#8217;ll be voting in three: Open Source CMS Award For this award, I&#8217;ll [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fnominations-open-in-the-packt-open-source-awards-2010%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fnominations-open-in-the-packt-open-source-awards-2010%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.packtpub.com/open-source-awards-home/nominations"><img class="alignnone" title="Packt open source awards 2010" src="http://johnmc.co/llum/wp-content/uploads/2010/09/nominate.jpg" alt="" width="479" height="59" /></a><br />
<a href="http://www.packtpub.com/open-source-awards-home/nominations"></a></p>
<p><a href="http://www.packtpub.com/open-source-awards-home/nominations">Nominations</a> are available in the following categories:</p>
<ul>
<li>Open Source CMS Award</li>
<li>Hall of Fame CMS</li>
<li>Most Promising Open Source Project</li>
<li>Open Source E-commerce Applications</li>
<li>Open Source JavaScript Libraries</li>
<li>Open Source Graphics Software</li>
</ul>
<p>You don&#8217;t have to vote in all categories; this year, I&#8217;ll be voting in three:</p>
<p><span id="more-230"></span></p>
<h3><span style="font-weight: normal;">Open Source CMS Award</span></h3>
<p>For this award, I&#8217;ll be voting for <a href="http://www.cmsmadesimple.org/">CMS Made Simple</a>.</p>
<p>At work we use a variety of CMS depending on the client&#8217;s needs, amongst them Joomla!, Drupal and CMS Made Simple. CMSMS has an extremely smooth learning curve; we&#8217;ve seen time and time again that even the least technical people can use it with ease. We have <em>never </em>needed to give anyone a second training session on CMSMS! (If only we could say the same about Joomla! <img src='http://johnmc.co/llum/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> )</p>
<h3>Most Promising Open Source Project</h3>
<p>I&#8217;ll be voting for <a href="http://nodejs.org/">node.js</a> for this one. We&#8217;re starting to see some really exciting and interesting demonstrations of the power of this framework, and I&#8217;ll be keenly watching its development.</p>
<h3>Open Source JavaScript Libraries</h3>
<p>I have to vote for <a href="http://jquery.com/">jQuery</a> for this one. It&#8217;s no exaggeration to say that jQuery has transformed the web; it has certainly transformed the way I write JavaScript, and it makes my life easier on a day to day basis.</p>
<p>These days I&#8217;m enjoying MooTools more and more, and I intend to use it for as many projects as I can, but I&#8217;m not quite there with it yet.</p>
<p>Feel free to share your votes in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/nominations-open-in-the-packt-open-source-awards-2010/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Disable CSRF protection for Django 1.2</title>
		<link>http://johnmc.co/llum/disable-csrf-protection-for-django-1-2/</link>
		<comments>http://johnmc.co/llum/disable-csrf-protection-for-django-1-2/#comments</comments>
		<pubDate>Mon, 05 Jul 2010 21:05:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[CSRF]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=198</guid>
		<description><![CDATA[One of the major changes to Django 1.2 was the automatic switching-on of CSRF protection. I ran into some problems today, hitting the following error. Forbidden (403) CSRF verification failed. Request aborted. There were a couple of issues at play here. Firstly, I was using django.contrib.auth.views.login to log my users in. Even if you don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fdisable-csrf-protection-for-django-1-2%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fdisable-csrf-protection-for-django-1-2%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the major changes to <a href="http://docs.djangoproject.com/en/dev/releases/1.2/">Django 1.2</a> was the automatic switching-on of CSRF protection. I ran into some problems today, hitting the following error.<br />
<pre><pre>Forbidden (403)
CSRF verification failed. Request aborted.</pre></pre><br />
<span id="more-198"></span>There were a couple of issues at play here. Firstly, I was using django.contrib.auth.views.login to log my users in. Even if you don&#8217;t have the CSRF middleware switched on, these views are protected.  Secondly, users were logging in from a different, non-Django sub-domain, so generating Django-compatible CSRF tokens wasn&#8217;t really an option.</p>
<p>Thirdly, the Django site in question was a relatively small, internal, non-client facing site.</p>
<p>With all that in mind, I took the decision to turn off Django&#8217;s CSRF protection.  I had to dig a bit to find this information, so hopefully it helps someone else.</p>
<p><strong>You probably shouldn&#8217;t do this: CSRF protection is a good thing!</strong></p>
<p>Implementing the following as middleware will do the trick.<br />
<pre><pre>class disableCSRF:
&nbsp;&nbsp;&nbsp;&nbsp;def process_request(self, request):
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setattr(request, &#039;_dont_enforce_csrf_checks&#039;, True)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return None</pre></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/disable-csrf-protection-for-django-1-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Stop talking about Web 2.0, start listening to your users</title>
		<link>http://johnmc.co/llum/stop-talking-about-web-2-0-start-listening-to-your-users/</link>
		<comments>http://johnmc.co/llum/stop-talking-about-web-2-0-start-listening-to-your-users/#comments</comments>
		<pubDate>Sat, 17 Apr 2010 08:38:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[web development]]></category>
		<category><![CDATA[web 2.0]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=154</guid>
		<description><![CDATA[Lately I&#8217;ve been getting an awful lot of requests for &#8216;Web 2.0&#8242; features. I&#8217;ve always hated the term for a number of reasons. Web 2.0 was supposed to mark a paradigm shift in the way web sites operated. It promised interactivity and community in an age where sites were static. While we certainly see more [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fstop-talking-about-web-2-0-start-listening-to-your-users%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fstop-talking-about-web-2-0-start-listening-to-your-users%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Lately I&#8217;ve been getting an awful lot of requests for &#8216;Web 2.0&#8242; features. I&#8217;ve always hated the term for a number of reasons.</p>
<p>Web 2.0 was supposed to mark a paradigm shift in the way web sites operated. It promised interactivity and community in an age where sites were static. While we certainly see more of that these days, you also have to remember that these philosophies have been central to the web for many, many years. Amazon was founded in 1994 and Ebay in 1995, and both sites heavily featured user-generated content, even in the early days. In fact Tim Berners Lee described Web 2.0 as:</p>
<blockquote><p>&#8230;people to people. But that was what the Web was supposed to be all along.</p></blockquote>
<p>Certainly, there&#8217;s a look and feel associated with Web 2.0, largely dictated by emerging technologies and limitations of the day. Some of the most representative Web 2.0 technologies, Javascript (created in 1995) and AJAX (1999) have been around for over a decade now. In Interweb years, that&#8217;s an age! In fact, a lot of what was erroneously described as AJAX was simply good ol&#8217; fashioned DHTML, re-packaged and re-branded for a new audience.</p>
<p>My biggest beef with Web 2.0 is that it&#8217;s frequently used as just another point on the checklist of requests, without any thought as to what such features actually are, or whether they&#8217;re appropriate for the site and audience. As in, &#8220;we need the site to be usable, accessible and Web 2.0&#8243;. As such, the term is completely meaningless! Much better to find out from your users what features they actually need, and go from there.</p>
<p>I&#8217;ve even been asked if I can &#8220;do&#8221; Web 2.0. I usually answer that any features are possible given the right budget. Whether or not you want to give them a label of Web 2.0 is up to you!</p>
<p>I guess the take home message for this article is exactly as the title of this article says: stop paying lip service to a marketing term, find out what your users <em>really</em> need, and implement it.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/stop-talking-about-web-2-0-start-listening-to-your-users/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A (slightly) better way of working with FireUnit</title>
		<link>http://johnmc.co/llum/a-slightly-better-way-of-working-with-fireunit/</link>
		<comments>http://johnmc.co/llum/a-slightly-better-way-of-working-with-fireunit/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 20:10:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[FireUnit]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=141</guid>
		<description><![CDATA[In &#8216;Anonymous Functions with FireUnit&#8216;, I looked at one quick way of doing some  unit testing within FireUnit. Here&#8217;s a slightly more robust pattern. In a seperate javascript file, you could do something like this: var tests = { &#160;&#160;&#160;&#160;testOk: function(){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;fireunit.ok(1==1, &#039;This test will pass&#039;); &#160;&#160;&#160;&#160;}, &#160;&#160;&#160;&#160;testCompare: function(){ &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;var numChildren = $(&#039;#myDiv&#039;).children(&#039;p&#039;); &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;fireunit.compare(numChildren, 4, &#039;#myDiv [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fa-slightly-better-way-of-working-with-fireunit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fa-slightly-better-way-of-working-with-fireunit%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In &#8216;<a href="http://johnmccollum.co.uk/2010/03/22/anonymous-functons-with-fireunit/">Anonymous Functions with FireUnit</a>&#8216;, I looked at one quick way of doing some  unit testing within FireUnit. Here&#8217;s a slightly more robust pattern. In a seperate javascript file, you could do something like this:</p>
<p><pre><code>
var tests = {
&nbsp;&nbsp;&nbsp;&nbsp;testOk: function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fireunit.ok(1==1, &#039;This test will pass&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;},
&nbsp;&nbsp;&nbsp;&nbsp;testCompare: function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var numChildren = $(&#039;#myDiv&#039;).children(&#039;p&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fireunit.compare(numChildren, 4, &#039;#myDiv should have 4 child paragraphs&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;}
};

main = function(){
&nbsp;&nbsp;&nbsp;&nbsp;if(typeof fireunit === &#039;object&#039;){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(var test in tests){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tests[test]();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fireunit.testDone();
&nbsp;&nbsp;&nbsp;&nbsp;}
}();

</code></pre></p>
<p>Now, any test functions you add to the tests object will be run when the main function is called (in this case, straight away.)</p>
<p>Simply include this JavaScript file when you want to run your tests, and comment it out or remove it in production.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/a-slightly-better-way-of-working-with-fireunit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another reason to love Python</title>
		<link>http://johnmc.co/llum/another-reason-to-love-python/</link>
		<comments>http://johnmc.co/llum/another-reason-to-love-python/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 21:53:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[list comprehension]]></category>
		<category><![CDATA[pythonic]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=129</guid>
		<description><![CDATA[Last night, I was doing some code kata at codingbat.com when I was presented with the following problem: Given a string and a non-negative int n, we&#039;ll say that the front of the string is the first 3 chars, or whatever is there if the string is less than length 3. Return n copies of [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fanother-reason-to-love-python%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fanother-reason-to-love-python%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Last night, I was doing some code kata at <a href="http://codingbat.com/">codingbat.com</a> when I was presented with the following problem:<br />
<pre><pre>Given a string and a non-negative int n,
we&#039;ll say that the front of the string is the
first 3 chars, or whatever is there
if the string is less than length 3.
Return n copies of the front;

front_times(&#039;Chocolate&#039;, 2) → &#039;ChoCho&#039;
front_times(&#039;Chocolate&#039;, 3) → &#039;ChoChoCho&#039;
front_times(&#039;Abc&#039;, 3) → &#039;AbcAbcAbc&#039;</pre></pre><br />
Pretty straightforward, right? The solution from the site was the following:<br />
<pre><pre>def front_times(str, n):
&nbsp;&nbsp;front_len = 3
&nbsp;&nbsp;if front_len &amp;gt; len(str):
&nbsp;&nbsp;&nbsp;&nbsp;front_len = len(str)
&nbsp;&nbsp;front = str[:front_len]

&nbsp;&nbsp;result = &quot;&quot;
&nbsp;&nbsp;for i in range(n):
&nbsp;&nbsp;&nbsp;&nbsp;result = result + front
&nbsp;&nbsp;return result</pre></pre><br />
I went for a totally different solution though:<br />
<pre><pre>def front_times(str, n):
&nbsp;&nbsp; return n*(&#039;&#039;.join([x for x in list(str[:3])]))</pre></pre><br />
Is it something I&#8217;d use in production? Nope. It&#8217;s less readable and less pythonic, in my opinion, than the longer answer. (Although some would argue that you don&#8217;t get more pythonic than list comprehensions.)</p>
<p>Did it make me smile? <em>Hell yes.</em> Although ultimately, the most pythonic is probably:<br />
<pre><pre>def front_times(str, n):
&nbsp;&nbsp; return n*(str[:3])</pre></pre></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/another-reason-to-love-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery 1.4 Reference Guide &#8211; reviewed</title>
		<link>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/</link>
		<comments>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 19:24:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[book review]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=116</guid>
		<description><![CDATA[Packt Publishing were kind enough to send me a copy of the jQuery 1.4 Reference Guide, by Jonathan Chaffer and Karl Swedberg. The book is intended to be a comprehensive reference for the library, aimed at intermediate to advanced readers. The first point I should make about this book is that it is not intended [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fjquery-1-4-reference-guide-reviewed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fjquery-1-4-reference-guide-reviewed%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Packt Publishing were kind enough to send me a copy of the <a href="http://www.packtpub.com/jquery-1-4-reference-guide/book">jQuery 1.4 Reference Guide</a>, by Jonathan Chaffer and Karl Swedberg. The book is intended to be a comprehensive reference for the library, aimed at intermediate to advanced readers.</p>
<p>The first point I should make about this book is that it is not intended for users who are new to the jQuery library &#8211; this is not a book full of tutorials. If that&#8217;s what you&#8217;re looking for, you should check out <a href="http://www.packtpub.com/learning-jquery-1.3/book">Learning jQuery 1.3</a> instead, by the same authors.</p>
<p>The book is organised into eleven chapters, covering (amongst other things) selectors, DOM traversal and manipulation, events, effects, and AJAX. The whole library is covered (as you would expect from a reference guide).</p>
<p>Each method in the library has its parameters documented. This is surprisingly helpful &#8211; many jQuery methods can be overloaded for various purposes, and this feature of the book is a great help towards learning the possibilities of each method. In fact, one of the take-home points for me was that many methods now support anonymous functions as parameters, offering lots of flexibility.</p>
<p>Next, a bare bones code sample is shown to demonstrate the method. It is followed  by an explanation of the code sample, along with any &#8216;gotchas&#8217; or quirks that you might experience. Multiple examples of code are shown where there might be different ways to use a particular method. The book really is quite exhaustive, and from that point of view offers great value for money.</p>
<p>Although this book works really well as a reference book, the surprise for me was that it didn&#8217;t <em>just </em>work well as a reference book<em>. </em>Reading through the book, I picked up a lot of hints and tips that will almost certainly change how I use jQuery. For example, I realised that my knowledge of selectors was sorely lacking. (Partly this was because I&#8217;d never bothered to learn the CSS3 selectors properly, but jQuery gives me a reason!)</p>
<p>Another excellent chapter for me was the last one, regarding plug in architecture. The structure of this chapter was a little different, basically walking the reader through the process of creating various types of plugin. Like the best technical books, this chapter actually inspired me to put the book down and write some code &#8211; surely a sign that it was doing its job properly!</p>
<p>It&#8217;s worthwhile to note that if you are considering purchasing a copy of this book, Packt will make a contribution to the jQuery project for every copy sold; so in buying this book, you&#8217;ll increase your own knowledge, and you&#8217;ll be directly helping the jQuery project too. For me, that&#8217;s one of the best reasons to buy.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Anonymous functons with FireUnit</title>
		<link>http://johnmc.co/llum/anonymous-functons-with-fireunit/</link>
		<comments>http://johnmc.co/llum/anonymous-functons-with-fireunit/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 19:04:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[FireUnit]]></category>
		<category><![CDATA[Unit Test]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=110</guid>
		<description><![CDATA[FireUnit makes it quick and easy to write unit tests in JavaScript, doing something like the following: fireunit.ok(foo==bar, &#039;foo should equal bar&#039;); But what if you need to do something a little more complex than a one liner? You can write and execute an anonymous function, like this: fireunit.ok(function(){ &#160;&#160;&#160;&#160;var myList = $(&#039;ul&#039;); &#160;&#160;&#160;&#160;var originalLen [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fanonymous-functons-with-fireunit%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fanonymous-functons-with-fireunit%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://fireunit.org">FireUnit</a> makes it quick and easy to write unit tests in JavaScript, doing something like the following:<br />
<pre>fireunit.ok(foo==bar, &#039;foo should equal bar&#039;);</pre><br />
But what if you need to do something a little more complex than a one liner? You can write and execute an anonymous function, like this:<br />
<br />
<pre><pre>fireunit.ok(function(){
&nbsp;&nbsp;&nbsp;&nbsp;var myList = $(&#039;ul&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;var originalLen = myList.children(&#039;li&#039;).length;
&nbsp;&nbsp;&nbsp;&nbsp;fireunit.click( myList );
&nbsp;&nbsp;&nbsp;&nbsp;return $(myList).children() == originalLen + 1;
}(), &#039;This test should return true&#039;);</pre></pre><br />
Two things to note here:</p>
<ol>
<li>Make sure that you include the extra parentheses after the function definition; this executes the function straight away</li>
<li>Make sure you  return true or false  from the function (or an expression that evaluates to true or false.)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/anonymous-functons-with-fireunit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pro Javascript Techniques by John Resig &#8211; a review</title>
		<link>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/</link>
		<comments>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 12:24:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=88</guid>
		<description><![CDATA[I&#8217;ve just finished reading Pro JavaScript Techniques by John Resig, and I thought I&#8217;d post some thoughts about it. The author, John Resig, is the creator of the popular jQuery library. He also works as a Javascript evangelist for Mozilla, so there&#8217;s no doubt that he&#8217;s one of the best known proponents of the language. [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fpro-javascript-techniques-by-john-resig-a-review%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fpro-javascript-techniques-by-john-resig-a-review%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignright size-full wp-image-89" title="pro-javascript-techniques" src="http://johnmccollum.co.uk/wp-content/uploads/2009/10/pro-javascript-techniques.jpg" alt="pro-javascript-techniques" width="240" height="240" />I&#8217;ve just finished reading <a href="http://www.amazon.com/gp/product/1590597273?ie=UTF8&amp;tag=johnmccollumc-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=1590597273">Pro JavaScript Techniques</a> by John Resig, and I thought I&#8217;d post some thoughts about it.</p>
<p>The author, <a href="http://ejohn.org">John Resig</a>, is the creator of the popular <a href="http://jquery.com">jQuery</a> library. He also works as a Javascript evangelist for <a href="http://www.mozilla.org/">Mozilla</a>, so there&#8217;s no doubt that he&#8217;s one of the best known proponents of the language.</p>
<p>Although I use the jQuery library on a daily basis, I was keen to brush up on some of the finer points of Javascript; my knowledge of the jQuery library probably exceeds my knowledge of Javascript! For this reason, I thought the book sounded good.</p>
<p>The first half of the book certainly doesn&#8217;t disappoint. Covering the nitty-gritty of DOM traversal, OO Javascript, and unobtrusive scripting, the book does a great job of covering a lot of ground in a concise, clear manner. The key concepts are illustrated with plenty of code snippets which do a great job of illuminating the subject matter.</p>
<p>The second part of the book was less useful for me, illustrating some examples of AJAX functionality, image galleries, autocomplete, that sort of thing. These topics might have been considered intermediate to advanced in 2006, when the book was released, but the plethora of options around today means that developing stuff like that now is re-inventing the wheel. (Of course you might be interested in <a href="http://www.codinghorror.com/blog/archives/001145.html">learning more about wheels</a>!)</p>
<p>You can almost see the snippets of code in this book forming the nuts and bolts of the jQuery library, and it&#8217;s interesting to take a look at the hoops we developers would have to jump through to otherwise gain cross-browser compliance.</p>
<p>I&#8217;m just glad I&#8217;m not the one having to negotiate those hoops myself!</p>
<p>To sum up, this book is still worth reading for the first half alone, and the stuff on OO javascript, scoping, closures etc is really useful. But some might consider the book a little out of date, so be warned.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/pro-javascript-techniques-by-john-resig-a-review/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Prototype&#8217;s Ajax.PeriodicalUpdater to jQuery</title>
		<link>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/</link>
		<comments>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:54:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=84</guid>
		<description><![CDATA[One of the things I missed when switching from Prototype to jQuery was the former&#8217;s Ajax.PeriodicalUpdater function. It is used to provide a &#8216;decay&#8217; mechanism for ajax calls, making them less and less frequent if the retrieved content doesn&#8217;t change inbetween calls. It can be a seriously useful piece of functionality. I took a chatroom [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fconverting-prototypes-ajaxperiodicalupdater-to-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fconverting-prototypes-ajaxperiodicalupdater-to-jquery%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the things I missed when switching from <a href="http://prototypejs.org">Prototype</a> to <a href="http://jquery.com">jQuery</a> was the former&#8217;s <a href="http://www.prototypejs.org/api/ajax/periodicalUpdater">Ajax.PeriodicalUpdater</a> function. It is used to provide a &#8216;decay&#8217; mechanism for ajax calls, making them less and less frequent if the retrieved content doesn&#8217;t change inbetween calls.</p>
<p>It can be a seriously useful piece of functionality. I took a chatroom that was polling every second and using an entire CPU core (50% usage!) and reduced it to 2-3% using this method. There were also errors retrieving content because sometimes the responses would take longer than a second to come back!</p>
<p>The problem is, there really isn&#8217;t a similar piece of functionality in jQuery.</p>
<p>So here it is! The script checks the returned data against previously received data, and increases the time between calls if it hasn&#8217;t changed.</p>
<p>I&#8217;d be interested in your comments. Would it be useful to turn this into a plugin?</p>
<p><a href="http://johnmccollum.co.uk/decay">View the demonstration here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using JSON to access the Twitter search API</title>
		<link>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/</link>
		<comments>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 09:35:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=81</guid>
		<description><![CDATA[Steve Reynolds recently wrote a blog post showing how to access the twitter search API using PHP, cURL, and JQuery. Steve used JQuery to post to a page on his server, which then cURLed in search results for a given term. This approach is often necessary to get avoid the issue of cross domain ajax [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fusing-json-to-access-the-twitter-search-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fusing-json-to-access-the-twitter-search-api%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.reynoldsftw.com/">Steve Reynolds</a> recently wrote a blog post showing <a href="http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/">how to access the twitter search API using PHP, cURL, and JQuery</a>.</p>
<p>Steve used JQuery to post to a page on his server, which then cURLed in search results for a given term. This approach is often necessary to get avoid the issue of cross domain ajax calls.</p>
<p>While this approach works well, there&#8217;s an even easier way to go about it &#8211; $.getJSON!</p>
<p>There are two main advantages to this approach:</p>
<ul>
<li>Server side technology isn&#8217;t an issue. You don&#8217;t have to rely on PHP, cURL, firewalls, anything like that. It will even work on a static HTML page!</li>
<li>All the work is done on the client&#8217;s browser &#8211; saving precious bandwidth! This could be important on busy sites.</li>
</ul>
<p>I&#8217;ve knocked up a quick-and-dirty demonstration of this concept. If a name doesn&#8217;t already exist for this methodology, my vote goes for JAJA (Javascript and JSON, asynchronous!)</p>
<p><a href="http://johnmccollum.co.uk/twitterjson/">View the demonstration here!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

