<?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>Global Nerdy &#187; Ruby</title>
	<atom:link href="http://www.globalnerdy.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.globalnerdy.com</link>
	<description>Tech Evangelist Joey deVilla on software development, tech news and other nerdy stuff</description>
	<lastBuildDate>Fri, 19 Mar 2010 00:24:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How and Where is _why?</title>
		<link>http://www.globalnerdy.com/2009/08/20/how-and-where-is-_why/</link>
		<comments>http://www.globalnerdy.com/2009/08/20/how-and-where-is-_why/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 17:59:10 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[People]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[disappearances]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[why the lucky stiff]]></category>
		<category><![CDATA[Why's (Poignant) Guide to Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/08/20/how-and-where-is-_why/</guid>
		<description><![CDATA[ Photo courtesy of &#34;ejc&#34;.
A Little Bit About _why
If you were to walk up to someone and utter the seemingly meaningless phrase “Chunky bacon!” and get a smile rather than a look a bewilderment, you could probably mark that person down as a Ruby programmer. That strange two-word combination is seared in the minds of [...]]]></description>
			<content:encoded><![CDATA[<p></p><p align="center"><a href="http://twitpic.com/ehkoy"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="why_missing_milk_carton" border="0" alt="why_missing_milk_carton" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/08/why_missing_milk_carton.jpg" width="284" height="480" /></a><em> Photo courtesy of &quot;ejc&quot;.</em></p>
<h3>A Little Bit About _why</h3>
<p><strong><img style="border-right-width: 0px; margin: 0px auto 10px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Cartoon foxes from &quot;Why&#39;s (Poignant) Guide to Ruby&quot; screaming &quot;Chunky Bacon!&quot;" border="0" alt="Cartoon foxes from &quot;Why&#39;s (Poignant) Guide to Ruby&quot; screaming &quot;Chunky Bacon!&quot;" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/08/chunky_bacon.jpg" width="280" height="242" />If you were to walk up to someone and utter the seemingly meaningless phrase “Chunky bacon!” and get a smile rather than a look a bewilderment,</strong> you could probably mark that person down as a Ruby programmer. That strange two-word combination is seared in the minds of those who have read what is probably the most whimsical programming language book in existence, <strong><em>Why’s (Poignant) Guide to Ruby</em></strong>. The book is one of the strange and beautiful Ruby-related works created by the enigmatic programmer, musician, artist, comic illustrator and wag known only as <strong>why the lucky stiff</strong>, or _why for short.</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="whys_poignant_guide" border="0" alt="whys_poignant_guide" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/08/whys_poignant_guide.jpg" width="600" height="467" /> </p>
<p>_why’s contributions to the world of Ruby programming are many. In addition to the <em>(Poignant) Guide</em>, some of his goodies that I’ve made use of are:</p>
<ul>
<li><strong>Camping</strong>, an incredibly tiny Ruby web application framework </li>
<li><strong>Hackety Hack</strong>, a “coder’s starter kit” for Ruby, meant to bring back the spirit of experimentation of those days when the BASIC programming language was built into every home computer </li>
<li><strong>Hpricot</strong>, a parser that’s great at scraping HTML and even parsing XML </li>
<li><strong>Redcloth</strong>, a library that implements the Textile markup language </li>
<li><strong>Shoes</strong>, a desktop UI toolkit </li>
<li><strong>Syck</strong>, a YAML library </li>
</ul>
<p>_why made it a point to reveal as little about himself as possible, and most of us were happy to indulge him. Most people were happy to simply know and address him as “why”, and in the community, it was a point of etiquette to <em>not</em> try and dig too deeply.</p>
<h3>_why Vanishes from the Net</h3>
<p><strong><a href="http://ejohn.org/blog/eulogy-to-_why">Yesterday, _why’s presence vanished from the web.</a></strong> The places online where you could find him have been taken down. These included:</p>
<ul>
<li><a href="http://twitter.com/_why">His Twitter account</a> </li>
<li><a href="http://github.com/why">His Github account</a> </li>
<li><a href="http://whytheluckystiff.net/">His old blog at whytheluckystiff.net</a> </li>
<li><a href="http://hackety.org/">Hackety.org, his last active blog</a> </li>
<li><a href="http://poignantguide.net/">The <em>(Poignant) Guide</em> site</a> </li>
<li><a href="http://shoooes.net/">The Shoes site</a> </li>
<li><a href="http://tryruby.hobix.com/">The <em>Try Ruby</em> site</a> </li>
</ul>
<p><a href="http://ejohn.org/blog/eulogy-to-_why">John Resig has written a lovely “eulogy” for _why</a>, and while I think it’s premature to say that he’s gone forever, it’s still nice to see a nice tribute to him. <strong>My favourite part of the eulogy is where John likens _why’s works to a </strong><a href="http://en.wikipedia.org/wiki/Sand_mandala"><strong>sand mandala</strong></a><strong>:</strong></p>
<blockquote><p>Sand mandalas are incredibly intricate works of art that take many people many days to construct. They&#8217;re very expressive, but fragile, works of art.</p>
<p>After a mandala has been constructed &#8211; and displayed &#8211; it is ceremoniously deconstructed &#8211; which is meant &quot;to symbolize the Buddhist doctrinal belief in the transitory nature of material life.&quot;</p>
<p>_why&#8217;s entire online presence and code was presented in the sand mandala that was &#8216;_why&#8217;. The person behind &#8216;_why&#8217; simply decided to move on and close that portion of his life.</p>
</blockquote>
<p>I hope that _why’s disappearance is a brief hiatus. The Ruby world – hey, the programming world, the art world, the music world too – just isn’t the same without him.</p>
<h3>Finding _why’s Stuff</h3>
<p>There’s only one problem with _why’s deletion of his online presence: a number of people have come to depend on his works, particularly his code. The <em>(Poignant) Guide</em> is <a href="http://www.scribd.com/doc/2236084/Whys-Poignant-Guide-to-Ruby">downloadable from Scribd</a>, and I figure that if it hasn’t happened already, someone will start a Github repository of his code. There’s also Facebook group called <a href="http://www.facebook.com/group.php?gid=125833150094"><em>Missing why the lucky stiff</em></a> &#8212; let’s hope it doesn’t get all maudlin and support-group-y.</p>
<p>Last but not least, there’s programmer <a href="http://leahculver.com/"><strong>Leah Culver</strong></a>, <a href="http://www.globalnerdy.com/2009/01/30/leahs-tattoo/">who commissioned a tattoo from _why</a>:</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="leah-culver" border="0" alt="leah-culver" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/08/leahculver.jpg" width="600" height="450" /> </p>
</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="leah-culver-tattoo" border="0" alt="leah-culver-tattoo" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/08/leahculvertattoo.jpg" width="600" height="450" /> </p>
<h3>In Closing</h3>
<p><strong>I’ll finish with <a href="http://www.globalnerdy.com/2008/08/08/why-the-lucky-stiff-on-why-you-should-create/">my favourite tweet from _why</a>,</strong> which I blogged about a year ago:</p>
<blockquote><p><strong>when you don’t create things, you become defined by your tastes rather than ability. your tastes only narrow &amp; exclude people. so create.</strong></p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/08/20/how-and-where-is-_why/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Exceptions: The Airbags of Code</title>
		<link>http://www.globalnerdy.com/2009/08/04/exceptions-the-airbags-of-code/</link>
		<comments>http://www.globalnerdy.com/2009/08/04/exceptions-the-airbags-of-code/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 19:19:35 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[defensive programming]]></category>
		<category><![CDATA[exception handling. C#]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/08/04/exceptions-the-airbags-of-code/</guid>
		<description><![CDATA[This article also appears in Canadian Developer Connection.

The trouble with a lot of example code covering exceptions is that the examples are often cases in which you shouldn’t be using an exception in the first place. Consider the classic known as “Someone’s trying to divide by zero” – here’s the C# version:
// C#

try
{
   [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="alert"><a href="http://blogs.msdn.com/cdndevs/archive/2009/08/04/exceptions-the-airbags-of-code.aspx">This article also appears in <em>Canadian Developer Connection</em>.</a></p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="its_okay_i_wrote_an_exception" border="0" alt="its_okay_i_wrote_an_exception" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/08/its_okay_i_wrote_an_exception.jpg" width="400" height="450" /></p>
<p>The trouble with a lot of example code covering exceptions is that the examples are often cases in which you shouldn’t be using an exception in the first place. Consider the classic known as “Someone’s trying to divide by zero” – here’s the C# version:</p>
<pre><code>// C#

try
{
    result = dividend / divisor;
}
catch (DivideByZeroException ex)
{
    Console.WriteLine(&quot;Idiot.&quot;);
}</code></pre>
<p>and here&#8217;s the Ruby version:</p>
<pre><code>// Ruby (works in IronRuby too!)

begin
    result = dividend / divisor
rescue ZeroDivisionError
    puts &quot;Idiot.&quot;
end

// You have to hand it to Ruby for picking great keywords for
// exception handling. While C# borrowed Java's &quot;try / catch / finally&quot;,
// Ruby went with the more macho &quot;begin / rescue / ensure&quot;.
// As Yoda himself would say: &quot;Do or do not. There is no try.&quot;</code></pre>
<p>The better approach would be to do a little defensive programming and make sure that <code>divisor</code> is non-zero <em>before</em> performing the division operation. So why do tutorials on exception handling almost always bring out the “Someone’s trying to divide by zero” example?</p>
<p>There are two reasons:</p>
<ul>
<li><strong>It’s simple.</strong> It’s only a handful of lines of code. </li>
<li><strong>It’s predictable.</strong> Set the value of divisor to zero and the exception gets thrown. Always. </li>
</ul>
<p>The truly exceptional exceptions &#8212; I/O errors, timeouts and other things that cause exceptions are a little harder to set up and take more code to handle. Hence the divide-by-zero example; it illustrates <code>try</code> and <code>catch</code> (or <code>rescue</code> in a Ruby block) in a way even the newest newbie can understand.</p>
<p>The problem is that many tutorial authors don’t get any deeper than simply explaining the keywords with simple examples, leading people to misuse exceptions, either as a substitute for checking for preconditions or as an unstructured form of flow control in the style of the much-maligned <code>goto</code> (which in many cases is <a href="http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html">considered harmful</a>).</p>
<p>Like goto, exceptions are unstructured jumps, which make your program’s flow more complex. Unlike goto, exceptions are computationally “expensive” because of all the extra work involved in setting up and backtracking program flow that comes with a thrown exception.</p>
<p><strong>A good guideline to follow is that exceptions are for exceptional cases.</strong> Stuff that you can’t easily predict. You can tell if a division operation is going to result in an undefined result – just look at the divisor! Harder to predict are things like whether a server access will time out or if the hard drive will decide that the moment you’re reading a file is the best possible time to corrupt it. Those hard-to-foresee, believed-to-be-rare, <em>exceptional </em>cases are really what exceptions are meant to handle. </p>
<p><strong>Think of exceptions is as being like the airbags in your car. The idea is that they’re a last resort; they’re no substitute for defensive driving.</strong> (Like airbags, they’re also expensive to reset.)</p>
<p>Lee Dumond goes into further detail on the topic of defensive programming as being like defensive driving in an article titled <a href="http://leedumond.com/blog/defensive-programming-or-why-exception-handling-is-like-car-insurance/"><strong><em>Defensive Programming, or Why Exception Handling Is Like Car Insurance</em></strong></a>. He cites the “Someone’s trying to divide by zero” example, provides a list of defensive programming strategies that you should consider before coding up that exception handler and talks about those exceptional cases when you <em>will</em> have to use an exception. <a href="http://leedumond.com/blog/defensive-programming-or-why-exception-handling-is-like-car-insurance/">Check it out!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/08/04/exceptions-the-airbags-of-code/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Open Source Language Roundtable Webcast: Wednesday, July 22nd</title>
		<link>http://www.globalnerdy.com/2009/07/20/open-source-language-roundtable-webcast-wednesday-july-22nd/</link>
		<comments>http://www.globalnerdy.com/2009/07/20/open-source-language-roundtable-webcast-wednesday-july-22nd/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 05:27:42 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[O'Reiilly]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[OSCON]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[webcasts]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/07/20/open-source-language-roundtable-webcast-wednesday-july-22nd/</guid>
		<description><![CDATA[
O’Reilly’s conference on Open Source, OSCON, takes place this week in San Jose, California. One of the events taking place at OSCON is the Open Source Language Roundtable, the abstract for which appears below:
We all have our favorite languages in our tool-belt, but is there a &#8216;best&#8217; overall language? If anyone can hash that out, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://www.oreillynet.com/pub/e/1386"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="oscon_language_roundtable" border="0" alt="oscon_language_roundtable" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/07/oscon_language_roundtable.jpg" width="403" height="496" /></a></p>
<p>O’Reilly’s conference on Open Source, <strong><a href="http://conferences.oreilly.com/oscon">OSCON</a></strong>, takes place this week in San Jose, California. One of the events taking place at OSCON is the <strong><a href="http://www.oreillynet.com/pub/e/1386">Open Source Language Roundtable</a></strong>, the abstract for which appears below:</p>
<blockquote><p>We all have our favorite languages in our tool-belt, but is there a &#8216;best&#8217; overall language? If anyone can hash that out, it will be the members of this roundtable discussion, some of the stars of the open source language space. This wide-ranging session, hosted and moderated by the O&#8217;Reilly Media editorial staff, and broadcast live on the web, will try to identify the best and worst features of each language, and which are best for various types of application development.</p>
</blockquote>
<p>The roundtable will me moderated by O’Reilly Media’s James Turner and will cover the following languages, listed below with the corresponding panelist:</p>
<ul>
<li><strong>Java:</strong> Rod Johnson (SpringSource)</li>
<li><strong>Perl:</strong> Jim Brandt (Perl Foundation)</li>
<li><strong>PHP:</strong> Laura Thomason (Mozilla)</li>
<li><strong>Python:</strong> Alex Martelli (Google)</li>
<li><strong>Ruby:</strong> Brian Ford (Engine Yard)</li>
</ul>
<p><strong>You can catch this roundtable even if you’re not going to be at OSCON because O’Reilly is webcasting the event.</strong> It takes place this Wednesday, July 22nd at 10pm EDT (7 pm Pacific) and is expected to run 90 minutes. It costs nothing to catch the webcast and you’ll even be able to ask the panelists questions via chat, but you’ll need to <a href="http://post.oreilly.com/rd/9z1z95hii30q4hc8e9c5r74c4s1cl6b97qsp4ivvp0o">register</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/07/20/open-source-language-roundtable-webcast-wednesday-july-22nd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LearnHub: Powered by Rails, Searches with Bing</title>
		<link>http://www.globalnerdy.com/2009/06/29/learnhub-powered-by-rails-searches-with-bing/</link>
		<comments>http://www.globalnerdy.com/2009/06/29/learnhub-powered-by-rails-searches-with-bing/#comments</comments>
		<pubDate>Mon, 29 Jun 2009 15:35:07 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software and Services]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[APIs]]></category>
		<category><![CDATA[Bing]]></category>
		<category><![CDATA[interoperability]]></category>
		<category><![CDATA[John Philip Green]]></category>
		<category><![CDATA[LearnHub]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[search engines]]></category>
		<category><![CDATA[Wesley Moxam]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/06/29/learnhub-powered-by-rails-searches-with-bing/</guid>
		<description><![CDATA[This article also appears in Canadian Developer Connection.
Introducing LearnHub
LearnHub&#8217;s home page.
If you’re a student applying to colleges and universities and are looking for help with the process, you should try LearnHub. Based in Toronto, LearnHub is a social learning network that helps students to prepare for standardized tests, assists with finding places to study abroad [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="alert"><a href="http://blogs.msdn.com/cdndevs/archive/2009/06/29/learnhub-powered-by-rails-searches-with-bing.aspx">This article also appears in <em>Canadian Developer Connection</em>.</a></p>
<h3>Introducing LearnHub</h3>
<p align="center"><a href="http://learnhub.com/"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="learnhub_home_page" border="0" alt="learnhub_home_page" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_home_page2.jpg" width="600" height="372" /></a><em>LearnHub&#8217;s home page.</em></p>
<p><strong>If you’re a student applying to colleges and universities and are looking for help with the process, you should try <a href="http://learnhub.com/">LearnHub</a>.</strong> Based in Toronto, LearnHub is a social learning network that helps students to prepare for standardized tests, assists with finding places to study abroad and provides career counseling. LearnHub’s site has hundreds of thousands of pages of free content, including the world&#8217;s largest bank of questions that appear in the GMAT and SAT standardized tests. The site has a large following among students worldwide, particularly in India, and has partnerships with 25 universities to recruit domestic and international students.</p>
<p><a href="http://learnhub.com/"><img style="border-right-width: 0px; margin: 0px 0px 10px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="learnhub" border="0" alt="learnhub" align="right" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub1.jpg" width="240" height="116" /></a></p>
<p>With those hundreds of thousands of pages, LearnHub needed to provide a way for students to find what they’re looking for. <strong>They provide a search function, and it’s powered by <a href="http://bing.com/">Bing</a>.</strong></p>
<p><strong>The people at LearnHub are part of that sector of Toronto tech that’s into Ruby on Rails, open source and founding startups.</strong> Founders <a href="http://married-inc.com/">John Philip Green and Malgosia Green</a> are a husband-and-wife team who are known for building web applications for education and have been active members of Toronto’s tightly-knit open source tech community since the earliest <a href="http://democamp.com/">DemoCamps</a>. John caught <a href="http://rubyonrails.org/">Rails</a> fever after trying it out and decided to rewrite a major application using it. The core development team of <a href="http://learnhub.com/users/wmoxam">Wesley Moxam</a>, <a href="http://heycarsten.com/">Carsten Nielsen</a> and <a href="http://blog.libinpan.com/">Libin Pan</a> are fixtures of the local Toronto’s on Rails scene; a gathering of local Rubyists doesn’t feel complete without them.</p>
<p>So what are they doing, using Bing?</p>
<h3>Site-Wide Search</h3>
<p align="center"><a href="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_dev_management_team2.jpg"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="learnhub_dev_management_team" border="0" alt="learnhub_dev_management_team" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_dev_management_team_thumb1.jpg" width="600" height="450" /></a><em>The main room at LearnHub’s offices. Management are to the left, developers to the right.</em></p>
<p><strong>In the beginning, they went with their first instinct, which was to use Google.</strong> “We launched in March 2008,” said co-founder John Philip Green, “and we needed to provide site-wide search, so we went with Google. We signed up, and for a few hundred bucks a year, we got a search function that covered about 5,000 pages. It seemed like a pretty big number, and we thought that would be more than enough to cover our site.”</p>
<p><strong>They soon found that the results weren’t what they expected.</strong> “We weren’t getting good results. We’d use our site-wide search to search for something that we knew was in our site, and it wouldn’t show up in the results.” The same search would work just fine if you did it from Google.com, but not from their Google-powered search function. “The results just weren’t relevant, and we also had a limited number of queries,” John said.</p>
<p align="center"><a href="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_management_dev_team2.jpg"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="learnhub_management_dev_team" border="0" alt="learnhub_management_dev_team" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_management_dev_team_thumb1.jpg" width="600" height="450" /></a><em>The main room at LearnHub’s offices. That’s management in the foreground, developers in the back.</em></p>
<p><strong>LearnHub’s page count grew quickly and beyond the 5,000 pages covered by their arrangement with Google.</strong> “Going up to a bigger package was expensive;” John said, “it would have cost a couple thousand for 50,000 pages, and we were already at hundreds of thousands.”</p>
<p>“We could’ve gotten the functionality for free, but that’s only an option when you show ads in the search results, and the ads that showed up were for our competitors.”</p>
<p align="center"><a href="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_sales_team2.jpg"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="learnhub_sales_team" border="0" alt="learnhub_sales_team" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_sales_team_thumb1.jpg" width="600" height="450" /></a><em>LearnHub&#8217;s sales team.</em></p>
<p><strong>There was another problem: Google’s site search returned its results as a web page.</strong> In order to make LearnHub’s site-wide search’s results page have the same look and feel as the rest of the site, they had to stick the Google results in an iframe. “And even then, what was inside the iframe didn’t match the rest of the page,” added John.</p>
<p><strong>They started looking at other options for implementing LearnHub’s site-wide search, including running their own spider.</strong> “We really didn’t want to do that,” said programmer Wesley Moxam.</p>
<h3>Enter Bing</h3>
<p align="center"><strong><a href="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/wes_moxam2.jpg"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="wes_moxam" border="0" alt="wes_moxam" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/wes_moxam_thumb1.jpg" width="450" height="600" /></a></strong><em>LearnHub developer Wesley Moxam.</em></p>
<p><strong>While looking around at search options, Wesley found the Live Search API, which is now known as the <a href="http://msdn.microsoft.com/en-us/library/dd251056.aspx">Bing API</a>.</strong> “It was free, well-designed and spits out JSON,” he said. “Google requires a JavaScript interface or SOAP, and SOAP libraries in Ruby are painful.”</p>
<p>“It took a day to implement and get it up and running,” said Wesley, “The entire switch-over project happened over three days, with us working on it on and off, while we were doing other tasks. Best of all, we get consistent results – the results from the API are the same results you’d get if you just used the Bing site.”</p>
<p><strong>“Bing’s API is simple and straightforward. You call it, you get the results, you take those results and use them how you like,”</strong> he continued. “It’s good. It’s hard to explain good software; good software is inherently simple.”</p>
<p>Here’s a screenshot of a LearnHub search results page for the search term “accordion” – and yes, the word appears on a handful of Learnhub pages!</p>
<p align="center"><a href="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_search_results_page.jpg"><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="LearnHub search results page for the search term &quot;accordion&quot;" border="0" alt="LearnHub search results page for the search term &quot;accordion&quot;" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/learnhub_search_results_page_thumb.jpg" width="600" height="350" /></a><em> LearnHub’s search results page for the term “accordion”.</em></p>
<p>LearnHub have benefited from using Bing to power their site-wide search, and they’ve decided to share the wealth. <strong>Wesley’s working on refactoring the Ruby library he wrote to act as a wrapper for the Bing API and open source it for anyone to use.</strong> It should be available later this summer. He’ll announce it when it’s released, and I’ll announce it here.</p>
<h3>The Bing API</h3>
</p>
<p><a href="http://bing.com/developers"><img style="border-right-width: 0px; margin: 0px 0px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Bing logo" border="0" alt="Bing logo" align="right" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/bing2.jpg" width="250" height="96" /></a></p>
<p>It’s easy to harness the power of Bing in your applications, whether for desktop, web or mobile.</p>
<p><strong>The first step is to <a href="http://www.bing.com/developers/createapp.aspx">get an AppID</a>,</strong> which is a string that uniquely identifies you as a registered Bing application developer. Go to the <a href="http://bing.com/developers/">Bing Developer Center</a>, sign in with your Windows Live ID (which you can get for free) and follow the link to created a new AppID. You’ll be asked to supply some very basic information about your application and to review the Bing API’s Terms of Use. If you provide the information and agree to the <a href="http://www.bing.com/developers/tou.aspx">Terms of Use</a> (which I summarize in plain English below), you&#8217;ll get an AppID.</p>
<p><strong>Once you have an AppID, you can start experimenting right away with the Bing API.</strong> All you need to do is start typing URLs with the format below into your browser’s address bar:</p>
</p>
<pre><code>http://api.search.live.net/xml.aspx?AppID=<em><strong>&lt;AppID&gt;</strong></em>&amp;query=<em><strong>&lt;SearchTerms&gt;</strong></em>&amp;sources=<em><strong>&lt;SourceTypes&gt;</strong></em></code></pre>
</p>
<p>where:</p>
<ul>
<li><strong><code>&lt;AppID&gt;</code></strong> is the AppID assigned to you </li>
<li><strong><code>&lt;SearchTerms&gt;</code></strong> are your urlencoded search terms </li>
<li><strong><code>&lt;SourceTypes&gt;</code></strong> specifies the type(s) of search results you want. The different sourcetypes are explained in the table below: </li>
</ul>
<table border="1" cellspacing="3" cellpadding="3" width="600">
<tbody>
<tr>
<td valign="top" width="114"><strong>SourceType</strong></td>
<td valign="top" width="286"><strong>Description</strong></td>
<td valign="top" width="200"><strong>Example Search Terms</strong></td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>Web</code></strong></td>
<td valign="top" width="286">Searches for web content</td>
<td valign="top" width="200">accordion – returns web pages containing the term “accordion”</td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>Image</code></strong></td>
<td valign="top" width="286">Searches for images on the web</td>
<td valign="top" width="200">accordion – returns images of accordions</td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>News</code></strong></td>
<td valign="top" width="286">Searches news stories</td>
<td valign="top" width="200">accordion – returns news articles about accordions</td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>InstantAnswer</code></strong></td>
<td valign="top" width="286">Searches Encarta online</td>
<td valign="top" width="200">what is an accordion – returns the definition of “accordion” </p>
<p>convert 1.6 kilometres to miles – returns “0.9941939 miles” </p>
<p>sin(30 degrees) – returns “0.5”</td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>Spell</code></strong></td>
<td valign="top" width="286">Searches Encarta Dictionary for spelling suggestions</td>
<td valign="top" width="200">accordi<strong><em>a</em></strong>n – returns “accordi<strong><em>o</em></strong>n”&#160; </td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>Phonebook</code></strong></td>
<td valign="top" width="286">Searches phonebook entries</td>
<td valign="top" width="200">accordions in Toronto – returns location results for “accordions in Toronto”</td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>RelatedSearch</code></strong></td>
<td valign="top" width="286">Returns query strings most similar to yours</td>
<td valign="top" width="200">accordion – returns results like “{piano accordion; button accordion; accordion store}”</td>
</tr>
<tr>
<td valign="top" width="114"><strong><code>Ad</code></strong></td>
<td valign="top" width="286">Returns advertisements to incorporate with results (use this to make money with you Bing-powered application)</td>
<td valign="top" width="200">accordion – returns ads relevant to the keyword “accordion”</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>The default format for results is XML, and that’s the format you get when typing in API calls in your browser. You can also have the results returned as JSON or SOAP if you prefer.</p>
<p>You can find out more about the Bing API in the <a href="http://msdn.microsoft.com/en-us/library/dd251056.aspx">Bing API section of MSDN</a>.</p>
<h3>Bing’s Terms of Use, Explained as Simply as Possible</h3>
<p><strong>Here’s a quick explanation of Bing’s Terms of Use for those of us without a law degree.</strong> It’s adapted from the Bing documentation and provides a quick summary of what application developers using the Bing API must do and cannot do (besides the obvious &quot;I promise not to use the API to plan a terrorist attack, run a drug smuggling ring or help the band Nickelback take forceful despotic rule of planet Earth&quot;).</p>
<p><strong>What you must do:</strong></p>
<ul>
<li>You must display all the results you request. No filtering! </li>
<li>You must display your results in the context of a user-facing application or website. </li>
<li>You must display attribution to Bing in a manner compliant with our branding rules. Currently, you may determine the specific manner in which you display attribution. A link to <a href="http://www.live.com">http://www.live.com</a> with the query echo is a suggested example. </li>
<li>You must restrict your usage to <strong>less than 7 queries per second per IP address</strong>. You may be permitted to exceed this limit under some conditions, but this must be approved through discussion with the folks at <a href="mailto:api_tou@microsoft.com">api_tou@microsoft.com</a>. </li>
<li>If you interleave data from any source other than the API with data from the API, you must clearly<br />
    <br />differentiate the respective sources. (Yes, you can interleave Bing results with other data!) </li>
</ul>
<p><strong>What you cannot do:</strong></p>
<ul>
<li>You cannot use API results for search engine optimization (SEO). In particular, using the API for rank checks is explicitly prohibited. </li>
<li>You cannot display advertisements in positions other than the mainline and sidebar. </li>
<li>You cannot change the order of the results the API returns from a SourceType other than <code>Web</code>. (In other words, you <em>can</em> re-order results from standard searches for web pages!) </li>
</ul>
<h3>Bing Your Apps!</h3>
<p>From there, the sky’s the limit. The Bing API is very straightforward and easy to use, it costs nothing to use it, and as someone who’s been using Bing as his default search engine since its beta period, the results it provides are great. Go forth and Bing your apps!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/06/29/learnhub-powered-by-rails-searches-with-bing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The &#8220;employment.nil?&#8221; Ruby Job Fair</title>
		<link>http://www.globalnerdy.com/2009/06/09/the-employmentnil-ruby-job-fair/</link>
		<comments>http://www.globalnerdy.com/2009/06/09/the-employmentnil-ruby-job-fair/#comments</comments>
		<pubDate>Wed, 10 Jun 2009 01:26:33 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[What Joey Did]]></category>
		<category><![CDATA[Community]]></category>
		<category><![CDATA[Pete Forde]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Unspace]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=3605</guid>
		<description><![CDATA[
One of the pillars of the Toronto developer scene is the Ruby/Rails community. They’re an active, engaged, hard-working bunch who work without the direct benefit of a large organization like The Empire or its resources (they do, through people like Yours Truly and Nik Garkusha, Microsoft Canada’s open source go-to guy, get some indirect support). [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="employment_nil_floor" border="0" alt="employment_nil_floor" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/employment-nil-floor.jpg" width="600" height="450" /></p>
<p><strong>One of the pillars of the Toronto developer scene is the Ruby/Rails community.</strong> They’re an active, engaged, hard-working bunch who work without the direct benefit of a large organization like <a href="http://microsoft.com/">The Empire</a> or its resources (they do, through people like Yours Truly and <a href="http://twitter.com/nik_g">Nik Garkusha</a>, Microsoft Canada’s open source go-to guy, get some <em>indirect</em> support). They – through the efforts of people like Pete Forde and the Ruby local heroes at <a href="http://unspace.ca/">Unspace</a> – know how to maximize grassroots organization and harness them into industry-leading events like last year’s <a href="http://rubyfringe.com/">RubyFringe</a> and the upcoming <a href="http://futureruby.com/">FutureRuby</a> conference.</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="meghann_and_pete" border="0" alt="meghann_and_pete" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/meghann-and-pete.jpg" width="450" height="600" /></p>
<p><strong>It should therefore not be a surprise that when Pete and company got the idea to help out their fellow Ruby developers during the econopocalypse with a job fair – <em><a href="http://rubyjobfair.ca/">employment.nil?</a></em> &#8212; they’d take the standard techie job fair formula, turn it upside down and make it their very own.</strong> They chose the Gladstone Hotel in Toronto’s hip <a href="http://westqueenwest.ca/">West Queen West neighbourhood</a>, which is better known as a venue for karaoke, rock bands and burlesque (in fact, I’ve performed in all three kinds of shows there) than for computer and IT-related employment fairs.</p>
<p>&#160;<img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="unspace" border="0" alt="unspace" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/unspace.jpg" width="600" height="450" /></p>
<p><strong>This was <em>not</em> your typical job fair.</strong> It didn’t have any of the fancy display stands that you normally see on the exhibition floor at tech conferences. Instead, both job-seekers and small companies were told to build poster board displays, a la high school science fairs. </p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="shindig" border="0" alt="shindig" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/shindig.jpg" width="600" height="450" /></p>
<p><strong>Another rule: <em>no computers allowed!</em></strong> Even iPhone apps were considered “cheating”. The closest you were allowed to get was using whiteboards or pen and paper for “live coding”. This wasn’t about staring at computer screens, but people talking to other people – people who were passionate about the Ruby programming language and its associated frameworks, libraries and communities. </p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="postrank" border="0" alt="postrank" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/postrank.jpg" width="600" height="450" /></p>
<p><strong>An excerpt from <a href="http://rubyjobfair.eventbrite.com/">the sign-up page for <em>employment.nil?</em></a>:</strong></p>
<blockquote><p>Let&#8217;s face it: it&#8217;s better to be a Ruby developer than a car manufacturer in 2009, but things have definitely slowed down — for everyone. And yet, there are solid reasons why this is an excellent time to start new projects, launch companies, and create new markets. By definition, Ruby has been adopted by creative individuals that grew frustrated with risk averse bureaucracies.</p>
<p>We believe that there are huge number of opportunities to be found during this economic downturn, both for freelance developers and aspiring entrepreneurs alike. As with most tragic historical near-misses, there are just a huge number of connections that aren&#8217;t made even in our own collective back yard.</p>
</blockquote>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="terry_smith" border="0" alt="terry_smith" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/terry-smith.jpg" width="600" height="450" /></p>
<p><strong>More from the job fair’s site:</strong></p>
<blockquote><p>That said, we also believe that Ruby people are determined self-starters that aren&#8217;t afraid to self-promote. Anything worth doing in life requires hard work and sacrifice. Sadly, while many developers are patient and willing to think orthogonally, we rarely get an opportunity to practice the other more social skills which make us desirable as team members, project managers, and co-founders. Unless we overcome our shyness and learn to speak eloquently about our experience and skill sets, we have nobody to blame for our work prospects but ourselves.</p>
<p>Our solution is to gather students, developers, development companies, and of course project leaders and company founders for a good old-fashioned career fair. </p>
</blockquote>
<p>As you can see from the photos, there were different kinds of booths set up. There were those for companies looking to hire some Ruby developers…</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="mulder_consulting" border="0" alt="mulder_consulting" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/mulder-consulting.jpg" width="600" height="450" /></p>
<p>and those deidicated to showcasing some interesting application of Ruby, such as lojacking iPhones:</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="tony_thompson" border="0" alt="tony_thompson" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/tony-thompson.jpg" width="600" height="450" /></p>
<p>…or <a href="http://hacklab.to/">HacklabTO’s</a> own Jed Smith showing how we harness Ruby to drive our laser (yes, we’ve got a laser etcher/cutter!):</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="ruby_laser_awesome" border="0" alt="ruby_laser_awesome" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/ruby-laser-awesome.jpg" width="600" height="450" />&#160;</p>
<p>And some booths were set up by Ruby programmers showcasing their own work and who were looking for a job:</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="talha_syed_1" border="0" alt="talha_syed_1" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/talha-syed-1.jpg" width="600" height="450" /></p>
<p>&#160;<img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="talha_syed_2" border="0" alt="talha_syed_2" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/talha-syed-2.jpg" width="600" height="450" /></p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="dan_mcgrady" border="0" alt="dan_mcgrady" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/dan-mcgrady.jpg" width="600" height="450" /></p>
<p>The event wasn’t just noticed by the Ruby community, who filled the room throughout the 11 a.m. to 6 p.m. course of the event. <strong>Late in the afternoon, Ontario’s Minister of Small Business and Consumer Services, <a href="http://www.hstakhar.com/">Harinder S. Takhar</a>, paid a visit to the job fair.</strong></p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="meghann_pete_minister" border="0" alt="meghann_pete_minister" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/meghann-pete-minister.jpg" width="600" height="450" /></p>
<p>Pete, ever the gracious event curator, took Mr. Takhar to several booths, introducing him to their owners, who were only too happy to show the Minister their Ruby-related work. Here’s <a href="http://www.shindigital.com/">Andrew Burke of Shindig</a>, showing him the projects he’s taking on in his independent software consultancy:</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="andrew_minister" border="0" alt="andrew_minister" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/andrew-minister.jpg" width="450" height="600" /></p>
<p>Here’s <a href="http://twitter.com/kieran">Kieran Huggins</a> showing Mr. Takhar his work in <a href="http://myttc.ca/">MyTTC.ca</a>: </p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="minister_kieran" border="0" alt="minister_kieran" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/minister-kieran.jpg" width="600" height="450" /></p>
<p>I’m sure that grassroots high-tech events with a strong “indie” aesthetic are outside the Minister’s everyday experience, but he seemed pretty impressed with the event: a dedicated group of nerds building software and careers using only laptops, stuff you can download for free and their brain cells.</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="minister_presentation" border="0" alt="minister_presentation" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/minister-presentation.jpg" width="450" height="600" /></p>
<p>Here’s Pete explaining the local Ruby developer scene and the concept of open source software to Mr. Takhar:</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="pete_minister" border="0" alt="pete_minister" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/pete-minister.jpg" width="600" height="450" /></p>
<p>And here’s Mr. Takhar presenting Pete with an award of recognition for Unspace for putting the event together. At that point, I broke out the accordion and played <em>For He’s a Jolly Good Fellow</em>, partly for the Minister for showing up on a Saturday afternoon, but partly for Pete for putting the event together.</p>
<p>&#160;<img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="pete_minister_certificate" border="0" alt="pete_minister_certificate" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/pete-minister-certificate.jpg" width="450" height="600" /></p>
<p>Here’s a close-up of the award:</p>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="award_of_recognition" border="0" alt="award_of_recognition" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/award-of-recognition.jpg" width="600" height="800" /></p>
<p>It reads:</p>
<blockquote><p>Award of Recognition</p>
<p>On behalf of the Government of Ontario,      <br />I am delight to extend my congratulations on the       <br />Employment.nil?       <br />First Toronto Ruby Job Fair</p>
<p>Unspace Interactive Inc.</p>
<p>Our government recognizes the importance of new and creative opportunities for      <br />business. Building a business requires vision and dedication. I applaud your work and       <br />success in web consulting through your team of industry-leading developers and       <br />designers under one roof.</p>
<p>Please accept my best wishes for continued success.</p>
<p>Harinder S. Takhar      <br />Minister of Small Business and Consumer Services       <br />June 06, 2009</p>
</blockquote>
<p>Congratulations to Pete, Meghann Millard, all the folks from Unspace and the Toronto Ruby community on a job well done!</p>
<h3>The Photo Gallery</h3>
<p><a href="http://www.flickr.com/photos/accordionguy/sets/72157619407493507/">I took a lot of photos at <strong><em>employment.nil?</em></strong> and shared them in a Flickr photoset</a>, which you can also view in the slideshow below:</p>
<p align="center"><iframe height="600" src="http://www.flickr.com/slideShow/index.gne?group_id=&amp;user_id=37996580467@N01&amp;set_id=72157619407493507&amp;tags=Ruby,Rails,jobfair,Toronto" frameborder="0" width="600" scrolling="no" align="center"></iframe>    <br /><small>Created with <a title="Admarket.se" href="http://www.admarket.se">Admarket&#8217;s</a> <a title="flickrSLiDR" href="http://flickrslidr.com">flickrSLiDR</a>.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/06/09/the-employmentnil-ruby-job-fair/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>&#8220;employment.nil&#8221;</title>
		<link>http://www.globalnerdy.com/2009/06/06/employmentnil/</link>
		<comments>http://www.globalnerdy.com/2009/06/06/employmentnil/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 16:49:39 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[What Joey Did]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[employment.nil]]></category>
		<category><![CDATA[job fairs]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[The Flintstones-Jetsons Approach]]></category>
		<category><![CDATA[Unspace]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/06/06/employmentnil/</guid>
		<description><![CDATA[In case you’re:

a programmer who works with the Ruby programming language 
looking for work 
available to get down to Toronto’s “West Queen West” neighbourhood soon 

you might want to do what I’m doing in a couple of minutes (as of this writing): heading down to the Gladstone Hotel (1214 Queen Street West, at Dufferin) to [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://rubyjobfair.ca/"><img style="border-right-width: 0px; margin: 0px 0px 0px 10px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="&quot;employment.nil&quot; poster" border="0" alt="&quot;employment.nil&quot; poster" align="right" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/06/employment-nil.jpg" width="300" height="464" /></a>In case you’re:</p>
<ul>
<li>a programmer who works with the Ruby programming language </li>
<li>looking for work </li>
<li>available to get down to Toronto’s “West Queen West” neighbourhood soon </li>
</ul>
<p>you might want to do what I’m doing in a couple of minutes (as of this writing): heading down to the <a href="http://www.gladstonehotel.com/">Gladstone Hotel</a> (<a href="http://www.bing.com/maps/default.aspx?v=2&amp;FORM=LMLTCP&amp;cp=43.642539~-79.426774&amp;style=r&amp;lvl=16&amp;tilt=-90&amp;dir=0&amp;alt=-1000&amp;phx=0&amp;phy=0&amp;phscl=1&amp;where1=1214%20Queen%20Street%20West%2C%20Toronto%20ON&amp;encType=1">1214 Queen Street West</a>, at Dufferin) to get a look at <strong><a href="http://rubyjobfair.ca/">employment.nil</a></strong>, which bills itself as “the first Toronto Ruby job fair”.</p>
<p>Organized by the fine folks at <a href="http://unspace.ca/">Unspace</a>, who are also organizing the upcoming <a href="http://futureruby.com/">FutureRuby</a> conference and <a href="http://failcampto.eventbrite.com/">FailCamp</a> (where I’ll be the MC), employment.nil isn’t your typical computer programmer job fair. <strong>No computers are allowed!</strong> They’re going to be strict about it – even the use of iPhone applications is <em>verboten</em>. Bring printouts of your resume and some scratch paper to do “live coding”. I’m going to bring my mini-whiteboard and dry-erase markers.</p>
<p>See you there!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/06/06/employmentnil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;employment.nil&#8221; &#8211; The Toronto Ruby Job Fair</title>
		<link>http://www.globalnerdy.com/2009/05/29/employmentnil-the-toronto-ruby-job-fair/</link>
		<comments>http://www.globalnerdy.com/2009/05/29/employmentnil-the-toronto-ruby-job-fair/#comments</comments>
		<pubDate>Fri, 29 May 2009 06:01:23 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[employment]]></category>
		<category><![CDATA[job fairs]]></category>
		<category><![CDATA[Pete Forde]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Unspace]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/05/29/employmentnil-the-toronto-ruby-job-fair/</guid>
		<description><![CDATA[ 
If programming in Ruby is your thing and you’re looking for work or workers, you should mark Saturday, June 6th on your calendar. That’s when employment.nil, Toronto’s first Ruby job fair, takes place at the Gladstone Hotel.
Organized by Pete Forde and the folks at Unspace – the local Ruby heroes behind things like the [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://rethink.unspace.ca/2009/5/14/ruby-job-fair"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="employment_nil" border="0" alt="employment_nil" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/05/employment-nil.jpg" width="400" height="262" /></a> </p>
<p>If programming in Ruby is your thing and you’re looking for work or workers, you should mark <strong>Saturday, June 6th</strong> on your calendar. That’s when <strong><a href="http://rethink.unspace.ca/2009/5/14/ruby-job-fair">employment.nil</a></strong>, Toronto’s first Ruby job fair, takes place at the Gladstone Hotel.</p>
<p>Organized by <a href="http://www.peteforde.com/">Pete Forde</a> and the folks at <a href="http://unspace.ca/">Unspace</a> – the local Ruby heroes behind things like the <a href="http://futureruby.com/">FutureRuby</a> conference – employment.nil is an old-school job fair for Ruby programmers. In fact, it’s so old-school that <strong><em>no computers of any kind are allowed.</em></strong> If you’re looking for work, bring printouts of your code and be ready to write out ideas with pen and paper. If you’re looking for people to work for you, you can set up a booth, grade school science fair-style.</p>
<p>Want to find out more? <strong><a href="http://rethink.unspace.ca/2009/5/14/ruby-job-fair" target="_blank">Check out the employment.nil article in <em>Rethink</em>, Unspace’s blog.</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/05/29/employmentnil-the-toronto-ruby-job-fair/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Named Parameters in Method Calls: Python Si, Ruby No</title>
		<link>http://www.globalnerdy.com/2009/03/16/named-parameters-in-method-calls-python-si-ruby-no/</link>
		<comments>http://www.globalnerdy.com/2009/03/16/named-parameters-in-method-calls-python-si-ruby-no/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 04:00:00 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[named arguments]]></category>
		<category><![CDATA[named parameters. method calls]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/03/16/named-parameters-in-method-calls-python-si-ruby-no/</guid>
		<description><![CDATA[ In an earlier article, Default and Named Parameters in C# 4.0 / Sith Lord in Training, I wrote about how C# 4.0 – that’s the version coming out with the next release of Visual Studio, known as Visual Studio 2010 – is going to provide support for named parameters.
In that article, I also incorrectly [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><img style="border-right-width: 0px; margin: 0px 0px 5px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="&quot;Hello My Name Is&quot; sticker" border="0" alt="&quot;Hello My Name Is&quot; sticker" align="right" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/03/hello-my-name-is-sticker.jpg" width="241" height="206" /> In an earlier article, <em><strong><a href="http://www.globalnerdy.com/2009/03/12/default-and-named-parameters-in-c-40-sith-lord-in-training/">Default and Named Parameters in C# 4.0 / Sith Lord in Training</a></strong></em>, I wrote about how C# 4.0 – that’s the version coming out with the next release of Visual Studio, known as <a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx">Visual Studio 2010</a> – is going to provide support for named parameters.</p>
<p>In that article, I also <em>incorrectly </em>stated that Ruby supported named parameters. Luckily, <a href="http://www.globalnerdy.com/2009/03/12/default-and-named-parameters-in-c-40-sith-lord-in-training/#comment-3982">Jörg W Mittag spotted my mistake an corrected me in a comment</a>. I’ve since corrected the article and thought I’d show you how I got it wrong in the first place.</p>
<h3>Ruby and My Named Parameter Goof</h3>
<p>I had a vague recollection of Ruby accepting named parameters. I figured I’d be empirical and fired up <strong>irb</strong> – the Ruby REPL shell – and put together a quick little method to see if the recollection was correct:</p>
<blockquote><pre># Ruby 1.8.6
def test_named_params(first, second)
    puts &quot;#{first}\n#{second}&quot;
end</pre>
</blockquote>
<p>Once put together, I made some test calls to the method:</p>
<blockquote>
<pre>

# irb session (Ruby 1.8.6)
irb(main):&gt; <strong>test_named_params(&quot;alpha&quot;, &quot;beta&quot;)</strong>
alpha
beta

=&gt; nil

irb(main):&gt; <strong>test_named_params(first = &quot;alpha&quot;, second = &quot;beta&quot;)</strong>
alpha
beta

=&gt; nil
</pre>
</blockquote>
<p>Seeing that the interpreter didn’t choke on that named parameter call, I thought to myself “Vague recollection confirmed, Ruby supports named parameters!” and wrote the blog article.</p>
<p>Had my brain actually been firing on all cylinders, I would’ve given the method a proper test by providing the named parameters out of the order in which they appear in the method signature. Here’s what I would’ve seen:</p>
<blockquote>
<pre># irb session (Ruby 1.8.6)
irb(main):&gt; <strong>test_named_params(second = &quot;alpha&quot;, first = &quot;beta&quot;)</strong>
alpha
beta


=&gt; nil

</pre>
</blockquote>
<p>Uh-oh. If named parameters worked, the first output line would be “beta” and the second would be “alpha”. Clearly something’s wrong with my recollection.</p>
<p>Let’s try some <em>non-existent</em> named parameters – say, ones involving current entertainemtn news headlines &#8212; just to see what happens:</p>
<blockquote>
<pre># irb session (Ruby 1.8.6)
irb(main):&gt; <strong>test_named_params(lindsay_lohan_dui = &quot;alpha&quot;,
jim_cramer_smackdown = &quot;beta&quot;)</strong>


alpha

beta

=&gt; nil
</pre>
</blockquote>
<p>Even with nonsensical named parameters, the method is still accepting the values in order. Why is that?</p>
<p>Just about everything in Ruby has a return value (which can be anything, including <code>nil</code>). You can see for yourself in irb – here’s a quick do-nothing method definition:</p>
<blockquote>
<pre>irb(main)&gt; <strong>def doNothing
</strong>irb(main)&gt; <strong>end</strong>
=&gt; nil</pre>
</blockquote>
<p>As you can see. defining a method returns a value of <code>nil</code>. </p>
<p>As Jorg pointed out, Ruby assignment statements return a value: the value used in the assigment. Once again, for proof, I&#8217;ll use an example from an irb session. In the example below, assigning the string <code>&quot;alpha&quot;</code> to the variable <code>first</code> also returns the string <code>&quot;alpha&quot;</code>:</p>
<blockquote>
<pre># irb session (Ruby 1.8.6)
irb(main):&gt; <strong>first = &quot;alpha&quot;</strong>=&gt; &quot;alpha&quot;</pre>
</blockquote>
<p>In the call to <code>test_named_params</code>, the Ruby interpreter was interpreting my “named parameters” as assignment statements. <code>first = &quot;alpha&quot;</code> evaluates to plain old <code>&quot;alpha&quot;</code>, but so does <code>second = &quot;alpha&quot;</code> (and for that matter, so does <code>lindsay_lohan_dui = &quot;alpha&quot;</code>). Each assignment statement in my parameter list was evaluated, and then those values were passed to method in positional order.</p>
<h3>Python Supports Named Parameters</h3>
<p>After getting the comment from Jorg and correcting my article, I wondered why I thought Ruby supported named parameters. Then it hit me – it’s Python.</p>
<p>So I fired up the Python REPL and put together this quick little method:</p>
<blockquote>
<pre># Python 3.0
def test_named_params(first, second):
    print(&quot;%s\n%s&quot; % (first, second))</pre>
</blockquote>
<p>And this time, I decided to be a little more thorough in my testing:</p>
<blockquote>
<pre># Python 3.0 REPL
&gt;&gt;&gt; <strong>test_named_params(&quot;alpha&quot;, &quot;beta&quot;)</strong>
alpha
beta

&gt;&gt;&gt; <strong>test_named_params(first = &quot;alpha&quot;, second = &quot;beta&quot;)</strong>
alpha
beta

&gt;&gt;&gt; <strong>test_named_params(second = &quot;alpha&quot;, first = &quot;beta&quot;)</strong>
beta
alpha</pre>
</blockquote>
<p>And some additional searching on the web confirmed that yes, Python method calling does in fact support named parameters.</p>
<p>So in conclusion, when it comes to named parameters, it’s <em>Python si, Ruby no</em>…and <em>C# <a href="http://dictionary.reverso.net/english-spanish/soon">pronto</a></em>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/03/16/named-parameters-in-method-calls-python-si-ruby-no/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>FutureRuby and Failcamp: Register Now!</title>
		<link>http://www.globalnerdy.com/2009/03/10/futureruby-and-failcamp-register-now/</link>
		<comments>http://www.globalnerdy.com/2009/03/10/futureruby-and-failcamp-register-now/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 20:11:06 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[FAILCamp]]></category>
		<category><![CDATA[FutureRuby]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/03/10/futureruby-and-failcamp-register-now/</guid>
		<description><![CDATA[
Last year, the folks at Unspace held a fantastic Ruby conference called RubyFringe. They took the standard conference format, threw out the stuff they didn’t like, amplified the stuff they loved and kept the attendance down to around Dunbar’s number. The end result: quite possibly the best geek conference I’ve ever attended (a lot of [...]]]></description>
			<content:encoded><![CDATA[<p></p><p><a href="http://futureruby.com/"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="futureruby" border="0" alt="futureruby" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/03/futureruby.jpg" width="600" height="219" /></a></p>
<p><strong>Last year, the folks at </strong><a href="http://unspace.ca/"><strong>Unspace</strong></a><strong> held a fantastic Ruby conference called </strong><a href="http://rubyfringe.com/"><strong>RubyFringe</strong></a><strong>.</strong> They took the standard conference format, threw out the stuff they didn’t like, amplified the stuff they loved and kept the attendance down to around Dunbar’s number. The end result: quite possibly the best geek conference I’ve ever attended (a lot of the other attendees would concur). I wrote quite extensively about RubyFringe in <a href="http://www.globalnerdy.com/2009/02/23/futureruby-july-9th-12th-2009/">this entry</a>, and here are my notes from the conference:</p>
<ul>
<li><a href="http://www.globalnerdy.com/2008/07/20/rubyfringe-day-1-notes-part-1/">Day 1 Notes, Part 1</a> </li>
<li><a href="http://www.globalnerdy.com/2008/07/20/rubyfringe-day-1-notes-part-2/">Day 1 Notes, Part 2</a> </li>
<li><a href="http://www.globalnerdy.com/2008/07/21/rubyfringe-day-2-notes-part-1/">Day 2 Notes, Part 1</a> </li>
<li><a href="http://www.globalnerdy.com/2008/07/22/rubyfringe-day-2-notes-part-2/">Day 2 Notes, Part 2</a> </li>
<li><a href="http://www.globalnerdy.com/2008/07/22/rubyfringe-day-2-notes-part-3/">Day 2 Notes, Part 3</a> </li>
</ul>
<p><strong>This year, they’re holding a slightly different conference called <a href="http://futureruby.com/">FutureRuby</a>.</strong> They’ve described it as bill it as “an opportunity to prepare for the future by learning from the mistakes of the past”, and promise us that it won’t just be RubyFringe warmed over – we shouldn’t expect to find the same things in the same places! Here’s what the <a href="http://futureruby.com/">FutureRuby site</a> says:</p>
<blockquote><p>We are the artists, philosophers, and troublemakers. We realize that the fringe of today is      <br />the mainstream of tomorrow. We grease the engines of progress, even when we&#8217;re working outside of the machine.</p>
<p>FutureRuby isn&#8217;t a Ruby conference, but a conference for Rubyists. This is a call to order &#8211; a congress of the curious characters that drew us to this community in the first place. We have a singular opportunity to express a long-term vision, a future where Ruby drives creativity and prosperity without being dampened by partisan politics.</p>
</blockquote>
<p><strong>FutureRuby runs from Friday, July 10th at 5:00 p.m. and officially end on Sunday, July 12th at around 11:55 p.m..</strong> FutureRuby will also be paired with FailCampTO, which will take place on Thursday, July 9th (I’ll be MCing this event, and I’ll talk more about it in another post).</p>
<p>The early bird tickets for FutureRuby, which sell for CAD$700, are already gone. The regular rate tickets, which sell for CAD$800, are still available, but probably not for long. <strong>If you want to attend FutureRuby, I strongly recommend that you </strong><a href="http://futureruby.eventbrite.com/"><strong>go to the FutureRuby registration page</strong></a><strong> and sign up right now.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/03/10/futureruby-and-failcamp-register-now/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FutureRuby: July 9th &#8211; 12th, 2009</title>
		<link>http://www.globalnerdy.com/2009/02/23/futureruby-july-9th-12th-2009/</link>
		<comments>http://www.globalnerdy.com/2009/02/23/futureruby-july-9th-12th-2009/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 04:50:56 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[FutureRuby]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyFringe]]></category>
		<category><![CDATA[Unspace]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2009/02/23/futureruby-july-9th-12th-2009/</guid>
		<description><![CDATA[First Came RubyFringe

I can’t talk about FutureRuby without first talking about RubyFringe.
Last July, the fine folks at Toronto’s Little Coding Shop That Could – Unspace – created one of the best and most memorable conferences I’ve ever attended: RubyFringe. RubyFringe made its mark by taking the standard geek conference formula and turning it on its [...]]]></description>
			<content:encoded><![CDATA[<p></p><h3>First Came RubyFringe</h3>
<p><a href="http://rubyfringe.com/"><img alt="RubyFringe logo" src="http://www.joeydevilla.com/wordpress/wp-content/uploads/2008/07/rubyfringe.jpg" width="600" height="278" /></a></p>
<p>I can’t talk about <strong><a href="http://rethink.unspace.ca/2009/2/19/future-ruby">FutureRuby</a></strong> without first talking about <a href="http://rubyfringe.com/">RubyFringe</a>.</p>
<p>Last July, the fine folks at Toronto’s Little Coding Shop That Could – <a href="http://unspace.ca/">Unspace</a> – created one of the best and most memorable conferences I’ve ever attended: <strong>RubyFringe</strong>. RubyFringe made its mark by taking the standard geek conference formula and turning it on its head. Among the things that distinguished it were:</p>
<ul>
<li>RubyFringe was intentionally a small conference, with its attendance capped at 150 attendees. </li>
<li>No sponsors! </li>
<li>It had a single conference track, and all presentations took place in the same room. </li>
<li>The presentations were vetted carefully by people who really, really, really loved the Ruby programming language. This meant that we got interesting speakers and no vendor pitches. We felt Damien Katz’ pain when he talked about his situation prior to creating CouchDB, grooved as Nick Sieger talked about the parallels between jazz and programming, and stayed glued to our seats as Giles Bowkett gave us his rousing call to action in his 400-slide extravaganza, even though he’d gone well beyond his allotted time and was cutting into lunch (it was <em>that </em>good). </li>
<li>They didn’t allow questions at the end of the presentations. In organizer Pete Forde’s words: “Our experience has been that questions are hard to hear, generally of poor quality, often just statements, and almost always an exercise in demonstrating how brilliant the questioner is while dominating the attention of the whole room.” </li>
<li>There was a “companion track” for attendees’ non-geeky significant others, where they were taken on a tour of the city while their partners were at the conference. </li>
<li>They served some of the best food I’ve ever had at a developer conference. The lunches were at the Downtown Metropolitan Hotel, and the big dinner at the Drake Hotel was beyond anything I’ve ever had at a developer conference. </li>
<li>The conference also included parties at some of the best spots in the city, some of which you wouldn’t find on vanilla tourist guides. Better yet, those parties were open bar! </li>
<li>Not only was there an opening party at a brewery, complete with stand-up comic, rock band and DJ, but there was a great closing party on Unspace’s roof. </li>
<li>The organizers paid attention to little details that set the conference apart, from giving everyone transit passes to heralding speakers as they walked on stage with the song of the choice to the giant polaroid montage featuring every attendee. </li>
</ul>
<p>The organizers’ decisions in crafting RubyFringe made it a high-quality, memorable and inspiring experience, and its carefully limited scale gave it a sense of community that I could almost describe as familial. </p>
<p>Many people who went declared it the best conference they’d ever attended, and many who passed up the opportunity kicked themselves for missing it. Those pale next to the highest praise for the conference: the fact that after attending RubyFringe, a half-dozen handful of attendees were so inspired that they quit their day jobs to strike out on their own doing Ruby development.</p>
<h3>Now Comes FutureRuby</h3>
<p><img style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" title="FutureRuby comic" border="0" alt="FutureRuby comic" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2009/02/future-ruby-comic.jpg" width="583" height="563" /></p>
<p>With RubyFringe’s resounding success, it was only natural that people would ask if Unspace would be doing it again next year. They gave it some serious thought – the last thing that they wanted to create was a weak sequel. They didn’t want to simply rehash RubyFringe, but <em>reinvent</em> it, just as they had reinvented the developer conference with RubyFringe.</p>
<p>So they reinvented RubyFringe as FutureRuby.</p>
<p>FutureRuby will take place from July 9th through 12th, and will build on what RubyFringe accomplished. The organizers bill it as “an opportunity to prepare for the future by learning from the mistakes of the past”, and promise us that it won’t just be RubyFringe warmed over – we shouldn’t expect to find the same things in the same places!</p>
<p>What else will it have?</p>
<ul>
<li>Parties and nightly entertainment, three nights in a row </li>
<li>FAILCamp (which I co-hosted last year, and which I am invited to host again) is back with a vengeance, and an adorable sailor suit </li>
<li>“More better than” swag that you’ll be proud to wear in public </li>
<li>The return of the companion track for partners and secret lovers during the conference </li>
<li>An amazing two nights of lunches and dinners that you’ll photograph and tweet about </li>
<li>Loving attention to all of the details, like excellent wifi, transit passes, and no paid presentations </li>
</ul>
<p><a href="http://rethink.unspace.ca/2009/2/19/future-ruby">All the details are in this post at Unspace’s blog, <em>Rethink</em>.</a><em></em> You can bet that I’ll be at FutureRuby.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2009/02/23/futureruby-july-9th-12th-2009/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails and Merb Merge!</title>
		<link>http://www.globalnerdy.com/2008/12/23/ruby-on-rails-and-merb-merge/</link>
		<comments>http://www.globalnerdy.com/2008/12/23/ruby-on-rails-and-merb-merge/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 21:47:27 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software and Services]]></category>
		<category><![CDATA[Merb]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[merger]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/2008/12/23/ruby-on-rails-and-merb-merge/</guid>
		<description><![CDATA[The Merb/Rails rivalry could’ve gone as depicted on the cover of the science fiction “classic” shown below…

&#160;
(I think Merb would be the Human Bat and Rails would be the Robot Gangster.)
…but instead, the two projects have merged! The result will be the upcoming Rails 3.
The merger is commemorated on a “plaque” page on the Rails [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>The <a href="http://merbivore.com/">Merb</a>/<a href="http://rubyonrails.org/">Rails</a> rivalry could’ve gone as depicted on the cover of the science fiction “classic” shown below…</p>
<p><img title="the_human_bat_v_the_robot_gangster" style="border-top-width: 0px; display: block; border-left-width: 0px; float: none; border-bottom-width: 0px; margin-left: auto; margin-right: auto; border-right-width: 0px" height="599" alt="the_human_bat_v_the_robot_gangster" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/12/the-human-bat-v-the-robot-gangster.jpg" width="400" border="0" /></p>
<p>&#160;</p>
<p>(I think Merb would be the Human Bat and Rails would be the Robot Gangster.)</p>
<p><a href="http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3">…but instead, the two projects have merged!</a> The result will be the upcoming <strong>Rails 3</strong>.</p>
<p>The merger is commemorated on a “plaque” page on the Rails site titled <a href="http://rubyonrails.org/merb"><strong><em>The Day Merb Joined Rails</em></strong></a>, which I’ve excerpted below:</p>
<blockquote><p><a href="http://www.merbivore.com/">Merb</a> was started two years ago by Ezra Zygmuntowicz as a tiny framework to serve ERb templates from Mongrel. This quickly grew into much more and carved out a niche as an alternative Rails stack. Merbists focused on among other things a small speedy core, being ORM/JavaScript agnostic, and having a rigorous API for extensions.</p>
<p>Along with the expansion in ambition came the fact that Merb and Rails started sharing more and more of the same ideas and even implementation. This lead to a fair amount of unnecessary duplication on both sides of the fence and lead to some paradox of choice. When do I choose one over the other and when?</p>
<h3>Rails 3</h3>
<p>On December 23rd, we decided to end the duplication and the paradox of choice. That was the day we declared our intentions of bringing the best ideas of Merb into Rails 3. That was the day <a href="http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3">we</a> <a href="http://yehudakatz.com/2008/12/23/rails-and-merb-merge/">announced</a> <a href="http://brainspl.at/articles/2008/12/23/merb-is-rails">our</a> <a href="http://merbist.com/2008/12/23/rails-and-merb-merge/">commitment</a> <a href="http://splendificent.com/2008/12/the-merb-rails-merger-announcement-an-inside-opinion/">to</a> work together.</p>
</blockquote>
<p>It’s nice to see this sort of thing happening. It’s more common to see projects forking over the tiniest disagreements, a la <a href="http://www.mwscomp.com/movies/brian/brian-07.htm">“The People’s Front of Judea” in Monty Python’s <em>Life of Brian</em></a><em>:</em></p>
<p style="text-align: center"><embed src="http://www.youtube.com/v/gb_qHP7VaZE&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed> </p>
<p>It’s a win for both projects, as well as the users. Rails gets some much-needed optimization, the ability to shed excess weight for speed, framework agnosticism and an API that won’t break with upgrades, and Merb gets a much bigger development community and mindshare momentum that Rails enjoys. Better still, the merger now has both teams’ big brains working on the same project, and isn’t that what the spirit of the <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> principle is all about?</p>
<p>Congratulations to both the Merb and Rails teams! And hey, congrats to all you Ruby/Rails/Merb developers out there too! 2009 just got a little more interesting for all of us.</p>
<h3>Links</h3>
<ul>
<li><a href="http://rubyonrails.org/merb"><strong>The Rails/Merb Commemorative Merger Page</strong></a> </li>
<li>The Rails Blog: <a href="http://weblog.rubyonrails.org/2008/12/23/merb-gets-merged-into-rails-3"><strong><em>Merb Gets Merged into Rails 3!</em></strong></a> </li>
<li>Yehuda Katz’ blog, <em>Katz Got Tour Tongue?</em>: <strong><em><a href="http://yehudakatz.com/2008/12/23/rails-and-merb-merge/">Rails and Merb Merge</a></em></strong> </li>
<li><em>The Merbist</em>: <a href="http://merbist.com/2008/12/23/rails-and-merb-merge/"><strong><em>Rails and Merb Core Team Working Together on Their Next Release</em></strong></a> </li>
<li><em>Brainspl.at</em>: <a href="http://brainspl.at/articles/2008/12/23/merb-is-rails"><em><strong>Merb *is* Rails</strong></em></a> </li>
<li>Lori Holden’s blog: <strong><em><a href="http://loriholden.com/archives/2008/12/23/16-merb-is-rails-30">Merb is Rails 3.0</a></em></strong> </li>
<li>Tom Mornini’s blog: <strong><em><a href="http://mornini.wordpress.com/2008/12/23/rails-2x-merb-1x-rails-30/">Rails 2.x + Merb 1.x = Rails 3.0!</a></em></strong> </li>
<li><em>Splendificent</em>: <strong><em><a href="http://splendificent.com/2008/12/the-merb-rails-merger-announcement-an-inside-opinion/">The Merb/Rails Merger Announcement, an Inside Opinion</a></em></strong> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/12/23/ruby-on-rails-and-merb-merge/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>My PDC Interviews: Don Box, Miguel de Icaza, John Lam, Phil Haack and .NET Micro Framework</title>
		<link>http://www.globalnerdy.com/2008/11/03/my-pdc-interviews-don-box-miguel-de-icaza-john-lam-phil-haack-and-net-micro-framework/</link>
		<comments>http://www.globalnerdy.com/2008/11/03/my-pdc-interviews-don-box-miguel-de-icaza-john-lam-phil-haack-and-net-micro-framework/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 16:28:31 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Interviews]]></category>
		<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software and Services]]></category>
		<category><![CDATA[What Joey Did]]></category>
		<category><![CDATA[.NET Micro Framework]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Don Box]]></category>
		<category><![CDATA[embedded]]></category>
		<category><![CDATA[IronRuby]]></category>
		<category><![CDATA[John Lam]]></category>
		<category><![CDATA[M]]></category>
		<category><![CDATA[Miguel de Icaza]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Oslo]]></category>
		<category><![CDATA[PDC]]></category>
		<category><![CDATA[PDC2008]]></category>
		<category><![CDATA[Phil Haack]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=2177</guid>
		<description><![CDATA[
A number of people have asked me how many sessions I attended at last week&#8217;s Microsoft Professional Developers Conference; my answer was &#8220;I only attended the keynotes&#8221;. Since every session was recorded on video (with a split screen showing both presenter and presentation) and made available online, I decided to focus on what you can&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p></p><p style="text-align:center;"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/11/pdc2008.jpg" alt="PDC2008 graphic" title="PDC2008 graphic" width="480" /></p>
<p>A number of people have asked me how many sessions I attended at last week&#8217;s <a href="http://microsoftpdc.com/"><strong>Microsoft Professional Developers Conference</strong></a>; my answer was &#8220;I only attended the keynotes&#8221;. Since every session was recorded on video (with a split screen showing both presenter and presentation) and made available online, <strong>I decided to focus on what you can&#8217;t replicate outside the conference: getting to know people in the Windows developer community.</strong></p>
<p>It&#8217;s standard procedure at Microsoft to assign &#8220;buddies&#8221; to new hires to help them get acclimated. I have the very good fortune of having <strong>John Bristowe</strong> as one of my buddies; not only is he a warm and friendly guy, but I also already know him (his sister Ashley and I went to <a href="http://queensu.ca/">Crazy Go Nuts University</a> together). John&#8217;s big on podcasting and was very generous in sharing the interviewer&#8217;s chair; he let me do a lot of interviews as a way to both get podcasting practice and introduce myself to people in the Windows world. Thanks, John!</p>
<p>You&#8217;re going to need <a href="http://silverlight.net/">Silverlight</a> to view these videos. If you&#8217;re rolling your eyes at the prospect of having to download yet another plugin, keep in mind that Silverlight is a pretty cool tool for writing rich internet apps, I&#8217;ll be covering it rather extensively soon, and it&#8217;s catching on. Besides, you can&#8217;t see the videos without it!</p>
<h3>Don Box on My Joining the Dark Side, Demos, Oslo and M, Zombies and How to Pronounce &#8220;Azure&#8221;</h3>
<p style="text-align:center;"><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-a-quick-chat-with-don-box.aspx"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/11/pdc2008_interview_don_box.jpg" alt="Still from Joey deVilla&#039;s interview with Don Box" title="Still from Joey deVilla&#039;s interview with Don Box" width="500" height="296" /></a><br /><span class="caption">Click the picture to see the video of the interview.</span></p>
<p>After introducing myself to Distinguished Engineer (yup, that&#8217;s really his title) <a href="http://www.pluralsight.com/community/blogs/dbox/"><strong>Don Box</strong></a> as &#8220;Microsoft&#8217;s Newest Employee&#8221;, I told him about my coming to Microsoft from the <a href="http://en.wikipedia.org/wiki/Free_and_open_source_software">F/OSS</a> world and asked him to please tell me that I hadn&#8217;t made a tragic mistake and ruined my life by coming over to the Dark Side. We also talked about his preparation process for his keynote demo, <a href="http://msdn.microsoft.com/oslo">the Oslo platform</a> and the M programming platform, the proper way to pronounce &#8220;Azure&#8221; and whether or not Microsoft is ready for the zombie apocalypse.</p>
<h4>Useful Don Box/Oslo Links</h4>
<ul>
<li><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-a-quick-chat-with-don-box.aspx"><strong>Video of my interview with Don Box.</strong></a></li>
<li>Video of Don Box&#8217;s and David Langworthy&#8217;s PDC 2008 presentation, <a href="http://channel9.msdn.com/pdc2008/TL27/"><strong>Oslo: The Language</strong></a>, which introduces the M programming language.</li>
<li>Video of Don Box&#8217;s and Florian Voss&#8217; PDC 2008 presentation, <a href="http://channel9.msdn.com/pdc2008/TL18/"><strong>&#8220;Oslo&#8221;: Customizing and Extending the Visual Design Experience</strong></a>.</li>
<li><a href="http://msdn.microsoft.com/oslo">The Oslo site.</a></li>
<li>If you&#8217;d like to read more about Oslo in Don&#8217;s own words, <a href="http://www.pluralsight.com/community/blogs/dbox/archive/2008/09/06/oslo.aspx">a good place to start is this entry in his blog</a>.</li>
<li>Don&#8217;s blog, <a href="http://www.pluralsight.com/community/blogs/dbox/default.aspx"><cite>Don Box&#8217;s Spoutlet</cite></a>.</li>
</ul>
<h3>Miguel de Icaza on Mono</h3>
<p style="text-align:center;"><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-miguel-de-icaza-on-mono.aspx"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/11/pdc2008_interview_miguel_de_icaza.jpg" alt="Still from Joey deVilla&#039;s interview with Miguel de Icaza" title="Still from Joey deVilla&#039;s interview with Miguel de Icaza" width="500" height="309" /></a><br /><span class="caption">Click the picture to see the video of the interview.</span></p>
<p>I had a great chat with <a href="http://www.mono-project.com/">Mono Project</a> lead <a href="http://tirania.org/blog/"><strong>Miguel de Icaza</strong></a> about Mono, their answer to <a href="http://silverlight.net/">Silverlight</a>, the number of people in the Mono Project and how you, as a Windows developer, can take Mono out for a spin. We also talked about how to pronounce &#8220;Azure&#8221;, and Miguel speculated that the name was a clever choice because the disagreement over its pronunciation is a great way to get people talking about it.</p>
<h4>Useful Miguel de Icaza/Mono Links</h4>
<ul>
<li><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-miguel-de-icaza-on-mono.aspx"><strong>Video of my interview with Miguel de Icaza.</strong></a></li>
<li>Video of Miguel de Icaza&#8217;s PDC 2008 presentation, <a href="http://channel9.msdn.com/pdc2008/PC54/"><strong>Mono and .NET</strong></a>.</li>
<li><a href="http://www.mono-project.com/">The Mono Project&#8217;s site.</a></li>
<li><a href="http://tirania.org/blog/">Miguel de Icaza&#8217;s blog</a>.</li>
</ul>
<h3>John Lam on IronRuby</h3>
<p style="text-align:center;"><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-john-lam-and-ironruby.aspx"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/11/pdc2008_interview_john_lam.jpg" alt="Still from Joey deVilla&#039;s interview with John Lam" title="Still from Joey deVilla&#039;s interview with John Lam" width="500" height="272" /></a><br /><span class="caption">Click the picture to see the video of the interview.</span></p>
<p>It&#8217;s always good to catch up with Toronto-area guy turned Redmond guy and <a href="http://www.ironruby.net/">IronRuby</a> creator <a href="http://www.iunknown.com/"><strong>John Lam</strong></a>. We had a quick chat about IronRuby and the current state of the project. In the interview, he reminds us that IronRuby <em>is</em> an open source project, talks about the Ruby standard implementation tests it&#8217;s currently passing and what to expect from IronRuby in the near future.</p>
<h4>Useful John Lam/IronRuby Links</h4>
<ul>
<li><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-john-lam-and-ironruby.aspx"><strong>Video of my interview with John Lam.</strong></a></li>
<li>Video of John Lam&#8217;s PDC 2008 presentation, <a href="http://channel9.msdn.com/pdc2008/TL44/"><strong>IronRuby: The Right Language for the Right Job</strong></a>.</li>
<li><a href="http://www.ironruby.net/">The IronRuby site</a>.</li>
<li><a href="http://poignantguide.net/ruby/"><cite>Why&#8217;s (Poignant) Guide to Ruby</cite></a> &#8212; the most whimsical introduction to a programming language, ever!</li>
<li>John Lam&#8217;s blog, <a href="http://www.iunknown.com/"><cite>John Lam on Software</cite></a>.</li>
</ul>
<h3>Phil Haack on ASP.NET MVC</h3>
<p style"text-align:center;"><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-you-ve-been-phil-haack-ed.aspx"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/11/pdc2008_interview_phil_haack.jpg" alt="Still from Joey deVilla&#039;s interview with Phil Haack" title="Still from Joey deVilla&#039;s interview with Phil Haack" width="500" height="295" /></a><br /><span class="caption">Click the picture to see the video of the interview.</span></p>
<p><a href="http://haacked.com/"><strong>Phil Haack</strong></a> not only has the coolest surname for a techie, he&#8217;s also got an MVC framework for ASP.NET, just like the ones the Rails, Django and Cake people get to play with. In this interview, we talk about MVC web frameworks for the uninitiated, as well as get his take on how to pronounce &#8220;Azure&#8221;.</p>
<h4>Useful Phil Haack/ASP.NET MVC Links</h4>
<ul>
<li><a href="http://blogs.msdn.com/cdndevs/archive/2008/10/30/canucks-at-pdc-you-ve-been-phil-haack-ed.aspx"><strong>Video of my interview with Phil Haack.</strong></a></li>
<li>Video of Phil Haack&#8217;s PDC 2008 presentation, <a href="http://channel9.msdn.com/pdc2008/PC21/"><strong>ASP.NET MVC: A New Framework for Building Web Applications</strong></a>.</li>
<li><a href="http://www.asp.net/mvc/">The official ASP.NET MVC site</a>.</li>
<li>Phil Haack&#8217;s blog, <a href="http://haacked.com/"><cite>You&#8217;ve Been HAACKED</cite></a>.</li>
</ul>
<h3>.NET Micro Framework</h3>
<p style="text-align:center;"><a href="http://blogs.msdn.com/cdndevs/archive/2008/11/01/canucks-at-pdc-net-micro-framework.aspx"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/11/pdc2008_interview_net_micro_framework.jpg" alt="Still from Joey deVilla&#039;s &quot;.NET Micro Framework&quot; interview" title="Still from Joey deVilla&#039;s &quot;.NET Micro Framework&quot; interview" width="500" height="293" /></a><br /><span class="caption">Click the picture to see the video of the interview.</span></p>
<p>Believe it or not, there&#8217;s a .NET framework for embedded devices, the <a href="http://msdn.microsoft.com/en-us/embedded/bb267253.aspx"><strong>.NET Micro Framework</strong></a>. In this interview, I learn about .NET programming for small devices, the <a href="http://dreamdifferentcontest.com/">&#8220;Dare to Dream Different&#8221; contest</a> (where you can win great prizes for coming up with new applications for the .NET Micro Framework) and about what donuts have to do with microcontrollers. <em>Mmm&#8230;donuts!</em></p>
<h4>Useful .NET Micro Framework Links</h4>
<ul>
<li><a href="http://blogs.msdn.com/cdndevs/archive/2008/11/01/canucks-at-pdc-net-micro-framework.aspx"><strong>Video of my .NET Micro Framework interview.</strong></a></li>
<li><a href="http://dreamdifferentcontest.com/">The &#8220;Dare to Dream Different&#8221; contest site.</a></li>
<li><a href="http://msdn.microsoft.com/en-us/embedded/bb267253.aspx">The .NET Micro Framework site</a>.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/11/03/my-pdc-interviews-don-box-miguel-de-icaza-john-lam-phil-haack-and-net-micro-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Notes from Ruby on Rails Project Night</title>
		<link>http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/</link>
		<comments>http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 21:37:50 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[Creative]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Rich Media Institute]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby/Rails Project Night]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=1567</guid>
		<description><![CDATA[It&#8217;s Back!
Last Friday marked the return of Ruby on Rails Project Night, a Toronto-based event where developers who worked on Ruby and Rails projects could do in-depth presentations on their current projects or ideas. It was on hiatus for the past couple of months (you can see this entry for the definition of &#8220;on hiatus&#8221;), [...]]]></description>
			<content:encoded><![CDATA[<p></p><h3>It&#8217;s Back!</h3>
<p><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/bruce_lee_rails_nunchucks.jpg" alt="Bruce Lee, brandishing &quot;Rails&quot; nunchucks" title="Bruce Lee, brandishing &quot;Rails&quot; nunchucks" width="270" height="200" align="right" />Last Friday marked the return of <strong>Ruby on Rails Project Night</strong>, a Toronto-based event where developers who worked on Ruby and Rails projects could do in-depth presentations on their current projects or ideas. It was on hiatus for the past couple of months (you can see <a href="http://www.globalnerdy.com/2008/09/17/the-return-of-ruby-on-rails-project-night/">this entry</a> for the definition of &#8220;on hiatus&#8221;), but thanks to the efforts of <a href="http://correlations.wordpress.com/"><strong>Corina Newby</strong></a>, who helped put together the event at its old venue, it&#8217;s back, and judging from the attendance, it was missed. Thanks, Corina, for all your work!</p>
<h3>James Robertson</h3>
<p>The first speaker was also the special guest (and the reason the event was held on a Friday, as opposed to the typical Monday or Tuesday): <a href="http://www.cincomsmalltalk.com/blog/blogView?content=bio"><strong>James Robertson</strong></a>, whom you may know from his blog <a href="http://www.cincomsmalltalk.com/blog/blogView"><cite>Smalltalk Tidbits, Industry Rants</cite></a>. He was on a &#8220;Canadian tour&#8221;, during which he was talking about the Smalltalk-based web app framework <a href="http://en.wikipedia.org/wiki/Seaside_(software)">Seaside</a> as well as Webvelocity, which puts the Smalltalk development experience within the browser.</p>
<p>Here&#8217;s the abstract for his presentation (<a href="http://correlations.wordpress.com/2008/09/19/update-for-tonight-toronto-ror-project-night-returns/">from this entry from Corina&#8217;s blog</a>):</p>
<blockquote><p>
WebVelocity is a new Smalltalk Development Environment that is oriented around Seaside for Web Development and Glorp for Object/Relatonal Mapping. Come and see how WebVelocity re-targets the Smalltalk development experience into the Web Browser and simplifies the challenge of learning a new environment for newcomers. We’ll even build an entire application using Active Record and Scaffolding during the presentation, with minimal programming. If you’re a fan of Ruby on Rails, you need to come out and see this presentation!
</p></blockquote>
<p>Here are my notes from his presentation:</p>
<pre>
- Seaside is open source, but Smalltalk ain't
- Seaside is maintained in Squeak, which you could call "the open source Smalltalk"

- Ruby on Rails is opinionated
- "Seaside is also opinated; it just has different opinions"
- When building Seaside, Avi Bryant asked "What if I took all the assumptions about web apps...
  and ignored them?"
- Some of what I show you is what happens when you blow those assumptions

- The canonical Seaside example -- the number increment/decrement button
  (now we know where that disastrous DemoCamp Seaside presentation came from!)
- Seaside uses continuations to remember state
- They enable "proper" support for the backbutton
- Session state info is keyed via a cryptographically secure key in the URL

- With Rails, you're dealing with two different worlds: templates and code
- Seaside is just one world: You don't write any HTML at all, you write all Smalltalk
- It's all in one place
- Support for debugger -- you can debug web apps as if they were desktop apps, with breakpoints and resumes
- In Seaside, the "html" argument is a "brush" that knows how to "paint" HTML
- You can debug in the middle of a page hit

- In beta: Seaside totally within the browser
- Editing code within a webpage, including tooltips and color hinting
- Every time a method is entered and it is syntactically correct, it is auto-saved -- no need to manual save!
- [Shows a Smalltalk debugger with an Ajax front end]
- "In some ways, it's even more productive than the real Smalltalk environment is"
- [Smalltalk console within the browser]
- [Auto-indenting within the browser]
- [Auto-generates a scaffolding-like page]
- The "call" method lets you write web app code very much like writing GUI stuff
</pre>
<h3>Paul Doerwald</h3>
<p>The second speaker was <a href="http://pauldoerwald.ca/"><strong>Paul Doerwald</strong></a>, who changed his topic from the more Ruby/Rails-specific &#8220;insights gained from working with ActiveRecord validation&#8221; to a more general (but still interesting) topic: Agile Documentation. He figured that it might be a better fit with James&#8217; presentation, and it was &#8212; it was also quite interesting.</p>
<p>Here&#8217;s the abstract for his presentation:</p>
<blockquote><p>
“Programmers generally hate writing documentation. That’s because most documentation is kept separate from the code and becomes hard to keep up-to-date. Besides violating the DRY principle… it can lead to misleading documentation, which is generally worse than none at all.” [Subramaniam/Hunt '06]. Why do developers hate writing documentation, and why do stakeholders and managers keep requiring it? Is there agile documentation beyond inline API documentation (JavaDoc, RDoc, etc.) and comments in the code? What parts of a project deserve separate-from-code documentation? How do we identify them, capture them, and keep them relevant?</p>
<p>Tonight’s Toronto Ruby on Rails Project Night presentation discusses the problem of documentation, explores some key aspects to consider when writing effective  documentation, and dreams of a future of testable, executable documentation, where non-code knowledge could be integrated into your code.“
</p></blockquote>
<p>And here are my notes from his talk:</p>
<pre>
- My original presentation was going to be about insights gained from ActiveRecord validation
- But I've decided to change it -- it's now on Agile Documentation
- It's my M.Sc. Thesis!
- "You'll find this talk a bit heavy on problem and not so heavy on solution"
- Think of this as an introduction -- I want to frame things and ask:
  what is Agile Documentation?

- By "documentation", I mean by the kind that's by programmers for programmers

- It's not a particularly sexy area
- Frameworks are sexy:
    - Rails is sexy
    - Django is sexy
    - CakePHP is sexy...(for PHP)
- Languages are sexy
    - Ruby is sexy
    - Objective-C is..."strangely alluring"
- Even databases are sexy! Consider CouchDB and AWS
- What's not sexy?
    - Documentation
    - Backup -- at least not until Apple's Time Machine
    - Both are viewed as a waste of time

- We're developers. We may grudgingly accept the presence of non-developer things,
  but we don't want to do them
- Documentation is hard to write
- It seems so much easier to program rather than write
- Writing -- the non code-type -- is not our core competency
- We say "Our code is the authoritative documentation!"
- Consider what DHH said in a "Signal vs. Noise" blog entry in February 2006
    - When asked "How do you document your projects?", he replied "We don't."
    - He also said:
        - "Never worked consistently or successfully"
        - "Not necessary for our work"
        - "Most Rails developers can walk in and find out"
        - "We use Ruby"
        - "Method docs only for non-obvious behaviour"
        - "Docs mean BDUF"
        - "Appropriate only for onerous enviroments with complex policies"
        - "Focus on code quality instead"

- Like backups, docs are important
- We're not the only people who'll be working on a project, especially if it's a success
- We don't want to feel like we're wasting time when we're working
- Running a documentation tool and taking its output and pasting it into a Word doc is not DRY
- Why are we writing highly-coupled docs?

- Is there such a thing as agile documentation? I'm going to say yes
- Look at the Agile Manifesto
    - "We value working software over comprehensive documentation"
    - But it doesn't say that comprehensive documentation isn't valued!

- What's the state of the Art
    - For API Documentation, it's JavaDoc
    - In Rails, the outer classes are well documented, but not the inner ones
    - The JDK is extremely well-documented
    - You could say that RSpec is a form of agile documentation
    - It's a stretch, but Domain-Specific Languages could also be agile documentation
    - After all these, I can only think of process
    - When do we do docs? At the beginning of the process? At the end?

- What could agile documentation look like? What does it feel like?
- I borrowed principle from Alastair Cockburn's "Agile Software Development:
  The Cooperative Game, 2nd ed."
- The goals set out in the book:
    - Finish the game (i.e. finish development and launch the product)
    - Set up the game for the next team
    - Think of pool: maybe you take the hard shot first to set yourself up later for the easy shot
    - Coburn calls this "residue": the stuff that one team leaves behind for the next team
    - Residue includes:
        - Code
        - Process in place
        - Documentation

- I would argue that DHH/37signals has an oral form of documentation
- It works if the company doesn't grow too quickly
- What are we really asking for when we ask for the documentation: Tacit Knowledge
    - "That which is seen but not noticed"
    - It is information that is understood and implied but not stated
    - If you've ever brought someone else onto a team, you spend a lot of time
      explaining things that are obvious to you
    - You might not explain that stuff if you're doing it on paper
    - You don't want to end up in a situtation where there's too much documentation

- What can we borrow from software engineering principles?
    - Orthogonality
        - A good thing in software development
        - Intersect at a clear and obvious point and do not influence each other at any other point
    - Cohesion
        - All attributes and methods are related to the essence of the class
        - Don't have people look in 5 different places to get the answer to a single question
    - Coupling
        - The extent to which one thing is dependent on each other

- To the future
    - 5 years ago, unit testing was unheard of in the web development world
    - Rails and similar projects have helped popularize unit testing
    - We've moved from the point to where we say "testing is awesome"
    - Testing is now a core value
    - Can we make documentation a core value?

- Agile documentation processes
    - Large companies are good at this; open source people not so good
    - Looking to Rails:
        - Documentaton conventions?
        - What if we had 5 steps for writing documentation that did 70% of the work?
    - Can we integrate documentation with code?
        - In many cases, the docs exist as a Word document
        - A step up is to use a Wiki -- support for multiple authors, versioning, linking
        - Can we put docs right in the codebase?
        - Every Rails app has a doc directory -- can we use that?
        - We test code -- is there a way to make testable documentation?
        - What if we could tag a method and class with a keyword and make that keyword appear in the docs?
          -- We could generate an alert when changes happen
</pre>
<h3>Checking Out the Rich Media Institute</h3>
<p>After the presentation, which was held in the Rich Media Institute&#8217;s basement-level lecture room, a number of us headed upstairs to check out its main floor. If you&#8217;re a techie with a creative bent, this place is like a candy store. The front part is a store full of books, t-shirts, music and other goodies that new media creators and aficionados would love, while the back is a gallery for local interactive artists&#8217; works.</p>
<p>I took some photos of the place and posted them in the gallery below. Click on any of the thumbnails to see a larger version of the picture:<br />

<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/books/' title='The Tech Bookshelf at the Rich Media Institute'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/books-150x150.jpg" class="attachment-thumbnail" alt="The Tech Bookshelf at the Rich Media Institute" title="The Tech Bookshelf at the Rich Media Institute" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/books_2/' title='Some of the books available at the Rich Media Institute&#039;s &quot;store&quot; section'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/books_2-150x150.jpg" class="attachment-thumbnail" alt="Some of the books available at the Rich Media Institute&#039;s &quot;store&quot; section" title="Some of the books available at the Rich Media Institute&#039;s &quot;store&quot; section" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/discs/' title='The music area of the Rich Media Institute&#039;s &quot;store&quot; section'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/discs-150x150.jpg" class="attachment-thumbnail" alt="The music area of the Rich Media Institute&#039;s &quot;store&quot; section" title="The music area of the Rich Media Institute&#039;s &quot;store&quot; section" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/discs_2/' title='Another shot of the music area of the Rich Media Institute&#039;s &quot;store&quot; section'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/discs_2-150x150.jpg" class="attachment-thumbnail" alt="Another shot of the music area of the Rich Media Institute&#039;s &quot;store&quot; section" title="Another shot of the music area of the Rich Media Institute&#039;s &quot;store&quot; section" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/far_from_equilibrium/' title='&quot;Far from Equilibrium: Essays on Technology and Design Culture&quot;'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/far_from_equilibrium-150x150.jpg" class="attachment-thumbnail" alt="&quot;Far from Equilibrium: Essays on Technology and Design Culture&quot;" title="&quot;Far from Equilibrium: Essays on Technology and Design Culture&quot;" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/interact_or_die/' title='&quot;Interact or Die!&quot;'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/interact_or_die-150x150.jpg" class="attachment-thumbnail" alt="&quot;Interact or Die!&quot;" title="&quot;Interact or Die!&quot;" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/robot/' title='Cardboard robot in the &quot;gallery&quot; part of the Rich Media Institute'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/robot-150x150.jpg" class="attachment-thumbnail" alt="Cardboard robot in the &quot;gallery&quot; part of the Rich Media Institute" title="Cardboard robot in the &quot;gallery&quot; part of the Rich Media Institute" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/store_wide/' title='A wide shot of the &quot;store&quot; part of the Rich Media Institute, taken from the back.'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/store_wide-150x150.jpg" class="attachment-thumbnail" alt="A wide shot of the &quot;store&quot; part of the Rich Media Institute, taken from the back." title="A wide shot of the &quot;store&quot; part of the Rich Media Institute, taken from the back." /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/store_wide_2/' title='A wide shot of the &quot;store&quot; part of the Rich Media Institute, taken from the front'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/store_wide_2-150x150.jpg" class="attachment-thumbnail" alt="A wide shot of the &quot;store&quot; part of the Rich Media Institute, taken from the front" title="A wide shot of the &quot;store&quot; part of the Rich Media Institute, taken from the front" /></a>
<a href='http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/toy_soldier_candle_holder/' title='&quot;Toy Soldier&quot; Candle Holder'><img width="150" height="150" src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/toy_soldier_candle_holder-150x150.jpg" class="attachment-thumbnail" alt="&quot;Toy Soldier&quot; Candle Holder" title="&quot;Toy Soldier&quot; Candle Holder" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/09/24/notes-from-ruby-on-rails-project-night/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Return of Ruby on Rails Project Night</title>
		<link>http://www.globalnerdy.com/2008/09/17/the-return-of-ruby-on-rails-project-night/</link>
		<comments>http://www.globalnerdy.com/2008/09/17/the-return-of-ruby-on-rails-project-night/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 16:28:39 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Meetups]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Toronto]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby/Rails Project Night. Rich Media Institute]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=1551</guid>
		<description><![CDATA[
After &#8220;a much-needed summer hiatus&#8221; (which you can read as &#8220;the complete implosion of Toronto&#8217;s worst-run software development shop, which used to host the event&#8221;) Ruby on Rails Project Night makes its comeback this Friday, September 19th at its new home at the Rich Media Institute in Kensington Market.
Event organizer Corina Newby promises that it [...]]]></description>
			<content:encoded><![CDATA[<p></p><p style="text-align:center;"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/rails_to_victory.jpg" alt="Rails to Victory" title="Rails to Victory" width="600" height="483"  /></p>
<p>After &#8220;a much-needed summer hiatus&#8221; (which you can read as &#8220;the complete implosion of <a href="http://tsotinc.com/">Toronto&#8217;s worst-run software development shop</a>, which used to host the event&#8221;) <a href="http://correlations.wordpress.com/2008/09/04/sept-19th-ruby-on-rails-project-night-the-rich-media-institute/"><strong>Ruby on Rails Project Night</strong></a> makes its comeback this Friday, September 19th at its new home at the <a href="http://www.richmediainstitute.com/">Rich Media Institute</a> in Kensington Market.</p>
<p>Event organizer <a href="http://correlations.wordpress.com/">Corina Newby</a> promises that it won&#8217;t normally be on Fridays, which should the minds of your significant others, party-going friends or World of Warcraft clans at ease. The event is being held on a Friday this time to accommodate the schedule of special guest <a href="http://www.cincomsmalltalk.com/blog/blogView"><strong>James &#8220;<cite>Smalltalk Tidbits, Industry Rants</cite>&#8221; Robertson</strong></a>, who&#8217;ll be there to give us a presentation of the Smalltalk-based web application framework <a href="http://en.wikipedia.org/wiki/Seaside_(software)">Seaside</a> and the Seaside-based Smalltalk development environment WebVelocity.</p>
<p>Also scheduled is local Ruby on Rails developer <a href="http://pauldoerwald.ca/"><strong>Paul Doerwald</strong></a>, who&#8217;ll be doing a presentation on insights he gained from working with ActiveRecord validation.</p>
<p>As always, one of the greatest benefits of these gatherings is actually meeting local developers who work with or are interested in working with Ruby and Rails. It&#8217;s good for you, your software development career and the future of <a href="http://en.wikipedia.org/wiki/Toronto">Accordion City</a> as a hub for high-tech when gatherings like this take place, so be a part of it!</p>
<p>By the way, did I mention that the event is <strong>FREE</strong>?</p>
<p>Once again, the date is this <strong>Friday, September 19th</strong> at the <a href="http://www.richmediainstitute.com/">Rich Media Institute</a> (<a href="http://maps.google.com/maps?f=q&#038;hl=en&#038;geocode=&#038;q=156+Augusta+Avenue,+Toronto,+ON&#038;sll=37.0625,-95.677068&#038;sspn=46.764446,112.148438&#038;ie=UTF8&#038;z=16&#038;iwloc=addr">156 Augusta Avenue</a>). The presentations will start at 6 p.m. and run until about 7:30. If you&#8217;re planning to attend, let Corina know at <a href="mailto:corecorina@hotmail.com">corecorina@hotmail.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/09/17/the-return-of-ruby-on-rails-project-night/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Enumerating Enumerable: A Cute Trick for Explaining inject / reduce / fold</title>
		<link>http://www.globalnerdy.com/2008/09/03/enumerating-enumerable-a-cute-trick-for-explaining-inject-reduce-fold/</link>
		<comments>http://www.globalnerdy.com/2008/09/03/enumerating-enumerable-a-cute-trick-for-explaining-inject-reduce-fold/#comments</comments>
		<pubDate>Wed, 03 Sep 2008 15:52:03 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Enumerating Enumerable]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=1446</guid>
		<description><![CDATA[
The next method I&#8217;m going to cover in Enumerating Enumerable &#8212; the series of articles in which I try to do a better job of documenting Ruby&#8217;s Enumerable module than Ruby-Doc.org does &#8212; is inject, a.k.a. reduce. Not only is it one of the trickiest methods to explain, it&#8217;s also one of the cornerstones of [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="center"><img src="http://globalnerdy.com/wordpress/wp-content/uploads/2008/06/enumerating_enumerable.jpg" alt="Enumerating Enumerable" title="enumerating_enumerable" width="350" height="120" /></p>
<p>The next method I&#8217;m going to cover in <cite>Enumerating Enumerable</cite> &#8212; the series of articles in which I try to do a better job of documenting Ruby&#8217;s <code>Enumerable</code> module than Ruby-Doc.org does &#8212; is <code>inject</code>, a.k.a. <code>reduce</code>. Not only is it one of the trickiest methods to explain, it&#8217;s also one of the cornerstones of functional programming. I thought that I&#8217;d take a little time to explain what the function does.</p>
<h3>inject</h3>
<p>The term <code>inject</code> comes from Smalltalk and isn&#8217;t terribly descriptive. I remember reading the documentation for it and being all confused until I saw some examples. I then realized that I&#8217;d seen this function before, but under two different names.</p>
<h3>reduce</h3>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/best_accordion_picture_ever_old.jpg" alt="The Second-Best Accordion Picture Ever" title="The Second-Best Accordion Picture Ever" width="312" height="465" class="size-full wp-image-1462" /><br /><span class="caption">Burning Man 1999: gratuitous nudity and even more gratuitous accordion!</span></p>
<p>The <em>second</em> name by which I encountered this function is <code>reduce</code>, and it was at <a href="http://www.burningman.com/whatisburningman/1999/">Burning Man 1999</a>. I was to start a new job the week after Burning Man, and I had to learn at least some basic Python by then. So along with my camping gear, accordion and a kilo of candy for barter, I also brought my laptop (a 233Mhz Toshiba Sattelite with a whopping 96MB of RAM) and O&#8217;Reilly&#8217;s <a href="http://oreilly.com/catalog/9781565924642/"><cite>Learning Python</cite></a> and noodled during the downtime (early morning and afternoon) on Python 1.6. When I got to covering the <code>reduce</code> function, I was confused until I saw some examples, after which I realized that I&#8217;d seen that function before, but under a different name.</p>
<p>(You may have also heard of <code>reduce</code> through Google&#8217;s much-vaunted <a href="http://labs.google.com/papers/mapreduce.html">MapReduce</a> programming model.)</p>
<h3>fold</h3>
<p>The <em>first</em> name by which I encountered this function is <a href="http://en.wikipedia.org/wiki/Fold_(higher-order_function)"><code>fold</code></a>, or more specifically, &#8220;fold left&#8221; or &#8220;foldl&#8221;, and it was at the <a href="http://research.cs.queensu.ca/home/cisc260/2007w/Resources.html">&#8220;Programming Paradigms&#8221;</a> course I took at <a href="http://queensu.ca/">Crazy Go Nuts University</a>. &#8220;Programming Paradigms&#8221; was a second-year course and had the reputation of being the most difficult course in the computer science curriculum. The <em>intended</em> purpose of this course was to provide students with an introduction to functional programming (these days, they use Haskell and Prolog, back then, it was <a href="http://en.wikipedia.org/wiki/Miranda_programming_language">Miranda</a>). Its actual effect was to make most of the students swear off functional programming for the rest of their lives.</p>
<p>In spite of the trauma from this course, I ended up remembering a lot from it that I was able to apply, first to Python and now to Ruby. One of these things is a cute little trick for cememnting in your mind what <code>fold</code> does.</p>
<h3>What Ruby-doc.org Says</h3>
<p>Before I cover that cute little trick, let&#8217;s take a look at what Ruby-doc.org&#8217;s documentation has to say about <code>Enumerable</code>&#8217;s <code>inject</code> method.</p>
<p>One thing you&#8217;ll find at Ruby-doc.org is that as of Ruby 1.8.7 and later, <code>inject</code> gained a synonym: the more familiar term <code>reduce</code>.</p>
<p>As for <a href="http://www.ruby-doc.org/core-1.9/classes/Enumerable.html#M002971">the description of the <code>inject</code>/<code>reduce</code> method</a>, I don&#8217;t find it terribly helpful:</p>
<blockquote><p>
Combines all elements of enum by applying a binary operation, specified by a block or a symbol that names a method or operator.</p>
<p>If you specify a block, then for each element in enum&lt;i&gt; the block is passed an accumulator value (&lt;i&gt;memo) and the element. If you specify a symbol instead, then each element in the collection will be passed to the named method of memo. In either case, the result becomes the new value for memo. At the end of the iteration, the final value of memo is the return value fo the method.</p>
<p>If you do not explicitly specify an initial value for memo, then uses the first element of collection is used as the initial value of memo.
</p></blockquote>
<p>(Yes, those stray &lt;i&gt; tags are part of the text of the description for <code>inject</code>. Hopefully they&#8217;ll fix that soon.)</p>
<p>This confusing text becomes a little clearer with some examples. The most typical example of <code>inject</code>/<code>reduce</code>/<code>fold</code> in action is the classic &#8220;compute the sum of the numbers in this range or array&#8221; problem. There are a number of approaches you can take in Ruby, all of which use <code>inject</code>/<code>reduce</code>:<br />
<code>
<pre>
(1..8).reduce(:+)
=> 36

(1..8).reduce {|sum, number| sum += number}
=> 36

(1..8).reduce(0) {|sum, number| sum += number}
=> 36
</pre>
<p></code></p>
<p>The <code>reduce</code> method takes some kind of operation and applies it across the enumerable to yield a single result. In this case, the operation is addition. </p>
<p>Explaining <em>how</em> that operation is applied is a little trickier, but I do just that in the next section.</p>
<h3>Demonstrating inject / reduce / fold With a Piece of Paper and Literal Folding</h3>
<p>To explain what&#8217;s happening in the code above, I&#8217;m going to do use a piece of paper. I&#8217;ve folded it into 8 even sections and then numbered each section, as shown in the photo below:</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_1.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>Think of the paper as the range <code>(1..8)</code>. We&#8217;re now going to compute the sum of the numbers in this range, step by step, using a literal <strong>fold</strong> &#8212; that is, by folding the paper. I&#8217;m going to start folding from the left side of the paper, and when I do, I&#8217;m going to add the numbers that I&#8217;m folding into each other.</p>
<p>In the first fold, I&#8217;m folding the number <strong>1</strong> onto the number <strong>2</strong>. Adding these two numbers yields <strong>3</strong>, which I write on the back of the fold:</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_2.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>For the second fold, I fold the first number <strong>3</strong> onto the second number <strong>3</strong>. The sum of these two numbers is <strong>6</strong>, and I write that on the back of the resulting fold:</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_3.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>I fold again: this time, it&#8217;s the number <strong>6</strong> onto the number <strong>4</strong>, the sum of which is <strong>10</strong>. I write that number down on the resulting fold:</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_4.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>Next, I fold <strong>10</strong> onto <strong>5</strong>, yielding the number <strong>15</strong>:</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_5.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>I then fold <strong>15</strong> onto <strong>6</strong>, which gives me <strong>21</strong>:</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_6.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>Next comes <strong>21</strong> folded onto <strong>7</strong>, which makes for a sum of <strong>28</strong>:</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_7.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>And finally, <strong>28</strong> folded onto <strong>8</strong>, which gives us a final total of <strong>36</strong>.</p>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/09/fold_8.jpg" alt="" title="fold_1" width="500" height="375" /></p>
<p>And there you have it: a paper-based explanation of <code>inject</code>/<code>reduce</code>/<code>fold</code>, as well as why I often refer to the operation as &#8220;folding&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/09/03/enumerating-enumerable-a-cute-trick-for-explaining-inject-reduce-fold/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Enumerating Enumerable: Enumerable#group_by</title>
		<link>http://www.globalnerdy.com/2008/08/31/enumerating-enumerable-enumerablegroup_by/</link>
		<comments>http://www.globalnerdy.com/2008/08/31/enumerating-enumerable-enumerablegroup_by/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 20:52:02 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Enumerating Enumerable]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=1392</guid>
		<description><![CDATA[
Once again, it&#8217;s Enumerating Enumerable time! This is the latest in my series of articles where I set out to make better documentation for Ruby&#8217;s Enumerable module than Ruby-Doc.org&#8217;s. In this installment &#8212; the seventeenth in the series &#8212; I cover the group_by method.
In case you missed any of the previous articles, they&#8217;re listed and [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="center"><img src="http://globalnerdy.com/wordpress/wp-content/uploads/2008/06/enumerating_enumerable.jpg" alt="Enumerating Enumerable" title="enumerating_enumerable" width="350" height="120" /></p>
<p>Once again, it&#8217;s <strong><cite>Enumerating Enumerable</cite></strong> time! This is the latest in my series of articles where I set out to make better documentation for Ruby&#8217;s <code>Enumerable</code> module than Ruby-Doc.org&#8217;s. In this installment &#8212; the <em>seventeenth</em> in the series &#8212; I cover the <code>group_by</code> method.</p>
<p>In case you missed any of the previous articles, they&#8217;re listed and linked below:</p>
<ol>
<li><a href="http://globalnerdy.com/2008/06/23/enumerating-enumerable-enumerableall/">all?</a></li>
<li><a href="http://globalnerdy.com/2008/06/24/enumerating-enumerable-enumerableany/">any?</a></li>
<li><a href="http://globalnerdy.com/2008/06/25/enumerating-enumerable-enumerablecollectenumerablemap/">collect / map</a></li>
<li><a href="http://globalnerdy.com/2008/07/02/enumerating-enumerable-enumerablecount/">count</a></li>
<li><a href="http://globalnerdy.com/2008/07/06/enumerating-enumerable-enumerablecycle/">cycle</a></li>
<li><a href="http://globalnerdy.com/2008/07/07/enumerating-enumerable-enumerabledetectenumerablefind/">detect / find</a></li>
<li><a href="http://globalnerdy.com/2008/07/10/enumerating-enumerable-enumerabledrop/">drop</a></li>
<li><a href="http://globalnerdy.com/2008/07/25/enumerating-enumerable-enumerabledrop_while/">drop_while</a></li>
<li><a href="http://globalnerdy.com/2008/07/28/enumerating-enumerable-enumerableeach_cons/">each_cons</a></li>
<li><a href="http://www.globalnerdy.com/2008/07/29/enumerating-enumerable-enumerableeach_slice/">each_slice</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/01/enumerating-enumerable-enumerableeach_with_index/">each_with_index</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/02/enumerating-enumerable-enumerableentries-enumerableto_a/">entries / to_a</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/07/enumerating-enumerable-enumerablefind_all-enumerableselect/">find_all / select</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/14/enumerating-enumerable-enumerablefind_index/">find_index</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/15/enumerating-enumerable-enumerablefirst/">first</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/21/enumerating-enumerable-enumerablegrep/">grep</a></li>
</ol>
<h3>Enumerable#group_by Quick Summary</h3>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/08/ruby_enumerablegroup_by.jpg" alt="Graphic representation of the &quot;group_by&quot; method in Ruby&#039;s &quot;Enumerable&quot; module." title="Graphic representation of the &quot;group_by&quot; method in Ruby&#039;s &quot;Enumerable&quot; module." width="425" height="397" /></p>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<th>In the simplest possible terms</th>
<td>Break a collection into groups based on some given criteria.</td>
</tr>
<tr>
<th>Ruby version</th>
<td>1.9 only</td>
</tr>
<tr>
<th>Expects</th>
<td>A block containing the criteria by which the items in the collection will be grouped.</td>
</tr>
<tr>
<th>Returns</th>
<td>A hash where each key represents a group. Each key&#8217;s corresponding value is an array containing the members of that group.</td>
</tr>
<tr>
<th>RubyDoc.org&#8217;s entry</th>
<td><a href="http://www.ruby-doc.org/core-1.9/classes/Enumerable.html#M002974">Enumerable#group_by</a></td>
</tr>
</table>
<h3>Enumerable#group_by and Arrays</h3>
<p>When used on an array, <code>group_by</code> iterates through the array, passing each element to to the block. The result value of the block is the group into which the element will be placed.</p>
<h4>Example 1</h4>
<p>For the first example, I&#8217;ll use some code similar to the example given in Ruby-doc.org&#8217;s writeup of <code>group_by</code>:</p>
<p><code>
<pre>
(0..15).group_by {|number| number % 3}
=> {0=>[0, 3, 6, 9, 12, 15], 1=>[1, 4, 7, 10, 13], 2=>[2, 5, 8, 11, 14]}
</pre>
<p></code></p>
<p>In the code above, the numbers 0 through 15 are passed to the block, which receives each number as the parameter <code>number</code>. The group that each number is placed into is determined by the result value of the block, <code>number % 3</code>, whose result can be one of 0, 1 or 2. This means that:</p>
<ul>
<li>The resulting hash will have three groups, represented by the keys <code>0</code>, <code>1</code> and <code>2</code></li>
<li>The key <code>0</code>&#8217;s corresponding value is an array containing the numbers in the range (0..15) that are evenly divisible by 3 (i.e. the numbers for which <code>number % 3</code> is 0.</li>
<li>The key <code>1</code>&#8217;s corresponding value is an array containing the numbers in the range (0..15) that when divided by 3 leave a remainder of 1 (i.e. the numbers for which <code>number % 3</code> is 1.</li>
<li>The key <code>2</code>&#8217;s corresponding value is an array containing the numbers in the range (0..15) that when divided by 3 leave a remainder of 2 (i.e. the numbers for which <code>number % 3</code> is 2.</li>
</ul>
<h4>Example 2</h4>
<p>In the first example, the keys in the resulting hash are the same type as the values in the array whose contents we&#8217;re grouping. In this example, I&#8217;ll show that the keys in the resulting hash don&#8217;t have to be the same type as the values in the array.<br />
<code>
<pre>
simpsons = %w(Homer Marge Bart Lisa Abraham Herb)
=> ["Homer", "Marge", "Bart", "Lisa", "Abraham", "Herb"]

simpsons.group_by{|simpson| simpson.length}
=> {5=>["Homer", "Marge"], 4=>["Bart", "Lisa", "Herb"], 7=>["Abraham"]}
</pre>
<p></code></p>
<p>In the code above, each Simpson name is passed to the block, which receives it as the parameter <code>simpson</code>. The block&#8217;s result is the length of <code>simpson</code>, and this result is the group into which the name will go.</p>
<p>In the resulting hash:</p>
<ul>
<li>Note that the keys are integers while the names in the groups are strings.</li>
<li>The key <code>5</code>&#8217;s array contains those names in <code>Simpsons</code> that are 5<br />
characters in length.</li>
<li>The key <code>4</code>&#8217;s array contains those names in <code>Simpsons</code> that are 4 characters in length.</li>
<li>The key <code>7</code>&#8217;s array contains those names in <code>Simpsons</code> that are 7 characters in length.</li>
</ul>
<h4>Example 3</h4>
<p>In the previous two examples, the keys for the resulting array were calculated from the values in the initial array. In this example, I&#8217;ll demonstrate that the keys for the groupings can be determined in a completely arbitrary fashion that has nothing to do with the values:</p>
<p><code>
<pre>
# Put the Simpsons into randomly determined groups
simpsons.group_by{rand(3) + 1}
=> {3=>["Homer", "Bart", "Abraham", "Herb"], 1=>["Marge", "Lisa"]}

# Let's try that again. The results are very likely to be different:
simpsons.group_by{rand(3) + 1}
=> {1=>["Homer", "Bart"], 2=>["Marge", "Lisa", "Herb"], 3=>["Abraham"]}

# One more time!
simpsons.group_by{rand(3) + 1}
=> {2=>["Homer", "Bart", "Lisa"], 3=>["Marge", "Herb"], 1=>["Abraham"]}
</pre>
<p></code></p>
<h3>Enumerable#group_by and Hashes</h3>
<p>When used on a hash, <code>group_by</code> passes each key/value pair in the hash to the block, which you can “catch” as either:</p>
<p>   1. A two-element array, with the key as element 0 and its corresponding value as element 1, or<br />
   2. Two separate items, with the key as the first item and its corresponding value as the second item.</p>
<h4>Example 1</h4>
<p>In this example, we&#8217;ll group the cast of <cite>Family Guy</cite> by the item that they&#8217;re bringing to a potluck dinner:<br />
<code>
<pre>
potluck = {"Peter" => "lasagna",
           "Lois"  => "potato salad",
           "Chris" => "lasagna",
           "Meg"   => "brownies",
           "Stewie" => "chateaubriand",
           "Brian" => "potato salad",
           "Evil Monkey" => "potato salad"}
=> {"Peter"=>"lasagna", "Lois"=>"potato salad", "Chris"=>"lasagna", "Meg"=>"brownies",
"Stewie"=>"chateaubriand", "Brian"=>"potato salad", "Evil Monkey"=>"potato salad"}

# Here's one way to do it:
potluck.group_by{|person, bringing| bringing}
=> {"lasagna"=>[["Peter", "lasagna"], ["Chris", "lasagna"]], "potato salad"=>[["Lois", "potato salad"],
["Brian", "potato salad"], ["Evil Monkey", "potato salad"]], "brownies"=>[["Meg", "brownies"]],
"chateaubriand"=>[["Stewie", "chateaubriand"]]}

# Here's another way to do it:
potluck.group_by{|person| person[1]}
=> {"lasagna"=>[["Peter", "lasagna"], ["Chris", "lasagna"]], "potato salad"=>[["Lois", "potato salad"],
["Brian", "potato salad"], ["Evil Monkey", "potato salad"]], "brownies"=>[["Meg", "brownies"]],
"chateaubriand"=>[["Stewie", "chateaubriand"]]}
</pre>
<p></code></p>
<h4>Example 2</h4>
<p>In the previous example, the groupings were based on a calculation performed on the objects in the original hash. In this example, the groupings will be random: a random number generator will determine whose car each potluck attendee will ride to the potluck dinner:</p>
<p><code>
<pre>
potluck.group_by {[:peters_car, :quagmires_car, :clevelands_car][rand(3)]}
=> {:peters_car=>[["Peter", "lasagna"], ["Chris", "lasagna"], ["Evil Monkey", "potato salad"]],
:quagmires_car=>[["Lois", "potato salad"], ["Meg", "brownies"], ["Stewie", "chateaubriand"]],
:clevelands_car=>[["Brian", "potato salad"]]}

# Let's try another random grouping
potluck.group_by {[:peters_car, :quagmires_car, :clevelands_car][rand(3)]}
=> {:peters_car=>[["Peter", "lasagna"], ["Meg", "brownies"]], :quagmires_car=>[["Lois", "potato salad"],
["Stewie", "chateaubriand"], ["Brian", "potato salad"], ["Evil Monkey", "potato salad"]],
:clevelands_car=>[["Chris", "lasagna"]]}

# One more time!
potluck.group_by {[:peters_car, :quagmires_car, :clevelands_car][rand(3)]}
=> {:peters_car=>[["Peter", "lasagna"], ["Chris", "lasagna"], ["Stewie", "chateaubriand"]],
:quagmires_car=>[["Lois", "potato salad"], ["Evil Monkey", "potato salad"]], :clevelands_car=>[["Meg", "brownies"],
["Brian", "potato salad"]]}
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/08/31/enumerating-enumerable-enumerablegroup_by/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumerating Enumerable: Enumerable#first</title>
		<link>http://www.globalnerdy.com/2008/08/15/enumerating-enumerable-enumerablefirst/</link>
		<comments>http://www.globalnerdy.com/2008/08/15/enumerating-enumerable-enumerablefirst/#comments</comments>
		<pubDate>Fri, 15 Aug 2008 04:39:56 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Enumerating Enumerable]]></category>
		<category><![CDATA[first]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=1238</guid>
		<description><![CDATA[
Welcome to another installment of Enumerating Enumerable, my series of articles in I attempt to do a better job of documenting Ruby&#8217;s Enumerable module than Ruby-Doc.org. In this installment, I cover the first method.
In case you missed any of the previous articles, they&#8217;re listed and linked below:

all?
any?
collect / map
count
cycle
detect / find
drop
drop_while
each_cons
each_slice
each_with_index
entries / to_a
find_all / select
find_index

Enumerable#first [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="center"><img src="http://globalnerdy.com/wordpress/wp-content/uploads/2008/06/enumerating_enumerable.jpg" alt="Enumerating Enumerable" title="enumerating_enumerable" width="350" height="120" /></p>
<p>Welcome to another installment of <strong><cite>Enumerating Enumerable</cite></strong>, my series of articles in I attempt to do a better job of documenting Ruby&#8217;s <code>Enumerable</code> module than Ruby-Doc.org. In this installment, I cover the <code>first</code> method.</p>
<p>In case you missed any of the previous articles, they&#8217;re listed and linked below:</p>
<ol>
<li><a href="http://globalnerdy.com/2008/06/23/enumerating-enumerable-enumerableall/">all?</a></li>
<li><a href="http://globalnerdy.com/2008/06/24/enumerating-enumerable-enumerableany/">any?</a></li>
<li><a href="http://globalnerdy.com/2008/06/25/enumerating-enumerable-enumerablecollectenumerablemap/">collect / map</a></li>
<li><a href="http://globalnerdy.com/2008/07/02/enumerating-enumerable-enumerablecount/">count</a></li>
<li><a href="http://globalnerdy.com/2008/07/06/enumerating-enumerable-enumerablecycle/">cycle</a></li>
<li><a href="http://globalnerdy.com/2008/07/07/enumerating-enumerable-enumerabledetectenumerablefind/">detect / find</a></li>
<li><a href="http://globalnerdy.com/2008/07/10/enumerating-enumerable-enumerabledrop/">drop</a></li>
<li><a href="http://globalnerdy.com/2008/07/25/enumerating-enumerable-enumerabledrop_while/">drop_while</a></li>
<li><a href="http://globalnerdy.com/2008/07/28/enumerating-enumerable-enumerableeach_cons/">each_cons</a></li>
<li><a href="http://www.globalnerdy.com/2008/07/29/enumerating-enumerable-enumerableeach_slice/">each_slice</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/01/enumerating-enumerable-enumerableeach_with_index/">each_with_index</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/02/enumerating-enumerable-enumerableentries-enumerableto_a/">entries / to_a</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/07/enumerating-enumerable-enumerablefind_all-enumerableselect/">find_all / select</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/14/enumerating-enumerable-enumerablefind_index/">find_index</a></li>
</ol>
<h3>Enumerable#first Quick Summary</h3>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/08/ruby_enumerablefirst.jpg" alt="Graphic representing the &quot;first&quot; method in Ruby&#039;s &quot;Enumerable&quot; module" title="Graphic representing the &quot;first&quot; method in Ruby&#039;s &quot;Enumerable&quot; module" width="329" height="244" /></p>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<th>In the simplest possible terms</th>
<td>What are the first <em>n</em> items in the collection?</td>
</tr>
<tr>
<th>Ruby version</th>
<td>1.8 and 1.9</td>
</tr>
<tr>
<th>Expects</th>
<td>An optional integer <em>n</em> that specifies the first <em>n</em> items of the collection to return. If this integer is not given, <em>n</em> is 1 by default.</td>
</tr>
<tr>
<th>Returns</th>
<td>If <code>first</code> is applied to a collection containing <em>m</em> elements:</p>
<ul>
<li>The first item in the collection, if <em>m</em> > 0 and no argument <em>n</em> is provided.</li>
<li>An array containing the first <em>n</em> items in the collection, if <em>m</em> > 0 and an argument <em>n</em> is provided.</li>
<li><code>nil</code> if the collection is empty and no argument <em>n</em> is provided.</li>
<li>The empty array <code>[]</code> if the collection is empty and an argument <em>n</em> is provided.</li>
</ul>
</td>
</tr>
<tr>
<th>RubyDoc.org&#8217;s entry</th>
<td><a href="http://www.ruby-doc.org/core-1.9/classes/Enumerable.html#M002975">Enumerable#first</a></td>
</tr>
</table>
<h3>Enumerable#first and Arrays</h3>
<p>When used on an array without an argument, <code>first</code> returns the first item in the array:<br />
<code>
<pre>
posts = ["First post!", "Second post!", "Third post!"]
=> ["First post!", "Second post!", "Third post!"]

# What's the first item in posts?
posts.first
=> "First post!"

# Here's the equivalent using array notation:
posts[0]
=> "First post!"
</pre>
<p></code></p>
<p>When used on an array with an integer argument <em>n</em>, <code>first</code> returns an array containing the first <em>n</em> items in the original array:<br />
<code>
<pre>
# What are the first 2 items in posts?
posts.first 2
=> ["First post!", "Second post!"]

# Note that when you provide an argument of 1,
# the result is still an array -- with just one element.
# If you want a scalar, don't use an argument.
posts.first 1
=> ["First post!"]

# Here's the equivalent using array slice notation:
posts[0..1]
=> ["First post!", "Second post!"]

posts[0...2]
=> ["First post!", "Second post!"]
</pre>
<p></code></p>
<p>When used on an empty array, <code>first</code> returns:</p>
<ul>
<li><code>nil</code> if no argument <em>n</em> is provided</li>
<li>The empty array, <code>[]</code>, if an argument <em>n</em> is provided</li>
</ul>
<p><code>
<pre>
[].first
=> nil

[].first 2
=> []
</pre>
<p></code></p>
<h3>Enumerable#first and Hashes</h3>
<p>In Ruby 1.8 and previous versions, hash order is seemingly arbitrary. Starting with Ruby 1.9, hashes retain the order in which they were defined, which makes the <code>first</code> method a little more applicable.</p>
<p>When used on a hash without an argument, <code>first</code> returns the first item in the hash as a two-element array, with the key as the first element and the corresponding value as the second element.<br />
<code>
<pre>
# Let's see what stages of partying our friends are in
party_stages = {"Alice" => :party_mineral,
                "Bob"   => :party_animal,
                "Carol" => :party_reptile,
                "Dave"  => :party_vegetable}
=> {"Alice"=>:party_mineral, "Bob"=>:party_animal, "Carol"=>:party_reptile, "Dave"=>:party_vegetable}

# Who's the first partier and what state is s/he in?
party_stages.first
=> ["Alice", :party_mineral]
</pre>
<p></code></p>
<p>When used on a hash with an integer argument <em>n</em>, <code>first</code> returns an array containing the first <em>n</em> items in the hash, with each item represented as a two-element array:<br />
<code>
<pre>
party_stages.first 2
=> [["Alice", :party_mineral], ["Bob", :party_animal]]

# Note that when you provide an argument of 1,
# the result is still an array -- with just one element.
# If you want a scalar, don't use an argument.
party_stages.first 1
=> [["Alice", :party_mineral]]
</pre>
<p></code></p>
<p>When used on an empty hash, <code>first</code> returns:</p>
<ul>
<li><code>nil</code> if no argument <em>n</em> is provided</li>
<li>The empty array, <code>[]</code>, if an argument <em>n</em> is provided</li>
</ul>
<p><code>
<pre>
{}.first
=> nil

{}.first 2
=> []
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/08/15/enumerating-enumerable-enumerablefirst/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumerating Enumerable: Enumerable#find_index</title>
		<link>http://www.globalnerdy.com/2008/08/14/enumerating-enumerable-enumerablefind_index/</link>
		<comments>http://www.globalnerdy.com/2008/08/14/enumerating-enumerable-enumerablefind_index/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 15:54:14 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Enumerating Enumerable]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=1207</guid>
		<description><![CDATA[
Once again, it&#8217;s Enumerating Enumerable, my series of articles in which I attempt to outdo Ruby-Doc.org&#8217;s documentation of Ruby&#8217;s Enumerable module. In this article, I cover the find_index method, which was introduced in Ruby 1.9.
In case you missed any of the previous articles, they&#8217;re listed and linked below:

all?
any?
collect / map
count
cycle
detect / find
drop
drop_while
each_cons
each_slice
each_with_index
entries / to_a
find_all / [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="center"><img src="http://globalnerdy.com/wordpress/wp-content/uploads/2008/06/enumerating_enumerable.jpg" alt="Enumerating Enumerable" title="enumerating_enumerable" width="350" height="120" /></p>
<p>Once again, it&#8217;s <strong><cite>Enumerating Enumerable</cite></strong>, my series of articles in which I attempt to outdo Ruby-Doc.org&#8217;s documentation of Ruby&#8217;s <code>Enumerable</code> module. In this article, I cover the <code>find_index</code> method, which was introduced in Ruby 1.9.</p>
<p>In case you missed any of the previous articles, they&#8217;re listed and linked below:</p>
<ol>
<li><a href="http://globalnerdy.com/2008/06/23/enumerating-enumerable-enumerableall/">all?</a></li>
<li><a href="http://globalnerdy.com/2008/06/24/enumerating-enumerable-enumerableany/">any?</a></li>
<li><a href="http://globalnerdy.com/2008/06/25/enumerating-enumerable-enumerablecollectenumerablemap/">collect / map</a></li>
<li><a href="http://globalnerdy.com/2008/07/02/enumerating-enumerable-enumerablecount/">count</a></li>
<li><a href="http://globalnerdy.com/2008/07/06/enumerating-enumerable-enumerablecycle/">cycle</a></li>
<li><a href="http://globalnerdy.com/2008/07/07/enumerating-enumerable-enumerabledetectenumerablefind/">detect / find</a></li>
<li><a href="http://globalnerdy.com/2008/07/10/enumerating-enumerable-enumerabledrop/">drop</a></li>
<li><a href="http://globalnerdy.com/2008/07/25/enumerating-enumerable-enumerabledrop_while/">drop_while</a></li>
<li><a href="http://globalnerdy.com/2008/07/28/enumerating-enumerable-enumerableeach_cons/">each_cons</a></li>
<li><a href="http://www.globalnerdy.com/2008/07/29/enumerating-enumerable-enumerableeach_slice/">each_slice</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/01/enumerating-enumerable-enumerableeach_with_index/">each_with_index</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/02/enumerating-enumerable-enumerableentries-enumerableto_a/">entries / to_a</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/07/enumerating-enumerable-enumerablefind_all-enumerableselect/">find_all / select</a></li>
</ol>
<h3>Enumerable#find_index Quick Summary</h3>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/08/ruby_enumerablefind_index.jpg" alt="Graphic representation of the &quot;find_index&quot; method in Ruby&#039;s &quot;Enumerable&quot; module" title="Graphic representation of the &quot;find_index&quot; method in Ruby&#039;s &quot;Enumerable&quot; module" width="323" height="226" /></p>
<table>
<tr>
<th>In the simplest possible terms</th>
<td>What&#8217;s the index of the first item in the collection that meets the given criteria?</td>
</tr>
<tr>
<th>Ruby version</th>
<td>1.9</td>
</tr>
<tr>
<th>Expects</th>
<td>A block containing the criteria.</td>
</tr>
<tr>
<th>Returns</th>
<td>
<ul>
<li>The index of the item in the collection that matches the criteria, if there is one.</li>
<li><code>nil</code>, if no item in the collection matches the crtieria.</li>
</ul>
</td>
</tr>
<tr>
<th>RubyDoc.org&#8217;s entry</th>
<td><a href="http://www.ruby-doc.org/core-1.9/classes/Enumerable.html#M002965">Enumerable#find_index</a></td>
</tr>
</table>
<h3>Enumerable#find_index and Arrays</h3>
<p>When used on an array, <code>find_index</code> passes each item in the array to the given block and either:</p>
<ul>
<li>Stops when the current item causes the block to return a value that evaluates to <code>true</code> (that is, anything that isn&#8217;t <code>false</code> or <code>nil</code>) and returns the index of that item, or</li>
<li>Returns <code>nil</code> if there is no item in the array that causes the block to return a value that evaluates to <code>true</code>.</li>
</ul>
<p>Some examples:<br />
<code>
<pre>
# How about an array of the name of the first cosmonauts and astronauts,
# listed in the chronological order of the missions?
mission_leaders = ["Gagarin", "Shepard", "Grissom", "Titov", "Glenn", "Carpenter",
"Nikolayev", "Popovich"]
=> ["Gagarin", "Shepard", "Grissom", "Titov", "Glenn", "Carpenter", "Nikolayev",
"Popovich"]

# Yuri Gagarin was the first in space
mission_leaders.find_index{|leader| leader == "Gagarin"}
=> 0

# John Glenn was the fifth
mission_leaders.find_index{|leader| leader == "Glenn"}
=> 4

# And James Tiberius Kirk is not listed in the array
kirk_present = mission_leaders.find_index{|leader| leader == "Kirk"}
=> nil
</pre>
<p></code></p>
<h3>Enumerable#find_index and Hashes</h3>
<p>When used on a hash, <code>find_index</code> passes each key/value pair in the hash to the block, which you can “catch” as either:</p>
<ol>
<li>A two-element array, with the key as element 0 and its corresponding value as element 1, or</li>
<li>Two separate items, with the key as the first item and its corresponding value as the second item.</li>
</ol>
<p>As with arrays, <code>find_index</code>:</p>
<ul>
<li>Stops when the current item causes the block to return a value that evaluates to <code>true</code> (that is, anything that isn&#8217;t <code>false</code> or <code>nil</code>) and returns the index of that item, or</li>
<li>Returns <code>nil</code> if there is no item in the array that causes the block to return a value that evaluates to <code>true</code>.</li>
</ul>
<p>Some examples:<br />
<code>
<pre>
require 'date'
=> true

# These are the names of the first manned spaceships and their launch dates
launch_dates = {"Kedr"              => Date.new(1961, 4, 12),
                "Freedom 7"         => Date.new(1961, 5, 5),
                "Liberty Bell 7"    => Date.new(1961, 7, 21),
                "Orel"              => Date.new(1961, 8, 6),
                "Friendship 7"      => Date.new(1962, 2, 20),
                "Aurora 7"          => Date.new(1962, 5, 24),
                "Sokol"             => Date.new(1962, 8, 11),
                "Berkut"            => Date.new(1962, 8, 12)}
=> {"Kedr"=>#&lt;Date: 4874803/2,0,2299161&gt;, "Freedom 7"=&gt;#&lt;Date: 4874849/2,0,2299161&gt;,
"Liberty Bell 7"=&gt;#&lt;Date: 4875003/2,0,2299161&gt;, "Orel"=&gt;#&lt;Date: 4875035/2,0,2299161&gt;,
"Friendship 7"=&gt;#&lt;Date: 4875431/2,0,2299161&gt;, "Aurora 7"=&gt;#&lt;Date: 4875617/2,0,2299161&gt;,
"Sokol"=&gt;#&lt;Date: 4875775/2,0,2299161&gt;, "Berkut"=&gt;#&lt;Date: 4875777/2,0,2299161&gt;}

# Where in the list is John Glenn's ship, the Friendship 7?
launch_dates.find_index{|ship, date| ship == "Friendship 7"}
=> 4

# Where in the list is the first mission launched in August 1962?
launch_dates.find_index{|ship, date| date.year == 1962 &#038;&#038; date.month == 8}
=> 6

# The same thing, expressed a little differently
launch_dates.find_index{|launch| launch[1].year == 1962 &#038;&#038; launch[1].month == 8}
=> 6
</pre>
<p></code></p>
<h3>Using find_index as a Membership Test</h3>
<p>Although <code>Enumerable</code> has a method for checking whether an item is a member of a collection (the <code>include?</code> method and its synonym, <code>member?</code>), <code>find_index</code> is a more powerful membership test for two reasons:</p>
<ol>
<li><code>include?</code>/<code>member?</code> only check membership by using the <code>==</code> operator, while <code>find_index</code> lets you define a block to set up all sorts of tests. <code>include?</code>/<code>member?</code> asks &#8220;Is there an object X in the collection equal to my object Y?&#8221; while <code>find_index</code> can be used to ask &#8220;Is there an object X in the collection that matches these criteria?&#8221;</li>
<li><code>include?</code>/<code>member?</code> returns <code>true</code> if there is an object X in the collection that is equal to the given object Y. <code>find_index</code> goes one step further: not only can it be used to report the equivalent of <code>true</code> if there is an object X in the collection that is equal to the given object Y, it also reports its location in the collection.</li>
</ol>
<p>A quick example of this use in action:<br />
<code>
<pre>
# Once again, the mission leaders
mission_leaders = ["Gagarin", "Shepard", "Grissom", "Titov", "Glenn", "Carpenter",
"Nikolayev", "Popovich"]
=> ["Gagarin", "Shepard", "Grissom", "Titov", "Glenn", "Carpenter", "Nikolayev",
 "Popovich"]

# Yuri Gagarin is in the list
gagarin_in_list = mission_leaders.find_index {|leader| leader == "Gagarin"}
=> 0

# Captain James T. Kirk is not
kirk_in_list = mission_leaders.find_index {|leader| leader == "Kirk"}
=> nil

# gagarin_in_list is 0, which as a non-false and non-nil value evaluates as true.
# We can use it as both a membership test *and* as his location in the list.
p "Gagarin's there. He's number #{gagarin_in_list + 1} in the list." if gagarin_in_list
"Gagarin's there. He's number 1 in the list."
=> "Gagarin's there. He's number 1 in the list."

# kirk_in_list is nil, which is one of Ruby's two "false" values.
# Let's use it with the "something OR something else" idiom that
# many Ruby programmers like.
kirk_in_list || (p "You only *think* he wasn't there.")
"You only *think* he wasn't there."
=> "You only *think* he wasn't there."
</pre>
<p></code></p>
<h3>Parts that Haven&#8217;t Been Implemented Yet</h3>
<p>Ruby-Doc.org&#8217;s documentation is generated from the comments in the C implementation of Ruby. It mentions a way of calling <code>find_index</code> that is just like calling <code>include?</code>/<code>member?</code>:<br />
<code>
<pre>
# What the docs say (does not work yet!)
["Alice", "Bob", "Carol"].find_index("Bob")
=> 1

# What happens with the current version of Ruby 1.9
["Alice", "Bob", "Carol"].find_index("Bob")
ArgumentError: wrong number of arguments(1 for 0)
...
</pre>
<p></code><br />
Ruby 1.9 is considered to be a work in progress, so I suppose it&#8217;ll get implemented in a later release.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/08/14/enumerating-enumerable-enumerablefind_index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumerating Enumerable: Enumerable#find_all / Enumerable#select</title>
		<link>http://www.globalnerdy.com/2008/08/07/enumerating-enumerable-enumerablefind_all-enumerableselect/</link>
		<comments>http://www.globalnerdy.com/2008/08/07/enumerating-enumerable-enumerablefind_all-enumerableselect/#comments</comments>
		<pubDate>Thu, 07 Aug 2008 19:04:49 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.globalnerdy.com/?p=1155</guid>
		<description><![CDATA[
We&#8217;re at lucky number 13 &#8212; the thirteenth article in the Enumerating Enumerable series, which covers the methods of Ruby&#8217;s Enumerable module. I started this series after being disappointed with the documentation at Ruby-Doc.org.
In this article, I&#8217;m covering the find_all &#8212; a.k.a. select &#8212; method.
In case you missed any of the previous articles, they&#8217;re listed [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="center"><img src="http://globalnerdy.com/wordpress/wp-content/uploads/2008/06/enumerating_enumerable.jpg" alt="Enumerating Enumerable" title="enumerating_enumerable" width="350" height="120" /></p>
<p>We&#8217;re at lucky number 13 &#8212; the thirteenth article in the <strong><cite>Enumerating Enumerable</cite></strong> series, which covers the methods of Ruby&#8217;s <code>Enumerable</code> module. I started this series after being disappointed with the documentation at Ruby-Doc.org.</p>
<p>In this article, I&#8217;m covering the <code>find_all</code> &#8212; a.k.a. <code>select</code> &#8212; method.</p>
<p>In case you missed any of the previous articles, they&#8217;re listed and linked below:</p>
<ol>
<li><a href="http://globalnerdy.com/2008/06/23/enumerating-enumerable-enumerableall/">all?</a></li>
<li><a href="http://globalnerdy.com/2008/06/24/enumerating-enumerable-enumerableany/">any?</a></li>
<li><a href="http://globalnerdy.com/2008/06/25/enumerating-enumerable-enumerablecollectenumerablemap/">collect / map</a></li>
<li><a href="http://globalnerdy.com/2008/07/02/enumerating-enumerable-enumerablecount/">count</a></li>
<li><a href="http://globalnerdy.com/2008/07/06/enumerating-enumerable-enumerablecycle/">cycle</a></li>
<li><a href="http://globalnerdy.com/2008/07/07/enumerating-enumerable-enumerabledetectenumerablefind/">detect / find</a></li>
<li><a href="http://globalnerdy.com/2008/07/10/enumerating-enumerable-enumerabledrop/">drop</a></li>
<li><a href="http://globalnerdy.com/2008/07/25/enumerating-enumerable-enumerabledrop_while/">drop_while</a></li>
<li><a href="http://globalnerdy.com/2008/07/28/enumerating-enumerable-enumerableeach_cons/">each_cons</a></li>
<li><a href="http://www.globalnerdy.com/2008/07/29/enumerating-enumerable-enumerableeach_slice/">each_slice</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/01/enumerating-enumerable-enumerableeach_with_index/">each_with_index</a></li>
<li><a href="http://www.globalnerdy.com/2008/08/02/enumerating-enumerable-enumerableentries-enumerableto_a/">entries / to_a</a></li>
</ol>
<h3>Enumerable#find_all / Enumerable#select Quick Summary</h3>
<p class="center"><img src="http://www.globalnerdy.com/wordpress/wp-content/uploads/2008/08/ruby_enumerablefind_all_enumerableselect.jpg" alt="Graphic representation of the \&quot;find_all\&quot; / \&quot;select\&quot; method in Ruby\&#039;s \&quot;Enumerable\&quot; module" title="Graphic representation of the \&quot;find_all\&quot; / \&quot;select\&quot; method in Ruby\&#039;s \&quot;Enumerable\&quot; module" width="317" height="304" /></p>
<table>
<tr>
<th>In the simplest possible terms</th>
<td>Which items in the collection meet the given criteria?</td>
</tr>
<tr>
<th>Ruby version</th>
<td>1.8 and 1.9</td>
</tr>
<tr>
<th>Expects</th>
<td>A block containing the criteria.</td>
</tr>
<tr>
<th>Returns</th>
<td>An array containing the items in the collection that meet the given criteria. If no items in the collection meet the given criteria, this is an empty array.</td>
</tr>
<tr>
<th>RubyDoc.org&#8217;s entry</th>
<td><a href="http://www.ruby-doc.org/core-1.9/classes/Enumerable.html#M002966">Enumerable#find_all / Enumerable#select</a></td>
</tr>
</table>
<h3>Enumerable#find_all / Enumerable#select and Arrays</h3>
<p>When used on an array, <code>find_all</code> and its synonym <code>select</code> passes each item from the array to the block, returning an array containing only those elements in the original array for which the block returns a value that doesn&#8217;t evaluate to <code>false</code>.</p>
<p>If no item in the array causes the block to return a value that doesn’t evaluate to false, <code>find_all</code>/<code>select</code> returns an empty array.</p>
<p>In the examples that follow (which are based on <a href="http://www.globalnerdy.com/2008/07/07/enumerating-enumerable-enumerabledetectenumerablefind/">my examples for the <code>detect</code>/<code>find</code> method</a>), I’ll be using the <code>find_all</code> method. <code>select</code> does exactly the same thing; it’s just that I prefer <code>find_all</code>.</p>
<p><code>
<pre>
# Once again,  I shall establish my "old fart" credentials
classic_rock_bands = ["AC/DC", "Black Sabbath", "Queen", \
"Ted Nugent and the Amboy Dukes", "Scorpions", "Van Halen"]
=> ["AC/DC", "Black Sabbath", "Queen", "Ted Nugent and the Amboy Dukes",
"Scorpions", "Van Halen"]

# Of the bands in the array, which ones have
# a name longer than 8 characters?
classic_rock_bands.find_all {|band| band.length > 8}
=> ["Black Sabbath", "Ted Nugent and the Amboy Dukes", "Scorpions", "Van Halen"]

# Which ones have a name exactly 5 characters long?
classic_rock_bands.find_all {|band| band.length == 5}
=> ["AC/DC", "Queen"]

# If no band in the array meets the criteria,
# find_all returns an empty array.
# Which ones have names shorter than 5 characters?
classic_rock_bands.find_all {|band| band.length < 5}
=> []
</pre>
<p></code></p>
<h3>Enumerable#find_all / Enumerable#select and Hashes</h3>
<p>When used on a hash, <code>find_all</code>/<code>select</code> passes each key/value pair in the hash to the block, which you can “catch” as either:</p>
<ol>
<li>A two-element array, with the key as element 0 and its corresponding value as element 1, or</li>
<li>Two separate items, with the key as the first item and its corresponding value as the second item.</li>
</ol>
<p>As with arrays, <code>find_all</code>/<code>select</code> passes each item from the hash to the block, returning an array containing only those items in the original array for which the block returns a value that doesn&#8217;t evaluate to <code>false</code>.</p>
<p>Note that each item in the result array is a two-element array corresponding to an item from the original hash. In this array, element 0 contains the key and element 1 contains the corresponding value.</p>
<p>If no item in the hash causes the block to return a value that doesn’t evaluate to false, find_all/select returns an empty array.</p>
<p><code>
<pre>
years_founded = {"AC/DC" => 1973, \
                 "Black Sabbath" => 1968, \
                 "Queen" => 1970, \
                 "Ted Nugent and the Amboy Dukes" => 1967, \
                 "Scorpions" => 1965, \
                 "Van Halen" => 1972}
=> {"AC/DC"=>1973, "Black Sabbath"=>1968, "Queen"=>1970,
"Ted Nugent and the Amboy Dukes"=>1967, "Scorpions"=>1965, "Van Halen"=>1972}

# Ruby 1.9 preserves hash order so that hashes keep the order in which
# you defined them, while Ruby 1.8 puts them in some mysterious order.
# All these examples are in Ruby 1.9

# Which bands were founded in 1970 or later?
years_founded.find_all {|band| band[1] >= 1970}
=> [["AC/DC", 1973], ["Queen", 1970], ["Van Halen", 1972]]

# Here's another way of phrasing it:
years_founded.find_all {|band, year_founded| year_founded >= 1970}
=> [["AC/DC", 1973], ["Queen", 1970], ["Van Halen", 1972]]

# Which bands were founded after 1980?
years_founded.find_all {|band, year_founded| year_founded > 1980}
=> []
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/08/07/enumerating-enumerable-enumerablefind_all-enumerableselect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enumerating Enumerable: Enumerable#each_with_index</title>
		<link>http://www.globalnerdy.com/2008/08/01/enumerating-enumerable-enumerableeach_with_index/</link>
		<comments>http://www.globalnerdy.com/2008/08/01/enumerating-enumerable-enumerableeach_with_index/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 04:00:27 +0000</pubDate>
		<dc:creator>Joey deVilla</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[each_with_index]]></category>
		<category><![CDATA[enumerable]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://globalnerdy.com/?p=1946</guid>
		<description><![CDATA[
Here&#8217;s number 11 in the Enumerating Enumerable series, in which I&#8217;m trying to outdo RubyDoc.org in their documentation of Ruby&#8217;s key Enumerable module. In this article, I cover the each_with_index method.
In case you missed the earlier articles, they&#8217;re listed and linked below:

all?
any?
collect / map
count
cycle
detect / find
drop
drop_while
each_cons
each_slice

Enumerable#each_with_index Quick Summary



In the simplest possible terms
Think of each_with_index as [...]]]></description>
			<content:encoded><![CDATA[<p></p><p class="center"><img src="http://globalnerdy.com/wordpress/wp-content/uploads/2008/06/enumerating_enumerable.jpg" alt="Enumerating Enumerable" title="enumerating_enumerable" width="350" height="120" /></p>
<p>Here&#8217;s number 11 in the <strong><cite>Enumerating Enumerable</cite></strong> series, in which I&#8217;m trying to outdo RubyDoc.org in their documentation of Ruby&#8217;s key <code>Enumerable</code> module. In this article, I cover the <code>each_with_index</code> method.</p>
<p>In case you missed the earlier articles, they&#8217;re listed and linked below:</p>
<ol>
<li><a href="http://globalnerdy.com/2008/06/23/enumerating-enumerable-enumerableall/">all?</a></li>
<li><a href="http://globalnerdy.com/2008/06/24/enumerating-enumerable-enumerableany/">any?</a></li>
<li><a href="http://globalnerdy.com/2008/06/25/enumerating-enumerable-enumerablecollectenumerablemap/">collect / map</a></li>
<li><a href="http://globalnerdy.com/2008/07/02/enumerating-enumerable-enumerablecount/">count</a></li>
<li><a href="http://globalnerdy.com/2008/07/06/enumerating-enumerable-enumerablecycle/">cycle</a></li>
<li><a href="http://globalnerdy.com/2008/07/07/enumerating-enumerable-enumerabledetectenumerablefind/">detect / find</a></li>
<li><a href="http://globalnerdy.com/2008/07/10/enumerating-enumerable-enumerabledrop/">drop</a></li>
<li><a href="http://globalnerdy.com/2008/07/25/enumerating-enumerable-enumerabledrop_while/">drop_while</a></li>
<li><a href="http://globalnerdy.com/2008/07/28/enumerating-enumerable-enumerableeach_cons/">each_cons</a></li>
<li><a href="http://www.globalnerdy.com/2008/07/29/enumerating-enumerable-enumerableeach_slice/">each_slice</a></li>
</ol>
<h3>Enumerable#each_with_index Quick Summary</h3>
<p style="text-align:center;"><img src="http://globalnerdy.com/wordpress/wp-content/uploads/2008/07/ruby_enumerableeach_with_index.jpg" alt="Graphic representation of the \&quot;each_with_index\&quot; method in Ruby\&#039;s \&quot;Enumerable\&quot; module" title="Graphic representation of the \&quot;each_with_index\&quot; method in Ruby\&#039;s \&quot;Enumerable\&quot; module" width="325" height="481" /></p>
<table>
<tr>
<th>In the simplest possible terms</th>
<td>Think of <code>each_with_index</code> as a version of <code>each</code> that includes an extra piece of information: a number representing the current iteration&#8217;s element&#8217;s position in the collection.</td>
</tr>
<tr>
<th>Ruby version</th>
<td>1.8 and 1.9</td>
</tr>
<tr>
<th>Expects</th>
<td>An optional block to receive the values from each iteration.</td>
</tr>
<tr>
<th>Returns</th>
<td>
<ul>
<li>The original collection, if used with a block.</li>
<li>An <code>Enumerator</code> object that outputs the collection&#8217;s items and indexes, if used without a block.</li>
</ul>
</td>
</tr>
<tr>
<th>RubyDoc.org&#8217;s entry</th>
<td><a href="http://www.ruby-doc.org/core-1.9/classes/Enumerable.html#M002988">Enumerable#each_with_index</a></td>
</tr>
</table>
<h3>Enumerable#each_with_index and Arrays</h3>
<p>When used with on an array and given a block, <code>each_with_index</code> iterates through the array, passing each item in the array and the number representing its order in the array to the block. Once again, I&#8217;ll use the &#8220;Justice League&#8221; example:</p>
<p><code>
<pre>
justice_league = ["Aquaman", "Batman", "Black Canary", \
                  "Flash", "Green Arrow", "Green Lantern", \
                  "Martian Manhunter", "Superman", \
                  "Vixen", "Wonder Woman"]
justice_league = ["Aquaman", "Batman", "Black Canary", "Flash", "Green Arrow",
"Green Lantern", "Martian Manhunter", "Superman", "Vixen", "Wonder Woman"]

justice_league.each_with_index {|member, index| puts "#{index}: #{member}"}
=> 0: Aquaman
1: Batman
2: Black Canary
3: Flash
4: Green Arrow
5: Green Lantern
6: Martian Manhunter
7: Superman
8: Vixen
9: Wonder Woman
=> ["Aquaman", "Batman", "Black Canary", "Flash", "Green Arrow", "Green Lantern",
"Martian Manhunter", "Superman", "Vixen", "Wonder Woman"]
</pre>
<p></code></p>
<p>Note that unlike the <code>each_cons</code> and <code>each_slice</code>, <code>each_with_index</code> <em>doesn&#8217;t</em> return <code>nil</code>, but the original array, just like <code>each</code> does. <code>each_cons</code> and <code>each_slice</code> are newer methods that were introduced in Ruby 1.9; perhaps Matz and company decided that it made more sense for &#8220;each&#8221; methods to return <code>nil</code> from now on. <code>each</code> and <code>each_with_index</code> have return the original array as they always have, since making changes to these methods might break a lot of existing Ruby code. Hooray for those little inconsistencies that creep into every programming language!</p>
<h3>Enumerable#each_with_index and Hashes</h3>
<p>When used with on a hash and given a block, <code>each_with_index</code> iterates through the hash, converting each item in the hash into a two-element array (where the first element is the key and the second element is the corresponding value), and then passing that array and the number representing its order in the original array to the block. Once again, I&#8217;ll use the &#8220;Enterprise Crew&#8221; example:</p>
<p><code>
<pre>
enterprise_crew = {:captain => "Picard",
                   :first_officer => "Riker",
                   :science_officer => "Data",
                   :tactical_officer => "Worf",
                   :chief_engineer => "LaForge",
                   :chief_medical_officer => "Crusher",
                   :ships_counselor => "Troi",
                   :annoying_ensign => "Crusher",
                   :attractive_ensign => "Ro",
                   :expendable_crew_member => "Smith"}
=> {:captain=>"Picard", :first_officer=>"Riker", :science_officer=>"Data",
:tactical_officer=>"Worf", :chief_engineer=>"LaForge",
:chief_medical_officer=>"Crusher", :ships_counselor=>"Troi",
:annoying_ensign=>"Crusher", :attractive_ensign=>"Ro",
:expendable_crew_member=>"Smith"}

enterprise_crew.each_with_index {|member, index| puts "#{index}: #{member}"}
=> 0: [:captain, "Picard"]
1: [:first_officer, "Riker"]
2: [:science_officer, "Data"]
3: [:tactical_officer, "Worf"]
4: [:chief_engineer, "LaForge"]
5: [:chief_medical_officer, "Crusher"]
6: [:ships_counselor, "Troi"]
7: [:annoying_ensign, "Crusher"]
8: [:attractive_ensign, "Ro"]
9: [:expendable_crew_member, "Smith"]
=> {:captain=>"Picard", :first_officer=>"Riker", :science_officer=>"Data",
:tactical_officer=>"Worf", :chief_engineer=>"LaForge",
:chief_medical_officer=>"Crusher", :ships_counselor=>"Troi",
:annoying_ensign=>"Crusher", :attractive_ensign=>"Ro",
:expendable_crew_member=>"Smith"}
</pre>
<p></code></p>
<h3>Enumerable#each_with_index Oddities</h3>
<h4>Blocks with a Single Parameter</h4>
<p>What happens if you use <code>each_with_index</code> with a block that has only one parameter? You&#8217;d think that the block would accept the item and index passed to it as a two-element array, with the item as the first element and the corresponding index as the second element, but that&#8217;s not the case:</p>
<p><code>
<pre>
# For each item in justice_league, this line will output the following:
# {second letter of member's name} : {first letter of member's name}
justice_league.each_with_index {|member| puts "#{member[1]}: #{member[0]}"}
=> q: A
a: B
l: B
l: F
r: G
r: G
a: M
u: S
i: V
o: W
=> ["Aquaman", "Batman", "Black Canary", "Flash", "Green Arrow", "Green Lantern"
, "Martian Manhunter", "Superman", "Vixen", "Wonder Woman"]
</pre>
<p></code></p>
<p>When <code>each_with_index</code> passes an item and its index to a block that takes only one parameter, the item goes into the paramter, and the index is discarded. Simply put, in this case, <code>each_with_index</code> behaves just like <code>each</code>.</p>
<h4>Without a Block</h4>
<p>What happens if you use <code>each_with_index</code> without a block to create an <code>Enumerator</code> object that spits out the next item when its <code>next</code> method is called? This:</p>
<p><code>
<pre>
hero = justice_league.each_with_index
=> #&lt;Enumerable::Enumerator:0x159cb98&gt;

hero.next
=> "Aquaman"

hero.next
=> "Batman"

hero.next
=> "Black Canary"
</pre>
<p></code></p>
<p>Note that calling <code>next</code> only yields the next item in the collection; the index information is lost. In this case, <code>each_with_index</code> behaves just like <code>each</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.globalnerdy.com/2008/08/01/enumerating-enumerable-enumerableeach_with_index/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
