<?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" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">

  <title><![CDATA[Sebastien Lachance]]></title>
  
  <link href="http://sebastienlachance.com/" />
  <updated>2012-05-29T11:40:27-04:00</updated>
  <id>http://sebastienlachance.com/</id>
  <author>
    <name><![CDATA[Sebastien Lachance]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/sebastienlachance/feed" /><feedburner:info uri="sebastienlachance/feed" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>sebastienlachance/feed</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><entry>
    <title type="html"><![CDATA[Rails model without ActiveRecord]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/xNFej05TNIc/" />
    <updated>2012-05-29T11:01:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/rails-model-without-activerecord</id>
    <content type="html">&lt;p&gt;Common scenario for a contact form.&lt;/p&gt;

&lt;p&gt;Here is how I do it:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Model without ActiveRecord in Rails&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Contact&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;ActiveModel&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Validations&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;ActiveModel&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Conversion&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attributes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nb"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nb"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;=&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;persisted?&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kp"&gt;false&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xNFej05TNIc:lhvVcmf72hU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xNFej05TNIc:lhvVcmf72hU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=xNFej05TNIc:lhvVcmf72hU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xNFej05TNIc:lhvVcmf72hU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=xNFej05TNIc:lhvVcmf72hU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xNFej05TNIc:lhvVcmf72hU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xNFej05TNIc:lhvVcmf72hU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/xNFej05TNIc" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/rails-model-without-activerecord/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[A real world application with Backbone and Rails - My story ... so far]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/Ldds-HjkioI/" />
    <updated>2012-05-24T09:20:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/an-real-world-application-with-backbone-my-story</id>
    <content type="html">&lt;p&gt;This is a post about the technology stack I use for my new project (available in the next few weeks).&lt;/p&gt;

&lt;p&gt;I can&amp;#8217;t tell you right now what it is&amp;#8230; (I&amp;#8217;m a little paranoid that my idea will be stolen :) ). But really soon I promise.&lt;/p&gt;

&lt;h2&gt;tl;dr&lt;/h2&gt;

&lt;p&gt;I used Rails, PostgreSql, Backbone and Twitter Bootstrap.&lt;/p&gt;

&lt;h2&gt;This is how I decided of the technology stack.&lt;/h2&gt;

&lt;h2&gt;Web framework&lt;/h2&gt;

&lt;p&gt;Most of my real-world experience was with Rails and .NET. I have done a lot of work in ASP.NET, MVC, Winforms, services, etc. Since I have a lot more experience in the Microsoft world, it would have been logical to use ASP.NET MVC, but Rails is part of my life for the last 2-3 years and it&amp;#8217;s a lot more fun and the development process is reduced by a strong percentage. Don&amp;#8217;t believe me? Try it yourself, you&amp;#8217;ll see what I mean. I have nothing against Visual Studio, It&amp;#8217;s a fantastic IDE and it&amp;#8217;s becoming pretty fast. But, not fast enough. Waiting for Visual Studio to build and attach the debugger is too painful when you are in a hurry. NuGet is starting to be really great but &amp;#8230;&lt;/p&gt;

&lt;p&gt;So I will use Rails latests version (3.2.3 at the moment) with Vim, all on my Macbook Pro. RVM included. I strongly belived that when you launch a startup you want to launch something as fast as possible and adjust to the need of your users. I can&amp;#8217;t built every tools from scratch. So I will use existing tools instead of reinventing the wheel. Rails assets pipeline will help compress and manage assets easily, Sass and CoffeeScript support out of the box. You need something complicated that you don&amp;#8217;t have time for? Gems! There is Gems for almost everything.&lt;/p&gt;

&lt;p&gt;I had considered and was almost sure that I would use Node. But I have realized that I couldn&amp;#8217;t be proefficient soon enough.&lt;/p&gt;

&lt;h2&gt;Database&lt;/h2&gt;

&lt;p&gt;For the database, I made the mistake to use MySql on my last project when I needed fulltext search. I will not use PostgreSQL. With Rails however, I didn&amp;#8217;t see any changes in my development process. Require the pg gem instead of MySql and it&amp;#8217;s done. NoSql is tempting but I don&amp;#8217;t see any real advantages for me, for now.&lt;/p&gt;

&lt;h2&gt;Client-side styling&lt;/h2&gt;

&lt;p&gt;For the css grid framework I wanted to use Skeleton but decided at the last moment to use Twitter Bootstrap (I know&amp;#8230;). You need to know that I am not a designer and Twitter Bootstrap has some customization possible. And it has all this Javascript plugins that are just great &lt;a href="http://twitter.github.com/bootstrap/index.html"&gt;Twitter Bootstrap&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Backbone&lt;/h2&gt;

&lt;p&gt;An obvious choice was to use Backbone. I didn&amp;#8217;t knew why at the time, but I am glad I didn&amp;#8217;t threw this choice away. It was important for me to be a client-side application. As I previously read, Performance is a feature. And it is one of my key principle.&lt;/p&gt;

&lt;p&gt;Backbone has a big learning curve. Here is how I manage to use it effectively:&lt;/p&gt;

&lt;p&gt;I wanted to use TDD to develop the client-side, but gave away after the first week. It was getting in my way and for me I didn&amp;#8217;t feel I was learning Backbone, I was learning how to test javascript. What I did instead was to only use the model part of Backbone and implement the rest using JQuery. It worked really well, until I finally saw a pattern emerging were I needed to reuse a certain part of the interface. So I created a view, listening to the change event of the model. After a while, I added another event listener to the blur event of an text input, and then listening to the reset event of a collection. And then another and another. I saw another case where a view could be appropriate and started implementing it. Created a sub view. Realized that a Router would be a welcome addition. And now I see where I could use it everywhere.&lt;/p&gt;

&lt;p&gt;I can now say that no more of the original JQuery code is left and everything is in either a view, model, router or collection.&lt;/p&gt;

&lt;h2&gt;Authentication&lt;/h2&gt;

&lt;p&gt;One of the other big challenge I faced was with authentication. It was a requirement to use a flexible authentication scheme.&lt;/p&gt;

&lt;p&gt;Twitter and Facebook were my two absolute must as well as the normal user/password combination. Thankfully, the Rails ecosystem has some great gems and OmniAuth was exactly what I was looking for.&lt;/p&gt;

&lt;h2&gt;A final note&lt;/h2&gt;

&lt;p&gt;I strongly believe in this project, not to generate a lot of revenue, but to help those in the same situation as WE were with our first baby&amp;#8230; (ohoh a hint here).&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Ldds-HjkioI:mFP7EHpQ584:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Ldds-HjkioI:mFP7EHpQ584:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=Ldds-HjkioI:mFP7EHpQ584:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Ldds-HjkioI:mFP7EHpQ584:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=Ldds-HjkioI:mFP7EHpQ584:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Ldds-HjkioI:mFP7EHpQ584:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Ldds-HjkioI:mFP7EHpQ584:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/Ldds-HjkioI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/an-real-world-application-with-backbone-my-story/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Rails Assets Pipeline and missing assets]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/0xjdsoofCIM/" />
    <updated>2012-05-10T10:00:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/rails-assets-pipeline-and-missing-assets</id>
    <content type="html">&lt;p&gt;I moved the entire &lt;a href="http://www.guidedescommercesdebeauce.com"&gt;Guide des Commerces&lt;/a&gt; from Rails 3.0.10 to Rails 3.2.3. I have to admit it, I was afraid of the assets pipeline and my first deployment attempt resulted in a lost afternoon and a bad case of stress. I had to revert back and lose some customer data (just my associate data).&lt;/p&gt;

&lt;p&gt;The problem was that I tried to use the assets pipeline for half the application and let everything in the public folder for the second half (admin part). I&amp;#8217;m pretty sure it is possible.&lt;/p&gt;

&lt;p&gt;Now everything is moved and I am actually quite happy. One css and one js per page is finally a dream came true.&lt;/p&gt;

&lt;p&gt;Anyway, what I really wanted to talk here is about one of the problems I had. When calling the assets precompile rake task, one compiled css file was missing. Like one of the manifest wasn&amp;#8217;t read or executed.&lt;/p&gt;

&lt;p&gt;When you have multiple manifest files (not called application.css or application.js), you actually have to tell which additionnal one to precompile.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;config/application.rb&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;precompile&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;administration.js&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;administration.css&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;h2&gt;One gotcha with scss manifest:&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;If you are using scss files as manifests&lt;/strong&gt;, you need to use the compiled version.&lt;/p&gt;

&lt;p&gt;Like this:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;config/application.rb&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;precompile&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;application.css&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="c1"&gt;# this will work for application.css.scss &lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Instead of:&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;config/application.rb&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assets&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;precompile&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;application.css.scss&amp;#39;&lt;/span&gt; &lt;span class="o"&gt;]&lt;/span&gt;  &lt;span class="c1"&gt;# this will not work, but no error will be thrown&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;



&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=0xjdsoofCIM:Kuw0KQw_oBI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=0xjdsoofCIM:Kuw0KQw_oBI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=0xjdsoofCIM:Kuw0KQw_oBI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=0xjdsoofCIM:Kuw0KQw_oBI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=0xjdsoofCIM:Kuw0KQw_oBI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=0xjdsoofCIM:Kuw0KQw_oBI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=0xjdsoofCIM:Kuw0KQw_oBI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/0xjdsoofCIM" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/rails-assets-pipeline-and-missing-assets/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Method decorators in Ruby]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/ne_IswzK-yY/" />
    <updated>2012-05-01T08:00:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/method-decorators-in-ruby</id>
    <content type="html">&lt;p&gt;While I was following the &lt;a href="http://twitter.com/#!/search/%23railsconf"&gt;#railsconf&lt;/a&gt; thread on Twitter, I heard some talking about method decorators with Ruby. I&amp;#8217;ve always wondered if there was a way to emulate the &lt;a href="http://www.codeguru.com/csharp/.net/article.php/c18741/Understanding-and-Using-NET-Attributes.htm"&gt;Attribute&lt;/a&gt; we have in .NET.&lt;/p&gt;

&lt;p&gt;Turns out it is possible (and with added value!). Using the &lt;a href="https://github.com/michaelfairley/method_decorators"&gt;method_decorators gem&lt;/a&gt; allow precisely that functionnality with some extras.&lt;/p&gt;

&lt;h2&gt;Defining a decorator&lt;/h2&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Defining a decorator&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ADecorator&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;MethodDecorator&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;orig&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This decorator actually does nothing, since we call the original method with supplied arguments and block (if provided).&lt;/p&gt;

&lt;h2&gt;Using the decorator&lt;/h2&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;Using the decorator&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AClass&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;extends&lt;/span&gt; &lt;span class="no"&gt;MethodDecorators&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="no"&gt;ADecorator&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;do_something&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;We can now do something before and after the call to  &lt;strong&gt;do_something&lt;/strong&gt; and even modify the return value.&lt;/p&gt;

&lt;h2&gt;A practical example&lt;/h2&gt;

&lt;p&gt;I&amp;#8217;ve had this little problem in .NET where I wanted to profile different method calls to see how much time they took to execute and send back the result via &lt;a href="http://miniprofiler.com/"&gt;MiniProfiler&lt;/a&gt;. For this, I wanted only to add an attribute to those methods. The only way I have found that possible without the use of an advanced profiling tool was to use &lt;a href="http://www.sharpcrafters.com/postsharp/features"&gt;PostSharp&lt;/a&gt; and it&amp;#8217;s injecting code feature. The Attribute functionnality does not offer any kind of before and after hook on execution.&lt;/p&gt;

&lt;p&gt;A custom implementation would look like this.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;MiniProfiler Attribute with PostSharp and C#&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;span class='line-number'&gt;16&lt;/span&gt;
&lt;span class='line-number'&gt;17&lt;/span&gt;
&lt;span class='line-number'&gt;18&lt;/span&gt;
&lt;span class='line-number'&gt;19&lt;/span&gt;
&lt;span class='line-number'&gt;20&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='c#'&gt;&lt;span class='line'&gt;&lt;span class="na"&gt;[Serializable]&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ProfilingAspectAttribute&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;OnMethodBoundaryAspect&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;IDisposable&lt;/span&gt; &lt;span class="n"&gt;_profiler&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ProfilingAspectAttribute&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="nf"&gt;OnEntry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MethodExecutionArgs&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;_profiler&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;MiniProfiler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Step&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;{0}.{1}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;       &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Method&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;DeclaringType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Method&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="nf"&gt;OnExit&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MethodExecutionArgs&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_profiler&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="n"&gt;_profiler&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Dispose&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="n"&gt;_profiler&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;PostSharp will inject the OnEntry and OnExit code at the start and at the end of the &amp;#8220;decorated&amp;#8221; method. By default, &lt;strong&gt;there is no way to achieve that easily&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;With Ruby, the method_decorators gem and a custom profiler, it would look like this.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;A custom profiling decorator&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;span class='line-number'&gt;16&lt;/span&gt;
&lt;span class='line-number'&gt;17&lt;/span&gt;
&lt;span class='line-number'&gt;18&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Profiling&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;MethodDecorator&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;profiler&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;orig&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;blk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;profiler&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stop&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;SomeClass&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="no"&gt;Profiling&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;some_method_to_be_profiled&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="c1"&gt;#some complex calculations&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;How nice is that?&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ne_IswzK-yY:4g16SF6zTpI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ne_IswzK-yY:4g16SF6zTpI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=ne_IswzK-yY:4g16SF6zTpI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ne_IswzK-yY:4g16SF6zTpI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=ne_IswzK-yY:4g16SF6zTpI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ne_IswzK-yY:4g16SF6zTpI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ne_IswzK-yY:4g16SF6zTpI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/ne_IswzK-yY" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/method-decorators-in-ruby/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Learning Rails : assert_valid_keys]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/kJdHVfhl-Pw/" />
    <updated>2012-04-30T06:00:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/learning-rails-assert-valid-keys</id>
    <content type="html">&lt;p&gt;While reading the source code of &lt;a href="https://github.com/thoughtbot/factory_girl"&gt;FactoryGirl&lt;/a&gt;, I came accross this method and tried to find where in FactoryGirl it was defined.
Turns out it&amp;#8217;s in Rails since version 3.0 (more specifically in active_support/core_ext/hash/keys).&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s an instance method of the Hash class, and what it allows you to do is to throw an ArgumentError when an unknown key is found on the hash instance.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;valid keys&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;joe&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:phone&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;555-5555&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assert_valid_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;joe&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="ss"&gt;:phone&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;555-5555&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;# no ArgumentError&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;




&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;missing key in hash&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;joe&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assert_valid_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;joe&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;  &lt;span class="c1"&gt;# no ArgumentError&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;




&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;unknown key in hash&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="ss"&gt;:name&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;joe&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:phone&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;555-5555&amp;#39;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;assert_valid_keys&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="no"&gt;ArgumentError&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;Unknown&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;&lt;a href="http://api.rubyonrails.org/classes/Hash.html#method-i-assert_valid_keys"&gt;assert_valid_keys&lt;/a&gt;&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kJdHVfhl-Pw:5KnZb-2nkUY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kJdHVfhl-Pw:5KnZb-2nkUY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=kJdHVfhl-Pw:5KnZb-2nkUY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kJdHVfhl-Pw:5KnZb-2nkUY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=kJdHVfhl-Pw:5KnZb-2nkUY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kJdHVfhl-Pw:5KnZb-2nkUY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kJdHVfhl-Pw:5KnZb-2nkUY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/kJdHVfhl-Pw" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/learning-rails-assert-valid-keys/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Large-scale Javascript Application Architecture by Addy Osmani]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/CtZu6hXWcsU/" />
    <updated>2012-04-27T08:18:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/large-scale-javascript-application-architecture-by-addy-osmani</id>
    <content type="html">&lt;p&gt;Sometime, great stuff just fall from sky. And this presentation is just what I needed. &lt;a href="http://speakerdeck.com/u/addyosmani"&gt;Addy Osmani&lt;/a&gt; (AOL) has made a presentation about &lt;a href="http://speakerdeck.com/u/addyosmani/p/scaling-your-javascript-applications"&gt;large-scale javascript application architecture&lt;/a&gt; and has made his slides public on &lt;a href="http://speakerdeck.com/"&gt;Speaker Deck&lt;/a&gt; (which by the way is great).&lt;/p&gt;

&lt;script async class="speakerdeck-embed" data-id="4ec3f44095903900510005cf" data-ratio="1.3333333333333333" src="http://sebastienlachance.com//speakerdeck.com/assets/embed.js"&gt;&lt;/script&gt;

&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=CtZu6hXWcsU:S1xuTCRUgH0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=CtZu6hXWcsU:S1xuTCRUgH0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=CtZu6hXWcsU:S1xuTCRUgH0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=CtZu6hXWcsU:S1xuTCRUgH0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=CtZu6hXWcsU:S1xuTCRUgH0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=CtZu6hXWcsU:S1xuTCRUgH0:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=CtZu6hXWcsU:S1xuTCRUgH0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/CtZu6hXWcsU" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/large-scale-javascript-application-architecture-by-addy-osmani/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Ruby and nested classes]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/407s_USsjnI/" />
    <updated>2012-04-24T07:45:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/ruby-and-nested-classes</id>
    <content type="html">&lt;h2&gt;What does it looks like?&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;class Book
    class Page
    end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;What is the purpose of nested classes?&lt;/h2&gt;

&lt;p&gt;It is useful when we want to group classes together instead of trying to keep them distinct. It make no sense in this example to have a standalone Page class without the Book class.&lt;/p&gt;

&lt;h2&gt;How can we instantiate Page class?&lt;/h2&gt;

&lt;p&gt;If we try to instantiate it normally:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;page = Page.new // will throw Uninitialized constant error
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;We get: Uninitialized constant Object::Page&lt;/p&gt;

&lt;p&gt;Instead we need to use:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;page = Book::Page.new
&lt;/code&gt;&lt;/pre&gt;

&lt;h2&gt;But why using :: ?&lt;/h2&gt;

&lt;p&gt;Using :: is a way to access constant. Does it make sense? Yes, because nested classes are stored in constant from within the class.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class A
    B = "A constant"
end
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A::B will return &amp;#8220;A constant&amp;#8221;&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=407s_USsjnI:8_y970KMBcU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=407s_USsjnI:8_y970KMBcU:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=407s_USsjnI:8_y970KMBcU:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=407s_USsjnI:8_y970KMBcU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=407s_USsjnI:8_y970KMBcU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=407s_USsjnI:8_y970KMBcU:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=407s_USsjnI:8_y970KMBcU:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/407s_USsjnI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/ruby-and-nested-classes/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[What can we do with Enumerable#Inject?]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/3enbaDCkzGg/" />
    <updated>2012-04-24T06:00:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/what-can-we-do-with-array-dot-inject</id>
    <content type="html">&lt;p&gt;Combine all elements of an enumerable with the supplied block (or symbol)&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[1, 3, 5, 10].inject { |sum, el| sum + el }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;What is happenning behid the scene is this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;1 + 3  # 1. 
4 + 5  # 2. The value of the precedent operation is passed back into the block as the first argument.
9 + 10 # 3. And so on.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;   #The result will be 19.&lt;/p&gt;

&lt;p&gt;You can also pass an ininial value like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[1,2,3].inject(10) { |sum, el| sum + el }

10 + 1
11 + 2
13 + 3
The result will be 16.
You can see it as (((10 + 1) + 2) + 3).
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The initial value will serve as the first argument of the block.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=3enbaDCkzGg:ldUDtL-_65k:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=3enbaDCkzGg:ldUDtL-_65k:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=3enbaDCkzGg:ldUDtL-_65k:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=3enbaDCkzGg:ldUDtL-_65k:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=3enbaDCkzGg:ldUDtL-_65k:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=3enbaDCkzGg:ldUDtL-_65k:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=3enbaDCkzGg:ldUDtL-_65k:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/3enbaDCkzGg" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/what-can-we-do-with-array-dot-inject/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Iterate over each line of a string in C#]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/NZdQbSalnG0/" />
    <updated>2012-04-17T07:53:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/iterate-over-each-line-of-a-string-in-c-sharp</id>
    <content type="html">&lt;p&gt;For future reference.&lt;/p&gt;

&lt;p&gt;Easy way to go through each line of a string.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;string iteration&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;StringReader&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;StringReader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;txt&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;line&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;line&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;reader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ReadLine&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;        &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;do anything with the line);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=NZdQbSalnG0:1YCenJGeLgY:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=NZdQbSalnG0:1YCenJGeLgY:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=NZdQbSalnG0:1YCenJGeLgY:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=NZdQbSalnG0:1YCenJGeLgY:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=NZdQbSalnG0:1YCenJGeLgY:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=NZdQbSalnG0:1YCenJGeLgY:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=NZdQbSalnG0:1YCenJGeLgY:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/NZdQbSalnG0" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/iterate-over-each-line-of-a-string-in-c-sharp/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[ASP.NET MVC ActionLink with image]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/Yo-x-gdCSb8/" />
    <updated>2012-04-12T07:49:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/asp-dot-net-mvc-actionlink-with-image</id>
    <content type="html">&lt;p&gt;It&amp;#8217;s not as hard as it seems. This is a way to create a link with an image.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;link to action with an image&lt;/span&gt;&lt;/figcaption&gt;&lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@Url.Action(&amp;quot;&lt;/span&gt;&lt;span class="n"&gt;Create&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;, &amp;quot;&lt;/span&gt;&lt;span class="n"&gt;LogBooks&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;)&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;img&lt;/span&gt; &lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;@Url.Content(&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;~/&lt;/span&gt;&lt;span class="n"&gt;Content&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="n"&gt;Images&lt;/span&gt;&lt;span class="p"&gt;/&lt;/span&gt;&lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;png&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;)&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;

&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Yo-x-gdCSb8:yOcox0Kff-s:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Yo-x-gdCSb8:yOcox0Kff-s:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=Yo-x-gdCSb8:yOcox0Kff-s:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Yo-x-gdCSb8:yOcox0Kff-s:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=Yo-x-gdCSb8:yOcox0Kff-s:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Yo-x-gdCSb8:yOcox0Kff-s:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=Yo-x-gdCSb8:yOcox0Kff-s:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/Yo-x-gdCSb8" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/asp-dot-net-mvc-actionlink-with-image/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Skyrim - A really awesome video]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/pQ5NBnruIqQ/" />
    <updated>2012-04-11T06:00:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/skyrim-a-really-awesome-video</id>
    <content type="html">&lt;p&gt;If you&amp;#8217;ve played more than a few hours of Skyrim, this is for you&amp;#8230;&lt;/p&gt;

&lt;iframe width="853" height="480" src="http://www.youtube.com/embed/ALbQQzePzt4" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;

&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=pQ5NBnruIqQ:FvY3pe2z0PM:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=pQ5NBnruIqQ:FvY3pe2z0PM:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=pQ5NBnruIqQ:FvY3pe2z0PM:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=pQ5NBnruIqQ:FvY3pe2z0PM:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=pQ5NBnruIqQ:FvY3pe2z0PM:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=pQ5NBnruIqQ:FvY3pe2z0PM:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=pQ5NBnruIqQ:FvY3pe2z0PM:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/pQ5NBnruIqQ" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/skyrim-a-really-awesome-video/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Completely unrealistic example - A Backbone Blog]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/vY5rtxxpdPQ/" />
    <updated>2012-04-10T06:00:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/completely-unrealistic-example-a-backbone-blog</id>
    <content type="html">&lt;p&gt;Last week, while I was playing and coding on my Backbone blog project (&lt;a href="https://github.com/sebastienlachance/backbone-rails-blog"&gt;backbone-rails-blog&lt;/a&gt;), I started wondering if it was something I could use to replace this blog, since I put so much time on it lately. But at the same time I kept telling myself, &lt;strong&gt;is Google going to index the content?&lt;/strong&gt; The short answer is: &lt;strong&gt;NO&lt;/strong&gt;, not now anyway.&lt;/p&gt;

&lt;p&gt;The long answer goes like this: Facebook comments are indexed. So there should be a way to provide this content to GoogleBot. I have done my homework and this document, &lt;a href="https://developers.google.com/webmasters/ajax-crawling/docs/getting-started"&gt;Making Ajax Applications Crawlable&lt;/a&gt;) provides some answers. Basically, we need the &lt;a href="http://en.wikipedia.org/wiki/Shebang_(Unix"&gt;hashbang&lt;/a&gt;) url format. This is achieved with Backbone when we are not using pushstate.&lt;/p&gt;

&lt;p&gt;Hashbang url:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;http://sebastienlachance.com#!blog-post
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My urls:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;http://sebastienlachacne.com/blog-post
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And frankly, I will not pursue this path. In my case anyway, it provides no real advantages to have an Ajax-powered blog.&lt;/p&gt;

&lt;p&gt;In fact, I could have left Backbone and only use it on the admin backend, but as a learning tool, I didn&amp;#8217;t want to revert back (and there is so much great blogging platform now anyway).&lt;/p&gt;

&lt;p&gt;Do you have any other web apps ideas (other than a todo list or blog)? In my next iteration (that is, the next app), I will be using Backbone with NodeJs and MongoDB. Sounds fun.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=vY5rtxxpdPQ:jW6T9bNtnxI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=vY5rtxxpdPQ:jW6T9bNtnxI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=vY5rtxxpdPQ:jW6T9bNtnxI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=vY5rtxxpdPQ:jW6T9bNtnxI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=vY5rtxxpdPQ:jW6T9bNtnxI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=vY5rtxxpdPQ:jW6T9bNtnxI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=vY5rtxxpdPQ:jW6T9bNtnxI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/vY5rtxxpdPQ" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/completely-unrealistic-example-a-backbone-blog/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Available]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/554lrX8rPkY/" />
    <updated>2012-04-06T15:12:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/available</id>
    <content type="html">&lt;p&gt;I am now available to do freelance web development. Contract or on site.&lt;/p&gt;

&lt;p&gt;I have experience in ASP.NET (MVC or WebForms) and Ruby On Rails. HTML, Javascript and CSS, no problem.&lt;/p&gt;

&lt;p&gt;You can see my CV here (&lt;a href="http://sebastienlachance.com/resume"&gt;CV&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;I can be on site if you are in the area or work remotely (I also have experience in that).&lt;/p&gt;

&lt;p&gt;I am looking forward to accept new challenges and deliver WORKING solutions!&lt;/p&gt;

&lt;p&gt;You can contact me here (&lt;a href="http://twitter.com/slachance"&gt;Twitter&lt;/a&gt;), (&lt;a href="http://www.linkedin.com/in/sebastienlachance"&gt;LinkedIn&lt;/a&gt;) or here (at sebastien.lachance creatiom.com).&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=554lrX8rPkY:dcWRGqXNGC8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=554lrX8rPkY:dcWRGqXNGC8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=554lrX8rPkY:dcWRGqXNGC8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=554lrX8rPkY:dcWRGqXNGC8:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=554lrX8rPkY:dcWRGqXNGC8:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=554lrX8rPkY:dcWRGqXNGC8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=554lrX8rPkY:dcWRGqXNGC8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/554lrX8rPkY" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/available/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Disponible pour mandat de développement]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/ykpNL2HXjfk/" />
    <updated>2012-04-06T13:30:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/disponible</id>
    <content type="html">&lt;p&gt;Je suis maintenant disponible pour des mandats de développement Web à la pige. Contrat ou sur place.&lt;/p&gt;

&lt;p&gt;J&amp;#8217;ai de l&amp;#8217;expérience en ASP.NET (MVC ou WebForms) et Ruby On Rails. HTML, Javascript et CSS, aucun problème.&lt;/p&gt;

&lt;p&gt;Vous pouvez consultez mon CV ici (&lt;a href="http://sebastienlachance.com/resume"&gt;CV&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;Je peux me déplacer si vous êtes dans la région ou travailler à distance (j&amp;#8217;ai aussi de l&amp;#8217;expérience dans ça).&lt;/p&gt;

&lt;p&gt;J&amp;#8217;ai très hâte de relever de nouveaux défis et de livrer des solutions qui FONCTIONNENT.&lt;/p&gt;

&lt;p&gt;Vous pouvez me contactez ici (&lt;a href="http://twitter.com/slachance"&gt;Twitter&lt;/a&gt;), ici (&lt;a href="http://www.linkedin.com/in/sebastienlachance"&gt;LinkedIn&lt;/a&gt;) ou ici (sebastien.lachance at creatiom.com).&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ykpNL2HXjfk:ccgpaHzDx18:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ykpNL2HXjfk:ccgpaHzDx18:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=ykpNL2HXjfk:ccgpaHzDx18:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ykpNL2HXjfk:ccgpaHzDx18:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=ykpNL2HXjfk:ccgpaHzDx18:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ykpNL2HXjfk:ccgpaHzDx18:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=ykpNL2HXjfk:ccgpaHzDx18:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/ykpNL2HXjfk" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/disponible/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Rerun all Guards]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/bxmnikhXz50/" />
    <updated>2012-03-30T15:16:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/rerun-all-guards</id>
    <content type="html">&lt;p&gt;I have been searching this feature for a while and never realized it was built-in into Guard. Whenever I tried to rerun all with pressing enter, nothing happened. I didn&amp;#8217;t realized I was because of an old gem version.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Ctrl-r if you are on Guard version &amp;lt; 7
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;enter if you are on a more recent version
&lt;/code&gt;&lt;/pre&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=bxmnikhXz50:SsC1l7Vzaow:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=bxmnikhXz50:SsC1l7Vzaow:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=bxmnikhXz50:SsC1l7Vzaow:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=bxmnikhXz50:SsC1l7Vzaow:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=bxmnikhXz50:SsC1l7Vzaow:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=bxmnikhXz50:SsC1l7Vzaow:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=bxmnikhXz50:SsC1l7Vzaow:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/bxmnikhXz50" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/rerun-all-guards/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Help needed, A Backbone blog]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/00wOdrBkEKw/" />
    <updated>2012-03-19T12:39:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/help-needed-a-backbone-blog</id>
    <content type="html">&lt;p&gt;I&amp;#8217;m currently doing my best to learn Backbone and his best practices. I have set up a demo blog application on GitHub (&lt;a href="https://github.com/sebastienlachance/backbone-rails-blog"&gt;Backbone-rails-blog&lt;/a&gt;).&lt;/p&gt;

&lt;p&gt;So, if you are interested to give me some feedback, tips or check out the development progress, just watch the project to see where things are going and I&amp;#8217;ll blog the important parts as I move forward.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=00wOdrBkEKw:W9Ua-nivMz0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=00wOdrBkEKw:W9Ua-nivMz0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=00wOdrBkEKw:W9Ua-nivMz0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=00wOdrBkEKw:W9Ua-nivMz0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=00wOdrBkEKw:W9Ua-nivMz0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=00wOdrBkEKw:W9Ua-nivMz0:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=00wOdrBkEKw:W9Ua-nivMz0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/00wOdrBkEKw" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/help-needed-a-backbone-blog/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Filling a select from an array on javascript object]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/OyLPGe2nQSM/" />
    <updated>2012-03-13T12:11:00-04:00</updated>
    <id>http://sebastienlachance.com/blog/filling-a-select-from-an-array-on-javascript-object</id>
    <content type="html">&lt;p&gt;As a reminder for my future self, here is how I fill a select from an array of javascript object.&lt;/p&gt;

&lt;iframe style="width: 100%; height: 300px" src="http://jsfiddle.net/z9Q4R/embedded/js,resources,html,css,result/light/"&gt;&lt;/iframe&gt;

&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=OyLPGe2nQSM:t2hp1YE-NY8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=OyLPGe2nQSM:t2hp1YE-NY8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=OyLPGe2nQSM:t2hp1YE-NY8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=OyLPGe2nQSM:t2hp1YE-NY8:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=OyLPGe2nQSM:t2hp1YE-NY8:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=OyLPGe2nQSM:t2hp1YE-NY8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=OyLPGe2nQSM:t2hp1YE-NY8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/OyLPGe2nQSM" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/filling-a-select-from-an-array-on-javascript-object/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Converting a BlogEngine.Net blog to Octopress]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/kTK2gIh-lwc/" />
    <updated>2012-02-21T12:52:00-05:00</updated>
    <id>http://sebastienlachance.com/blog/converting-a-blogengine-dot-net-blog-to-octopress</id>
    <content type="html">&lt;p&gt;Some months ago, I moved my BlogEngine.net blog (hosted on GoDaddy) to Octopress hosted on Heroku. I needed a tool to migrate all my posts and found nothing that could apply to my case (I&amp;#8217;m pretty sure there is something out there, but I didn&amp;#8217;t look very far and wanted to code the tool myself anyway).&lt;/p&gt;

&lt;p&gt;Octopress blog post format look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;---
layout: post
title: "Setting ComVisible"
date: 2005-01-19 14:46:00
comments: true
categories: 
---

** This is my post using Markdown **
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My BlogEngine.Net was configured to use xml files to store posts. Which look like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="utf-8" standalone="yes"?&amp;gt;
&amp;lt;post&amp;gt;
  &amp;lt;author&amp;gt;SebastienLachance&amp;lt;/author&amp;gt;
  &amp;lt;title&amp;gt;Building a new app - Introduction&amp;lt;/title&amp;gt;
  &amp;lt;description&amp;gt;The introduction&amp;lt;/description&amp;gt;
  &amp;lt;content&amp;gt;This is ...
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At first, I wanted to move each post individually whenever I could. After a week and pretty much nothing converted, I created a little .Net tool to make the conversion/migration much easier.&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s a pretty basic windows form application that takes a path and output a bundle of simili-markdown (because the original posts are html, but, since markdown accept html, it&amp;#8217;s fine) files that are compatible with the Octopress format.&lt;/p&gt;

&lt;p&gt;It&amp;#8217;s also generating a &lt;strong&gt;redirection.rb&lt;/strong&gt; file that contains necessary code to be used by rack-rewrite to make necessary 301 redirection. It can be useful if you don&amp;#8217;t want to write it all manually.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use Rack::Rewrite do

    r301 %r{^/post/The-surprising-science-of-motivation-by-Dan-Pink.aspx?$}, '/blog/the-surprising-science-of-motivation-by-dan-pink'
    r301 %r{^/post/Building-a-new-application-Introduction.aspx?$}, '/blog/building-a-new-application-introduction'
    r301 %r{^/post/tight-deadlines.aspx?$}, '/blog/tight-deadlines'
    r301 %r{^/post/no-such-file-to-load-cucumberrailsactive_record-(LoadError).aspx?$}, '/blog/no-such-file-to-load-cucumberrailsactive_record-(loaderror)'
    r301 %r{^/post/Buying-games-on-Steam.aspx?$}, '/blog/buying-games-on-steam'
    r301 %r{^/post/AlternativeToNet-review.aspx?$}, '/blog/alternativetonet-review'
    r301 %r{^/post/Excellent-post-by-Uncle-Bob.aspx?$}, '/blog/excellent-post-by-uncle-bob'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can grab the source here : &lt;a href="https://github.com/sebastienlachance/BlogEngineToOctopress"&gt;BlogEngineToOctopres&lt;/a&gt;&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kTK2gIh-lwc:2ZglznTKoc0:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kTK2gIh-lwc:2ZglznTKoc0:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=kTK2gIh-lwc:2ZglznTKoc0:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kTK2gIh-lwc:2ZglznTKoc0:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=kTK2gIh-lwc:2ZglznTKoc0:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kTK2gIh-lwc:2ZglznTKoc0:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=kTK2gIh-lwc:2ZglznTKoc0:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/kTK2gIh-lwc" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/converting-a-blogengine-dot-net-blog-to-octopress/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[My starting Gemfile]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/xBveuTDm_m8/" />
    <updated>2012-02-17T15:08:00-05:00</updated>
    <id>http://sebastienlachance.com/blog/my-starting-gemfile</id>
    <content type="html">&lt;p&gt;This is how my Gemfile looks like at the moment. Continuous feedback with Guard and metrics to keep track on defects and best practices not used.&lt;/p&gt;

&lt;div&gt;&lt;script src='https://gist.github.com/1855201.js?file='&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;pre&gt;&lt;code&gt;source 'https://rubygems.org'

gem 'rails', '3.2.1'
gem 'pg'
gem 'omniauth-twitter'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-identity'

group :assets do
  gem 'sass-rails',   '~&amp;gt; 3.2.3'
  gem 'coffee-rails', '~&amp;gt; 3.2.1'
  gem 'uglifier',     '&amp;gt;= 1.0.3'
end

gem 'jquery-rails'
gem 'skeleton-rails'
gem 'rails-backbone'
gem 'jasminerice'

gem 'rspec-rails', :group =&amp;gt; [:development, :test]

group :development do 
  gem 'heroku'
  gem 'guard'
  gem 'guard-rspec'
  gem 'guard-jasmine'
  gem 'growl'
  gem 'metrical'
  gem 'fattr'         # for Metric_fu
  gem 'arrayfields'   # for Metric_fu
  gem 'map'           # for Metric_fu
  gem 'annotate', :git =&amp;gt; 'git://github.com/ctran/annotate_models.git'
end

group :test do
  gem 'database_cleaner', :group =&amp;gt; :test
  gem 'factory_girl_rails', :group =&amp;gt; :test
end

gem 'bcrypt-ruby', '~&amp;gt; 3.0.0'&lt;/code&gt;&lt;/pre&gt;&lt;/noscript&gt;&lt;/div&gt;



&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xBveuTDm_m8:cAullhhKLvI:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xBveuTDm_m8:cAullhhKLvI:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=xBveuTDm_m8:cAullhhKLvI:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xBveuTDm_m8:cAullhhKLvI:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=xBveuTDm_m8:cAullhhKLvI:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xBveuTDm_m8:cAullhhKLvI:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=xBveuTDm_m8:cAullhhKLvI:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/xBveuTDm_m8" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/my-starting-gemfile/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Startup Camp Quebec]]></title>
    <link href="http://feedproxy.google.com/~r/sebastienlachance/feed/~3/v169pCllARI/" />
    <updated>2012-02-13T12:11:00-05:00</updated>
    <id>http://sebastienlachance.com/blog/startup-camp-quebec</id>
    <content type="html">&lt;p&gt;&lt;img class="left" src="http://sebastienlachance.com/images/startupcampquebec.jpg" title="Startup Camp Québec" &gt;&lt;/p&gt;

&lt;p&gt;Jeudi dernier, avait lieu l&amp;#8217;événement &lt;a href="http://www.startupcampquebec.com"&gt;Startup Camp Québec&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Je ne suis pas un habitué de ces événements même si j&amp;#8217;ai &lt;a href="http://www.guidedescommercesdebeauce.com"&gt;ma propre compagnie&lt;/a&gt; et ait participé à quelques coktails et diners aux homards (j&amp;#8217;aime pas le homard). C&amp;#8217;était quand un monde nouveau avec de nouvelles personnes.&lt;/p&gt;

&lt;p&gt;Il y avait 8 startups qui présentaient leur produits. J&amp;#8217;ai bien aimé les présentations, et j&amp;#8217;ai beaucoup accroché sur quelques projets. Particulièrement le projet Trapèze École de &lt;a href="http://mx4.yolasite.com/"&gt;MX4&lt;/a&gt;. Ils ont créer une manière de gérer les horaires dans les écoles, et ca, c&amp;#8217;est ce que j&amp;#8217;appelle trouver des solutions à un problème.&lt;/p&gt;

&lt;p&gt;Mais le grand gagnant de cette édition est &lt;a href="http://theriansaga.fatecraft.com/"&gt;FateCraft&lt;/a&gt;, qui développe des jeux sociaux.&lt;/p&gt;

&lt;p&gt;Je n&amp;#8217;ai malheureusement pu rester jusqu&amp;#8217;à la fin et voir la remise des prix. Mais je souhaite quand même bonne chance à toutes ces jeunes entreprises et puissent-elles continuer malgré toutes les embuches qui peuvent se présenter devant elles.&lt;/p&gt;
&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=v169pCllARI:3zw1yGZo-D8:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=v169pCllARI:3zw1yGZo-D8:V_sGLiPBpWU"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=v169pCllARI:3zw1yGZo-D8:V_sGLiPBpWU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=v169pCllARI:3zw1yGZo-D8:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?i=v169pCllARI:3zw1yGZo-D8:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=v169pCllARI:3zw1yGZo-D8:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=7Q72WNTAKBA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/sebastienlachance/feed?a=v169pCllARI:3zw1yGZo-D8:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/sebastienlachance/feed?d=qj6IDK7rITs" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/sebastienlachance/feed/~4/v169pCllARI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://sebastienlachance.com/blog/startup-camp-quebec/</feedburner:origLink></entry>
  
</feed>
