<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Confessions of a Chief Home Officer</title>
	
	<link>http://gregmoreno.ca</link>
	<description>growing a home-based business before bedtime</description>
	<lastBuildDate>Thu, 05 Nov 2009 05:12:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/pinoymicroisv" type="application/rss+xml" /><feedburner:emailServiceId>pinoymicroisv</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader (e.g. Mozilla Thunderbird) or syndicated to another site.</feedburner:browserFriendly><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Why I do not use Frontpage</title>
		<link>http://gregmoreno.ca/why-i-do-not-use-frontpage/</link>
		<comments>http://gregmoreno.ca/why-i-do-not-use-frontpage/#comments</comments>
		<pubDate>Fri, 18 Sep 2009 04:21:12 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Geekiness]]></category>
		<category><![CDATA[Getting Things Done]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=487</guid>
		<description><![CDATA[Note: This post was written 5 years ago in my old blog. One of the rare times I had time to write an essay.
One late night, while I was working on a web page, my wife asked why am I using a text editor and coding HTML when I can use Microsoft FrontPage. I tried [...]]]></description>
			<content:encoded><![CDATA[<p><em>Note: This post was written 5 years ago in my old blog. One of the rare times I had time to write an essay.</em></p>
<p>One late night, while I was working on a web page, my wife asked why am I using a text editor and coding HTML when I can use Microsoft FrontPage. I tried to explain to her the benefits of my approach  but she was not convinced.  Honestly, I was not also convinced of my reasons but somehow, deep inside of me, I knew that I should not be using FrontPage or other tools that let you do it visually.</p>
<p>Some people see creating web pages as an activity reserved for graphic designers. For many, it makes sense for a fine arts major to become a web designer. These same people also think that website is about creating and placing pictures, assigning colors, and fonts.</p>
<h3>Structure and Presentation</h3>
<p>People venturing into web designs, I guess, have a choice between two roads &#8211; a presentation-oriented approach or structure-oriented approach. Not that one approach is superior to the other (I have no right to judge that) but from experience, a structure-oriented approach provides more flexibility that you will be thankful for when you started worrying about presentation.</p>
<p>For example, in almost all documents, whether in print or digital, there are items that appear more important than others, such as chapter title to a section heading.  Any good designer would distinguish the important elements with the less important ones &#8211; make the element bold, increase its size, and change the font, for example.</p>
<p>My first goal is to structure the web page using HTML tags taking into account the semantics. For example, the heading tag &lt;h1&gt;, ideally, should be used to markup the most important heading in a web page while &lt;h2&gt; tag for the next important.  So if I want to show importance, I decide which heading is more important then use the &lt;h1&gt; tag. Of course, nothing stops you from using an &lt;h5&gt; or a &lt;p&gt; tag for the page title.</p>
<p>A presentation-oriented approach does not make a distinction between an &lt;h1&gt; or &lt;p&gt; as long the elements appear as the designer intends to. Is there something wrong with that? A visitor would not care if your web page is constructed structurally or not. This is one major reason why there are web page designers that do not care about structure.</p>
<h3>Structure as an element of presentation</h3>
<p>Some may think that the two approaches do not converge, but as I have experienced, a good structure helps significantly in creating a good presentation.</p>
<p>First, the principle of contrast. If we are conscious in our choice of what tag to use, we are making contrast explicit in the content of our web page. In the absence of any formatting, a web browser can provide more emphasis on the important text against the less important. This is possible because the contrast is present and the browser can understand it. It may not be visually appealing at first but when you start formatting and use CSS, you will thank yourself for making structure a priority.</p>
<p>Another design principle is proximity, which states that related items should be close to each other. A good structure groups related elements. When you structure your content as a hierarchy of &lt;h1&gt;, &lt;h2&gt;, and so on, you are already grouping elements together.  You can also use the &lt;div&gt; tag to group elements. In fact, using &lt;div&gt; is the most common and effective way of creating layouts (with some little help from CSS).</p>
<h3>So what if it is not structured</h3>
<p>We could create two web pages that looks exactly the same but constructed using different approaches. So where is the advantage? The well structured web page makes presentations manageable.</p>
<p>When you structure your web page, you separate the content from the presentation. You compose the content using only HTML tags and you prepare the layout, fonts, colors, margins, etc. using CSS. I do not deny that I lack artistic talent and that is why it is very important for me to able to try different designs and see the results as soon as possible. In programming, you should isolate things that may change from things that most likely, will not. </p>
<p>So how do these things answer why I do not use FrontPage?</p>
<p>If we are given a problem to solve, the perspective from which we view the problem affects our analysis and eventually our solution. Some have the ability to see things from various perspectives while others find it difficult to change perspective. (I guess this is why the world still have racism and religious prejudices.)</p>
<p>I see web page construction from a structured-oriented view. I see no need for FrontPage because a text editor and browser supports very well the approach I am taking.</p>
<h3>Frontpage is not evil but&#8230;</h3>
<p>I am not saying using FrontPage is evil. The purpose of a tool is to help us accomplish tasks easily, or with less effort than doing it without the tool.  In the software domain, the use of WYSIWYG (What-You-See-Is-What-You-Get) and the GUI (Graphical-User-Interface) has been one of the most effective technique of making tasks simpler.  There is no doubt that software like Microsoft Word has helped a lot people especially those writing documents. If you work on a computer, there is a big chance you have used Microsoft Word. Because of the experience, you would have come to expect that every software application provides a similar ability.</p>
<p>Of course, not all tasks is better done visually but for designing web page it makes sense if you can do it the way you would design a teaser.  I will not be surprised if you find FrontPage a very useful tool because it supports very well a presentation-oriented approach.</p>
<p>One common mantra, especially in management domain, is &#8220;I do not care how is it done, just get it done&#8221;.  FrontPage allows you to get it done and the fact that you can focus on getting it done, allows you to ignore how it is done.</p>
<p>Fine, FrontPage still allows you to see the HTML &#8211; to see everything that is going on behind the scenes. But that is an optional thing to do. I bet you do not have time to do it and it does not interest you. In case it interests you, there is a bigger problem. FrontPage shows you how he does it, not how it should be done properly. You, as the person, is at the mercy of FrontPage, the tool. I cannot live with that.</p>
<p>If you have been relying solely on FrontPage and not really learning HTML, you may come to accept that FrontPage does the correct thing. It is like the case of Dr. Evil (in <a href="http://www.austinpowers.com/">Austin Powers</a>) who have been raised by a Belgian couple to be evil and knows no good deeds.</p>
<p>You may say, &#8220;I do not need to know the inner workings of car, I just need to drive&#8221;. First, as I have said before, a good structure lends to a flexible design. Second, if you understand what is happening in your web pages, you have control. Control allows you to improve things, to innovate, and to fix things when they are broken. Lastly, HTML is very darn simple so the only reason I could see to skip learning proper use of HTML tags is pure laziness.</p>
<h3>I am really a keyboard guy</h3>
<p>Another reason why I tend not use FrontPage or similar tools is influenced by my preference to use the keyboard in almost every computing tasks that I do. As a programmer and aspiring writer, I live and breath via the keyboard.</p>
<p>The most popular task in computer is saving documents. While most people would use the mouse, I prefer to use the keyboard. I am not comfortable leaving the keyboard, touching the mouse and positioning the pointer over the &#8217;save&#8217; button. Sometimes, I would miss it and the &#8216;File Open&#8217; dialog box would pop out instead.</p>
<p>Every time I use a new software, the first thing, I check is the &#8217;save&#8217; shortcut, which is often, &#8216;Ctrl-S&#8217;. In Windows 98, the version of Notepad has no save shortcut but the Windows 2000 and XP version have it.</p>
<p>I guess non-programmers would find it odd that programmers would rather use the keyboard in everything we do. The keyboard is our primary tool and we want to be masters of it.</p>
<p>So if you want to use FrontPage, go ahead but I encourage you to take time to learn proper HTML and consider creating a structure first for your web pages before presentation details. I also invite you to learn CSS.</p>
<p>If you are looking for more information, <a href="http://www.alistapart.com">A List Apart</a> is an excellent starting point. Dan Cenderhom&#8217;s book, <a href="http://www.amazon.com/exec/obidos/ASIN/1590593812/gaboogle-20">Web Standards Solutions</a> is a great book on using HTML and CSS.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/why-i-do-not-use-frontpage/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>If browsers were women</title>
		<link>http://gregmoreno.ca/if-browsers-were-women/</link>
		<comments>http://gregmoreno.ca/if-browsers-were-women/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 21:21:17 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Sideways]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=480</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-481" title="If browsers were women - Firefox, Opera, Safari, IE, Chrome" src="http://gregmoreno.ca/wp-content/uploads/2009/09/if_browsers_were_women-s569x1250-12173.jpg" alt="If browsers were women - Firefox, Opera, Safari, IE, Chrome" width="569" height="1250" /></p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/if-browsers-were-women/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>7 signs that you’re a bad boss</title>
		<link>http://gregmoreno.ca/7-signs-that-youre-a-bad-boss/</link>
		<comments>http://gregmoreno.ca/7-signs-that-youre-a-bad-boss/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 20:42:42 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Getting Things Done]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=476</guid>
		<description><![CDATA[#7 The creation of  &#8220;boss rules&#8221;
The staff has developed guidelines for dealing with you and quietly passes them to new employees. &#8220;Never suggest that there might be another way of doing something,&#8221; they might say. Or &#8220;Act self-deprecating so he doesn&#8217;t feel threatened.&#8221;
#6 Employees start sucking up
You have one or two fanatical acolytes. Yes, [...]]]></description>
			<content:encoded><![CDATA[<h3>#7 The creation of  &#8220;boss rules&#8221;</h3>
<p>The staff has developed guidelines for dealing with you and quietly passes them to new employees. &#8220;Never suggest that there might be another way of doing something,&#8221; they might say. Or &#8220;Act self-deprecating so he doesn&#8217;t feel threatened.&#8221;</p>
<h3>#6 Employees start sucking up</h3>
<p>You have one or two fanatical acolytes. Yes, such devotion may be a testament to your fabulousness. But often when a boss is perceived as universally loathed, the staff opportunist offers herself up as sole confidante and friend, seeking power and favor at the expense of more honest, critical employees.</p>
<h3>#5 Your staff hides from you</h3>
<p>You never see people walk by. Employees would rather circumnavigate the entire office to get to the coffee machine or bathroom than take the shortcut past your door and risk being invited in.</p>
<h3>#4 Bogus reviews</h3>
<p>Your 360-degree evaluations come back short and full of generically positive comments, with one very mild criticism (&#8221;Sometimes she works too damn hard for her own good&#8221;) thrown in for credibility&#8217;s sake.</p>
<h3>#3 Apprehension</h3>
<p>People don&#8217;t volunteer for your pet projects. The idea sucks, and they&#8217;re afraid to tell you, or it&#8217;s brilliant, but the consequences for letting you down are too terrible to imagine. And, of course, if it&#8217;s your pet project, you&#8217;ll probably work on it as well. Which means more time spent…gulp…with you.</p>
<h3>#2 Former employees disappear forever</h3>
<p>You have legions of former employees, but they rarely give your name as a reference for new jobs. Either they don&#8217;t trust you to give them their due, or they worry that because they were so miserable working for you, your recollections will also be dismal.</p>
<h3>#1 The revolving door</h3>
<p>You have legions of former employees, period. If your staff falls away like linty Post-it notes, ask yourself: Is high turnover the problem? Or am I?</p>
<p>[via <a href="http://www.inc.com/multimedia/slideshows/content/7-signs-that-youre-a-bad-boss_pagen_1.html">Inc.</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/7-signs-that-youre-a-bad-boss/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>The 10 Commandments of Web Design</title>
		<link>http://gregmoreno.ca/the-10-commandments-of-web-design/</link>
		<comments>http://gregmoreno.ca/the-10-commandments-of-web-design/#comments</comments>
		<pubDate>Thu, 27 Aug 2009 20:41:39 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[User Happiness]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=474</guid>
		<description><![CDATA[
Thou shalt not abuse Flash.
Thou shalt not hide content.
Thou shalt not clutter.
Thou shalt not overuse glassy reflections.
Thou shalt not name your Web 2.0 company with an unnecessary
surplus or dearth of vowels.
Thou shalt worship at the altar of typography.
Thou shalt create immersive experiences.
Thou shalt be social.
Thou shalt embrace proven technologies.
Thou shalt make content king.

via BusinessWeek
]]></description>
			<content:encoded><![CDATA[<ol>
<li>Thou shalt not abuse Flash.</li>
<li>Thou shalt not hide content.</li>
<li>Thou shalt not clutter.</li>
<li>Thou shalt not overuse glassy reflections.</li>
<li>Thou shalt not name your Web 2.0 company with an unnecessary<br />
surplus or dearth of vowels.</li>
<li>Thou shalt worship at the altar of typography.</li>
<li>Thou shalt create immersive experiences.</li>
<li>Thou shalt be social.</li>
<li>Thou shalt embrace proven technologies.</li>
<li>Thou shalt make content king.</li>
</ol>
<p>via <a href="http://www.businessweek.com/innovate/content/jun2008/id20080623_750025.htm?chan=top+news_top+news+index_web+design">BusinessWeek</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/the-10-commandments-of-web-design/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to create Google-friendly URLs in Rails</title>
		<link>http://gregmoreno.ca/how-to-create-google-friendly-urls-in-rails/</link>
		<comments>http://gregmoreno.ca/how-to-create-google-friendly-urls-in-rails/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 04:52:25 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Geekiness]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=448</guid>
		<description><![CDATA[If you are building content-management systems or any applications with pages that you want to appear in a Google search, it is very important that you employ search engine optimization techniques or SEO. One such technique involves URLs.
Given a default URL in Rails, e.g.  http://cia.gov/users/123, we know as developers that this request involves the [...]]]></description>
			<content:encoded><![CDATA[<p>If you are building content-management systems or any applications with pages that you want to appear in a Google search, it is very important that you employ search engine optimization techniques or SEO. One such technique involves URLs.</p>
<p>Given a default URL in Rails, e.g.  http://cia.gov/users/123, we know as developers that this request involves the controller &#8216;Users&#8217;,  an action &#8217;show&#8217;, and a User with an ID &#8216;123&#8242;. However, Google doesn&#8217;t care about controllers actions, no &#8216;id&#8217;s &#8211; it only cares what the URL represents.  To tell Google what the URL represents, we need to add more information like a name.</p>
<p>The most common approach in the Rails community is create URLs like this  &#8216;/users/123-greg-moreno&#8217;.  <a href="http://www.seomoz.org/blog/perfecting-keyword-targeting-on-page-optimization">Hyphens are highly recommended</a> because it is the king of word separation. To accomplish this, we modify our User model:</p>
<pre class="syntax-highlight:ruby">
def to_params
  &quot;#{id}-#{name.parameterize}&quot;
end
</pre>
<p>I think this became prevalent because it is the easiest and involves the least amount of code. There&#8217;s no need to change all your controller code because this format, i.e &#8216;users/123-greg-moreno&#8217;, works well with User.find(params[:id]) thanks to Ruby&#8217;s string to numeric conversion.</p>
<pre class="syntax-highlight:ruby">
&gt;&gt; id_s = params[:id]
=&gt; &quot;123-greg-moreno&quot;
&gt;&gt; id = id_s.to_i
=&gt; 123
</pre>
<p>One principle in SEO is that the relevant keywords should appear first, which is &#8216;name&#8217; in our case. As an alternative, we can change our URL to &#8216;/users/greg-moreno-123&#8242;. Let&#8217;s see if this works.</p>
<pre class="syntax-highlight:ruby">
&gt;&gt; id_s = params[:id]
=&gt; &quot;greg-moreno-123&quot;
&gt;&gt; id = id_s.to_i
=&gt; 0
</pre>
<p>This won&#8217;t work as is because Ruby looks at the first digits it can recognize. If we go by this route, we need to build a method to extract the &#8216;id&#8217;.</p>
<pre class="syntax-highlight:ruby">
def extract_id(s)
  s.gsub(/.+-(\d+)$/, &#039;\1&#039;) if s
end

User.find extract_id(params[:id])
</pre>
<p>This isnt&#8217; nice because you need to make sure  you call the &#8216;extract_id&#8217; method every time we need the &#8216;id&#8217;.</p>
<p>What we want is a URL that is SEO-friendly and at the same time requires minimal changes to our code. My friend who maintains a site with <a href="http://videokeman.com/">4M visitors a month</a>, recommends this format &#8216;users/greg-moreno/123&#8242;.</p>
<p>This is better but it will fail because it will match the route &#8216;users/:id/:action&#8217;. To work around this, we need to change the format and add a new route. Before we got into the technical details, let&#8217;s discuss our goals first:</p>
<p>1. The URL we are preparing is for use by Google and other search engines.<br />
2. We also expect this URL to be pasted in blogs, forums, and other websites.</p>
<p>The URL we are preparing is for external use. Pages that need authentication doesn&#8217;t need to be in a SEO-friendly format because after all we don&#8217;t intend Google to see them.</p>
<p>If you agree with me, let&#8217;s continue :)</p>
<p>Here are the things we need to do then.<br />
1. Remove &#8216;to_params&#8217; from our models. Use Rails&#8217; default.<br />
2. Create a new route to distinguish our Google-friendly URL with Rails&#8217; default<br />
3. Use the Google-friendly URLs in pages that we want Google to see (e.g. public forum pages)</p>
<p>Here&#8217;s the new route:</p>
<pre class="syntax-highlight:ruby">
map.user_permalink &#039;u/:name/:id&#039;, :controller =&gt; &#039;users&#039;, :action =&gt; &#039;show&#039;
# =&gt; u/greg-moreno/1

# in  template
link_to user.name, user_permalink_path(:name =&gt; user.name.parameterize, :id =&gt; user.id)
</pre>
<p>I&#8217;m sure you would be using this URL in at least one 1 page so you better move this to a helper method.</p>
<pre class="syntax-highlight:ruby">
module UrlsHelper
  def permalink(object)
    case object
    when User
      user_permalink_path(user_permalink(object))
    when Book
      book_permalink_path(book_permalink(object))
    end
  end

  def user_permalink(user)
    {:name =&gt; &quot;#{user.name.parameterize}&quot;,
     :id  =&gt; user.id,
    }
  end

  def book_permalink(book)
    # your code here
  end
end

# in your template
link_to user.name, permalink(user)
</pre>
<p>Wait, we&#8217;re not done yet. Let&#8217;s improve the code a little bit. In our UrlsHelper, we can do away with the case/when statements by checking the object&#8217;s class.</p>
<pre class="syntax-highlight:ruby">
def permalink(object)
  name = object.class.name.downcase
  params = send(&quot;#{name}_permalink&quot;, object)
  send(&quot;#{name}_permalink_path&quot;, params)
end
</pre>
<p>But wait there&#8217;s more!</p>
<p>Wouldn&#8217;t it be nice if instead of another helper, we could just use the generated route names instead? What if we can do this?</p>
<pre class="syntax-highlight:ruby">
user_path(user, :permalink =&gt; true)
# =&gt; u/greg-moreno/123
user_path(user)
# =&gt; users/123
user_path(user, :permalink =&gt; true, :sort =&gt; &#039;votes&#039;)
# =&gt; u/greg-moreno/123?sort=votes
</pre>
<p>That would be cool! To do this we need to dig deeper into Rails. We still use the same technique as our UrlsHelper but we need to modify Rails&#8217;s default URL generation code:</p>
<pre class="syntax-highlight:ruby">
module ActionController
  class UrlRewriter
    private

    def rewrite_url_with_permalink(options)
      debugger
      if options.delete(:permalink)
        case options[:use_route]
        when :user
          options.merge!(user_permalink(options[:id]))
        when :book
          options.merge!(workspace_permalink(options[:id]))
        end
      end

      rewrite_url_without_permalink(options)
    end
    alias_method_chain :rewrite_url, :permalink

    def user_permalink(id)
      object = id.is_a?(Fixnum) ? User.find(id) : id
      { :use_route =&gt; :user_permalink,
        :name      =&gt; object.profile ? object.profile.name.parameterize : object.name.parameterize,
        :subdomain  =&gt; false
      }
    end

    def book_permalink(id)
    end
  end
end
</pre>
<p>The method &#8216;url_rewrite&#8217; handles the generation of the URL after Rails has decided what route to use. For example, in &#8216;user_path(user, :permalink =&gt; true)&#8217;, options would have the following values:</p>
<pre class="syntax-highlight:ruby">
{:action=&gt;&quot;show&quot;, :controller=&gt;&quot;user&quot;, :only_path=&gt;true,
:permalink=&gt;true, :id=&gt;#&lt;User id: 123,  name: &quot;Greg Moreno&quot;...&gt;,
:use_route=&gt;:user}
</pre>
<p>What we do then is tell Rails the route to use, i.e.  :user_route =&gt; :user_permalink, and pass the extra options to generate our Google-friendly URL. If the code looks a bit strange, that&#8217;s OK. This code uses  method chaining to add functionality to &#8216;url_rewrite&#8217;</p>
<pre class="syntax-highlight:ruby">
alias_method_chain :rewrite_url, :permalink

# above line is a shortcut for 2 method aliases:

alias_method :url_rewrite_without_permalink, :url_rewrite
alias_method :url_rewrite, :url_rewrite_with_permalink
</pre>
<p>For further reading, you can check <a href="http://weblog.jamisbuck.org/2006/10/4/under-the-hood-route-recognition-in-rails">Jamis Buck&#8217;s detailed post on Rails route generation and recognition</a>.</p>
<p>Limitations: This doesn&#8217;t work with nested resources and additional member/collection methods. If you have a solution, I would love to try your code :)</p>
<p>Update: The <a href="http://friendly-id.rubyforge.org/">friendly_id plugin</a> uses slugs and even has redirect options. <a href="http://github.com/mbleigh/subdomain-fu/tree/master">subdomain_fu</a> uses &#8216;url_rewrite&#8217; to add a subdomain to your URL. You can also this approach to modify the protocol like change it to &#8216;https&#8217; for some accounts.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/how-to-create-google-friendly-urls-in-rails/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Don’t forget to help your visitors</title>
		<link>http://gregmoreno.ca/don%e2%80%99t-forget-to-help-your-visitors/</link>
		<comments>http://gregmoreno.ca/don%e2%80%99t-forget-to-help-your-visitors/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 17:14:24 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[User Happiness]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=84</guid>
		<description><![CDATA[All newspapers, magazines, and catalogs work the same way &#8211; you start at the front cover and keep turning the pages. That is not the case with websites.
When visitors arrive at a new website, they pause, look around, and figure out how to proceed. There are a lot of question marks in their head and [...]]]></description>
			<content:encoded><![CDATA[<p><!--content with more link-->All newspapers, magazines, and catalogs work the same way &#8211; you start at the front cover and keep turning the pages. That is not the case with websites.</p>
<p>When visitors arrive at a new website, they pause, look around, and figure out how to proceed. There are a lot of question marks in their head and as soon as your website answers them the better. Otherwise, your visitor will leave and may never come back.</p>
<h4>Websites are difficult to use</h4>
<p>All visitors suffer a moment of difficulty in a website. Some find it a simple annoyance while others become frustrated. Recognizing that websites are still not as easy to use like a newspaper is the right attitude when designing webpages.</p>
<p>Who does not want a visitor-friendly website? I’m sure you do but your actions do not say so. Too often your websites serve the needs of your company, or sometimes, even your egos. You cannot accept the truth that your visitor are finding it difficult to move around your website. This has to change.</p>
<p>When building the pages of your website how often do you ask yourself this question: “Am I helping my visitor with this webpage?”</p>
<p>We understand the pressure. Different people in an organization have different and often conflicting goals for the website. You throw up your arms and give up. Helping visitors requires fighting some fights. You may need to fight with the sales guy, the programmer, your boss, and yourself.</p>
<p>Yes, including yourself.</p>
<p>You thrust your own views upon your visitors. You want him to accept your website, your design, your creation. You want your visitor to change to satisfy you. When she does not, you call her stupid.</p>
<h4>It is not just layout and colors</h4>
<p>You have spent a lot of time designing the layout and choosing the right color combinations that you believe would appeal to your visitors but you forgot how to talk to them. Just like any human being on the planet we use words, not colors nor diagrams.</p>
<p>If you want to help your visitors, then talk to them in a language they understand. Use words and terms that are relevant to your visitors — not words only you and your friends understand. Craft your messages the way you would talk to a person face-to-face. The online world is a lonely place — your visitors need company.</p>
<h4>Does it matter?</h4>
<p>At one point, you have also visited a website that is inconsiderate of you. How does it feel? Don’t forget that you are a visitor, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/don%e2%80%99t-forget-to-help-your-visitors/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to share code between Javascript and Rails</title>
		<link>http://gregmoreno.ca/how-to-share-code-between-javascript-and-rails/</link>
		<comments>http://gregmoreno.ca/how-to-share-code-between-javascript-and-rails/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 17:17:55 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Geekiness]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=408</guid>
		<description><![CDATA[Rails&#8217; validations is great because it allows you to quickly implement the valid states of your models and at the same time have a ready-made way of displaying the errors to your users.  For example, below is a screenshot of a registration form written with just a few lines of code:

However, this approach requires [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html">Rails&#8217; validations</a> is great because it allows you to quickly implement the valid states of your models and at the same time have a ready-made way of displaying the errors to your users.  For example, below is a screenshot of a registration form written with just a few lines of code:</p>
<p><img class="aligncenter" title="Rails validation" src="http://img.skitch.com/20090724-kx8jyp3agdu67bijyqn2nuwnn.jpg" alt="" width="461" height="406" /></p>
<p>However, this approach requires the server to perform the validation even for simple things like checking the length of a password.  To improve response time (and thus the user experience), we use Javascript to pass some workload to the browser. For example, the popular <a href="http://docs.jquery.com/Plugins/Validation">jQuery framework</a> has a validation plugin similar to that of Rails.</p>
<p><img class="aligncenter" title="jQuery validation" src="http://img.skitch.com/20090724-mdwirtirnqhta916xmu6fpryu2.jpg" alt="" width="475" height="196" /></p>
<p>Here are  the <a href="http://rubyonrails.org">Rails</a> and <a href="http://jquery.com/">jQuery</a> code snippets for our form validation:</p>
<pre class="syntax-highlight:ruby">
validates_presence_of     :login
validates_length_of       :login,    :within =&gt; 3..40
</pre>
<pre class="syntax-highlight:javascript">
$(&#039;#new_user&#039;).validate({
rules: {
&#039;user[login]&#039;: {
required: true,
maxlength: 40,
minlength: 3
}
},
});
</pre>
<p>Notice the length condition of the login is repeated in Rails and jQuery, which violates the <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">Don&#8217;t Repeat Yourself</a> principle. To remedy this, one approach is to publish the constants from your Rails code as Javascript code. To do this, we need to refactor our model a bit and use a Rails helper method.</p>
<pre class="syntax-highlight:ruby">
# User model
MIN_LENGTH = 3
MAX_LENGTH = 40

validates_presence_of     :login
validates_length_of       :login,    :within =&gt; MIN_LENGTH..MAX_LENGTH

# in your helper
def js_user_format
format = {
&quot;MAX_LENGTH&quot; =&gt; User::MAX_LENGTH,
&quot;MIN_LENGTH&quot; =&gt; User::MIN_LENGTH
}
javascript_tag &quot;var User=#{format.to_json}&quot;
end
</pre>
<p>Then, in your form template:</p>
<pre class="syntax-highlight:html">
&lt;%= js_user_format %&gt;
</pre>
<p>This will produce the following Javascript code in your page:</p>
<pre class="syntax-highlight:html">
&lt;script type=&quot;text/javascript&quot;&gt;
//&lt;![CDATA[
var User={&quot;MIN_LENGTH&quot;: 3, &quot;MAX_LENGTH&quot;: 40}
//]]&gt;
&lt;/script&gt;
</pre>
<p>You can now improve your jQuery code:</p>
<pre class="syntax-highlight:javascript">
$(&#039;#new_user&#039;).validate({
rules: {
&#039;user[login]&#039;: {
required: true,
maxlength: User.MAX_LENGTH,
minlength: User.MIN_LENGTH
}
},
});
</pre>
<p>This is just a simple example and I bet you can extend this one. For example, if you use regular expressions with validates_format_of, you can use the same regex to validate the format of the input in jQuery.</p>
<p><strong>Update</strong>: One reader had a problem including Javascript in templates using <a href="http://haml.hamptoncatlin.com/">HAML</a>.  You can include Javascript in HAML templates but there should be no indentation. Otherwise, HAML would complain of  &#8220;illegal nesting&#8221;. Of course, no indentation would make it harder to read your Javascript.  To preserve the whitespace, you can use multiline string. I also suggest you put it in  a helper to isolate your Javascript code. If you can get away with it in your helper, the better.</p>
<pre class="syntax-highlight:ruby">
# in helper
def js_foo
javascript_tag &lt;&lt;-eos
function onAfter() {
var current = $(this).attr(&#039;id&#039;);
if (current!=&quot;&quot;) {
$(&#039;.&#039;+current).removeClass(&quot;active&quot;, &#039;timeout&#039;);
}
};
eos
end

# in haml template
= js_foo
</pre>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/how-to-share-code-between-javascript-and-rails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>10 guidelines for building the credibility of a website</title>
		<link>http://gregmoreno.ca/10-guidelines-for-building-the-credibility-of-a-website/</link>
		<comments>http://gregmoreno.ca/10-guidelines-for-building-the-credibility-of-a-website/#comments</comments>
		<pubDate>Thu, 23 Jul 2009 17:15:27 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[User Happiness]]></category>
		<category><![CDATA[design]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=86</guid>
		<description><![CDATA[Here are 10 guidelines for building the credibility of a web site based on research in Stanford University:

Make it easy to verify the accuracy of the information on your site.
Show that there’s a real organization behind your site.
Highlight the expertise in your organization and in the content and services you provide.
Show that honest and trustworthy [...]]]></description>
			<content:encoded><![CDATA[<p><!--content with more link-->Here are 10 guidelines for building the credibility of a web site <a href="http://credibility.stanford.edu/guidelines/index.html">based on research in Stanford University</a>:</p>
<ol>
<li>Make it easy to verify the accuracy of the information on your site.</li>
<li>Show that there’s a real organization behind your site.</li>
<li>Highlight the expertise in your organization and in the content and services you provide.</li>
<li>Show that honest and trustworthy people stand behind your site.</li>
<li>Make it easy to contact you.</li>
<li>Design your site so it looks professional (or is appropriate for your purpose).</li>
<li>Make your site easy to use — and useful.</li>
<li>Update your site’s content often (at least show it’s been reviewed recently).</li>
<li>Use restraint with any promotional content (e.g., ads, offers).</li>
<li>Avoid errors of all types, no matter how small they seem.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/10-guidelines-for-building-the-credibility-of-a-website/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>13 creativity hacks</title>
		<link>http://gregmoreno.ca/13-creativity-hacks/</link>
		<comments>http://gregmoreno.ca/13-creativity-hacks/#comments</comments>
		<pubDate>Wed, 22 Jul 2009 18:14:41 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Creativity Hacks]]></category>
		<category><![CDATA[Getting Things Done]]></category>
		<category><![CDATA[motivation]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=373</guid>
		<description><![CDATA[



Ask &#8216;Why?&#8217; constantly. All creativity stems from questioning why things are the way they are. The more everyday obvious a thing is, the more it needs to be questioned.
Always be suspicious when people say, &#8216;It stands to reason&#8217;. Human progress has come from those who had the courage to challenge the generally held view.
When working [...]]]></description>
			<content:encoded><![CDATA[<div>
<p style="text-align: center;"><a href="http://weburbanist.com/2009/05/17/faux-photoshop-15-incredible-images-that-look-altered-but-arent/"><img class="aligncenter" title="Li Wei action photo" src="http://weburbanist.com/wp-content/uploads/2009/05/action-art-li-wei.jpg" alt="http://weburbanist.com/2009/05/17/faux-photoshop-15-incredible-images-that-look-altered-but-arent/" width="468" height="468" /></a></p>
</div>
<ol>
<li>Ask &#8216;Why?&#8217; constantly. All creativity stems from questioning why things are the way they are. The more everyday obvious a thing is, the more it needs to be questioned.</li>
<li>Always be suspicious when people say, &#8216;It stands to reason&#8217;. Human progress has come from those who had the courage to challenge the generally held view.</li>
<li>When working on a problem, never be satisfied with your first solution even if it seems correct. Always look for other answers.</li>
<li>Never worry about ideas that don&#8217;t work. Most ideas are like that. Just be encouraged to keep trying for a better idea.</li>
<li>Always carry a notebook for jotting down any bright ideas that you may have. Ideas come to the surface all the time but, unless they are quickly caught, will often escape and you may well find that you are quite unable to remember them later.</li>
<li>It is always easier to ask for forgiveness that to ask for permission. If you believe in your idea, you must go ahead with it at all costs. If you wait for a permission, it might never come.  If you find that you are wrong, admit it frankly and then get on you with your next project.</li>
<li>Take a random word &#8212; the more ridiculous the better &#8212; and try to find a way to work it into your creative project.  This exercise may seem tough and you might not see right away how it will help but if you persist you&#8217;ll be surprised at the number of original notions that suddenly pop into your mind.</li>
<li>Always look for new experiences that will stretch your mind. For example, listen to new music, read a magazine that you don&#8217;t normally look at, watch a TV documentary on a subject you know nothing about, go somewhere new, talk to new people. If you always stick to your usual routine, you make it hard for new things to influence and inspire you.</li>
<li>It is often a good idea to spend some time visualizing what you think a project will look like when it&#8217;s finished. This can sometimes show you the path from where you are now to where you will be at the end.</li>
<li>It is possible to make a trigger (such as a gesture) that you deliberately associate with creative thought.  For example, you could run the tip of your index finger up and down the bridge of your nose whenever you are involved in creative thinking.  When you have a bright idea, make sure that you use  your trigger. Eventually, the process can be made to work the other way around, and the use of your gesture will prompt you to enter your creative mode and produce bright ideas.</li>
<li>Ask a dumb question and you may look stupid for five minutes. Fail to ask it and you will be stupid forever.</li>
<li>Always keep stirring the pot. Good ideas will float to the surface unpredictably, but for that to happen there has to be plenty of thought and action going on.</li>
<li>First the chaos; then the production of order from chaos.  In this way, interesting ideas may be born.</li>
</ol>
<p>&#8211;<br />
From <a href="http://www.amazon.ca/Boost-Your-Creativity-Exercises-Creative/dp/1843402424/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1248286652&amp;sr=8-1">Robert Allen&#8217;s Boost Your Creativity</a></p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/13-creativity-hacks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can you become as famous as Einstein?</title>
		<link>http://gregmoreno.ca/can-you-become-as-famous-as-einstein/</link>
		<comments>http://gregmoreno.ca/can-you-become-as-famous-as-einstein/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 23:04:06 +0000</pubDate>
		<dc:creator>Greg Moreno</dc:creator>
				<category><![CDATA[Creativity Hacks]]></category>
		<category><![CDATA[Getting Things Done]]></category>

		<guid isPermaLink="false">http://gregmoreno.ca/?p=368</guid>
		<description><![CDATA[

The short answer: No.

Einstein is a genius. Just like Newton, da Vinci, and Mozart, he belongs to a small group that very few of us will ever be part of. This is not an insult to your capacity but I’m just stating a simple truth – geniuses are born, not made.

However, you share one characteristic [...]]]></description>
			<content:encoded><![CDATA[<p><!--StartFragment--></p>
<p class="MsoNoteLevel1CxSpFirst"><a href="http://www.etsu.edu/math/gardner/einstein/conclusion.htm"><img class="aligncenter" title="Albert Einstein" src="http://www.etsu.edu/math/gardner/einstein/time.jpg" alt="" width="304" height="400" /></a></p>
<p class="MsoNoteLevel1CxSpFirst">The short answer: No.</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpMiddle">Einstein is a genius. Just like Newton, da Vinci, and Mozart, he belongs to a small group that very few of us will ever be part of.<span> </span>This is not an insult to your capacity but I’m just stating a simple truth – geniuses are born, not made.</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpMiddle">However, you share one characteristic with these geniuses that can make you famous, too. It is called creativity.</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpMiddle">Creativity is a human characteristic available to everyone. While there is no guarantee you’ll come with an idea as revolutionary as e=mc2,<span> </span>tapping into your creative capacity can help you succeed.</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpMiddle">First, you have to accept that you are creative. Even retards exhibit some creativity. However, creativity is not something you enroll in college. It is stupid to think you can just pick a bum on the street, enroll him in Harvard, and he’ll become a genius after 4 years. Creativity needs a room to grow, encouragement, and nourishment.</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpMiddle"><strong>Capture your ideas</strong>. Always have a pen and paper ready. If you think of something, just write it down. You can worry about whether it is good or stupid later. Unless quickly caught,  ideas will escape and you may not remember them again.</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpMiddle"><strong>Start a project</strong>. <span> </span>Buy some Lego and start playing with it. You can buy a model set but don’t restrict yourself with it. How about gardening?</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpMiddle"><strong>Work on your project regularly</strong>.<span> </span>Some people think they need a spark. Well, that spark will not happen if you just sit around. There is no way to predict when that spark will happen but if you regularly work on your project, you will definitely come up with something.</p>
<p class="MsoNoteLevel1CxSpMiddle">
<p class="MsoNoteLevel1CxSpLast"><strong>Happiness and creativity are partners</strong>.<span> </span>Have you ever met an inventor who doesn’t like what he’s doing?<span> </span>If you don’t enjoy what you’re doing, your force yourself into it and everything becomes a burden. If you are not enjoying your project anymore, find a new one.</p>
<p class="MsoNoteLevel1CxSpLast">This is not an exhaustive list and I&#8217;m sure there are tons of books written on this subject. Just always keep in mind that creativity is available to everyone but only those who develop their creative power can benefit from it.</p>
<p><!--EndFragment--></p>
]]></content:encoded>
			<wfw:commentRss>http://gregmoreno.ca/can-you-become-as-famous-as-einstein/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
