<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>grande.dev = true</title>
	<atom:link href="http://mattgrande.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattgrande.wordpress.com</link>
	<description>Random ramblings of a Ruby on Rails developer</description>
	<lastBuildDate>Mon, 31 Oct 2011 14:17:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mattgrande.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>grande.dev = true</title>
		<link>http://mattgrande.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mattgrande.wordpress.com/osd.xml" title="grande.dev = true" />
	<atom:link rel='hub' href='http://mattgrande.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Thoughts on REST: Who gives a shit?</title>
		<link>http://mattgrande.wordpress.com/2010/08/09/thoughts-on-rest-who-gives-a-shit/</link>
		<comments>http://mattgrande.wordpress.com/2010/08/09/thoughts-on-rest-who-gives-a-shit/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 16:10:20 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[rest]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=99</guid>
		<description><![CDATA[I feel like I&#8217;ve come to a new understanding of REST. I&#8217;ve long been an evangelical supporter of REST. I&#8217;ve felt that Controllers should have, at most, the Seven Actions (List, Show, Edit, Update, New, Create, Delete). But no longer&#8230; I&#8217;m currently working on a project that had a normal, everyday requirement. Purchase Orders can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=99&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I feel like I&#8217;ve come to a new understanding of <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a>.</p>
<p>I&#8217;ve long been an evangelical supporter of REST.  I&#8217;ve felt that Controllers should have, at most, the Seven Actions (List, Show, Edit, Update, New, Create, Delete).</p>
<p>But no longer&#8230;</p>
<p>I&#8217;m currently working on a project that had a normal, everyday requirement.  Purchase Orders can be edited, and they can also be closed.  From the Pure-REST point-of-view, I have two options: A convoluted Update action that does two things or a creating a specific PurchaseOrderClose controller that does one highly-specific thing.</p>
<p>Instead, I opted to do something terrible and dangerous&#8230;</p>
<p>I added a Close method to my PurchaseOrder controller.  I added a custom route (<code>/PurchaseOrders/{id}/Close</code>).  The world didn&#8217;t explode, and the API is still easy to understand.</p>
<p>It&#8217;s a simple lesson, but one that&#8217;s often hard-learned: <strong>To every rule, there is always an exception.  Always err on the side of cleaner code.</strong></p>
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// This is it.  This is the one that will infect your soul, curve your spine,
/// and keep the country from winning the war.
/// &lt;/summary&gt;
public ActionResult Close(int id)
{
	var po = _poRepository.Close(id);
	return View(po);
}
</pre>
<br />Filed under: <a href='http://mattgrande.wordpress.com/category/net/'>.Net</a> Tagged: <a href='http://mattgrande.wordpress.com/tag/c/'>C#</a>, <a href='http://mattgrande.wordpress.com/tag/mvc/'>MVC</a>, <a href='http://mattgrande.wordpress.com/tag/rest/'>rest</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/99/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/99/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/99/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=99&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2010/08/09/thoughts-on-rest-who-gives-a-shit/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Some Simple NUnit Code Snippets</title>
		<link>http://mattgrande.wordpress.com/2009/11/11/some-simple-nunit-code-snippets/</link>
		<comments>http://mattgrande.wordpress.com/2009/11/11/some-simple-nunit-code-snippets/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:16:15 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Snippets]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=94</guid>
		<description><![CDATA[I decided to learn how to write code snippets and wrote a couple quick ones to help out my NUnit testing. You can grab them here. What&#8217;s in these snippets? Just a couple quick &#38; easy Assert completers. Hopefully these will help you learn how to write your own (better) snippets. ae &#8211; Assert.AreEqual(expected, actual); [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=94&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I decided to learn how to write code snippets and wrote a couple quick ones to help out my NUnit testing.  You can grab them <a href="http://pastie.org/693764">here</a>.</p>
<p><strong>What&#8217;s in these snippets?</strong></p>
<p>Just a couple quick &amp; easy Assert completers.  Hopefully these will help you learn how to write your own (better) snippets.</p>
<ul>
<li><kbd>ae</kbd> &#8211; Assert.AreEqual(expected, actual);</li>
<li><kbd>ait</kbd> &#8211; Assert.IsTrue(true);</li>
<li><kbd>aif</kbd> &#8211; Assert.IsFalse(false);</li>
</ul>
<p><strong>How to install snippets</strong></p>
<p>Copy and paste the XML from the link above and save it in a file with the extension <em>.snippet</em>.  I&#8217;d recommend saving it in the default code snippets folder (C:\Users\lskywalker\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets).  Then, in Visual Studio, go to <strong>Tools</strong> -&gt; <strong>Code Snippets Manager&#8230;</strong>, and click <strong>Add</strong>.  Navigate to the file you saved, and you&#8217;re done!</p>
<p><strong>Neat!  Where can I learn more?</strong></p>
<p>Everything I learned, I learned from the <a href="http://msdn.microsoft.com/en-us/library/ms165392(VS.80).aspx">MSDN</a> articles about code snippets.</p>
<p>Good luck, and happy coding.</p>
<br />Posted in .Net Tagged: .Net, C#, Code Snippets, NUnit, Snippets <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/94/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/94/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/94/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=94&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/11/11/some-simple-nunit-code-snippets/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Pluralization Helper for C#</title>
		<link>http://mattgrande.wordpress.com/2009/10/28/pluralization-helper-for-c/</link>
		<comments>http://mattgrande.wordpress.com/2009/10/28/pluralization-helper-for-c/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 17:06:56 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Pluralization]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=89</guid>
		<description><![CDATA[I recently wanted a pluralization inflector in a C# project, one similar to the one in Ruby on Rails. Unable to find a satisfactory one, I whipped up my own. Here&#8217;s what I&#8217;ve got. And of course, some NUnit tests. And finally, usage. Now, I&#8217;m sure that I&#8217;m missing some cases in there. For example, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=89&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I recently wanted a pluralization inflector in a C# project, one similar to the one in Ruby on Rails.  Unable to find a satisfactory one, I whipped up my own.  Here&#8217;s what I&#8217;ve got.</p>
<pre class="brush: csharp;">
namespace MyNamespace
{
    public class Formatting
    {
        private static readonly IList&lt;string&gt; Unpluralizables = new List&lt;string&gt;
        { &quot;equipment&quot;, &quot;information&quot;, &quot;rice&quot;, &quot;money&quot;, &quot;species&quot;, &quot;series&quot;, &quot;fish&quot;, &quot;sheep&quot;, &quot;deer&quot; };
        private static readonly IDictionary&lt;string, string&gt; Pluralizations = new Dictionary&lt;string, string&gt;
        {
            // Start with the rarest cases, and move to the most common
            { &quot;person&quot;, &quot;people&quot; },
            { &quot;ox&quot;, &quot;oxen&quot; },
            { &quot;child&quot;, &quot;children&quot; },
            { &quot;foot&quot;, &quot;feet&quot; },
            { &quot;tooth&quot;, &quot;teeth&quot; },
            { &quot;goose&quot;, &quot;geese&quot; },
            // And now the more standard rules.
            { &quot;(.*)fe?&quot;, &quot;$1ves&quot; },         // ie, wolf, wife
            { &quot;(.*)man$&quot;, &quot;$1men&quot; },
            { &quot;(.+[aeiou]y)$&quot;, &quot;$1s&quot; },
            { &quot;(.+[^aeiou])y$&quot;, &quot;$1ies&quot; },
            { &quot;(.+z)$&quot;, &quot;$1zes&quot; },
            { &quot;([m|l])ouse$&quot;, &quot;$1ice&quot; },
            { &quot;(.+)(e|i)x$&quot;, @&quot;$1ices&quot;},    // ie, Matrix, Index
            { &quot;(octop|vir)us$&quot;, &quot;$1i&quot;},
            { &quot;(.+(s|x|sh|ch))$&quot;, @&quot;$1es&quot;},
            { &quot;(.+)&quot;, @&quot;$1s&quot; }
        };

        public static string Pluralize(int count, string singular)
        {
            if (count == 1)
                return singular;

            if (Unpluralizables.Contains(singular))
                return singular;

            var plural = &quot;&quot;;

            foreach (var pluralization in Pluralizations)
            {
                if (Regex.IsMatch(singular, pluralization.Key))
                {
                    plural = Regex.Replace(singular, pluralization.Key, pluralization.Value);
                    break;
                }
            }

            return plural;
        }
    }
}
</pre>
<p>And of course, some NUnit tests.</p>
<pre class="brush: csharp;">
namespace AutomatedTests
{
    [TestFixture]
    public class FormattingTests
    {
        [Test]
        public void StandardPluralizationTests()
        {
            var dictionary = new Dictionary&lt;string, string&gt;();
            dictionary.Add(&quot;sausage&quot;, &quot;sausages&quot;);  // Most words - Just add an 's'
            dictionary.Add(&quot;status&quot;, &quot;statuses&quot;);   // Words that end in 's' - Add 'es'
            dictionary.Add(&quot;ax&quot;, &quot;axes&quot;);           // Words that end in 'x' - Add 'es'
            dictionary.Add(&quot;octopus&quot;, &quot;octopi&quot;);    // Some Words that end in 'us' - Replace 'us' with 'i'
            dictionary.Add(&quot;virus&quot;, &quot;viri&quot;);        // Some Words that end in 'us' - Replace 'us' with 'i'
            dictionary.Add(&quot;crush&quot;, &quot;crushes&quot;);     // Words that end in 'sh' - Add 'es'
            dictionary.Add(&quot;crutch&quot;, &quot;crutches&quot;);   // Words that end in 'ch' - Add 'es'
            dictionary.Add(&quot;matrix&quot;, &quot;matrices&quot;);   // Words that end in 'ix' - Replace with 'ices'
            dictionary.Add(&quot;index&quot;, &quot;indices&quot;);     // Words that end in 'ex' - Replace with 'ices'
            dictionary.Add(&quot;mouse&quot;, &quot;mice&quot;);        // Some Words that end in 'ouse' - Replace with 'ice'
            dictionary.Add(&quot;quiz&quot;, &quot;quizzes&quot;);      // Words that end in 'z' - Add 'zes'
            dictionary.Add(&quot;mailman&quot;, &quot;mailmen&quot;);   // Words that end in 'man' - Replace with 'men'
            dictionary.Add(&quot;man&quot;, &quot;men&quot;);           // Words that end in 'man' - Replace with 'men'
            dictionary.Add(&quot;wolf&quot;, &quot;wolves&quot;);       // Words that end in 'f' - Replace with 'ves'
            dictionary.Add(&quot;wife&quot;, &quot;wives&quot;);        // Words that end in 'fe' - Replace with 'ves'
            dictionary.Add(&quot;day&quot;, &quot;days&quot;);          // Words that end in '[vowel]y' - Replace with 'ys'
            dictionary.Add(&quot;sky&quot;, &quot;skies&quot;);         // Words that end in '[consonant]y' - Replace with 'ies'

            foreach (var singular in dictionary.Keys)
            {
                var plural = dictionary[singular];

                Assert.AreEqual(plural, Formatting.Pluralize(2, singular));
                Assert.AreEqual(singular, Formatting.Pluralize(1, singular));
            }
        }

        [Test]
        public void IrregularPluralizationTests()
        {
            var dictionary = new Dictionary&lt;string, string&gt;();
            dictionary.Add(&quot;person&quot;, &quot;people&quot;);
            dictionary.Add(&quot;child&quot;, &quot;children&quot;);
            dictionary.Add(&quot;ox&quot;, &quot;oxen&quot;);

            foreach (var singular in dictionary.Keys)
            {
                var plural = dictionary[singular];

                Assert.AreEqual(plural, Formatting.Pluralize(2, singular));
                Assert.AreEqual(singular, Formatting.Pluralize(1, singular));
            }
        }

        [Test]
        public void NonPluralizingPluralizationTests()
        {
            var nonPluralizingWords = new List&lt;string&gt; { &quot;equipment&quot;, &quot;information&quot;, &quot;rice&quot;, &quot;money&quot;, &quot;species&quot;, &quot;series&quot;, &quot;fish&quot;, &quot;sheep&quot;, &quot;deer&quot; };

            foreach (var word in nonPluralizingWords)
            {
                Assert.AreEqual(word, Formatting.Pluralize(2, word));
                Assert.AreEqual(word, Formatting.Pluralize(1, word));
            }
        }
    }
}
</pre>
<p>And finally, usage.</p>
<pre class="brush: csharp;">
var output = Formatting.Pluralization(2, &quot;item&quot;);
// Produces &quot;items&quot;
output = Formatting.Pluralization(5, &quot;sheep&quot;);
// Produces &quot;sheep&quot;
output = Formatting.Pluralization(100, &quot;sausage&quot;);
// Produces &quot;sausages&quot;
output = Formatting.Pluralization(1, &quot;sausage&quot;);
// Produces &quot;sausage&quot;
</pre>
<p>Now, I&#8217;m sure that I&#8217;m missing some cases in there.  For example, I haven&#8217;t found a good way to pluralize &#8220;proof.&#8221;  If any of you wonderful people find another missing case, or if you want to add one, let me know in the comments.</p>
<br />Posted in .Net, Rails Tagged: .Net, C#, NUnit, Pluralization <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/89/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/89/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/89/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=89&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/10/28/pluralization-helper-for-c/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Google Maps Street View in Hamilton!</title>
		<link>http://mattgrande.wordpress.com/2009/10/08/google-maps-street-view-in-hamilton/</link>
		<comments>http://mattgrande.wordpress.com/2009/10/08/google-maps-street-view-in-hamilton/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 01:22:24 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=86</guid>
		<description><![CDATA[A couple days back, Google Maps Street View was finally added to Hamilton. Here&#8217;s some of my favourite images: My house, for all you stalkers. Hamilton&#8217;s Finest, hard at work. The Hamilton GO Station, one of my favourite buildings in this city of fantastic architecture. Actually, that&#8217;s all the neat stuff I&#8217;ve seen around Hamilton [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=86&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A couple days back, Google Maps Street View was finally added to Hamilton.  Here&#8217;s some of my favourite images:</p>
<ul>
<li><a href="http://bit.ly/Doxex">My house</a>, for all you stalkers.</li>
<li><a href="http://bit.ly/2OppN">Hamilton&#8217;s Finest</a>, hard at work.</li>
<li><a href="http://bit.ly/2NU4FZ">The Hamilton GO Station</a>, one of my favourite buildings in this city of fantastic architecture.</li>
</ul>
<p>Actually, that&#8217;s all the neat stuff I&#8217;ve seen around Hamilton so far&#8230;  Not that much, come to think of it.</p>
<p>In other news, I start a new job in just over a week.  Things will be hectic for the next while, so I won&#8217;t be posting as much.  And I don&#8217;t really post all that much to begin with so&#8230; Things will be <em>really</em> bad.</p>
<br />Posted in Uncategorized  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=86&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/10/08/google-maps-street-view-in-hamilton/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Love vs. Hate</title>
		<link>http://mattgrande.wordpress.com/2009/10/01/love-vs-hate/</link>
		<comments>http://mattgrande.wordpress.com/2009/10/01/love-vs-hate/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 14:40:03 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[lovestuffhatestuff.info]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=81</guid>
		<description><![CDATA[So, I created a website. Maybe you&#8217;d like to visit it? It&#8217;s just a quick little thing. You can see it here: lovestuffhatestuff.info Posted in lovestuffhatestuff.info, Rails<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=81&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, I created a website.  Maybe you&#8217;d like to visit it?  It&#8217;s just a quick little thing.  You can see it here: <a href="http://www.lovestuffhatestuff.info/">lovestuffhatestuff.info</a></p>
<br />Posted in lovestuffhatestuff.info, Rails  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/81/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/81/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/81/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=81&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/10/01/love-vs-hate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Delaying File Processing &amp; Uploading with DelayedJob and PaperClip</title>
		<link>http://mattgrande.wordpress.com/2009/08/11/delayedjob/</link>
		<comments>http://mattgrande.wordpress.com/2009/08/11/delayedjob/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 20:51:33 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[delayedjob]]></category>
		<category><![CDATA[paperclip]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=69</guid>
		<description><![CDATA[I&#8217;m going to say it right now. I love DelayedJob. I&#8217;ve been working on a project that involves uploading assets, mostly images, to S3 and resizing the images to three sizes. With the addition of DelayedJob, this can happen much faster. Before I go on, I should mention that I wouldn&#8217;t have been able to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=69&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m going to say it right now.  I love <a href="http://github.com/collectiveidea/delayed_job/tree/master">DelayedJob</a>.  I&#8217;ve been working on a project that involves uploading assets, mostly images, to S3 and resizing the images to three sizes.  With the addition of DelayedJob, this can happen much faster.</p>
<p>Before I go on, I should mention that I wouldn&#8217;t have been able to delay paperclip without <a href="http://eastblue.org/blag/2009/05/07/delaying-paperclip.html">this post</a>, and I wouldn&#8217;t have been able to delay S3 uploads without <a href="http://codewordstudios.com/posts/3-delayed-upload-delivery-to-s3-with-paperclip-delayed-job">this post</a>.  Thanks go out to both bloggers!</p>
<p>The <a href="http://github.com/tobi/delayed_job/tree/master">original DelayedJob</a> was done by <a href="http://github.com/tobi">tobi</a>.  I&#8217;ll be using the version created by <a href="http://github.com/collectiveidea">collectiveidea</a>, which has a few extra nice features.</p>
<p>So the first step is to install it.  I had to install both the plugin <em>and</em> the gem.  The plugin was unable to generate the database migration, and the gem was unable to run the rake task.  Hopefully, it was either a mistake on my part, or they&#8217;ll fix it soon.</p>
<pre class="brush: bash;">
script/plugin install git://github.com/collectiveidea/delayed_job.git
sudo gem install collectiveidea-delayed_job
</pre>
<p>Collectiveidea&#8217;s delayed_job has a nice generation script which will make your <code>delayed_jobs</code> table for you.</p>
<pre class="brush: bash;">
script/generate delayed_job
rake db:migrate
</pre>
<p>You&#8217;ll also want to add a <code>processing</code> column to your asset table.</p>
<pre class="brush: ruby;">
class AddProcessingToAsset &lt; ActiveRecord::Migration
  def self.up
    add_column :assets, :processing, :boolean, :default =&gt; true
  end

  def self.down
    remove_column :assets, :processing
  end
end
</pre>
<p>Your next step is to move into the code.  To prevent the S3 upload, we subclass our Asset model with TempAsset, and just save locally.</p>
<pre class="brush: ruby;">
class TempAsset &lt; Asset
  has_attached_file :media, :path =&gt; &quot;:rails_root/tmp/uploads/:id/:basename.:extension&quot;
end
</pre>
<p>In your controller, save your TempAsset instead of Asset, and call a method that will queue up the processing.</p>
<pre class="brush: ruby;">
class AssetsController &lt; ApplicationController
  def create
    @asset = TempAsset.new(params[:asset])
    @asset.save
    @asset.queue_move_to_s3
    redirect_to @asset
  end
end
</pre>
<p>From there, we want to make our <code>queue_move_to_s3</code> method.  I&#8217;m using <code>send_later</code> in this example, but <code>enqueue</code> works just as well.  While we&#8217;re at it, we&#8217;ll write the method that will perform the saving.</p>
<pre class="brush: ruby;">
# In temp_asset.rb
def queue_move_to_s3
  self.send_later(:perform)
end

def perform
  asset = Asset.find(self.id) # This is the same db record as self
  asset.media = self.media.to_file
  asset.processing = false
  asset.save!  # This will re-upload &amp; re-size your image as per your has_attached_file method in Asset

  path = self.media.path
  self.media.to_file.close
  File.delete(path)
end
</pre>
<p>One last thing you may want to do is have a &#8220;We&#8217;re Still Processing This File&#8221; image.  Thanks to the <code>processing</code> column we added earlier, it&#8217;s a piece of cake.</p>
<pre class="brush: ruby;">
# In asset.rb
def url(style=:thumb)
  if processing
    still_processing_image_path
  else
    self.media.url(style)
  end
end
</pre>
<p>There are unfortunately a few hoops to jump through to get this working, but in the end you have a much faster response time which leads to a much better user experience.  Hope this helps!</p>
<br />Posted in delayedjob, paperclip, Rails, Ruby, s3  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/69/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/69/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/69/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=69&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/08/11/delayedjob/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Features I&#8217;m Currently Infatuated with in Rails</title>
		<link>http://mattgrande.wordpress.com/2009/08/05/features-im-currently-infatuated-with-in-rails/</link>
		<comments>http://mattgrande.wordpress.com/2009/08/05/features-im-currently-infatuated-with-in-rails/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 20:28:50 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=57</guid>
		<description><![CDATA[I&#8217;ve recently started a new project in Rails and I&#8217;m trying to follow all the best practices. Sometimes at my company they have fallen by the wayside, but I&#8217;m really putting an effort into enforcing them on the team. In doing so, I&#8217;ve started using a few methods that I&#8217;ve known about for awhile, but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=57&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently started a new project in Rails and I&#8217;m trying to follow all the best practices.  Sometimes at my company they have fallen by the wayside, but I&#8217;m really putting an effort into enforcing them on the team.  In doing so, I&#8217;ve started using a few methods that I&#8217;ve known about for awhile, but never really had a chance to use.</p>
<h2>Nested Routes</h2>
<p>In a blog, Post has_many Comments, that&#8217;s a given.  Wouldn&#8217;t it be nice if your URLs reflected this relationship?  Now they can!  In your routes file, simply add <code>map.resources :post, :has_many =&gt; [:comments]</code>.  Then, change your paths from <code>new_comment_path</code> to <code>new_post_comment_path(@post)</code>.  In your CommentsController, you&#8217;ll have access to both params[:id] and params[:post_id] now.</p>
<p>While we&#8217;re talking about related objects, rather than creating objects like this:</p>
<pre class="brush: ruby;">
@post = Post.find(params[:post_id])
@comment = Comment.new(params[:comment])
@comment.post_id = @post.id
@comment.save
</pre>
<p>Do something like this:</p>
<pre class="brush: ruby;">
@post = Post.find(params[:post_id])
@comment = @post.comments.build(params[:comment])
@comment.save
</pre>
<p>This way, your association is automatically built.</p>
<h2>The new and improved render method</h2>
<p>This has been in Rails for awhile now, but I&#8217;m just now getting a chance to use it.  I always hated doing this:</p>
<pre class="brush: ruby;">
&lt;% @comments.each do |comment| %&gt;
  &lt;%= render :partial =&gt; &quot;comments/comment&quot;, :locals =&gt; { :comment =&gt; comment } %&gt;
&lt;% end %&gt;
</pre>
<p>It seemed so overly verbose, having the singular and plural form of &#8216;comment&#8217; in there six times.  As of Rails 2.2 (I believe) there&#8217;s been a handy helper, though.</p>
<pre class="brush: ruby;">
&lt;%= render @comments %&gt;
</pre>
<p>The loops through all of your comments and renders them into the partial &#8216;comments/_comment.html.erb&#8217; and give them a variable name of <code>comment</code>.  But what do you do when you&#8217;re in the partial?  Well that brings me to my next point&#8230;</p>
<h2>The joy of div_for</h2>
<p>You&#8217;re in a comment partial.  You want to wrap the comment in a div with a unique id.  You want to give all your comments the same class.  Don&#8217;t do this:</p>
<pre class="brush: ruby;">
&lt;div id=&quot;comment_&lt;%= comment.id -%&gt;&quot; class=&quot;comment&quot;&gt;
  &lt;!-- display the comment --&gt;&lt;/div&gt;
</pre>
<p>when you can do this:</p>
<pre class="brush: ruby;">
&lt;% div_for(comment) do %&gt;
  &lt;!-- display the comment --&gt;
&lt;% end %&gt;
</pre>
<p>Nice and easy.</p>
<br />Posted in Rails, Ruby  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/57/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/57/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/57/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=57&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/08/05/features-im-currently-infatuated-with-in-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Installing Ruby 1.9 from sources on Ubuntu</title>
		<link>http://mattgrande.wordpress.com/2009/07/28/installing-ruby-1-9-from-sources-on-ubuntu/</link>
		<comments>http://mattgrande.wordpress.com/2009/07/28/installing-ruby-1-9-from-sources-on-ubuntu/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 19:25:38 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=53</guid>
		<description><![CDATA[I found a few posts on how to do this, and all of them over-complicate things. Here&#8217;s a simple, step-by-step method to install ruby 1.9.1 from source. First, ensure that the latest stable version is still 1.9.1-p129. If it isn&#8217;t, make sure to change the appropriate file names. Step 1: Download the source. wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p129.tar.gz [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=53&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I found a few posts on how to do this, and all of them over-complicate things.  Here&#8217;s a simple, step-by-step method to install ruby 1.9.1 from source.</p>
<p>First, ensure that the latest stable version is still <a href="http://www.ruby-lang.org/en/downloads/">1.9.1-p129</a>.  If it isn&#8217;t, make sure to change the appropriate file names.</p>
<p><strong>Step 1:</strong> Download the source.<br />
<code>wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p129.tar.gz</code></p>
<p><strong>Step 2:</strong> Un-Tar<br />
<code>tar -zvxf ruby-1.9.1-p129.tar.gz</code></p>
<p><strong>Step 3:</strong> Configure (aka, Make the makefile)<br />
<code>cd ruby-1.9.1-p129/<br />
./configure</code></p>
<p><strong>Step 4:</strong> Make<br />
<code>make</code></p>
<p><strong>Step 5:</strong> Run the tests.  This is optional if you hate tests.<br />
<code>make test</code></p>
<p><strong>Step 6:</strong> Install Ruby<br />
<code>sudo make install</code></p>
<p>And that&#8217;s it!  You&#8217;re done!</p>
<br />Posted in Ruby, Ubuntu  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/53/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/53/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/53/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=53&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/07/28/installing-ruby-1-9-from-sources-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler #3</title>
		<link>http://mattgrande.wordpress.com/2009/05/13/project-euler-3/</link>
		<comments>http://mattgrande.wordpress.com/2009/05/13/project-euler-3/#comments</comments>
		<pubDate>Wed, 13 May 2009 22:04:32 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[Golf]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=48</guid>
		<description><![CDATA[Here&#8217;s the next one. I&#8217;m not happy with the way I determine if it&#8217;s a prime number (checking the modulo of every possible number), but it works. The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? And the golf&#8230; Posted in Golf, [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=48&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s <a href="http://projecteuler.net/index.php?section=problems&amp;id=3">the next one</a>.  I&#8217;m not happy with the way I determine if it&#8217;s a prime number (checking the modulo of every possible number), but it works.</p>
<blockquote><p>The prime factors of 13195 are 5, 7, 13 and 29.</p>
<p>What is the largest prime factor of the number 600851475143 ?</p></blockquote>
<pre class="brush: ruby;">
def find_largest_prime_factor(n)
  if n % 2 == 0
    find_largest_prime_factor(n/2)
  else
    x = find_divisor(n, 3)
  end
  puts x
end

def find_divisor(number, divisor)
  return divisor if divisor &gt;= number
  if number % divisor == 0
    find_divisor(number/divisor, divisor)
  else
    find_divisor(number, divisor+2)
  end
end

find_largest_prime_factor(600851475143)
</pre>
<p>And the golf&#8230;</p>
<pre class="brush: ruby;">
# Score: 98
def a n;p n%2==0?a(n/2):b(n,3);end;def b(n, d);d&gt;=n ?d:n%d==0?b(n/d,d):b(n,d+2);end;a 600851475143
</pre>
<br />Posted in Golf, Project Euler, Ruby  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=48&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/05/13/project-euler-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Euler #2</title>
		<link>http://mattgrande.wordpress.com/2009/05/11/project-euler-2/</link>
		<comments>http://mattgrande.wordpress.com/2009/05/11/project-euler-2/#comments</comments>
		<pubDate>Tue, 12 May 2009 03:10:43 +0000</pubDate>
		<dc:creator>Matt Grande</dc:creator>
				<category><![CDATA[Golf]]></category>
		<category><![CDATA[Project Euler]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://mattgrande.wordpress.com/?p=41</guid>
		<description><![CDATA[Here we go, Project Euler #2! Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, &#8230; Find the sum of all the even-valued terms in the sequence [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=41&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here we go, <a href="http://projecteuler.net/index.php?section=problems&amp;id=2">Project Euler #2</a>!</p>
<blockquote><p>Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:</p>
<p style="text-align:center;">1, 2, 3, 5, 8, 13, 21, 34, 55, 89, &#8230;</p>
<p>Find the sum of all the even-valued terms in the sequence which do not exceed four million.</p></blockquote>
<pre class="brush: ruby;">
one_back, two_back, current_fib, total = 1, 1, 0, 0&lt;/code&gt;

while current_fib &amp;lt; 4_000_000 do
two_back = one_back
one_back = current_fib
current_fib = one_back + two_back
total += current_fib if current_fib % 2 == 0
end

puts total
</pre>
<p>And the golf&#8230;</p>
<pre class="brush: ruby;">
# Score: 69
a,b,c,t=1,0,0,0;while(c&lt;4000000):b=a;a=c;c=a+b;t+=c if c%2==0;end;p t
</pre>
<p>EDIT!</p>
<p>I knew there was a way to do it without that stupid current_fib variable, but I couldn&#8217;t get it to work at first.  Then, as soon as I post, I realised what I was doing wrong.</p>
<pre class="brush: ruby;">
one_back, two_back, total = 1, 1, 0

while one_back &lt; 4_000_000 do
  total += one_back if one_back % 2 == 0
  current = one_back
  one_back += two_back
  two_back = current
end

puts total
</pre>
<p>And, even better, it improved my golf score!</p>
<pre class="brush: ruby;">
# Score: 63
a,b,t=1,1,0;while a&lt;4000000:t+=a if a%2==0;c=a;a+=b;b=c;end;p t
</pre>
<br />Posted in Golf, Project Euler, Ruby  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mattgrande.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mattgrande.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mattgrande.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mattgrande.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mattgrande.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mattgrande.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mattgrande.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mattgrande.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mattgrande.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mattgrande.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mattgrande.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mattgrande.wordpress.com/41/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mattgrande.wordpress.com/41/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mattgrande.wordpress.com/41/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mattgrande.wordpress.com&amp;blog=4237388&amp;post=41&amp;subd=mattgrande&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mattgrande.wordpress.com/2009/05/11/project-euler-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">Matt Grande</media:title>
		</media:content>
	</item>
	</channel>
</rss>
