<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
  <title>Code Like Zell</title>
  <subtitle></subtitle>
  <link href="http://codelikezell.com/rss.xml" rel="self" />
  <link href="http://codelikezell.com/" />
  <updated>2010-02-02T11:00:11-05:00</updated>
  <author>
    <name>Lou Zell</name>
    <email>lzell11@gmail.com</email>
  </author>
  <id>http://codelikezell.com/</id>3
  
  <entry>
    <title>belongs_to association callbacks fixed in rails 2.3.3</title>
    <link href="/belongsto-association-callbacks-fixed-in-rails-233/" />
    <id>tag:codelikezell.com,2009-07-20:1248125340</id>
    <updated>2009-07-20T17:29:00-04:00</updated>
    <content type="html">&lt;p&gt;Last night I noticed certain callbacks weren&amp;#8217;t being called for belongs_to associations in Rails 2.3.2.  Here is a simple example to demonstrate:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;Foo&lt;span class=&quot;InheritedClass&quot;&gt; &lt;span class=&quot;InheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  has_many &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;bars&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;  
  
&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;Bar&lt;span class=&quot;InheritedClass&quot;&gt; &lt;span class=&quot;InheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  belongs_to &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;foo&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I overwrote the callbacks in both of these classes to print its name upon being called.  Take a look at the output using Rails 2.3.2:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;LibraryClassType&quot;&gt;Bar&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;create&lt;/span&gt;(&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;foo&lt;/span&gt; =&amp;gt; &lt;span class=&quot;LibraryClassType&quot;&gt;Foo&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;h4&gt;Callback order:&lt;/h4&gt;&lt;p&gt;Bar before validation&lt;br /&gt;
Bar before validation on create&lt;br /&gt;
Bar validate&lt;br /&gt;
Bar validate on create&lt;br /&gt;
Bar after validation&lt;br /&gt;
Bar after validation on create&lt;br /&gt;
Foo before save&lt;br /&gt;
Foo before create&lt;br /&gt;
Foo after create&lt;br /&gt;
Foo after save&lt;br /&gt;
Bar before save&lt;br /&gt;
Bar before create&lt;br /&gt;
Bar after create&lt;br /&gt;
Bar after save&lt;/p&gt;
&lt;p&gt;As you can see, none of the validation callbacks for Foo were called. Lucky for me, &lt;a href=&quot;http://weblog.rubyonrails.org/2009/7/20/rails-2-3-3-touching-faster-json-bug-fixes&quot;&gt;Rails 2.3.3 is out today&lt;/a&gt; and the problem seems to be fixed.  Using the same models:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;LibraryClassType&quot;&gt;Bar&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;create&lt;/span&gt;(&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;foo&lt;/span&gt; =&amp;gt; &lt;span class=&quot;LibraryClassType&quot;&gt;Foo&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;h4&gt;Callback order:&lt;/h4&gt;&lt;p&gt;Bar before validation&lt;br /&gt;
Bar before validation on create&lt;br /&gt;
Bar validate&lt;br /&gt;
Bar validate on create&lt;br /&gt;
Bar after validation&lt;br /&gt;
Bar after validation on create&lt;br /&gt;
Foo before validation&lt;br /&gt;
Foo before validation on create&lt;br /&gt;
Foo validate&lt;br /&gt;
Foo validate on create&lt;br /&gt;
Foo after validation&lt;br /&gt;
Foo after validation on create&lt;br /&gt;
Foo before save&lt;br /&gt;
Foo before create&lt;br /&gt;
Foo after create&lt;br /&gt;
Foo after save&lt;br /&gt;
Bar before save&lt;br /&gt;
Bar before create&lt;br /&gt;
Bar after create&lt;br /&gt;
Bar after save&lt;/p&gt;
&lt;p&gt;Now they are all called!&lt;/p&gt;
&lt;p&gt;Also, it appears that this problem was introduced in Rails 2.3.2.  The example above produced the same results with Rails 2.2.2 as it did with 2.3.3.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>How To Send Email with Ruby and Gmail</title>
    <link href="/how-to-send-email-with-ruby-and-gmail/" />
    <id>tag:codelikezell.com,2009-07-08:1247026223</id>
    <updated>2009-07-08T00:10:23-04:00</updated>
    <content type="html">&lt;p&gt;I previously posted about sending &lt;a href=&quot;http://codelikezell.com/using-gmail-with-rails&quot;&gt;email from Rails through your Gmail account&lt;/a&gt;.  This is the first of two posts demonstrating sending and receiving emails from any old Ruby script.  For sending emails, I wanted an interface like this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  gmail &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;GmailSender&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt;(&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;login&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;yourgmail@example.com&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, 
                          &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;password&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;yourpass&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)
                       
  gmail.&lt;span class=&quot;FunctionName&quot;&gt;deliver&lt;/span&gt;(&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;to&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;friend@example.com&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, 
                &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;subject&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;Ricky A&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,
                &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;body&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;ShirtsTasteGood has two rick astley shirts&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is my implementation: &lt;a style=&quot;font-size: 0.9em; text-decoration: none;&quot; href=&quot;#&quot; id=&quot;toggleGmailSend&quot;&gt;[shrink code]&lt;/a&gt;&lt;br /&gt;
&lt;div id=&quot;toggleGmailSendCode&quot;&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;net/smtp&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;rubygems&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;tlsmail&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
  
&lt;span class=&quot;LibraryClassType&quot;&gt;Net&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;SMTP&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;enable_tls&lt;/span&gt;(&lt;span class=&quot;LibraryClassType&quot;&gt;OpenSSL&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;SSL&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;VERIFY_NONE&lt;/span&gt;)
  
&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;GmailSender&lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;SMTP_ADDR&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;smtp.gmail.com&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
  
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;initialize&lt;/span&gt;(&lt;span class=&quot;FunctionArgument&quot;&gt;opts &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;FunctionArgument&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;FunctionArgument&quot;&gt;}&lt;/span&gt;&lt;/span&gt;)
    &lt;span class=&quot;Keyword&quot;&gt;unless&lt;/span&gt; opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;login&lt;/span&gt;] &lt;span class=&quot;Operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;password&lt;/span&gt;]
      &lt;span class=&quot;Keyword&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;ArgumentError&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;provide login and password&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;) 
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;login&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;login&lt;/span&gt;]
    &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;password&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;password&lt;/span&gt;]
    &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;domain&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;login&lt;/span&gt;[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;@&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;(&lt;/span&gt;.+&lt;span class=&quot;String&quot;&gt;)&lt;/span&gt;&lt;/span&gt;$&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;/&lt;/span&gt;&lt;/span&gt;,&lt;span class=&quot;Number&quot;&gt;1&lt;/span&gt;]
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;deliver&lt;/span&gt;(&lt;span class=&quot;FunctionArgument&quot;&gt;opts &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;FunctionArgument&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;FunctionArgument&quot;&gt;}&lt;/span&gt;&lt;/span&gt;)
    tostr &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;to&lt;/span&gt;].&lt;span class=&quot;FunctionName&quot;&gt;is_a?&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;Array&lt;/span&gt;) &lt;span class=&quot;Operator&quot;&gt;?&lt;/span&gt; opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;to&lt;/span&gt;].&lt;span class=&quot;FunctionName&quot;&gt;join&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;) : opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;to&lt;/span&gt;]
    msg &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; [&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;FROM: &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;login&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
           &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;TO: &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;#{&lt;/span&gt;tostr&lt;span class=&quot;String&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
           &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;SUBJECT: &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;#{&lt;/span&gt;opts&lt;span class=&quot;String&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;subject&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]
    msgstr &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; msg.&lt;span class=&quot;FunctionName&quot;&gt;join&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;) &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;\n&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;#{&lt;/span&gt;opts&lt;span class=&quot;String&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;body&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    smtp_args &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; [&lt;span class=&quot;Variable&quot;&gt;SMTP_ADDR&lt;/span&gt;, &lt;span class=&quot;Number&quot;&gt;25&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;domain&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;login&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;password&lt;/span&gt;, &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;login&lt;/span&gt;]
    &lt;span class=&quot;LibraryClassType&quot;&gt;Net&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;SMTP&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;start&lt;/span&gt;(&lt;span class=&quot;Operator&quot;&gt;*&lt;/span&gt;smtp_args) &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;smtp&lt;/span&gt;|
      status &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; smtp.&lt;span class=&quot;FunctionName&quot;&gt;send_message&lt;/span&gt; msgstr, &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;login&lt;/span&gt;, opts[&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;to&lt;/span&gt;]
      puts status
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;I made this single file into a local gem, so now I&amp;#8217;m ready to write command line email hacks to my heart&amp;#8217;s content.  Now if you are thinking, &amp;#8220;why don&amp;#8217;t you just use ActionMailer and tlsmail like you did in the Rails example?&amp;#8221;  Well, &lt;a href=&quot;http://www.ariel.com.au/jokes/The_Evolution_of_a_Programmer.html&quot;&gt;this is the best explanation&lt;/a&gt; I&amp;#8217;ve got.  Next up, receiving emails from GMail!&lt;/p&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
  jQuery(document).ready(function(){
    jQuery(&quot;#toggleGmailSend&quot;).click(function(){
      if(this.innerHTML=='[shrink code]'){
        this.innerHTML = '[expand code]';
        jQuery(&quot;#&quot; + this.id + &quot;Code&quot;).hide();
      }else{
        this.innerHTML = '[shrink code]';
        jQuery(&quot;#&quot; + this.id + &quot;Code&quot;).show();
      }
      return false;
    })
  });

&lt;/script&gt;</content>
  </entry>
  
  <entry>
    <title>Top search result for &quot;dick gallery&quot;</title>
    <link href="/top-search-result-for-dick-gallery/" />
    <id>tag:codelikezell.com,2009-07-06:1246852960</id>
    <updated>2009-07-06T00:02:40-04:00</updated>
    <content type="html">&lt;p&gt;&lt;a href=&quot;https://www.google.com/webmasters&quot;&gt;Google webmaster tools&lt;/a&gt; shows you the most popular queries that return your pages in the search results.  It looks something like this:&lt;/p&gt;
&lt;p&gt;&lt;img style=&quot;border: 1px solid #125AA7;&quot; src=&quot;/resources/images/top_queries1.png&quot;&gt;&lt;/p&gt;
&lt;p&gt;I was pretty excited to see we were on the front page for our &lt;a href=&quot;http://www.shirtstastegood.com/shirts/grape-lady&quot;&gt;grape lady t-shirt&lt;/a&gt; already!  Then I noticed this gem a bit farther down the page, and knew I had to share:&lt;/p&gt;
&lt;p&gt;&lt;img style=&quot;border: 1px solid #125AA7;&quot; src=&quot;/resources/images/top_queries2.png&quot;&gt;&lt;/p&gt;
&lt;p&gt;Thank you Google.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Pre-fill forms in development</title>
    <link href="/pre-fill-forms-in-development/" />
    <id>tag:codelikezell.com,2009-07-05:1246766560</id>
    <updated>2009-07-05T00:02:40-04:00</updated>
    <content type="html">&lt;p&gt;Automated testing is great, but I often want to click through the many pages of my application myself, without slowing down to fill in form data.  I use three javascript functions to provide a simple way for me to pre-fill form data.  Say I have an order form that takes a first name, last name, and credit card type.  Like this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;TagAttribute&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;order[first_name]&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;TagAttribute&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;text&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;TagAttribute&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;order[last_name]&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;TagAttribute&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;text&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;TagAttribute&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;order[card_type]&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;option&lt;/span&gt; &lt;span class=&quot;TagAttribute&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;visa&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Visa&lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;option&lt;/span&gt; &lt;span class=&quot;TagAttribute&quot;&gt;value&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;american_express&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;American Express&lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;option&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;select&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  ...
  &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;form&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I could write a javascript file that I only include in my development environment that would look like this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  fill(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[first_name]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Lou&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
  fill(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[last_name]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Zell&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
  &lt;span class=&quot;CommandMethod&quot;&gt;select&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[card_type]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;American Express&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The javascript functions that enable me to do this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;find&lt;/span&gt;(&lt;span class=&quot;FunctionArgument&quot;&gt;name&lt;/span&gt;){
  n &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;NamedConstant&quot;&gt;forms&lt;/span&gt;.&lt;span class=&quot;NamedConstant&quot;&gt;length&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;Storage&quot;&gt;var&lt;/span&gt; i&lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Number&quot;&gt;0&lt;/span&gt;; i &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt; n; i&lt;span class=&quot;Operator&quot;&gt;++&lt;/span&gt;){
    k &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;NamedConstant&quot;&gt;forms&lt;/span&gt;[i].&lt;span class=&quot;NamedConstant&quot;&gt;elements&lt;/span&gt;.&lt;span class=&quot;NamedConstant&quot;&gt;length&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt;(&lt;span class=&quot;Storage&quot;&gt;var&lt;/span&gt; j&lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Number&quot;&gt;0&lt;/span&gt;; j &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt; k; j&lt;span class=&quot;Operator&quot;&gt;++&lt;/span&gt;){
      &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt;(&lt;span class=&quot;LibraryClassType&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;NamedConstant&quot;&gt;forms&lt;/span&gt;[i].&lt;span class=&quot;NamedConstant&quot;&gt;elements&lt;/span&gt;[j].&lt;span class=&quot;NamedConstant&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;==&lt;/span&gt; name){
        &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt;(&lt;span class=&quot;LibraryClassType&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;NamedConstant&quot;&gt;forms&lt;/span&gt;[i].&lt;span class=&quot;NamedConstant&quot;&gt;elements&lt;/span&gt;[j])
      }
    }
  }
}
  
&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;fill&lt;/span&gt;(&lt;span class=&quot;FunctionArgument&quot;&gt;name, content&lt;/span&gt;){
  &lt;span class=&quot;CommandMethod&quot;&gt;find&lt;/span&gt;(name).&lt;span class=&quot;NamedConstant&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; content;
}
  
&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;select&lt;/span&gt;(&lt;span class=&quot;FunctionArgument&quot;&gt;name, content&lt;/span&gt;){
  s &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;CommandMethod&quot;&gt;find&lt;/span&gt;(name)
  &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;Storage&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;0&lt;/span&gt;; i &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt; s.&lt;span class=&quot;NamedConstant&quot;&gt;options&lt;/span&gt;.&lt;span class=&quot;NamedConstant&quot;&gt;length&lt;/span&gt;; i&lt;span class=&quot;Operator&quot;&gt;++&lt;/span&gt;){
    &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; (s.&lt;span class=&quot;NamedConstant&quot;&gt;options&lt;/span&gt;[i].innerHTML &lt;span class=&quot;Operator&quot;&gt;==&lt;/span&gt; content){
      s.&lt;span class=&quot;NamedConstant&quot;&gt;selectedIndex&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; i;
      &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt;;
    }
  }
}
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;These functions don&amp;#8217;t rely on any library, and they also shouldn&amp;#8217;t be used in production because they are far from optimized.  Yes, I am 100% sure there is a much more efficient way to write them, but they work just fine for what I need them to do.&lt;/p&gt;
&lt;p&gt;If you want to get fancy pants you could create different sets of data to fill a form with, and attach each fill function to a link&amp;#8217;s click event.  Something like:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagAttribute&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;fill_with_bob&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;fill with bob's info&lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagAttribute&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;fill_with_jane&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;fill with jane's info&lt;span class=&quot;TagContainer&quot;&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;TagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;TagContainer&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Operator&quot;&gt;$&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;#fill_with_bob&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;CommandMethod&quot;&gt;click&lt;/span&gt;(&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(){
    fill(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[first_name]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Bob&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
    fill(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[last_name]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Jones&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
    &lt;span class=&quot;CommandMethod&quot;&gt;select&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[card_type]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;American Express&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
  });
    
  &lt;span class=&quot;Operator&quot;&gt;$&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;#fill_with_jane&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;CommandMethod&quot;&gt;click&lt;/span&gt;(&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(){
    fill(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[first_name]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Jane&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
    fill(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[last_name]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Jones&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
    &lt;span class=&quot;CommandMethod&quot;&gt;select&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;order[card_type]&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Visa&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;);
  });
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I used jquery for that last part.  And it&amp;#8217;s not tested.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Steer Clear of Paypal</title>
    <link href="/steer-clear-of-paypal/" />
    <id>tag:codelikezell.com,2009-06-23:1245795640</id>
    <updated>2009-06-23T18:20:40-04:00</updated>
    <content type="html">&lt;p&gt;If you are considering using Paypal&amp;#8217;s Website Payments Pro service for $30 per month, I would think twice.  I was warned that their customer service was atrocious, but it&amp;#8217;s much worse.  If you are currently using them, you already know that every phone number they provide to reach merchant services directly takes you through the same automated system as every other Paypal number.  Here are the steps I recommend to get you through to someone that can help, without losing your mind:&lt;/p&gt;
&lt;p&gt;1.  Take a shot (and one additional shot for each time you are disconnected)&lt;br /&gt;
2.  Call any of several &amp;#8220;direct lines&amp;#8221; to merchant services&lt;br /&gt;
3.  Say &amp;#8220;no&amp;#8221; when the automated system picks up&lt;br /&gt;
4.  Say &amp;#8220;agent&amp;#8221; three times in a row, you will be placed on hold&lt;br /&gt;
5.  You will get an agent, but they will be in the wrong department.  They will inevitably discover that they cannot help you, and will transfer you to the merchant support group (which is the one you wanted in the first place).  So save yourself the pain and demand an immediate transfer to merchant support.  You will be on hold again for a while.&lt;/p&gt;
&lt;p&gt;Good luck!&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>ShirtsTasteGood.com, YouTube&amp;trade; Inspired T-Shirts!</title>
    <link href="/shirtstastegoodcom-youtube-inspired-t-shirts/" />
    <id>tag:codelikezell.com,2009-06-16:1245190840</id>
    <updated>2009-06-16T18:20:40-04:00</updated>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://www.shirtstastegood.com&quot;&gt;&lt;img style=&quot;float:left; width: 30%;&quot; src=&quot;/resources/images/icon_white.png&quot;/&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I am very proud to announce &lt;a href=&quot;http://www.shirtstastegood.com&quot;&gt;ShirtsTasteGood.com&lt;/a&gt;, a collection of t-shirts inspired by our favorite YouTube&amp;trade; videos.  It&amp;#8217;s a four man team consisting of &lt;a href=&quot;http://www.toddham.com&quot;&gt;Todd Hamilton&lt;/a&gt; on artwork and web design, Doug and George Cline on screen printing, and myself on web development.  Doug and George ditched their custom screen printing business that they had been running for the last few years, and Todd and I both quit our contracting/freelancing gigs in the city to full time STG.  The &lt;a href=&quot;http://vimeo.com/5180171&quot;&gt;operation&lt;/a&gt; is run out of a barn that Doug and George converted to a print shop near their home in New Jersey.  The video that inspired each shirt is embedded on the shirt&amp;#8217;s home page, so even if you aren&amp;#8217;t interested in buying a t-shirt, you can come hang out and watch some &lt;a href=&quot;http://www.shirtstastegood.com/shirts/im-on-a-boat&quot;&gt;hilarious videos&lt;/a&gt;.  There is also a &lt;a href=&quot;http://www.shirtstastegood.com/suggestions&quot;&gt;suggestions&lt;/a&gt; page where we auto-embed any videos that you would like us to turn into shirts!  The suggestions page is particularly useful during that 1-3pm slot when you pretend to be working.  We hope you enjoy the site, and please feel free to post any suggestions, questions, or comments.  Thanks!&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>The Hudson Raft Project</title>
    <link href="/the-hudson-raft-project/" />
    <id>tag:codelikezell.com,2009-06-04:1244154040</id>
    <updated>2009-06-04T18:20:40-04:00</updated>
    <content type="html">&lt;p&gt;&lt;a href=&quot;http://hudsonraftproject.com&quot;&gt;&lt;img src=&quot;http://hudsonraftproject.com/wp-content/uploads/2008/07/3rd-raft-41.jpg&quot;/&gt;&lt;/a&gt; &lt;p&gt;Over the last four years a few friends of mine, led by Dallas Trombley, have attempted to sail from Albany to Manhattan on homemade boats.  They now have a &lt;a href=&quot;http://hudsonraftproject.com/&quot;&gt;site&lt;/a&gt; up describing their &lt;a href=&quot;http://hudsonraftproject.com/the-uss-crab-legs/&quot;&gt;trials&lt;/a&gt; &lt;a href=&quot;http://hudsonraftproject.com/the-manhattan-project/&quot;&gt;and&lt;/a&gt; &lt;a href=&quot;http://hudsonraftproject.com/2008-construction/&quot;&gt;tribulations&lt;/a&gt;.  Most of their content is in the form of Wordpress pages rather than posts, so be sure to check out the left nav.  It&amp;#8217;s a really entertaining read.  Good luck this year Dallas, Rob, and Co.&lt;/p&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Disable SSL during Rails development</title>
    <link href="/disable-ssl-during-rails-development/" />
    <id>tag:codelikezell.com,2009-05-26:1243395480</id>
    <updated>2009-05-26T23:38:00-04:00</updated>
    <content type="html">&lt;p&gt;Assuming you are using &lt;a href=&quot;http://github.com/rails/ssl_requirement/tree/master&quot;&gt;ssl_requirement&lt;/a&gt;, to disable SSL in your development environment:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;ApplicationController&lt;span class=&quot;InheritedClass&quot;&gt; &lt;span class=&quot;InheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActionController::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;SslRequirement&lt;/span&gt;
  
  &lt;span class=&quot;Keyword&quot;&gt;protected&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;ssl_required?&lt;/span&gt;
    &lt;span class=&quot;Variable&quot;&gt;RAILS_ENV&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;development&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;super&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Deploying Wordpress with Rails on Passenger</title>
    <link href="/deploying-wordpress-with-rails-on-passenger/" />
    <id>tag:codelikezell.com,2009-05-20:1242877080</id>
    <updated>2009-05-20T23:38:00-04:00</updated>
    <content type="html">&lt;p&gt;I just finished integrating a Wordpress blog into a soon-to-be released Rails app, and I would like to share the steps I took to get it deployed on Phusion Passenger.  Getting the permalinks working correctly had me hung up for a bit, so I&amp;#8217;ll show you how to get around that.&lt;/p&gt;
&lt;p&gt;To get started we can drop the blog right into the public directory of our rails app:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  cd /yourapp/public
  wget http://wordpress.org/latest.tar.gz
  tar xzvf latest.tar.gz
  mv wordpress blog     &amp;lt;--- blog will be at http://yourapp/blog
  cd blog
  mv wp-config-sample.php wp-config.php
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Now edit the wp-config.php file (instructions are in the file) and be sure to grant database privileges to the user you specify.&lt;/p&gt;
&lt;p&gt;Next, you have to edit your apache config file to disable passenger for the blog directory:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;&amp;lt;VirtualHost ...&amp;gt;
    ServerName ...
    DocumentRoot ...
    &amp;lt;Location /blog&amp;gt;
       PassengerEnabled off
    &amp;lt;/Location&amp;gt;
&amp;lt;/VirtualHost&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I found that snippet &lt;a href=&quot;http://groups.google.com/group/phusion-passenger/browse_thread/thread/8ceba77706d94fdd&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Restart Apache and point your browser to http://yourapp/blog/index.php to setup the rest of your blog through Wordpress&amp;#8217;s web interface.  One thing you will probably edit is the default permalink structure (Found at settings &amp;gt; permalink).  I prefer to set a custom structure of &amp;#8216;/%postname%&amp;#8217;.  Regardless of the structure you use, wordpress will tell you to edit the .htaccess file in your blog directory.  For the life of me I could not get .htaccess file to be recognized, so as a workaround I copied the snippet that wordpress specified into my apache config as follows:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;&amp;lt;VirtualHost ...&amp;gt;
    ServerName ...
    DocumentRoot ...
    &amp;lt;Location /blog&amp;gt;
       PassengerEnabled off
       &amp;lt;IfModule mod_rewrite.c&amp;gt;
         RewriteEngine On
         RewriteBase /blog/
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteCond %{REQUEST_FILENAME} !-d
         RewriteRule . /blog/index.php [L]
       &amp;lt;/IfModule&amp;gt;
    &amp;lt;/Location&amp;gt;
&amp;lt;/VirtualHost&amp;gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Finally, restart Apache.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>A more readable sort by</title>
    <link href="/a-more-readable-sort-by/" />
    <id>tag:codelikezell.com,2009-04-03:1238797540</id>
    <updated>2009-04-03T18:25:40-04:00</updated>
    <content type="html">&lt;p&gt;Suppose we want to sort a collection of accounts by their account balance.  We could put them in ascending order like this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;accounts&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;sort&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;x&lt;/span&gt;,&lt;span class=&quot;Variable&quot;&gt;y&lt;/span&gt;| x.&lt;span class=&quot;FunctionName&quot;&gt;balance&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;&amp;lt;=&amp;gt;&lt;/span&gt; y.&lt;span class=&quot;FunctionName&quot;&gt;balance&lt;/span&gt;}
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or descending order like this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;accounts&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;sort&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;x&lt;/span&gt;,&lt;span class=&quot;Variable&quot;&gt;y&lt;/span&gt;| y.&lt;span class=&quot;FunctionName&quot;&gt;balance&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;&amp;lt;=&amp;gt;&lt;/span&gt; x.&lt;span class=&quot;FunctionName&quot;&gt;balance&lt;/span&gt;}
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To me this isn&amp;#8217;t very readable.  How about this as an alternative:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;accounts&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;sort_by_ascending&lt;/span&gt;(&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;balance&lt;/span&gt;)
&lt;span class=&quot;LineComment&quot;&gt;  &lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; or &lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;accounts&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;sort_by_descending&lt;/span&gt;(&lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;balance&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Much more readable.  The implementation is pretty simple, first create the methods:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;ReadableSortBy&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;sort_by_ascending&lt;/span&gt;(&lt;span class=&quot;FunctionArgument&quot;&gt;method&lt;/span&gt;)
      sort {|&lt;span class=&quot;Variable&quot;&gt;x&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;y&lt;/span&gt;| x.&lt;span class=&quot;FunctionName&quot;&gt;send&lt;/span&gt;(method) &lt;span class=&quot;Operator&quot;&gt;&amp;lt;=&amp;gt;&lt;/span&gt; y.&lt;span class=&quot;FunctionName&quot;&gt;send&lt;/span&gt;(method)}
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;sort_by_descending&lt;/span&gt;(&lt;span class=&quot;FunctionArgument&quot;&gt;method&lt;/span&gt;)
      sort {|&lt;span class=&quot;Variable&quot;&gt;x&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;y&lt;/span&gt;| y.&lt;span class=&quot;FunctionName&quot;&gt;send&lt;/span&gt;(method) &lt;span class=&quot;Operator&quot;&gt;&amp;lt;=&amp;gt;&lt;/span&gt; x.&lt;span class=&quot;FunctionName&quot;&gt;send&lt;/span&gt;(method)}
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then include them in Array:&lt;br /&gt;

&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;Array&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;ReadableSortBy&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You could also make &lt;code&gt;sort_by_ascending!&lt;/code&gt; and &lt;code&gt;sort_by_descending!&lt;/code&gt; methods that modify the collection itself.  Do this by replacing &lt;code&gt;sort&lt;/code&gt; with &lt;code&gt;sort!&lt;/code&gt; in both cases.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Introducing Nickel</title>
    <link href="/introducing-nickel/" />
    <id>tag:codelikezell.com,2009-03-29:1238303140</id>
    <updated>2009-03-29T01:05:40-04:00</updated>
    <content type="html">&lt;h3&gt;A natural language date and time parser, with message extraction&lt;/h3&gt;
&lt;p&gt;Nickel is a client for &lt;a href=&quot;http://www.naturalinputs.com&quot;&gt;Natural Inputs&lt;/a&gt;&lt;br /&gt;

&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  sudo gem install lzell-nickel
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then try it out:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;rubygems&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;nickel&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
  n &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;Nickel&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;query&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;party this friday at 10pm&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
  
  n.&lt;span class=&quot;FunctionName&quot;&gt;message&lt;/span&gt; &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; =&amp;gt; party&lt;/span&gt;
  n.&lt;span class=&quot;FunctionName&quot;&gt;occurrences&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;first&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;start_date&lt;/span&gt; &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; =&amp;gt; 20090403&lt;/span&gt;
  n.&lt;span class=&quot;FunctionName&quot;&gt;occurrences&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;first&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;start_time&lt;/span&gt; &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; =&amp;gt; 22:00:00&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Many more examples &lt;a href=&quot;http://github.com/lzell/nickel/tree/master&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>A cheap abstract class in ruby</title>
    <link href="/a-cheap-abstract-class-in-ruby/" />
    <id>tag:codelikezell.com,2009-03-29:1238302960</id>
    <updated>2009-03-29T01:02:40-04:00</updated>
    <content type="html">&lt;p&gt;When I create a class that I don&amp;#8217;t want to allow anyone to instantiate, I use the following pattern:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;MakeMeAbstract&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;initialize&lt;/span&gt;
      &lt;span class=&quot;Keyword&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Don't instantiate me!&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; abstract_class?
      puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Instantiated!&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;private&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;abstract_class?&lt;/span&gt;
      &lt;span class=&quot;Variable&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;MakeMeAbstract&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It can&amp;#8217;t be instantiated:&lt;br /&gt;

&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;LibraryClassType&quot;&gt;MakeMeAbstract&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;I'm abstract&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;   &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; =&amp;gt; &amp;quot;I'm abstract&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But it can be subclassed, and the subclass can be instantiated:&lt;br /&gt;

&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;Child&lt;span class=&quot;InheritedClass&quot;&gt; &lt;span class=&quot;InheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; MakeMeAbstract&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;LibraryClassType&quot;&gt;Child&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt;   &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; =&amp;gt; &amp;quot;Instantiated!&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As a full disclaimer, this is a learning experience for me.  When subclassing an abstract class I wonder if it would be better to use a mixin instead: I could overwrite mixed in methods just as easily as methods in a parent class.  The structure changes from this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;Bar&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;status&lt;/span&gt;
      print &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;is full&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;WetBar&lt;span class=&quot;InheritedClass&quot;&gt; &lt;span class=&quot;InheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; Bar&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;status&lt;/span&gt;
      print &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;is wet, &lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;Keyword&quot;&gt;super&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  wet_bar &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;WetBar&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt;
  wet_bar.&lt;span class=&quot;FunctionName&quot;&gt;status&lt;/span&gt;    &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; =&amp;gt; &amp;quot;is wet, is full&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;module&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;Bar&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;status&lt;/span&gt;
      print &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;is full&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;WetBar&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Bar&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;status&lt;/span&gt;
      print &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;is wet, &lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;Keyword&quot;&gt;super&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  wet_bar &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;WetBar&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;new&lt;/span&gt;
  wet_bar.&lt;span class=&quot;FunctionName&quot;&gt;status&lt;/span&gt;    &lt;span class=&quot;LineComment&quot;&gt;&lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; =&amp;gt; &amp;quot;is wet, is full&amp;quot;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Input is welcome in the comments.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>How to backup and restore a mysql database</title>
    <link href="/how-to-backup-and-restore-a-mysql-database/" />
    <id>tag:codelikezell.com,2009-03-29:1238302600</id>
    <updated>2009-03-29T00:56:40-04:00</updated>
    <content type="html">&lt;p&gt;To dump your database:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  mysqldump -u USER -p PASS my_db &amp;gt; my_db.sql
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then to restore:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  mysql -u USER -p PASS my_db &amp;lt; my_db.sql
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Or, using gzip for compression, dump with:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  mysqldump -u USER -p PASS my_db | gzip &amp;gt; my_db.sql.gz
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And restore with:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  gzip -cd my_db.sql.gz | mysql -u USER -p PASS my_db
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Using Gmail with Rails</title>
    <link href="/using-gmail-with-rails/" />
    <id>tag:codelikezell.com,2009-03-29:1238302300</id>
    <updated>2009-03-29T00:51:40-04:00</updated>
    <content type="html">&lt;p&gt;To send email from Rails using your &lt;a href=&quot;http://www.google.com/a&quot;&gt;Google Apps&lt;/a&gt; account, you will need TLS support:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  sudo gem install tlsmail
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Next, edit environment.rb to look like this:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;LibraryClassType&quot;&gt;Rails&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;Initializer&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;run&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;config&lt;/span&gt;|
    config.&lt;span class=&quot;FunctionName&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;tlsmail&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    ...
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;LibraryClassType&quot;&gt;Net&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;SMTP&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;enable_tls&lt;/span&gt;(&lt;span class=&quot;LibraryClassType&quot;&gt;OpenSSL&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;SSL&lt;/span&gt;::&lt;span class=&quot;FunctionName&quot;&gt;VERIFY_NONE&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then add this to environments/development.rb:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  config.&lt;span class=&quot;FunctionName&quot;&gt;action_mailer&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;delivery_method&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;smtp&lt;/span&gt;
  config.&lt;span class=&quot;FunctionName&quot;&gt;action_mailer&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;smtp_settings&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; {
    &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;address&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;smtp.gmail.com&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
    &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;port&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;25&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
    &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;domain&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;your_domain.com&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
    &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;user_name&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;your_login@your_domain.com&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
    &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;password&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;your_password&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,
    &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;authentication&lt;/span&gt; =&amp;gt; &lt;span class=&quot;UserDefinedConstant&quot;&gt;&lt;span class=&quot;UserDefinedConstant&quot;&gt;:&lt;/span&gt;login&lt;/span&gt;
  }
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Test it out by sending an email to yourself, create the model mailer.rb:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;TypeName&quot;&gt;Mailer&lt;span class=&quot;InheritedClass&quot;&gt; &lt;span class=&quot;InheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActionMailer::Base&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;FunctionName&quot;&gt;test&lt;/span&gt;
      from &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;your name &amp;lt;your_login@your_domain.com&amp;gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
      recipients [&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;your_login@your_domain.com&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]
      subject &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;working?&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
      body &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;sending from rails&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Finally, from script/console:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;LibraryClassType&quot;&gt;Mailer&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;deliver_test&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Use inject for nicer output in IRB</title>
    <link href="/use-inject-for-nicer-output-in-irb/" />
    <id>tag:codelikezell.com,2009-03-29:1238301940</id>
    <updated>2009-03-29T00:45:40-04:00</updated>
    <content type="html">&lt;p&gt;Sometimes you want to inspect an array in irb by iterating through it and printing out some key values, for example:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  events.&lt;span class=&quot;FunctionName&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;event&lt;/span&gt;|
    puts event.&lt;span class=&quot;FunctionName&quot;&gt;title&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But if the array is large, you will first have to scroll up through the returned array to get to your desired printout. We can prevent that by using inject instead:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  events.&lt;span class=&quot;FunctionName&quot;&gt;inject&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;x&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;event&lt;/span&gt;|
    puts event.&lt;span class=&quot;FunctionName&quot;&gt;title&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Now nil will be returned instead of the events array, and your desired output is in view.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Preventing default event behavior with Javascript</title>
    <link href="/preventing-default-event-behavior-with-javascript/" />
    <id>tag:codelikezell.com,2009-03-29:1238301280</id>
    <updated>2009-03-29T00:34:40-04:00</updated>
    <content type="html">&lt;h3&gt;with examples using jQuery and Prototype&lt;/h3&gt;
&lt;p&gt;Let’s say we want to disable all the links on a page, using jQuery we just have to return false from the click handler:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  jQuery(&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(){
    jQuery(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;body a&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;CommandMethod&quot;&gt;click&lt;/span&gt;(&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(){
      &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;BuiltInConstant&quot;&gt;false&lt;/span&gt;;
    });
  });
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Using Prototype, we pass the event instance to Event.stop():&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;LibraryClassType&quot;&gt;document&lt;/span&gt;.observe(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;dom:loaded&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(){
    &lt;span class=&quot;Operator&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;Operator&quot;&gt;$&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;body a&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).each(&lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(a, num){
      &lt;span class=&quot;Operator&quot;&gt;$&lt;/span&gt;(a).observe(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;click&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(e){
        Event.&lt;span class=&quot;CommandMethod&quot;&gt;stop&lt;/span&gt;(e);
      });
    });
  });
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;With everyday Javascript, we again return false from the click handler:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  &lt;span class=&quot;LibraryClassType&quot;&gt;window&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;onload&lt;/span&gt; = &lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(){
    elements &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;LibraryClassType&quot;&gt;document&lt;/span&gt;.&lt;span class=&quot;CommandMethod&quot;&gt;getElementsByTagName&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;a&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;);
    &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; (&lt;span class=&quot;Storage&quot;&gt;var&lt;/span&gt; i &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;0&lt;/span&gt;; i &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&lt;/span&gt; elements.&lt;span class=&quot;NamedConstant&quot;&gt;length&lt;/span&gt;; i&lt;span class=&quot;Operator&quot;&gt;++&lt;/span&gt;){
      elements[i].&lt;span class=&quot;FunctionName&quot;&gt;onclick&lt;/span&gt; = &lt;span class=&quot;Storage&quot;&gt;function&lt;/span&gt;(){
        &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;BuiltInConstant&quot;&gt;false&lt;/span&gt;;
      }
    }
  }
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Ruby Bitwise Notes</title>
    <link href="/ruby-bitwise-notes/" />
    <id>tag:codelikezell.com,2009-03-29:1238300320</id>
    <updated>2009-03-29T00:18:40-04:00</updated>
    <content type="html">&lt;p&gt;Start with an integer:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  x &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Shift by two bit positions:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  x &lt;span class=&quot;Operator&quot;&gt;&amp;lt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;2&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;OR with 1:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  x &lt;span class=&quot;Operator&quot;&gt;|=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;AND with 14 (hex E):&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  x &lt;span class=&quot;Operator&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;0xE&lt;/span&gt;
&lt;span class=&quot;LineComment&quot;&gt;  &lt;span class=&quot;LineComment&quot;&gt;#&lt;/span&gt; is the same as:&lt;/span&gt;
  x &lt;span class=&quot;Operator&quot;&gt;&amp;amp;=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;14&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Get binary representation:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  x.&lt;span class=&quot;FunctionName&quot;&gt;to_s&lt;/span&gt;(&lt;span class=&quot;Number&quot;&gt;2&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Get hex representation:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  x.&lt;span class=&quot;FunctionName&quot;&gt;to_s&lt;/span&gt;(&lt;span class=&quot;Number&quot;&gt;16&lt;/span&gt;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;XOR (exclusive OR) with 1&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  x &lt;span class=&quot;Operator&quot;&gt;^=&lt;/span&gt; &lt;span class=&quot;Number&quot;&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Vim single line move when :set wrap is on</title>
    <link href="/vim-single-line-move-when-set-wrap-is-on/" />
    <id>tag:codelikezell.com,2009-03-29:1238299360</id>
    <updated>2009-03-29T00:02:40-04:00</updated>
    <content type="html">&lt;p&gt;If you are editing a long paragraph with word wrap on, you may find that ‘j’ and ‘k’ jump farther than you would expect. This is because ‘j’ is moving to the next real line instead of the next wrapped line. To make vim behave more intuitively (at least for me, and probably you since you are here), put this in your vim config file (~/.vimrc in my case):&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  function! ScreenMovement(movement)
     if &amp;amp;wrap
        return &amp;quot;g&amp;quot; . a:movement
     else
        return a:movement
     endif
  endfunction
  onoremap   j ScreenMovement(&amp;quot;j&amp;quot;)
  onoremap   k ScreenMovement(&amp;quot;k&amp;quot;)
  onoremap   0 ScreenMovement(&amp;quot;0&amp;quot;)
  onoremap   ^ ScreenMovement(&amp;quot;^&amp;quot;)
  onoremap   $ ScreenMovement(&amp;quot;$&amp;quot;)
  nnoremap   j ScreenMovement(&amp;quot;j&amp;quot;)
  nnoremap   k ScreenMovement(&amp;quot;k&amp;quot;)
  nnoremap   0 ScreenMovement(&amp;quot;0&amp;quot;)
  nnoremap   ^ ScreenMovement(&amp;quot;^&amp;quot;)
  nnoremap   $ ScreenMovement(&amp;quot;$&amp;quot;)
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks to rick_h in #vim&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Rails 2.2 migrations without the timestamp</title>
    <link href="/rails-migrations-without-the-timestamp/" />
    <id>tag:codelikezell.com,2009-03-28:1238299000</id>
    <updated>2009-03-28T23:56:40-04:00</updated>
    <content type="html">&lt;p&gt;For Rails 1 style migrations, set this in environment.rb:&lt;/p&gt;
&lt;p&gt;
&lt;div class=&quot;UltraViolet&quot;&gt;&lt;pre class=&quot;active4d&quot;&gt;  config.&lt;span class=&quot;FunctionName&quot;&gt;active_record&lt;/span&gt;.&lt;span class=&quot;FunctionName&quot;&gt;timestamped_migrations&lt;/span&gt; &lt;span class=&quot;Operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;BuiltInConstant&quot;&gt;false&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;pre&gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note this will not work before Rails 2.2. Thanks to mikeg1a in #rubyonrails.&lt;/p&gt;</content>
  </entry>
  
  <entry>
    <title>Edit through FTP with TextMate and Cyberduck</title>
    <link href="/edit-through-ftp-with-textmate-and-cyberduck/" />
    <id>tag:codelikezell.com,2009-03-28:1238298700</id>
    <updated>2009-03-28T23:51:40-04:00</updated>
    <content type="html">&lt;p&gt;I do a bit of freelance php work where I need to edit files through FTP. Textmate does not support this very well out of the box, and at first it seemed like I would have to open and edit each file in its own window. But by combining &lt;a href=&quot;http://lists.macromates.com/textmate/2006-February/008636.html&quot;&gt;this tip&lt;/a&gt; by &lt;a href=&quot;http://subtlegradient.com/&quot;&gt;subtlegradient&lt;/a&gt; with &lt;a href=&quot;http://ciaranwal.sh/2007/11/27/textmate-tip-where-am-i&quot;&gt;this tip&lt;/a&gt; by &lt;a href=&quot;http://ciaranwal.sh/&quot;&gt;ciaranwal.sh&lt;/a&gt; we can use tabbed editing, project drawer, and cmd+t to switch files. The steps:&lt;/p&gt;
&lt;p&gt;1. In Cyberduck’s preferences make sure external editor is set to TextMate. Also, it helps if “Double click opens file in external editor” is set to true.&lt;/p&gt;
&lt;p&gt;2. Open up a file from your FTP project that is close to the top level directory of your project, you’ll see why in a minute.&lt;/p&gt;
&lt;p&gt;3. In the TextMate window that popped up, hit ctrl+shift+o (Bundles &amp;gt; Shell Script &amp;gt; Open Terminal). The terminal will open at the temporary location where the file you are editing is.&lt;/p&gt;
&lt;p&gt;4. cd .. back to the top level directory of your project and enter: mate .&lt;/p&gt;
&lt;p&gt;Now any subsequent files you open using Cyberduck will be added as tabs in the current TextMate project.&lt;/p&gt;</content>
  </entry>
  
</feed>
