<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US">
  <title>Tetromino.com - Home</title>
  <id>tag:tetromino.com,2008:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  
  <link href="http://tetromino.com/" rel="alternate" type="text/html" />
  <updated>2008-06-18T18:50:00Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/tetromino" type="application/atom+xml" /><entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2008-06-18:54</id>
    <published>2008-06-18T18:46:00Z</published>
    <updated>2008-06-18T18:50:00Z</updated>
    <category term="Misc" />
    <category term="Web Dev" />
    <category term="browser" />
    <category term="colour profiles" />
    <category term="firefox" />
    <category term="photography" />
    <link href="http://tetromino.com/2008/6/18/firefox-3-with-colour-profiling-support" rel="alternate" type="text/html" />
    <title>Firefox 3 - With Colour Profiling Support!</title>
<content type="html">
            &lt;div&gt;&lt;a href="http://www.flickr.com/photos/chuckbergeron/2590878222/" title="photo sharing"&gt;&lt;img src="http://farm4.static.flickr.com/3043/2590878222_8a7d7d466e.jpg" alt="a tear in the fabric" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;span&gt;&lt;a href="http://www.flickr.com/photos/chuckbergeron/2590878222/"&gt;a tear in the fabric&lt;/a&gt;, originally uploaded by &lt;a href="http://www.flickr.com/people/chuckbergeron/"&gt;chuck.bergeron&lt;/a&gt;&lt;/div&gt;

	&lt;p&gt;Just wanted to let you in a little (big) secret. Firefox 3 is out! It’s effin’ insanely good, I can’t even believe it. http://www.mozilla.com/en-US/firefox/&lt;/p&gt;


	&lt;p&gt;To get the full colour profile support, after downloading and installing open up a tab and instead of typing in http://whatever, type in &lt;i&gt;about:config&lt;/i&gt; and press enter. It’ll warn you that you can screw things up, but just ignore the warning and continue on. Here’s where you can configure &lt;span class="caps"&gt;EVERYTHING&lt;/span&gt; about the browser. In the “filter” bar near the top, type in &lt;i&gt;gfx&lt;/i&gt; and double-click the &lt;i&gt;gfx.color_management.enabled&lt;/i&gt; option so that it’s value is set to &lt;i&gt;true&lt;/i&gt;. Restart Firefox. Now your photos and everyone elses will look the way they should (no more desaturation on Flickr!) – wooo!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2008-02-20:53</id>
    <published>2008-02-20T22:08:00Z</published>
    <updated>2008-02-20T22:49:47Z</updated>
    <category term="Misc" />
    <category term="Ruby &amp; Rails" />
    <category term="capistrano" />
    <category term="deployment" />
    <category term="rails" />
    <link href="http://tetromino.com/2008/2/20/upgrading-to-capistrano-2-0" rel="alternate" type="text/html" />
    <title>Upgrading to Capistrano 2.0</title>
<content type="html">
            &lt;p&gt;&lt;img src="/images/post_19.jpg" height="200" alt="Jesus, scary." width="318" /&gt;&lt;/p&gt;


	&lt;p&gt;This past week I finally took the time to update my deploy recipe to the new Capistrano 2.0 format. It’s amazing how &lt;span class="caps"&gt;DRY&lt;/span&gt; the new namespaces feature is. I was able to take all of my custom tasks used for our Apis Networks shared hosting packages and separate them into their own plugin. This way, I’m no longer clobbering the default Capistrano deployment strategy.&lt;/p&gt;


	&lt;p&gt;It’s as easy as creating a two folders in your vendor/plugins directory. One for the name of the plugin, and one dubbed ‘recipes’. Here’s a typical directory tree:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;-- rails_app&lt;tt&gt;
&lt;/tt&gt; -- vendor&lt;tt&gt;
&lt;/tt&gt;  -- plugins&lt;tt&gt;
&lt;/tt&gt;   -- your_cap_plugin&lt;tt&gt;
&lt;/tt&gt;    -- recipes&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Then, create a file in the recipes directory using any filename you like. Capistrano 2.0 will automatically load any tasks inside this file. Begin naming your deployment recipe inside it’s own namespace, like so:&lt;/p&gt;


&lt;h3&gt;
  recipes/tasks.rb
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;namespace &lt;span class="sy"&gt;:my_tasks&lt;/span&gt; &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  namespace &lt;span class="sy"&gt;:deploy&lt;/span&gt; &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    desc &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;Restart the FCGI ruby process&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    task &lt;span class="sy"&gt;:restart&lt;/span&gt;, &lt;span class="sy"&gt;:roles&lt;/span&gt; =&amp;gt; &lt;span class="sy"&gt;:app&lt;/span&gt; &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      puts &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;Restarting the ruby processes...&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="c"&gt;# Ignore this confusing unix syntax, it's just for examples sake&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      run &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;ps lx | grep ruby | grep -v grep | awk '{print $3}' | xargs --no-run-if-empty kill -9&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;To hook your custom tasks into your deployment strategy, add before and after filters to your config/deploy.rb.&lt;/p&gt;


&lt;h3&gt;
  config/deploy.rb
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;namespace &lt;span class="sy"&gt;:deploy&lt;/span&gt; &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# After restarting the ruby process, run the default cleanup task&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# and run my custom 'post_live' task&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  after &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;deploy:restart&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;deploy:cleanup&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;my_tasks:deploy:post_live&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  desc &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;This overrides the default Capistrano deploy:restart task&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  task &lt;span class="sy"&gt;:restart&lt;/span&gt;, &lt;span class="sy"&gt;:roles&lt;/span&gt; =&amp;gt; &lt;span class="sy"&gt;:app&lt;/span&gt; &lt;span class="r"&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    my_tasks.deploy.restart&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;  &lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Re-usable plugin code, fun for every project!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2008-02-15:48</id>
    <published>2008-02-15T00:48:00Z</published>
    <updated>2008-02-15T00:59:27Z</updated>
    <category term="Ruby &amp; Rails" />
    <category term="pagination" />
    <category term="rails" />
    <link href="http://tetromino.com/2008/2/15/series-plug-in-arsenal-paginating-find" rel="alternate" type="text/html" />
    <title>Series: Plug-in arsenal - Paginating Find</title>
<content type="html">
            &lt;p&gt;&lt;img src="/images/post_18_paginating_find.png" height="200" alt="Books and recordsets!" width="200" /&gt;&lt;/p&gt;


	&lt;p&gt;Oh, pagination. How you have been tormented over the years in the Rails community. For those of you who have no idea what the devil pagination is, run a &lt;a href="http://www.google.com/search?q=what+is+pagination&amp;amp;#38;hl=en&amp;amp;#38;start=10&amp;amp;#38;sa=N"&gt;search on Google&lt;/a&gt; and take a look at near the bottom of the page – You should see “previous” and “next” links, alongside numbers of pages with which to jump to. That’s pagination!&lt;/p&gt;


	&lt;p&gt;I believe the majority of current opinion on paginating through records is to avoid using the Rails 1.0 built-in Pagination class. In Rails 2.0, it’s been removed and requires the install of an additional plug-in to receive the previous functionality. Cue &lt;i&gt;Paginating Find&lt;/i&gt;, a plug-in written by Alex Wolfe of &lt;a href="http://cardboardrocket.com/pages/paginating_find"&gt;Carboard Rocket&lt;/a&gt;. I first learned of &lt;i&gt;Paginating Find&lt;/i&gt; via &lt;a href="http://www.igvita.com/2006/09/10/faster-pagination-in-rails/"&gt;Ilya Grigorik’s blog&lt;/a&gt;, as he had written some Helpers &amp;amp; View Partials to support it. Let’s jump in, shall we?&lt;/p&gt;


You can install &lt;i&gt;Paginating Find&lt;/i&gt; here:
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;ruby script/plugin install http://svn.cardboardrocket.com/paginating_find&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;&lt;i&gt;Paginating Find&lt;/i&gt; overrides the default ActiveRecord::find method, and allows a new set of options dubbed :page to accompany the familiar :conditions, :order, etc. We’ll use a &lt;i&gt;Bulletin&lt;/i&gt; model for our example:&lt;/p&gt;


&lt;h3&gt;
  bulletin.rb (Model)
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.find_all_using_pagination( options = {} )&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;return&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.find( &lt;span class="sy"&gt;:all&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="sy"&gt;:page&lt;/span&gt; =&amp;gt; { &lt;tt&gt;
&lt;/tt&gt;      &lt;span class="sy"&gt;:size&lt;/span&gt; =&amp;gt; options[&lt;span class="sy"&gt;:number_of_records&lt;/span&gt;],&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="sy"&gt;:current&lt;/span&gt; =&amp;gt; options[&lt;span class="sy"&gt;:current_page&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;    } )&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;These options are typically provided by &lt;span class="caps"&gt;GET&lt;/span&gt; variables passed through the &lt;span class="caps"&gt;URL&lt;/span&gt; string to the controller. The new :page option requirs two vars, :size &amp;amp; :current. Use :size to dictate how many &lt;i&gt;Bulletin’s&lt;/i&gt; should be pulled from the database per page, and :current to state which page we’re currently viewing. For example, if :current is set to 2, and :size is at 10, we would receive Bulletin’s 11-21.&lt;/p&gt;


	&lt;p&gt;The best part about &lt;i&gt;Paginating Find&lt;/i&gt; is that it works transparently. If you don’t provide the :page option in the find() call, Rails will enact a regular find() call and ignore the fact that &lt;i&gt;Paginating Find&lt;/i&gt; is even installed.&lt;/p&gt;


&lt;h3&gt;
  Further readings:
&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;
    Want to display the page numbers, ‘previous’ and ‘next’ links, as well as &lt;span class="caps"&gt;CSS&lt;/span&gt; styling? See Ilya’s &lt;a href="http://www.igvita.com/2006/09/10/faster-pagination-in-rails/"&gt;Faster Pagination in Rails&lt;/a&gt; article.
  &lt;/li&gt;
  &lt;li&gt;
    Find more info for this plug-in at the &lt;a href="http://cardboardrocket.com/pages/paginating_find"&gt;Carboard Rocket page&lt;/a&gt;.
  &lt;/li&gt;
&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2008-02-05:40</id>
    <published>2008-02-05T19:24:00Z</published>
    <updated>2008-02-14T23:24:13Z</updated>
    <category term="Ruby &amp; Rails" />
    <link href="http://tetromino.com/2008/2/5/a-variation-on-rails-verbose-time-helper" rel="alternate" type="text/html" />
    <title>A Variation On Rails' Verbose Time Helper </title>
<content type="html">
            &lt;p&gt;Oh tax season. Does anyone else find that January is the busiest month of the year?&lt;/p&gt;


	&lt;p&gt;A client of ours recently wanted a custom version of the built-in Rails helper &lt;em&gt;distance_of_time_in_words&lt;/em&gt;. Basically, they were looking for a countdown that would dynamically let the customers know how much time they had left to order.&lt;/p&gt;


	&lt;p&gt;For those unfamiliar with &lt;em&gt;distance_of_time_in_words&lt;/em&gt;, you provide it with Date &amp;amp; Time objects and it will state the duration between them in a more human readable format. For instance:&lt;/p&gt;


&lt;h3&gt;
  index.html.erb (View)
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&amp;lt;%= distance_of_time_in_words( &lt;span class="co"&gt;Time&lt;/span&gt;.now, &lt;span class="i"&gt;45&lt;/span&gt;.days.from_now ) &lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;tt&gt;
&lt;/tt&gt;  # =&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; about &lt;span class="i"&gt;1&lt;/span&gt; month&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= distance_of_time_in_words( &lt;span class="co"&gt;Time&lt;/span&gt;.mktime( &lt;span class="i"&gt;2008&lt;/span&gt;, &lt;span class="i"&gt;02&lt;/span&gt;, &lt;span class="i"&gt;05&lt;/span&gt; ), &lt;span class="co"&gt;Time&lt;/span&gt;.mktime( &lt;span class="i"&gt;2008&lt;/span&gt;, &lt;span class="i"&gt;03&lt;/span&gt;, &lt;span class="i"&gt;29&lt;/span&gt; ) ) &lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;tt&gt;
&lt;/tt&gt;  # =&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; about &lt;span class="i"&gt;1&lt;/span&gt; month&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This default behavior is great for informal purposes, such as how long it’s been since a blog article was posted or a comment made. However, I’ve come up with something a little more accurate:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&amp;lt;%= distance_of_time_in_words( &lt;span class="co"&gt;Time&lt;/span&gt;.now, &lt;span class="i"&gt;45&lt;/span&gt;.days.from_now ) &lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt; &lt;tt&gt;
&lt;/tt&gt;  # =&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="i"&gt;1&lt;/span&gt; month, &lt;span class="i"&gt;14&lt;/span&gt; days&lt;tt&gt;
&lt;/tt&gt;&amp;lt;%= distance_of_time_in_words( &lt;span class="co"&gt;Time&lt;/span&gt;.mktime( &lt;span class="i"&gt;2008&lt;/span&gt;, &lt;span class="i"&gt;02&lt;/span&gt;, &lt;span class="i"&gt;05&lt;/span&gt; ), &lt;span class="co"&gt;Time&lt;/span&gt;.mktime( &lt;span class="i"&gt;2008&lt;/span&gt;, &lt;span class="i"&gt;03&lt;/span&gt;, &lt;span class="i"&gt;29&lt;/span&gt; ) ) &lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;tt&gt;
&lt;/tt&gt;  # =&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="i"&gt;1&lt;/span&gt; month, &lt;span class="i"&gt;22&lt;/span&gt; days&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


&lt;h3&gt;
  application_helper.rb (Helper)
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;distance_of_time_in_words&lt;/span&gt;( from_time, to_time = &lt;span class="i"&gt;0&lt;/span&gt;, include_seconds = &lt;span class="pc"&gt;true&lt;/span&gt; )&lt;tt&gt;
&lt;/tt&gt;  from_time = from_time.to_time &lt;span class="r"&gt;if&lt;/span&gt; from_time.respond_to?(&lt;span class="sy"&gt;:to_time&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  to_time = to_time.to_time &lt;span class="r"&gt;if&lt;/span&gt; to_time.respond_to?(&lt;span class="sy"&gt;:to_time&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;  distance_in_minutes = (((to_time - from_time).abs)/&lt;span class="i"&gt;60&lt;/span&gt;).round&lt;tt&gt;
&lt;/tt&gt;  distance_in_seconds = ((to_time - from_time).abs).round&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;case&lt;/span&gt; distance_in_minutes&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;0&lt;/span&gt;..&lt;span class="i"&gt;1&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;case&lt;/span&gt; distance_in_seconds&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;0&lt;/span&gt;..&lt;span class="i"&gt;59&lt;/span&gt; &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;pluralize( distance_in_seconds, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;second&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; )&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="r"&gt;else&lt;/span&gt;             &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;1 minute&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;2&lt;/span&gt;..&lt;span class="i"&gt;59&lt;/span&gt;           &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;distance_in_minutes&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="k"&gt; minutes&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;60&lt;/span&gt;              &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;1 hour&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;61&lt;/span&gt;..&lt;span class="i"&gt;1439&lt;/span&gt;        &lt;span class="r"&gt;then&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      hours, minutes = (distance_in_minutes.to_f / &lt;span class="fl"&gt;60.0&lt;/span&gt;), (distance_in_minutes.to_f % &lt;span class="fl"&gt;60.0&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;pluralize( hours.floor, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;hour&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; )&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="k"&gt;, &lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;pluralize( minutes.floor, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;minutes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; )&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;      &lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;1440&lt;/span&gt;..&lt;span class="i"&gt;1500&lt;/span&gt;      &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;1 day&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;1501&lt;/span&gt;..&lt;span class="i"&gt;2879&lt;/span&gt;      &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;1 day, &lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;pluralize( (distance_in_minutes.to_f / &lt;span class="i"&gt;60&lt;/span&gt; - &lt;span class="i"&gt;24&lt;/span&gt;).floor, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;hour&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; )&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;2880&lt;/span&gt;..&lt;span class="i"&gt;43199&lt;/span&gt;     &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;(distance_in_minutes / &lt;span class="i"&gt;1440&lt;/span&gt;).round&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="k"&gt; days&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;43200&lt;/span&gt;..&lt;span class="i"&gt;44641&lt;/span&gt;    &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;1 month&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;44641&lt;/span&gt;..&lt;span class="i"&gt;86399&lt;/span&gt;    &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;1 month, &lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;pluralize( ( distance_in_minutes / &lt;span class="i"&gt;1440&lt;/span&gt; - &lt;span class="i"&gt;30&lt;/span&gt; ).floor, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;day&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; )&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;when&lt;/span&gt; &lt;span class="i"&gt;86400&lt;/span&gt;..&lt;span class="i"&gt;525599&lt;/span&gt;   &lt;span class="r"&gt;then&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;over &lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;(distance_in_minutes / &lt;span class="i"&gt;43200&lt;/span&gt;).floor&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="k"&gt; months&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;else&lt;/span&gt;                      &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;over &lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;pluralize( (distance_in_minutes / &lt;span class="i"&gt;525600&lt;/span&gt;).round, &lt;span class="s"&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="k"&gt;years&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;/span&gt; ) &lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


Alternatively, we could use the method alias &lt;em&gt;time_ago_in_words&lt;/em&gt; to skip the need for a first argument, and assume we’re comparing the current time with the provided distant time:
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&amp;lt;%= time_ago_in_words( &lt;span class="co"&gt;Time&lt;/span&gt;.mktime( &lt;span class="i"&gt;2008&lt;/span&gt;, &lt;span class="i"&gt;03&lt;/span&gt;, &lt;span class="i"&gt;29&lt;/span&gt; ) ) &lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;tt&gt;
&lt;/tt&gt; #=&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="i"&gt;1&lt;/span&gt; month, &lt;span class="i"&gt;22&lt;/span&gt; days (assuming current time is &lt;span class="co"&gt;February&lt;/span&gt; &lt;span class="i"&gt;5&lt;/span&gt;th, &lt;span class="i"&gt;2008&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-12-28:36</id>
    <published>2007-12-28T04:26:00Z</published>
    <updated>2007-12-28T04:42:56Z</updated>
    <category term="Misc" />
    <category term="Ruby &amp; Rails" />
    <category term="Web Dev" />
    <category term="leopard" />
    <category term="mac os x" />
    <category term="mysql" />
    <category term="rails" />
    <category term="tiger" />
    <link href="http://tetromino.com/2007/12/28/welcome-to-leopard-migrating-your-old-database" rel="alternate" type="text/html" />
    <title>Welcome to 10.5! Migrating Your Tiger MySQL Databases to Leopard</title>
<content type="html">
            &lt;p&gt;After quite a bit of deliberation, I’ve decided to move up from Tiger to Leopard. Thankfully, the path to Rails w/ MySQL has been much easier than it ever was on Tiger.&lt;/p&gt;


	&lt;p&gt;So far, my greatest obstacle has been installing MySQL and bringing my old databases over from my backup. The gracious folks over at Hivelogic have created a brilliant, line-by-line &lt;a href="http://hivelogic.com/articles/installing-mysql-on-mac-os-x/" title="make, make install, ya know"&gt;tutorial for building MySQL on Leopard&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;After getting MySQL up and running successfully, I completely overlooked the fact that my databases would be wiped clean. I realized the easiest thing to do would be to copy the databases from my Tiger backup.&lt;/p&gt;


	&lt;p&gt;&lt;i&gt;Note:&lt;/i&gt; Both of my MySQL installs are Version 5, so I crossed my fingers hoping they’d be compatible and so far there’s been no problems.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Step 1.&lt;/b&gt; Make sure to turn off your current Leopard MySQL install. The command for this in the tutorial is: sudo launchctl unload -w /Library/LaunchDaemons/com.mysql.mysqld.plist which sends the unload command to your plist file.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Step 2.&lt;/b&gt; Locate the “data” or “var” folder in your MySQL backup directory. For instance, mine was in /usr/local/mysql on my Tiger install.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Step 3.&lt;/b&gt; sudo cp -rf /Volumes/Backup/usr/local/mysql/data /usr/local/mysql
Or substitute the paths for the proper source and destination. This will copy the database folder from your Tiger backup to your fresh Leopard MySQL install.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Step 4.&lt;/b&gt; sudo chown -R mysql /usr/local/mysql/data mysql
Give ownership of the database directory to the mysql user.&lt;/p&gt;


	&lt;p&gt;&lt;b&gt;Step 5.&lt;/b&gt; Start up the server and you should be good to go!&lt;/p&gt;


	&lt;p&gt;Happy Leopard’ing.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-12-14:35</id>
    <published>2007-12-14T03:47:00Z</published>
    <updated>2007-12-14T03:59:51Z</updated>
    <category term="Ruby &amp; Rails" />
    <link href="http://tetromino.com/2007/12/14/to-trick-to_xml" rel="alternate" type="text/html" />
    <title>To Trick 'to_xml'</title>
<content type="html">
            &lt;p&gt;&lt;img src="/images/post_15_xml_knowledge.jpg" height="191" alt="XML Knowledge!" width="200" /&gt;&lt;/p&gt;


	&lt;p&gt;Recently, I’ve been sprinkling more and more &lt;span class="caps"&gt;XML&lt;/span&gt; into my projects. There’s a terrific helper method in Rails dubbed to_xml, which you can run over a collection of records.&lt;/p&gt;


	&lt;p&gt;At first, I had trouble using this because I was limited to outputting every typical AR attribute for the given model. (ie. I’d receive &amp;lt;name&gt;, &amp;lt;description&gt;, &amp;lt;url&gt;, etc. &lt;span class="caps"&gt;XML&lt;/span&gt; tags) After a bit of digging I found some options for to_xml which provides you with control over which attributes it &lt;span class="caps"&gt;XML&lt;/span&gt;’izes.&lt;/p&gt;


	&lt;p&gt;Here they are in action:&lt;/p&gt;


&lt;h3&gt;
  xml_controller.rhtml (Controller)
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;compile_slides&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="iv"&gt;@slides&lt;/span&gt; = &lt;span class="co"&gt;Slide&lt;/span&gt;.find( &lt;span class="sy"&gt;:all&lt;/span&gt; )&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# The :only call is necessary to omit all of the typical attributes&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  render( &lt;span class="sy"&gt;:xml&lt;/span&gt; =&amp;gt; &lt;span class="iv"&gt;@slides&lt;/span&gt;.to_xml(&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="sy"&gt;:only&lt;/span&gt; =&amp;gt; [],&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="sy"&gt;:methods&lt;/span&gt; =&amp;gt; [ &lt;span class="sy"&gt;:name&lt;/span&gt;, &lt;span class="sy"&gt;:cover_photo_url&lt;/span&gt;, &lt;span class="sy"&gt;:xml_url&lt;/span&gt; ]&lt;tt&gt;
&lt;/tt&gt;  ) )&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;The :only option is overriding the to_xml’s default behaviour of spitting out every attribute, while :methods is stating which custom methods for the AR Model I want to include. For instance, instances of Slide repond to a method named ‘xml_url’:&lt;/p&gt;


&lt;h3&gt;
  slide.rb (Model)
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;xml_url&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;return&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="r"&gt;if&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.url.blank?&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;return&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;http://&lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;&lt;span class="pc"&gt;self&lt;/span&gt;.url&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="r"&gt;unless&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.url[&lt;span class="rx"&gt;&lt;span class="dl"&gt;/&lt;/span&gt;&lt;span class="k"&gt;http&lt;/span&gt;&lt;span class="ch"&gt;\:&lt;/span&gt;&lt;span class="ch"&gt;\/&lt;/span&gt;&lt;span class="ch"&gt;\/&lt;/span&gt;&lt;span class="dl"&gt;/&lt;/span&gt;&lt;/span&gt;]&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;return&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.url&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;...&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This will give us something like:&lt;/p&gt;


&lt;h3&gt;
  slides.xml (XML)
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="ta"&gt;&amp;lt;slide&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="ta"&gt;&amp;lt;xml-link&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    /articles/1-how-to-search-google&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="ta"&gt;&amp;lt;/xml-link&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="ta"&gt;&amp;lt;/slide&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Flexible!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-11-27:34</id>
    <published>2007-11-27T22:22:00Z</published>
    <updated>2007-11-27T22:30:30Z</updated>
    <category term="Misc" />
    <link href="http://tetromino.com/2007/11/27/weak-apple-keyboards" rel="alternate" type="text/html" />
    <title>Weak Apple Keyboards</title>
<content type="html">
            &lt;p&gt;Today, my gal mentioned that for the third time in a year, something was amiss with her Macbook keyboard. This time it’s starting to crack a bit, which will only get worse as we all know. The first time the “V” key didn’t work at all, and the second the spacebar wasn’t registering properly on one side. Of course, all she has to do is take it to the Mac store on campus and they’ll fix it up for her under warranty at no cost, but it’s more of an annoyance than anything.&lt;/p&gt;


	&lt;p&gt;Don’t get me wrong, I love Apple &amp; I’ve had much more luck with my Macbook. Still, I feel the need to dedicate this video to Apple and their shoddy laptop keyboards:&lt;/p&gt;


&amp;lt;object height="355" width="425"&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;param&gt;&amp;lt;/param&gt;&amp;lt;embed src="http://www.youtube.com/v/unkIVvjZc9Y&amp;amp;#38;rel=1" height="355" width="425"&gt;&amp;lt;/embed&gt;&amp;lt;/object&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-11-22:33</id>
    <published>2007-11-22T23:14:00Z</published>
    <updated>2007-11-22T23:19:13Z</updated>
    <category term="Business" />
    <category term="Ruby &amp; Rails" />
    <category term="hosting" />
    <category term="rails" />
    <link href="http://tetromino.com/2007/11/22/rails-hosting" rel="alternate" type="text/html" />
    <title>Rails hosting</title>
<content type="html">
            &lt;p&gt;My buddy just sent me a link to a hosting company I haven’t seen before: &lt;a href="http://www.sitefive.com" title="Site5 Hosting"&gt;Site5&lt;/a&gt;. I’m curious as to how their customer support is, and how much control you get over your hosting package. (e.g. &lt;span class="caps"&gt;SSH&lt;/span&gt;? Multiple domains? etc.)&lt;/p&gt;


	&lt;p&gt;We at &lt;a href="http://carbonmedia.ca" title="Carbon Media Design"&gt;Carbon Media&lt;/a&gt; have always trusted our sites to &lt;a href="http://apisnetworks.com" title="Apis Networks hosting"&gt;Apis Networks&lt;/a&gt;, which we’ve had nothing but exceptional customer service from. Plus, they were more than accommodating when starting off with Ruby on Rails and helping us get our applications up and running.&lt;/p&gt;


	&lt;p&gt;However, &lt;a href="http://www.sitefive.com/hosting/rails.php" title="Site5's Rails Page"&gt;Site5&lt;/a&gt; does support Rails. If anybody has experience with this company, please leave a comment or send an email to let me know what you think of them! I may just have to start up a personal project to give them a test run…&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-11-19:32</id>
    <published>2007-11-19T03:29:00Z</published>
    <updated>2007-11-19T04:16:25Z</updated>
    <category term="Misc" />
    <category term="audio" />
    <category term="c" />
    <category term="java" />
    <category term="javascript" />
    <category term="Max" />
    <category term="MSP" />
    <link href="http://tetromino.com/2007/11/19/max-msp" rel="alternate" type="text/html" />
    <title>Max / MSP</title>
<content type="html">
            &lt;p&gt;I believe I’ll be skipping a post on Rails this week, as I’ve been sidetracked by a new toy:&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.cycling74.com/products/maxmsp" title="Max / MSP"&gt;&lt;img src="/images/post_12_max_msp.gif" height="325" alt="Max / MSP in action" width="450" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.cycling74.com/products/maxmsp" title="Max / MSP"&gt;Max / &lt;span class="caps"&gt;MSP&lt;/span&gt;&lt;/a&gt; is a graphical programming language for audio, and it looks like it. The interface isn’t pretty, but it’s insides provide you with the powerful ability to create whatever your digital heart desires. This program has been around for over 15 years now, and has been used by quite a few artists I highly regard. The best part is, it’s extensible using C, Java and JavaScript! If you’re interested in both sound &amp; programming, make sure to check it out. (&lt;a href="http://en.wikipedia.org/wiki/Max_%28software%29" title="Max / MSP on Wikipedia"&gt;wiki&lt;/a&gt;)&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-11-12:28</id>
    <published>2007-11-12T00:46:00Z</published>
    <updated>2007-12-04T22:32:37Z</updated>
    <category term="JavaScript" />
    <category term="Ruby &amp; Rails" />
    <category term="Web Dev" />
    <category term="XHTML &amp; CSS" />
    <link href="http://tetromino.com/2007/11/12/series-my-arsenal-of-plug-ins-bundle-fu" rel="alternate" type="text/html" />
    <title>Series: My arsenal of plug-ins - Bundle-fu</title>
<content type="html">
            &lt;p&gt;&lt;b&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;:&lt;/b&gt; Looks like they’ve added functionality like this in Rails 2.0 using &lt;i&gt;&amp;lt;%= stylesheet_link_tag( “main”, “forms”, “utilities”, { :cache =&amp;gt; “frontend” } )  %&amp;gt;&lt;/i&gt;. Check out the &lt;a href="http://weblog.rubyonrails.org/2007/9/30/rails-2-0-0-preview-release" title="Rails 2.0 RC2"&gt;latest release candidate w/ notes&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;After writing about all of the &lt;a href="http://tetromino.com/2007/10/23/firefox-extensions-i-use" title="Previous article: Firefox Extensions I Use"&gt;nifty Firefox extensions&lt;/a&gt; I use on a daily basis, I had an idea to detail the Rails plug-ins and gems I’m in love with. This marks the beginning.&lt;/p&gt;


&lt;p class="center"&gt;
  &lt;a href="http://code.google.com/p/bundle-fu/" title="Bundle-fu on Google code"&gt;&lt;img class="no-border" src="/images/post_11_bundle_fu_logo.png" alt="Bundle-fu fake logo" /&gt;&lt;/a&gt;&lt;/p&gt;

	&lt;p&gt;Tim Harper’s &lt;a href="http://code.google.com/p/bundle-fu/" title="Bundle-fu on Google code"&gt;Bundle-fu&lt;/a&gt; plug-in was just the thing I was looking for while trying to cut down on the number of server requests per page. All you have to do is wrap both your stylesheets &amp;amp; javascripts in your layout file into separate code blocks, and bundle-fu will take care of the rest.&lt;/p&gt;


&lt;h3&gt;
  layout.rhtml
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&amp;lt;% bundle( { &lt;span class="sy"&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;styles&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; } ) &lt;span class="r"&gt;do&lt;/span&gt; -&lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;%= stylesheet_link_tag( &amp;quot;common&amp;quot;, :media =&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;screen&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; ) &lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;tt&gt;
&lt;/tt&gt;  &amp;lt;%= stylesheet_link_tag( &amp;quot;main&amp;quot;,   :media =&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;screen&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; ) &lt;span class="s"&gt;&lt;span class="dl"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="k"&gt;&lt;tt&gt;
&lt;/tt&gt;  ... etc.&lt;tt&gt;
&lt;/tt&gt;&amp;lt;% end -%&lt;/span&gt;&lt;span class="dl"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;This outputs a one-liner pointing to one lovely file all your css:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="ta"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="an"&gt;href&lt;/span&gt;=&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;/stylesheets/cache/styles.css?20071111142032&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="an"&gt;media&lt;/span&gt;=&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;screen&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="an"&gt;rel&lt;/span&gt;=&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;Stylesheet&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="an"&gt;type&lt;/span&gt;=&lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;text/css&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="ta"&gt;/&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Here’s the install:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;script/plugin install http://bundle-fu.googlecode.com/svn/tags/bundle_fu&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Make sure to read the &lt;a href="http://code.google.com/p/bundle-fu/wiki/FAQ" title="Bundle-fu's FAQs &amp;amp;amp; caveats"&gt;caveats page&lt;/a&gt; as there is a few (as always). I believe the largest is the fact that conditionally loaded stylesheets for Internet Explorer need to be outside of the code block.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-11-08:27</id>
    <published>2007-11-08T17:47:00Z</published>
    <updated>2007-11-12T00:45:20Z</updated>
    <category term="Business" />
    <link href="http://tetromino.com/2007/11/8/why-i-won-t-adopt-facebook-s-pages-model" rel="alternate" type="text/html" />
    <title>Why I Won't Adopt Facebook's Pages Model</title>
<content type="html">
            &lt;p&gt;Yesterday, Facebook released a new ‘feature’ on it’s social network dubbed ‘Pages’. After checking it out, and creating my own page I realized it was directly for marketing, probably to compete with &lt;a href="http://adwords.google.com/" title="AdWords"&gt;Google AdWords&lt;/a&gt; and other such inventions.&lt;/p&gt;


	&lt;p&gt;Here’s the stitch, I already have a group on Facebook for my business with near 200 subscribed members. Do I really want to start over from scratch with a ‘Page’ that people can become a ‘fan’ of. No, I’m not in the least bit interested. In fact, I’m downright confused. What is the relevance of Groups at this point?&lt;/p&gt;


	&lt;p&gt;After reading a terrific article on &lt;a href="http://www.techcrunch.com/2007/11/07/the-facebook-ad-backlash-begins/#comments" title="TechCrunch's article on Facebook's Pages"&gt;TechCrunch&lt;/a&gt; what I already believed to be true was amplified, and I’m quickly losing interest in using Facebook as a method of marketing.&lt;/p&gt;


	&lt;p&gt;Good luck with your cash grab, FB!&lt;/p&gt;


	&lt;h3&gt;In other news:&lt;/h3&gt;


	&lt;p&gt;The US dollar is still on it’s greatest decline since the civil war, here’s a nice little extra that &lt;a href="http://xe.com" title="XE: Currency Converter"&gt;xe.com&lt;/a&gt; through up on their site:&lt;/p&gt;


	&lt;p&gt;&lt;img src="/images/post_10_xe_conversion_graph.jpg" height="155" alt="Currency graph explicitly stating Canadian dollar worth more" width="650" /&gt;&lt;/p&gt;


	&lt;p&gt;Yup, they have to define what’s going on with a big question mark, possibly because a few fellow Canadians are actually stumped by the fact that our dollar is worth &lt;span class="caps"&gt;MORE&lt;/span&gt; than the Americano.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-11-05:26</id>
    <published>2007-11-05T01:14:00Z</published>
    <updated>2007-11-05T01:15:41Z</updated>
    <category term="JavaScript" />
    <category term="Web Dev" />
    <category term="XHTML &amp; CSS" />
    <link href="http://tetromino.com/2007/11/5/keep-elements-in-line-with-grids" rel="alternate" type="text/html" />
    <title>Keep elements in line with grids</title>
<content type="html">
            &lt;p&gt;I just stumbled upon Allan Jardine’s &lt;a href="http://www.sprymedia.co.uk/article/Grid" title="Allan Jardine's Grid Bookmarklet site"&gt;Grid Bookmarklet&lt;/a&gt;, which quickly draws a grid in your browser on any page you’re viewing. It’s highly customizable as you go, so you can make sure your stylesheets are matching up with a proper grid template.&lt;/p&gt;


	&lt;p&gt;&lt;img src="/images/post_9_grid_bookmarkelet.jpg" height="175" alt="Grid Bookmarklet in action!" width="625" /&gt;&lt;/p&gt;


	&lt;p&gt;I could find myself using this one quite a bit.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-11-03:25</id>
    <published>2007-11-03T02:07:00Z</published>
    <updated>2007-11-03T02:20:10Z</updated>
    <category term="Ruby &amp; Rails" />
    <link href="http://tetromino.com/2007/11/3/custom-404-routes-pages-in-rails" rel="alternate" type="text/html" />
    <title>Custom 404 Routes &amp; Pages in Rails</title>
<content type="html">
            Lately, I’ve been using a nice ‘catch-all’ trick in my &lt;i&gt;routes.rb&lt;/i&gt; file to send users to a custom 404 page. It’s as simple as throwing this below the rest of your routes:
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="c"&gt;# If the user has typed an Invalid URL&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;map.connect &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;*path&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class="sy"&gt;:controller&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;www&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class="sy"&gt;:action&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;unrecognized&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;# Make sure you don't have this default route in there:&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="c"&gt;# map.connect ':controller/:action/:id' # Comment or remove!&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Now, if any invalid URLs are typed in, the app will respond by dishing up the action ‘unrecognized’ from the WwwController.&lt;/p&gt;


	&lt;p&gt;Here’s where the problem comes in. We recently redesigned a site using Rails, however I noticed that Google was continuing to index the old &lt;span class="caps"&gt;PHP&lt;/span&gt; version of the site just as it always had. Instead of removing the page from it’s index, it was displaying the content of my new custom 404 page. After some research, I realized the reason was my custom 404 page wasn’t a true 404, and was instead sending a 200 Successful &lt;span class="caps"&gt;HTTP&lt;/span&gt; response header instead. This turned out to be a quick fix, but I found it quite undocumented on the net:&lt;/p&gt;


&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;WwwController&lt;/span&gt; &amp;lt; &lt;span class="co"&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;unrecognized&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    render( &lt;span class="sy"&gt;:status&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;404 Not Found&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; )&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;


	&lt;p&gt;Now our server will dish up the standard ‘404 Not Found’ &lt;span class="caps"&gt;HTTP&lt;/span&gt; response header. It’s just that easy.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-10-23:24</id>
    <published>2007-10-23T03:09:00Z</published>
    <updated>2007-10-23T03:58:57Z</updated>
    <category term="JavaScript" />
    <category term="Web Dev" />
    <category term="XHTML &amp; CSS" />
    <link href="http://tetromino.com/2007/10/23/firefox-extensions-i-use" rel="alternate" type="text/html" />
    <title>Firefox Extensions I Use</title>
<content type="html">
            &lt;p&gt;
  Whenever somebody sits down at my laptop and uses it’s default browser, they’re generally curious as to what exactly is going on. It’s pretty cluttered (in an organized mess kinda way), and there’s all these crazy icon sets and toolbars everywhere. I’ve decided some clarification was in order, so here goes:
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    Joe Hewitt’s &lt;a href="http://www.getfirebug.com/" title="Download the Firebug add-on"&gt;Firebug&lt;/a&gt; – The premier tool for anybody interested in advanced web development &amp;amp; design. When I found this one my job became 147% easier. Quickly jump right inside the &lt;span class="caps"&gt;DOM&lt;/span&gt; and see what’s going on. Edit stylesheets, live. View the network statistics of each page you request. Oh, did I mention it debugs JavaScript? The list goes on…
  &lt;/li&gt;
  &lt;li&gt;
    Yahoo’s &lt;a href="http://developer.yahoo.com/yslow/" title="Download the YSlow add-on"&gt;YSlow&lt;/a&gt; – Can’t figure out why a page is taking forever to load? Convinced it isn’t &lt;span class="caps"&gt;SQL&lt;/span&gt; related? Enlist this helper to explain where the bottlenecks could be. (Requires Firebug)
  &lt;/li&gt;
  &lt;li&gt;
    Chris Pederick’s &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/60" title="Download the Web Developer add-on"&gt;Web Developer&lt;/a&gt; – I had this one before Firebug, and I was impressed by it at the time. There’s two wonderful features I find handy in it these days: “Automatically Populate Form Fields” and “Disable JavaScript”.
  &lt;/li&gt;
  &lt;li&gt;
    Aaron Boodman’s &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/748" title="Download the Greasemonkey add-on"&gt;Greasemonkey&lt;/a&gt; – Write custom JavaScript to be executed each time you hit a specified page. For instance, sick of filling in the username and password box on a site that won’t ‘remember’ you? Let Greasemonkey do it for you!
  &lt;/li&gt;
  &lt;li&gt;
    Alex Sirota’s &lt;a href="http://www.iosart.com/firefox/colorzilla/" title="Download the ColorZilla add-on"&gt;ColorZilla&lt;/a&gt; – This glorious tool adds a tiny eyedropper (much like Photoshop’s) to the bottom left of your Firefox window. A great alternative to print-screen, open Photoshop, paste, select eyedropper tool, etc.
  &lt;/li&gt;
  &lt;li&gt;
    Kevin Freitas’ &lt;a href="http://www.kevinfreitas.net/extensions/measureit/" title="Download the MeasureIt add-on"&gt;MeasureIt&lt;/a&gt; – A quick ruling tool which lets you draw boxes and see the width and height of any element, right in your browser.&lt;br /&gt;
  &lt;img src="/images/post_7_measureit.jpg" height="85" alt="an example of the measureit add-on" width="397" /&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Devon Jensen’s &lt;a href="http://downloadstatusbar.mozdev.org/" title="Download the Download Statusbar add-on"&gt;Download Statusbar&lt;/a&gt; – Firefox’s built-in file downloader is bulky and old-school. This pretty gem downloads files in a minimalist fashion at the bottom of your browser and gives you more functionality over how to handle downloads.&lt;br /&gt;
  &lt;img src="/images/post_7_download_statusbar.jpg" height="48" alt="an example of the download statusbar add-on" width="415" /&gt;
  &lt;/li&gt;
  &lt;li&gt;
    Zeniko’s &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1951" title="Download the Fission add-on"&gt;Fission&lt;/a&gt; – A simple add-on which displays an animated loading progress bar to the &lt;span class="caps"&gt;URL&lt;/span&gt; (location) bar at the top. You even have a choice of colors. (woo!)&lt;br /&gt;
  &lt;img src="/images/post_7_fission.jpg" height="69" alt="an example of the fission add-on" width="551" /&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/1945" title="Download the Séparé add-on"&gt;Séparé&lt;/a&gt; – Purely cosmetic, truly organizational. Create lil’ orange tabs which separate one group of tabs from the next. (Warning: I have a feeling there may be some strange memory leak in this add-on, use at your own risk!)
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  And remember, if you find tons of use from any of these extensions then I urge you to donate! Most of them are developed by individuals who could probably use the help.
&lt;/p&gt;
&lt;p&gt;
  Think I’m missing one or two that you can’t live without? &lt;a href="mailto:info@tetromino.com" title="Email me!"&gt;Let me know!&lt;/a&gt;
&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://tetromino.com">
    <author>
      <name>chuck</name>
    </author>
    <id>tag:tetromino.com,2007-10-16:23</id>
    <published>2007-10-16T16:02:00Z</published>
    <updated>2007-10-16T16:06:33Z</updated>
    <category term="Ruby &amp; Rails" />
    <category term="activerecord" />
    <category term="migrations" />
    <link href="http://tetromino.com/2007/10/16/overriding-class-methods-for-migrations-a-follow-up" rel="alternate" type="text/html" />
    <title>Overriding class methods for migrations, a follow-up</title>
<content type="html">
            &lt;p&gt;
  I realized I left one important point out from my previous post. I’m sure a few of you may have already picked up on this as well. When you override the class in the migration, you can add in whatever methods you would like the migration to use. We’ll use the same example as before:
&lt;/p&gt;
&lt;h3&gt;
  004_add_live_pages.rb
&lt;/h3&gt;
&lt;table class="CodeRay"&gt;&lt;tr&gt;
  &lt;td title="click to toggle" class="line_numbers"&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;5&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;15&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;25&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class="code"&gt;&lt;pre&gt;&lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;AddLivePages&lt;/span&gt; &amp;lt; &lt;span class="co"&gt;ActiveRecord&lt;/span&gt;::&lt;span class="co"&gt;Migration&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# Say for instance the Page.rb model has 20 instance methods in it&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# that we don't want to have affect our migration, but there is&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="c"&gt;# 1 method we want to use below&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;class&lt;/span&gt; &lt;span class="cl"&gt;Page&lt;/span&gt; &amp;lt; &lt;span class="co"&gt;ActiveRecord&lt;/span&gt;::&lt;span class="co"&gt;Base&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;    &lt;span class="c"&gt;# The method 'stripped_name' below is an extension&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="c"&gt;# of the String class&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="fu"&gt;set_permalink&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="pc"&gt;self&lt;/span&gt;.update_attribute( &lt;span class="sy"&gt;:permalink&lt;/span&gt;, &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;&lt;span class="pc"&gt;self&lt;/span&gt;.id&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="k"&gt;-&lt;/span&gt;&lt;span class="il"&gt;&lt;span class="dl"&gt;#{&lt;/span&gt;&lt;span class="pc"&gt;self&lt;/span&gt;.stripped_name&lt;span class="dl"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; ) &lt;span class="r"&gt;if&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.permalink.blank?&lt;tt&gt;
&lt;/tt&gt;    &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.up  &lt;tt&gt;
&lt;/tt&gt;    page = &lt;span class="co"&gt;Page&lt;/span&gt;.create(&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="sy"&gt;:name&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;About&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;      &lt;span class="sy"&gt;:body&lt;/span&gt; =&amp;gt; &lt;span class="s"&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;span class="k"&gt;Write your about page content here.&lt;/span&gt;&lt;span class="dl"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    )&lt;tt&gt;
&lt;/tt&gt;    page.set_permalink&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;def&lt;/span&gt; &lt;span class="pc"&gt;self&lt;/span&gt;.down&lt;tt&gt;
&lt;/tt&gt;  &lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;tt&gt;
&lt;/tt&gt;&lt;span class="r"&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;

&lt;p&gt;
  Ta da! Now we can use the ‘set_permalink’ instance method anywhere inside our migration
&lt;/p&gt;
          </content>  </entry>
</feed>
