<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Rock, Paper, Software &#187; Uncategorized</title>
	<atom:link href="http://software.tulentsev.com/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://software.tulentsev.com</link>
	<description>Random thoughts about programming</description>
	<lastBuildDate>Fri, 03 Feb 2012 13:47:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ruby: how to override class method with a module</title>
		<link>http://software.tulentsev.com/2012/02/ruby-how-to-override-class-method-with-a-module/</link>
		<comments>http://software.tulentsev.com/2012/02/ruby-how-to-override-class-method-with-a-module/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 13:09:00 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[metaprogramming]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=298</guid>
		<description><![CDATA[This seems to be a popular interview question. It indeed requires advanced knowledge of ruby. You have a class with a class method. Write a module that, when included, will override that class method. Explanation of the problem Now classic way of mixing in class methods is this (and it doesn&#8217;t solve the problem, of [...]]]></description>
			<content:encoded><![CDATA[<p>This seems to be a popular interview question. It indeed requires advanced knowledge of ruby.</p>

<blockquote>
  <p>You have a class with a class method. Write a module that, when included, will override that class method.</p>
</blockquote>

<h3>Explanation of the problem</h3>

<p>Now classic way of mixing in class methods is this (and it doesn&#8217;t solve the problem, of course).</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">module</span> FooModule
      <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">included</span> base
        base.<span style="color:#9900CC;">extend</span> ClassMethods
      <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">module</span> ClassMethods
        <span style="color:#9966CC; font-weight:bold;">def</span> bar
          <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;module&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">class</span> Klass
      <span style="color:#9966CC; font-weight:bold;">include</span> FooModule
&nbsp;
      <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">bar</span>
        <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'class'</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
&nbsp;
    Klass.<span style="color:#9900CC;">bar</span> <span style="color:#008000; font-style:italic;">#=&gt; class</span></pre></div></div>




<p>When modules are included or extended into a class, its methods are placed right above this class&#8217; methods in inheritance chain. This means that if we were to call <code>super</code> in that class method, it would print &#8220;module&#8221;. But we don&#8217;t want to touch original class definition, we want to alter it from outside.</p>

<h3>So, can we do something?</h3>

<p>Good for us, ruby has a concept of <a href="http://www.google.ru/search?ix=hca&amp;sourceid=chrome&amp;ie=UTF-8&amp;q=ruby+open+classes">&#8220;open classes&#8221;</a>. This means that we can change virtually everything in the app, even some 3rd-party libraries. Every class can &#8220;opened&#8221; and new methods can be added to it, or old methods can be redefined. Let&#8217;s look how it works.<span id="more-298"></span></p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">class</span> Klass
      <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">bar</span>
        <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'class'</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">class</span> Klass
      <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">bar</span>
        <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'class 2'</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    Klass.<span style="color:#9900CC;">bar</span> <span style="color:#008000; font-style:italic;">#=&gt; class 2</span></pre></div></div>




<p>The second class definition does not overwrite previous one, it opens and alters it. In this case, it happened to define a method with the same name. This resulted in old method being overwritten by the new one. This works with any classes, even base library classes.</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;">#=&gt; [1, 2, 3]</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC0066; font-weight:bold;">Array</span>
      <span style="color:#9966CC; font-weight:bold;">def</span> to_s
        <span style="color:#996600;">&quot;an array: #{join ', '}&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;">#=&gt; an array: 1, 2, 3</span></pre></div></div>




<p>Or the same code can be rewritten as</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;">#=&gt; [1, 2, 3]</span>
&nbsp;
    <span style="color:#CC0066; font-weight:bold;">Array</span>.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
      <span style="color:#9966CC; font-weight:bold;">def</span> to_s
        <span style="color:#996600;">&quot;an array: #{join ', '}&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span>, <span style="color:#006666;">2</span>, <span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_s</span> <span style="color:#008000; font-style:italic;">#=&gt; an array: 1, 2, 3</span></pre></div></div>




<h3>Applying the knowledge</h3>

<p>Let&#8217;s start with simpler things, like overriding an instance method.</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">class</span> Klass
      <span style="color:#9966CC; font-weight:bold;">def</span> say
        <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'class'</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">module</span> FooModule
      <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">included</span> base
        base.<span style="color:#9900CC;">class_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
          <span style="color:#9966CC; font-weight:bold;">def</span> say
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;module&quot;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
&nbsp;
    Klass.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span>:<span style="color:#9966CC; font-weight:bold;">include</span>, FooModule<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    Klass.<span style="color:#9900CC;">new</span>.<span style="color:#9900CC;">say</span> <span style="color:#008000; font-style:italic;">#=&gt; module</span></pre></div></div>




<p>Modules have a special callback that gets called every time a module is included in a class. We can use that to call class_eval on that class and redefine a method.</p>

<p>Replacing a class method is done in a similar way.</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#9966CC; font-weight:bold;">class</span> Klass
      <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">say</span>
        <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">'class'</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">module</span> FooModule
      <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">included</span> base
        base.<span style="color:#9900CC;">instance_eval</span> <span style="color:#9966CC; font-weight:bold;">do</span>
          <span style="color:#9966CC; font-weight:bold;">def</span> say
            <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;module&quot;</span>
          <span style="color:#9966CC; font-weight:bold;">end</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
&nbsp;
    Klass.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span>:<span style="color:#9966CC; font-weight:bold;">include</span>, FooModule<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    Klass.<span style="color:#9900CC;">say</span> <span style="color:#008000; font-style:italic;">#=&gt; module</span></pre></div></div>




<p>The only difference here is that we call instance_eval instead of class_eval. This can be a very confusing part. In short, class_eval creates instance methods and instance_eval creates class methods.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2012/02/ruby-how-to-override-class-method-with-a-module/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mongoid, db.system.namespaces queries</title>
		<link>http://software.tulentsev.com/2012/02/mongoid-db-system-namespaces-queries/</link>
		<comments>http://software.tulentsev.com/2012/02/mongoid-db-system-namespaces-queries/#comments</comments>
		<pubDate>Fri, 03 Feb 2012 12:12:54 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[MongoDb]]></category>
		<category><![CDATA[MongoId]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=295</guid>
		<description><![CDATA[Recently I faced some issues with Mongoid when upgrading my Rails app from REE+Passenger to MRI 1.9.3+Unicorn. There are some Resque workers in the background. After some deploy they started to consume a ton of traffic from MongoDB. After some investigation, I found that they heavily read system.namespaces collection. I tried upgrading to latest versions [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I faced some issues with <a href="http://mongoid.org">Mongoid</a> when upgrading my Rails app from REE+Passenger to MRI 1.9.3+Unicorn.</p>

<p>There are some Resque workers in the background. After some deploy they started to consume a ton of traffic from MongoDB. After some investigation, I found that they heavily read <code>system.namespaces</code> collection. I tried upgrading to latest versions of <code>mongoid</code>(2.4.3) and <code>mongo</code>(1.5.2) to no avail. This does not happen with normal unicorn workers. This also does not happen if I downgrade <code>mongoid</code> to 2.0.1.</p>

<p>I am still not sure what&#8217;s happening here. I&#8217;ll update this post when I discover something.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2012/02/mongoid-db-system-namespaces-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to quickly lock screen in Mac OS X?</title>
		<link>http://software.tulentsev.com/2012/01/how-to-quickly-lock-screen-in-mac-os-x/</link>
		<comments>http://software.tulentsev.com/2012/01/how-to-quickly-lock-screen-in-mac-os-x/#comments</comments>
		<pubDate>Fri, 27 Jan 2012 13:28:28 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=291</guid>
		<description><![CDATA[I am tired of googling the same information over and over, so I am posting it here. To quickly lock your screen, press Ctrl+Shift+Eject. Also, you can press Fn+Ctrl+Eject to quickly restart your Mac, shut it down or put to sleep.]]></description>
			<content:encoded><![CDATA[<p>I am tired of googling the same information over and over, so I am posting it here.</p>

<p>To quickly lock your screen, press Ctrl+Shift+Eject.</p>

<p>Also, you can press Fn+Ctrl+Eject to quickly restart your Mac, shut it down or put to sleep.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2012/01/how-to-quickly-lock-screen-in-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email validation done right</title>
		<link>http://software.tulentsev.com/2012/01/email-validation-done-right/</link>
		<comments>http://software.tulentsev.com/2012/01/email-validation-done-right/#comments</comments>
		<pubDate>Wed, 11 Jan 2012 13:48:24 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=289</guid>
		<description><![CDATA[Let&#8217;s imagine that you have to check if a string is a valid email. You could come up with something like: /&#91;a-zA-Z0-9\.&#93;+@&#91;a-z&#93;+\.&#91;a-z&#93;+/ It works, right? WRONG. Sure it&#8217;ll handle a couple of your test examples. But it&#8217;s not ready for real world usage. Here&#8217;s a standards compliant Perl regex. /&#40;?&#40;DEFINE&#41; &#40;?&#60;address&#62; &#40;?&#38;mailbox&#41; &#124; &#40;?&#38;group&#41;&#41; &#40;?&#60;mailbox&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Let&#8217;s imagine that you have to check if a string is a valid email. You could come up with something like:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">    <span style="color: #339933;">/</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>zA<span style="color: #339933;">-</span>Z0<span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+@</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>z<span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span>\<span style="color: #339933;">.</span><span style="color: #009900;">&#91;</span>a<span style="color: #339933;">-</span>z<span style="color: #009900;">&#93;</span><span style="color: #339933;">+/</span></pre></div></div>

<p>It works, right? WRONG. Sure it&#8217;ll handle a couple of your test examples. But it&#8217;s not ready for real world usage. Here&#8217;s a standards compliant Perl regex.</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#40;</span>DEFINE<span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;address&gt;</span>         <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;mailbox</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;group</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;mailbox&gt;</span>         <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;name_addr</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;addr_spec</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;name_addr&gt;</span>       <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;display_name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;angle_addr</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;angle_addr&gt;</span>      <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;addr_spec</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;group&gt;</span>           <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;display_name</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;mailbox_list</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #339933;">;</span>
                                          <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;display_name&gt;</span>    <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;phrase</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;mailbox_list&gt;</span>    <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;mailbox</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span> <span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;mailbox</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;addr_spec&gt;</span>       <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;local_part</span><span style="color: #009900;">&#41;</span> \<span style="color: #339933;">@</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;domain</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;local_part&gt;</span>      <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;dot_atom</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;quoted_string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;domain&gt;</span>          <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;dot_atom</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;domain_literal</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;domain_literal&gt;</span>  <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> \<span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;dcontent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>
                                 \<span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;dcontent&gt;</span>        <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;dtext</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;quoted_pair</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;dtext&gt;</span>           <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;NO_WS_CTL</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">\x21</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x5a</span><span style="color: #0000ff;">\x5e</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x7e</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;atext&gt;</span>           <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;ALPHA</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;DIGIT</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#91;</span><span style="color: #339933;">!</span><span style="color: #666666; font-style: italic;">#\$%&amp;'*+-/=?^_`{|}~])</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;atom&gt;</span>            <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;atext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;dot_atom&gt;</span>        <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;dot_atom_text</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;dot_atom_text&gt;</span>   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;atext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span> \<span style="color: #339933;">.</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;atext</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;text&gt;</span>            <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">\x01</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x09</span><span style="color: #0000ff;">\x0b</span><span style="color: #0000ff;">\x0c</span><span style="color: #0000ff;">\x0e</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x7f</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;quoted_pair&gt;</span>     \\ <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;text</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;qtext&gt;</span>           <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;NO_WS_CTL</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">\x21</span><span style="color: #0000ff;">\x23</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x5b</span><span style="color: #0000ff;">\x5d</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x7e</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;qcontent&gt;</span>        <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;qtext</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;quoted_pair</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;quoted_string&gt;</span>   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;DQUOTE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;qcontent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>
                        <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;DQUOTE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CFWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;word&gt;</span>            <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;atom</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;quoted_string</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;phrase&gt;</span>          <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;word</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># Folding white space</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;FWS&gt;</span>             <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;WSP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;CRLF</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;WSP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;ctext&gt;</span>           <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;NO_WS_CTL</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">\x21</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x27</span><span style="color: #0000ff;">\x2a</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x5b</span><span style="color: #0000ff;">\x5d</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x7e</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;ccontent&gt;</span>        <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;ctext</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;quoted_pair</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;comment</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;comment&gt;</span>         \<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;ccontent</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> \<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;CFWS&gt;</span>            <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;comment</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>
                       <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?:</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;comment</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&amp;FWS</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;"># No whitespace control</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;NO_WS_CTL&gt;</span>       <span style="color: #009900;">&#91;</span><span style="color: #0000ff;">\x01</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x08</span><span style="color: #0000ff;">\x0b</span><span style="color: #0000ff;">\x0c</span><span style="color: #0000ff;">\x0e</span><span style="color: #339933;">-</span><span style="color: #0000ff;">\x1f</span><span style="color: #0000ff;">\x7f</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
&nbsp;
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;ALPHA&gt;</span>           <span style="color: #009900;">&#91;</span>A<span style="color: #339933;">-</span>Za<span style="color: #339933;">-</span>z<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;DIGIT&gt;</span>           <span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">9</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;CRLF&gt;</span>            <span style="color: #0000ff;">\x0d</span> <span style="color: #0000ff;">\x0a</span><span style="color: #009900;">&#41;</span>
   <span style="color: #009900;">&#40;</span><span style="color: #339933;">?</span><span style="color: #009999;">&lt;DQUOTE&gt;</span>          <span style="color: #ff0000;">&quot;)
   (?&lt;WSP&gt;             [<span style="color: #000099; font-weight: bold;">\x</span>20<span style="color: #000099; font-weight: bold;">\x</span>09])
 )
&nbsp;
 (?&amp;address)/x</span></pre></div></div>

<p> I couldn&#8217;t even imagine that the matter is *this* complex.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2012/01/email-validation-done-right/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Funny side benefit :-)</title>
		<link>http://software.tulentsev.com/2010/08/funny-side-benefit/</link>
		<comments>http://software.tulentsev.com/2010/08/funny-side-benefit/#comments</comments>
		<pubDate>Sun, 22 Aug 2010 16:17:18 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[LINQ]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=187</guid>
		<description><![CDATA[There I was, minding my own business, trying to solve problems in graph theory and I accidentally made a Sudoku puzzle solver! Isn&#8217;t it funny how life turns out sometimes? But that&#8217;s just how awesome LINQ is. Eric Lippert on LINQ]]></description>
			<content:encoded><![CDATA[<blockquote><p>There I was, minding my own business, trying to solve problems in graph theory and I accidentally made a Sudoku puzzle solver! Isn&#8217;t it funny how life turns out sometimes? But that&#8217;s just how awesome LINQ is.</p></blockquote>
<p><a href="http://blogs.msdn.com/b/ericlippert/archive/2010/07/29/graph-colouring-part-five.aspx">Eric Lippert on LINQ</a></p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2010/08/funny-side-benefit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intuitive behaviour</title>
		<link>http://software.tulentsev.com/2009/05/intuitive-behaviour/</link>
		<comments>http://software.tulentsev.com/2009/05/intuitive-behaviour/#comments</comments>
		<pubDate>Mon, 18 May 2009 15:19:25 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[RubyMine]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=176</guid>
		<description><![CDATA[Today I was looking at exception stack trace. One of suspicious places was &#8216;&#8230;\reports_controller.rb:129&#8243;. Okay, navigating to this location using RubyMine is a piece of cake. Ctrl+Shift+N to get to reports_controller.rb, then Ctrl+G to position caret at specified line. But hey, that&#8217;s two actions. I hit Ctrl+Shift+N, put &#8216;reports_controller.rb:129&#8242; in and voila! It worked just [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was looking at exception stack trace. One of suspicious places was &#8216;&#8230;\reports_controller.rb:129&#8243;. Okay, navigating to this location using RubyMine is a piece of cake. Ctrl+Shift+N to get to reports_controller.rb, then Ctrl+G to position caret at specified line. But hey, that&#8217;s two actions. I hit Ctrl+Shift+N, put &#8216;reports_controller.rb:129&#8242; in and voila! It worked just as I expected!<br />
RubyMine: +1 to intuitivity, +1 to overall impression. </p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2009/05/intuitive-behaviour/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced default parameters</title>
		<link>http://software.tulentsev.com/2009/03/advanced-default-parametes/</link>
		<comments>http://software.tulentsev.com/2009/03/advanced-default-parametes/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 02:20:29 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=162</guid>
		<description><![CDATA[Today I was quite amazed by one of Ruby features. It is about default values of method parameters. For example you can do something like this: def get_current_actions&#40;project_id, status_id = params&#91;:status_id&#93; &#124;&#124; DEFAULT_STATUS_ID&#41; # implementation goes here end The code is saying basically this: &#8220;if status_id is not passed explicitly, try to take its value [...]]]></description>
			<content:encoded><![CDATA[<p>Today I was quite amazed by one of Ruby features. It is about default values of method parameters. For example you can do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">def</span> get_current_actions<span style="color:#006600; font-weight:bold;">&#40;</span>project_id, status_id = params<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:status_id</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">||</span> DEFAULT_STATUS_ID<span style="color:#006600; font-weight:bold;">&#41;</span>    
    <span style="color:#008000; font-style:italic;"># implementation goes here</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The code is saying basically this: &#8220;if status_id is not passed explicitly, try to take its value from <strong>params</strong> array. If it doesn&#8217;t contain specified key, then fall back to a constant&#8221;. This feature (as almost all the rest of Ruby magic) made avaiable by Ruby&#8217;s nature: it is interpreted language. This type of code is totally unusual to guys like me, who come from the world of static typing and compiled languages. But I think I&#8217;m gonna get used to it :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2009/03/advanced-default-parametes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Iterations are good</title>
		<link>http://software.tulentsev.com/2009/03/iterations-are-good/</link>
		<comments>http://software.tulentsev.com/2009/03/iterations-are-good/#comments</comments>
		<pubDate>Wed, 04 Mar 2009 19:11:47 +0000</pubDate>
		<dc:creator>Sergei Tulentsev</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Agile]]></category>

		<guid isPermaLink="false">http://software.tulentsev.com/?p=155</guid>
		<description><![CDATA[Iterations in software development. Tried to implement proper solution on the first try? I bet you failed. It’s like in Google Earth zooming in your house from the planet view. To achieve your goal, you&#8217;ve got to advance a little bit, adjust your position, advance further… Iterate until done.]]></description>
			<content:encoded><![CDATA[<p>Iterations in software development. Tried to implement proper solution on the first try? I bet you failed. It’s like in Google Earth zooming in your house from the planet view. To achieve your goal, you&#8217;ve got to advance a little bit, adjust your position, advance further… Iterate until done.</p>
]]></content:encoded>
			<wfw:commentRss>http://software.tulentsev.com/2009/03/iterations-are-good/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

