<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>ELC Code Feed</title>
    <link>http://elctech.com/</link>
    <description>News, projects, and more.</description>
    <language>en-us</language>
    <item>
      <title>ZOMG assembly metaprogrammin shitz!</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Joe Damato over at &lt;a href=&quot;http://timetobleed.com&quot; target=&quot;_blank&quot;&gt;timetobleed.com&lt;/a&gt; just let their new memory profiler out of the box. &lt;/p&gt;&lt;p&gt;Go read more about it &lt;a href=&quot;http://timetobleed.com/memprof-a-ruby-level-memory-profiler/&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;...and whoever is interested in Ruby internals and lowlevel x86 architecture, do take the time to read through the previous posts about the road to achieve unintrusive instrumentation to the VM. Some pretty crazy ZOMG assembly metaprogramming shitz.&lt;/p&gt;
&lt;/div&gt;</description>
      <author>David Palm</author>
      <pubDate>Sat, 12 Dec 2009 14:13:56 +0000</pubDate>
      <link>http://elctech.com/articles/zomg-assembly-metaprogrammin-shitz</link>
      <guid>http://elctech.com/articles/zomg-assembly-metaprogrammin-shitz</guid>
    </item>
    <item>
      <title>Amazon Reduces S3/EC2/Data transfer prices</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;
Amazon announced today some modifications to their pricing tiers.
&lt;/p&gt;
&lt;p&gt;
If you're a power user of S3, you'll be glad to know that multi-petabyte ( &gt; 1 million Gigs) users costs have been reduced by more than 15%.
&lt;/p&gt;
&lt;p&gt;
There's also some good news for users at any level:
&lt;/p&gt;&lt;blockquote&gt;
Data Transfer into AWS will be free of charge from now through June 30, 2010, making it even easier for customers to get their data into AWS. This applies to data transfer into Amazon EC2, Amazon S3, Amazon SimpleDB, Amazon Relational Database Service, Amazon Simple Queue Service, and Amazon Virtual Private Cloud. Other applicable charges for use of these services continue to apply.
&lt;/blockquote&gt;
&lt;/p&gt;

&lt;p&gt;
Some additional price reductions apply to EU S3 and EC2, you can check out the complete newsletter here: &lt;a href=&quot;http://aws.amazon.com/about-aws/whats-new/2009/12/08/aws-announces-pricing-changes/&quot;&gt;http://aws.amazon.com/about-aws/whats-new/2009/12/08/aws-announces-pricing-changes/&lt;/a&gt;
&lt;/p&gt;

&lt;p&gt;Happy uploading / cloud computing.&lt;/p&gt;
&lt;/div&gt;</description>
      <author>Daniel LaBare</author>
      <pubDate>Tue, 08 Dec 2009 22:19:08 +0000</pubDate>
      <link>http://elctech.com/articles/amazon-reduces-s3-ec2-data-transfer-prices</link>
      <guid>http://elctech.com/articles/amazon-reduces-s3-ec2-data-transfer-prices</guid>
    </item>
    <item>
      <title>Fixing Class Hierarchy In STI Under Development Mode</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;If you're running your application in development mode, you may be frustrated when ActiveRecord seems to ignore the class hierarchy in your models, not loading any Apple objects when you call TreeFruit.find(:all).  Blame this on the lazy class loading that development mode works with.  You can avoid the problem at the cost of a few lines of code that explicitly declare your hierarchy without changing behavior in production mode, just make sure you do it correctly or you'll end up loading Figs when you try loading Bananas (forgive my running with the silly fruit example).  More after the fold...&lt;/p&gt;
&lt;/div&gt;

&lt;h2&gt;Declaring Children at Each Level&lt;/h2&gt;
&lt;p&gt;Without eager loading, ActiveRecord won't have the entire hierarchy mapped, and so you'll have to do it explicitly, but simply declaring children at the top, in the example below, isn't enough.&lt;/p&gt;

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; This won't work&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;TreeFruit&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.subclasses&lt;/span&gt;
    [&lt;span class=&quot;Variable&quot;&gt;Apple&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;Pear&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;JEntityNameType&quot;&gt;Apple&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; TreeFruit&lt;/span&gt;&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;JEntityNameType&quot;&gt;Pear&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; TreeFruit&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Setting the subclasses manually gets inherited with everything else, however, and so in the above example loading Apples will also load Pears, and any other subclasses defined in the array at the top.  You have to follow through and define subclasses at each level, even the leaf nodes.&lt;/p&gt;

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; This works&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;TreeFruit&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.subclasses&lt;/span&gt;
    [&lt;span class=&quot;Variable&quot;&gt;Apple&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;RedDelicious&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;Pear&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;JEntityNameType&quot;&gt;Apple&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; TreeFruit&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.subclasses&lt;/span&gt;
    [&lt;span class=&quot;Variable&quot;&gt;RedDelicious&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;JEntityNameType&quot;&gt;RedDelicious&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; Apple&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.subclasses&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;JEntityNameType&quot;&gt;Pear&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; TreeFruit&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.subclasses&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;/code&gt;</description>
      <author>ceberz</author>
      <pubDate>Wed, 02 Dec 2009 22:25:59 +0000</pubDate>
      <link>http://elctech.com/articles/fixing-class-hierarchy-in-sti-under-development-mode</link>
      <guid>http://elctech.com/articles/fixing-class-hierarchy-in-sti-under-development-mode</guid>
    </item>
    <item>
      <title>Exporting MySQL database</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Exporting mySQL dumps can sometimes be tricky. Some sites suggest exporting dump like so:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;mysqldump database_name &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt; dump.sql
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;
However, the problem with this method, is that the stream redirect might not be able to handle UTF-8 encoding correctly on certain OSes. I recently had a project that uses exotic characters and some characters would appear garbled up in the database because it was exported this way. 
&lt;/p&gt;

&lt;p&gt;
The way to export it, with the original characters intact, is to let mysqldump write to disk using the -r flag:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;mysqldump database_name &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;r dump.sql
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;
Ok, I lied. Exporting MySQL dump is easy.
&lt;/p&gt;
&lt;/div&gt;

</description>
      <author>Alex Chee</author>
      <pubDate>Fri, 20 Nov 2009 22:44:36 +0000</pubDate>
      <link>http://elctech.com/articles/exporting-mysql-database</link>
      <guid>http://elctech.com/articles/exporting-mysql-database</guid>
    </item>
    <item>
      <title>RAILS_ENV set to &quot;test&quot; in development</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;
I came across this rather annoying detail early on in one of our projects. 
&lt;/p&gt;

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;Loading&lt;/span&gt; development environment (&lt;span class=&quot;Variable&quot;&gt;Rails&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;2.3&lt;/span&gt;.&lt;span class=&quot;Constant&quot;&gt;4&lt;/span&gt;)
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;RAILS_ENV&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;development&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;ENV&lt;/span&gt;[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;RAILS_ENV&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;]
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;development&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;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;spec/rails&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; []
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;RAILS_ENV&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;test&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;ENV&lt;/span&gt;[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;RAILS_ENV&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;]
=&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;development&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; exit
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
Turns out that just by requiring 'spec/rails' it was blindly setting the RAILS_ENV constant to 'test' without warning. It sorta makes sense, as you would only really need the rspec gem when running tests, but I like to use the standard:
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;config.&lt;span class=&quot;Entity&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;rspec&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,         &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;lib&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;spec&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,         &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;version&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;1.2.9&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
config.&lt;span class=&quot;Entity&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;rspec-rails&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;lib&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;spec/rails&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;version&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;1.2.9&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
so that when new devs come into the project, they know exactly what gems and what versions are required.
&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;
    This is fine, but saying config.gem actually goes out and requires the rspec gem right then. Obviously this isn't needed on production, so we can go ahead and do something like
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; list gems here that only need to be around for development&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;RAILS_ENV&lt;/span&gt; &lt;span class=&quot;Keyword&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;
  config.&lt;span class=&quot;Entity&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;rspec&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,                   &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;lib&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;spec&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,           &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;version&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;1.2.9&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
  config.&lt;span class=&quot;Entity&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;rspec-rails&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,             &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;lib&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;spec/rails&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;,     &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;version&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;1.2.9&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
But that still doesn't solve my issue. So the hunt is on... I started looking in 'spec/rails'
&lt;/p&gt;

&lt;p&gt;
Then narrowed it down within that file to:
require 'spec/rails/extensions'
&lt;/p&gt;

&lt;p&gt;
Then from that file to:
require 'spec/rails/extensions/spec/runner/configuration'
&lt;/p&gt;

&lt;p&gt;
Then from that file to:
require 'test_help'
&lt;/p&gt;

&lt;p&gt;
Which lives in Rails, (railties/lib/test_help.rb) and performs this brilliant idea:&lt;br /&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Make double-sure the RAILS_ENV is set to test,&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; so fixtures are loaded to the right database&lt;/span&gt;
silence_warnings { &lt;span class=&quot;Variable&quot;&gt;RAILS_ENV&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;test&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; }
&lt;/pre&gt;&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
As long as you make sure you have
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;ENV&lt;/span&gt;[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;RAILS_ENV&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;test&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
in your spec_helper.rb, you shouldn't have any issue with the environment. So I decided to fight fire with fire, and ended up just sticking this into my config/initializers/

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; NOTE: this is here because using &lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; config.gem 'rspec',              :lib =&amp;gt; 'spec',        :version =&amp;gt; '1.2.9'&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; config.gem 'rspec-rails',        :lib =&amp;gt; 'spec/rails',  :version =&amp;gt; '1.2.9'&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; automatically sets the RAILS_ENV to 'test' no matter what ENV['RAILS_ENV'] is&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; see vendor/rails/railties/lib/test_help.rb:3&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; so we fire back our own silent hack. pew pew pew. -danny (2009.10.29)&lt;/span&gt;

silence_warnings { &lt;span class=&quot;Variable&quot;&gt;RAILS_ENV&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;ENV&lt;/span&gt;[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;RAILS_ENV&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;] &lt;span class=&quot;Keyword&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;/pre&gt;&lt;/code&gt;
&lt;/p&gt;

&lt;p&gt;
And just like magic, my development environment is back to RAILS_ENV == 'development'
&lt;/p&gt;</description>
      <author>Daniel LaBare</author>
      <pubDate>Fri, 20 Nov 2009 21:38:35 +0000</pubDate>
      <link>http://elctech.com/articles/rails_env-set-to-test-in-development</link>
      <guid>http://elctech.com/articles/rails_env-set-to-test-in-development</guid>
    </item>
    <item>
      <title>In the Good Old Days</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;I wanted to generate an Rails app running on 1.2.3 ... so I don't forget here is the command.&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;rails _1.&lt;span class=&quot;Constant&quot;&gt;2.&lt;/span&gt;3_ app_on_1_2_3
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;Just make sure the rails 1.2.3 gem is also installed.
&lt;/p&gt;&lt;/div&gt;</description>
      <author>Shane Mingins</author>
      <pubDate>Thu, 19 Nov 2009 07:07:15 +0000</pubDate>
      <link>http://elctech.com/snippets/in-the-good-old-days</link>
      <guid>http://elctech.com/snippets/in-the-good-old-days</guid>
    </item>
    <item>
      <title>How to Handle Credential Storage</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
  &lt;div class=&quot;document&quot;&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;http://vrt.cc/javascripts/swfobject.js&quot;&gt;&lt;/script&gt;
    &lt;div id=&quot;document_preview&quot;&gt;This website requires &lt;a href=&quot;http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&amp;promoid=BIOW&quot; target=&quot;_blank&quot;&gt;Flash player&lt;/a&gt; 9.0.0 or higher.&lt;/div&gt;&lt;script type=&quot;text/javascript&quot;&gt;
var flashvars = {};
flashvars.fileHeightOverride = &quot;300&quot;;
flashvars.filename = 'http:%2F%2Fvrt.cc%2Fpublic%2Fhttp%253A%252F%252Felccore.s3.amazonaws.com%252Fpresentations%252FStoring%252520Credentials%252520in%252520Web%252520Applications.pdf%2Fcached.swf';
var params = {};
params.wmode = 'transparent';
params.allowFullScreen = 'true';
params.quality = 'high';
var attributes = {};
swfobject.embedSWF('http://vrt.cc/swfs/viewer.swf', 'document_preview', '560', '460', '9.0.0', 'expressInstall.swf', flashvars, params, attributes);&lt;/script&gt;
  &lt;/div&gt;

&lt;/div&gt;
</description>
      <author>Jonathan Siegel</author>
      <pubDate>Wed, 18 Nov 2009 11:28:20 +0000</pubDate>
      <link>http://elctech.com/articles/how-to-handle-credential-storage</link>
      <guid>http://elctech.com/articles/how-to-handle-credential-storage</guid>
    </item>
    <item>
      <title>If in doubt, try try again</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;h2&gt;If in doubt, try try agin&lt;/h2&gt;
&lt;p&gt;On some recent projects I have seen the following code similar to:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Support&quot;&gt;User&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find_by_login&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;noone&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;id&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;nil&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;So I just wanted to remind people of the try method.&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Support&quot;&gt;User&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find_by_login&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;noone&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;).&lt;span class=&quot;Entity&quot;&gt;try&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;id&lt;/span&gt;)
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;
Personally I think &lt;em&gt;try&lt;/em&gt; communicates the intent of the code.
&lt;/p&gt;
&lt;/div&gt;</description>
      <author>Shane Mingins</author>
      <pubDate>Fri, 13 Nov 2009 01:10:44 +0000</pubDate>
      <link>http://elctech.com/snippets/if-in-doubt-try-try-again</link>
      <guid>http://elctech.com/snippets/if-in-doubt-try-try-again</guid>
    </item>
    <item>
      <title>Friday late night hacking</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Pairing with Heineken on some cool stuff we will show you soon - live from Paris&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://elccore.s3.amazonaws.com/29/922/prost.jpg&quot; alt=&quot;Prost&quot; width=&quot;500&quot; /&gt;&lt;/p&gt;
&lt;/div&gt;</description>
      <author>Gregor Martynus</author>
      <pubDate>Fri, 06 Nov 2009 21:57:07 +0000</pubDate>
      <link>http://elctech.com/articles/friday-late-night-hacking</link>
      <guid>http://elctech.com/articles/friday-late-night-hacking</guid>
    </item>
    <item>
      <title>Add Solr Searching to External Gem and Third Party Database</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;h2&gt;Problem&lt;/h2&gt;
&lt;p&gt;
Say you have a third party database that you need your rails applications to access. But of course you want it to be modular and use it again for other applications, so you write a gem to provide access to the non-rails standard database. Now you want to add in &lt;a href=&quot;http://acts-as-solr.rubyforge.org/&quot; target=&quot;_blank&quot;&gt;acts as solr&lt;/a&gt; to search across the database from your application.
&lt;/p&gt;
&lt;h2&gt;Solution&lt;/h2&gt;
&lt;p&gt;Acts as solr is a rails plugin and requires a solr server instance be running and therefore its not necessarily correct to add in the acts_as_solr plugin into your gem library. The consuming applications should be responsible for indexing what they and and how they want it. So a common trick is used to add in the application specific functionality into the gem. Initializers are used to inject the desired functionality into the gems classes. Given you have your gem named third_party_db_gem, create a file in config/initializers named something along the lines of third_party_db_gem_extensions.rb. And put in some code like:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&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;third_party_db_gem&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;Support&quot;&gt;ThirdPartyModel&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;class_eval&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;include&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;ActsAsSolr&lt;/span&gt;
  acts_as_solr &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;fields&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;email&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;phone&lt;/span&gt;, job]
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;h2&gt;Explanation&lt;/h2&gt;
&lt;p&gt;So first we had to require our gem, because our gem hasn't been loaded yet. Then we do a class_eval to inject our solr definition into one of the models. You would repeat that block for every class you wanted to index. Here's &lt;a href=&quot;http://blog.jayfields.com/2007/03/ruby-instanceeval-and-classeval-method.html&quot; target=&quot;_blank&quot;&gt;Jay Fields article more on class and instance eval&lt;/a&gt;.  &lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;/div&gt;</description>
      <author>Nicholaus</author>
      <pubDate>Fri, 06 Nov 2009 00:49:09 +0000</pubDate>
      <link>http://elctech.com/articles/add-solr-searching-to-external-gem-and-third-party-database</link>
      <guid>http://elctech.com/articles/add-solr-searching-to-external-gem-and-third-party-database</guid>
    </item>
    <item>
      <title>batch finding composite primary keys [SOLVED]</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Issue with composite_primary_keys and find_in_batches. In short, they don't play nicely together.&lt;/p&gt;
&lt;/div&gt;

&lt;h2&gt;Issue:&lt;/h2&gt;
&lt;p&gt;Rails 2.3+ find_in_batches will not work if your model has composite primary keys.&lt;/p&gt;
&lt;h2&gt;Solution:&lt;/h2&gt;
&lt;p&gt;I found this gist:
&lt;br /&gt; https://gist.github.com/105318/13fe7c42c95c820fadbad84d54e00680ce9d110f
&lt;br /&gt;
which solved the issue. I just dropped it into a file in RAILS_ROOT/config/initializers to extend active record to be able to do batch finds on those models which use composite_primary_keys&lt;/p&gt;</description>
      <author>Max Murphy</author>
      <pubDate>Thu, 05 Nov 2009 19:14:05 +0000</pubDate>
      <link>http://elctech.com/articles/batch-finding-composite-primary-keys-solved</link>
      <guid>http://elctech.com/articles/batch-finding-composite-primary-keys-solved</guid>
    </item>
    <item>
      <title>[SOLVED] 64bit MySQL and 32bit Ruby: FAIL</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;For the people out there using RVM to rock multiple Ruby versions, here's a gotcha with REE and Snow Leopard that took me hours to solve: if you happened to boot your mac in 32-bit mode when building ree with the oh so awesome:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;rvm install ree
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;And then install MySQL 64bit and try to install the gem, ruby will positively hate you. It will also do it's best not to help you understand the issue whining about missing libraries and whatnot.&lt;/p&gt;
&lt;p&gt;
No, it's not a library issue. Your ruby is built for 32bit and the mysql libs are 64bit. I know for sure nokogiri has the same issue and I think many others as well.
&lt;/p&gt;
&lt;p&gt;
What kernel version am I running?
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; uname -m&lt;/span&gt;
x86_64

&lt;span class=&quot;Keyword&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; uname -m&lt;/span&gt;
i386
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;To force 64bit mode, reboot holding down the &quot;6&quot; and &quot;4&quot; keys on the keyboard.&lt;/p&gt;
&lt;p&gt;Recompiling your rubies is fun for sure, but if you get tired of it, here's how to make the 64bit switch permanent:
&lt;/p&gt;&lt;p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; sudo vim /Library/Preferences/SystemConfiguration/com.apple.Boot.plist&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;/p&gt;&lt;p&gt;Change the last &lt;string&gt;&lt;/string&gt; key to &lt;string&gt;arch=x86_64&lt;/string&gt;. You'll end up with:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;?x&lt;/span&gt;ml version&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;1.0&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; encoding&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;UTF-8&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;?&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;!&lt;span class=&quot;Variable&quot;&gt;DOCTYPE&lt;/span&gt; plist &lt;span class=&quot;Variable&quot;&gt;PUBLIC&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;-//Apple Computer//DTD PLIST 1.0//EN&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;http://www.apple.com/DTDs/PropertyList-1.0.dtd&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;plist version&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;1.0&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;dict&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;key&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;Kernel&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;key&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;string&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;mach_kernel&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;string&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;key&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;Kernel&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Flags&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;key&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;string&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;arch&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;x86_64&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;string&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;dict&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;plist&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

To check if a lib is 64bit, run:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; lipo -info /usr/local/mysql/lib/libmysqld.a &lt;/span&gt;
input file &lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;usr&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;local&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;mysql&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;lib&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;libmysqld.&lt;span class=&quot;Entity&quot;&gt;a&lt;/span&gt; is &lt;span class=&quot;Keyword&quot;&gt;not&lt;/span&gt; a fat file
&lt;span class=&quot;Variable&quot;&gt;Non&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;fat file: &lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;usr&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;/&lt;/span&gt;&lt;/span&gt;local&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;mysql&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;lib&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;libmysqld.&lt;span class=&quot;Entity&quot;&gt;a&lt;/span&gt; is architecture: x86_64
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;
What about my ruby version?
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; lipo -info ~/.rvm/ree-1.8.7-2009.10/lib/libruby-static.a &lt;/span&gt;
input file &lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;david&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;rvm&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;ree&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;1.8&lt;/span&gt;.&lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;2009.10&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;lib&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;libruby&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;static.&lt;span class=&quot;Entity&quot;&gt;a&lt;/span&gt; is &lt;span class=&quot;Keyword&quot;&gt;not&lt;/span&gt; a fat file
&lt;span class=&quot;Variable&quot;&gt;Non&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;fat file: &lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;/&lt;/span&gt;&lt;/span&gt;david&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;rvm&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;ree&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;1.8&lt;/span&gt;.&lt;span class=&quot;Constant&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;2009.10&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;lib&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;libruby&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;static.&lt;span class=&quot;Entity&quot;&gt;a&lt;/span&gt; is architecture: x86_64

&lt;span class=&quot;Keyword&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; lipo -info ~/.rvm/ruby-1.9.1-p243/lib/libruby-static.a &lt;/span&gt;
input file &lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;david&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;rvm&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;ruby&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;1.9&lt;/span&gt;.&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;p243&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;lib&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;libruby&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;static.&lt;span class=&quot;Entity&quot;&gt;a&lt;/span&gt; is &lt;span class=&quot;Keyword&quot;&gt;not&lt;/span&gt; a fat file
&lt;span class=&quot;Variable&quot;&gt;Non&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;fat file: &lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;/&lt;/span&gt;&lt;/span&gt;david&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;rvm&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;ruby&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;1.9&lt;/span&gt;.&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;p243&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;lib&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;libruby&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;static.&lt;span class=&quot;Entity&quot;&gt;a&lt;/span&gt; is architecture: i386
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;code
&lt;/pre&gt;&lt;/code&gt;&lt;p&gt;
Looks like I'll have to nuke my Ruby 1.9 install too. Sigh.
&lt;/p&gt;
&lt;h2&gt;Give us the fix already!&lt;/h2&gt;
&lt;p&gt;
Ok ok. Here it goes:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; One&lt;/span&gt;
echo &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;rvm_archflags='-arch x86_64'&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;~&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringRegexp&quot;&gt;.rvmrc&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;Now rvm will now know what we want.&lt;/p&gt;
&lt;p&gt;That's not enough though and we need to make sure REE doesn't build with tcmalloc (at least until the good people at Google solve the non-64bit-ness of it). Only thing is rvm as of v0.64 has a little bug stopping params to be passed along. The soon to be released v0.75 fixes this but for now you need head:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Two&lt;/span&gt;
rvm rvm update &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;head
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;Now we're ready to reinstall REE:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Three&lt;/span&gt;
rvm &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;force install ree &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;ree&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;options &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;no&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;tcmalloc
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;
Many thanks to wayneeseguin for helping with this issue! Rvm is the best thing since sliced bread.
&lt;/p&gt;&lt;/div&gt;
</description>
      <author>David Palm</author>
      <pubDate>Thu, 05 Nov 2009 14:22:27 +0000</pubDate>
      <link>http://elctech.com/articles/-solved-64bit-mysql-and-32bit-ruby-fail</link>
      <guid>http://elctech.com/articles/-solved-64bit-mysql-and-32bit-ruby-fail</guid>
    </item>
    <item>
      <title>iPhone Tech Talk World Tour - San Jose</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Last week I went out to San Jose, CA to go to Apple's iPhone Tech Talk World Tour!&lt;/p&gt;
&lt;/div&gt;
&lt;img src=&quot;http://elccore.s3.amazonaws.com/4/916/photo 4.jpg&quot; alt=&quot;Photo 4&quot; /&gt;
Apple once a year holds 9 single day &quot;Tech Talks&quot; across the world. This year only 3 were in the US and I was lucky enough to get a spot at the San Jose meetup. The conference was focused on getting developers to use best practices in all regions of their applications. Apple's stance was even if the app is small, it might as well be designed as well as possible.

&lt;img src=&quot;http://elccore.s3.amazonaws.com/4/915/photo 3.jpg&quot; alt=&quot;Photo 3&quot; /&gt;

The day started with a nice overview of the iPhone platform. They sell tons of these things and people seem to love the App store. No real news there. Nice overview of the creative apps in the store. Certainly got everyone's brains working for an exciting day.

&lt;img src=&quot;http://elccore.s3.amazonaws.com/4/914/photo 2.jpg&quot; alt=&quot;Photo 2&quot; /&gt;

After looking over all the sessions I decided to spend my whole day in Room A which seemed to focus on the performance, threading and data management. The main tech point to take away from the conference was how threading is done on the iPhone. Apple's goal is to abstract away the complexities of classical threading. I went to an hour session on it and the only times I heard the words semaphore or lock was the speaker saying that they didn't exist anymore.

The iPhone has may build in calls which are blocking calls. This means that when performed on the main thread functionality will halt until they are done. A very commonly used blocking call is initWithContentsOfURL:. This method is used commonly for XML parsing and grabbing images from the internet. Apple has created a solution for this that essentially automizes your thread management with a single line of code. Lets say for example I am creating an app that on launch parses an XML source. If I have a containing method called parseXML() that does all the parsing I can call this method on a managed thread simply by using.
&lt;code language=&quot;objective-c&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;NSOperationQueue *queue = [[NSOperationQueue &lt;span class=&quot;SupportFunction&quot;&gt;alloc&lt;/span&gt;] &lt;span class=&quot;SupportFunction&quot;&gt;init&lt;/span&gt;];
NSInvocationOperation *op = [[NSInvocationOperation &lt;span class=&quot;SupportFunction&quot;&gt;alloc&lt;/span&gt;] &lt;span class=&quot;SupportFunction&quot;&gt;initWithTarget&lt;span class=&quot;SupportFunction&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;self&lt;/span&gt; &lt;span class=&quot;SupportFunction&quot;&gt;selector&lt;span class=&quot;SupportFunction&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Storage&quot;&gt;&lt;span class=&quot;Storage&quot;&gt;@&lt;/span&gt;selector&lt;/span&gt;(parseXML) &lt;span class=&quot;SupportFunction&quot;&gt;object&lt;span class=&quot;SupportFunction&quot;&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;nil&lt;/span&gt;];
[queue &lt;span class=&quot;SupportFunction&quot;&gt;addOperation&lt;span class=&quot;SupportFunction&quot;&gt;:&lt;/span&gt;&lt;/span&gt;op];
[op &lt;span class=&quot;SupportFunction&quot;&gt;release&lt;/span&gt;];
&lt;/pre&gt;&lt;/code&gt;

That's it. Apple has made a general class called NSOperation that gives users the power to create their own automated threading classes. In this case I am using the built in NSIvocationoperation object that takes in a method and runs it on a secondary thread. Throw the operation into an operation queue and you are done. Very powerful stuff.

&lt;img src=&quot;http://elccore.s3.amazonaws.com/4/917/photo-1.jpg&quot; alt=&quot;Photo-1&quot; /&gt;

Aside from the fun tech stuff it was a great opportunity to meet people in the developer community and share ideas. 
&lt;p&gt;&lt;/p&gt;</description>
      <author>ELC</author>
      <pubDate>Mon, 02 Nov 2009 20:56:27 +0000</pubDate>
      <link>http://elctech.com/articles/iphone-tech-talk-world-tour---san-jose</link>
      <guid>http://elctech.com/articles/iphone-tech-talk-world-tour---san-jose</guid>
    </item>
    <item>
      <title>Great Resource For Testing Regular Expressions</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Through my travels through the internets, I have stumbled upon a very useful resource.  It is a site (written in rails of course) for testing your regular expressions.  It has a very clean interface and uses fancy ajax to give you real time results about your regular expressions.  The URL of the this site is &lt;a href=&quot;http://rubular.com/&quot; target=&quot;_blank&quot;&gt;http://rubular.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;
&lt;img src=&quot;http://elccore.s3.amazonaws.com/30/905/screenshot_06.png&quot; alt=&quot;Screenshot_06&quot; width=&quot;500&quot; /&gt;
&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;
Not only does it provide real-time feedback on your regular expressions, it also will give you information about your matches.  This is much more useful than trial and error in your code.  Also, if you have an error in your regex, rubular will let you know about it.
&lt;/p&gt;

&lt;p&gt;A little rusty on your regex skills? No problem, the site even includes a box at the bottom detailing all of the most important regex strings.  So be sure to&lt;a href=&quot;http://rubular.com/&quot; target=&quot;_blank&quot;&gt; check it out&lt;/a&gt;&lt;/p&gt;</description>
      <author>Brandon Trebitowski</author>
      <pubDate>Thu, 29 Oct 2009 16:43:10 +0000</pubDate>
      <link>http://elctech.com/articles/great-resource-for-testing-regular-expressions</link>
      <guid>http://elctech.com/articles/great-resource-for-testing-regular-expressions</guid>
    </item>
    <item>
      <title>Executing SQL commands in Rails</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Most of the times, ActiveRecord's helpers to access database info is all you need; sometimes, you want to do some hacky stuff.&lt;/p&gt; 
&lt;p&gt;For example, I had to figure out a database's timezone and schema but I had no shell access to the server. So I ran this used Base.connection.execute and fetch_row to get the result&lt;/p&gt;

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;q&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Support&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;Base&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;connection&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;execute&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;SELECT NOW();&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;mysql::result:0x2b783735c4f8&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; q.&lt;span class=&quot;Entity&quot;&gt;fetch_row&lt;/span&gt;
=&amp;gt; [&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;2009-10-20 17:30:49&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Time&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;now&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;Variable&quot;&gt;Tue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Oct&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;32&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;02&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0700&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;2009&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;q.&lt;span class=&quot;Entity&quot;&gt;free&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;mysql::&lt;span class=&quot;Entity&quot;&gt;result&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;0x2b783735c4f8&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
You can basically run any SQL query you want with these two methods. Now go crash some servers!
&lt;/p&gt;

&lt;p&gt;
Note: You should also free your result to free up memory. Thanks Emmanuel.
&lt;/p&gt;
&lt;/div&gt;
</description>
      <author>Alex Chee</author>
      <pubDate>Thu, 29 Oct 2009 01:19:47 +0000</pubDate>
      <link>http://elctech.com/snippets/executing-sql-commands-in-rails</link>
      <guid>http://elctech.com/snippets/executing-sql-commands-in-rails</guid>
    </item>
    <item>
      <title>Can't add git remote branch</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;
I love git, but it's full of gotchas. Here's one I ran into recently when trying to create a remote branch to do some major code refactoring.

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;22&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;03&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;git push origin origin&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;refs&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;heads&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;new_remote_branch
error: src refspec origin does &lt;span class=&quot;Keyword&quot;&gt;not&lt;/span&gt; match any.
fatal: &lt;span class=&quot;Variable&quot;&gt;The&lt;/span&gt; remote &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt; hung up unexpectedly
error: failed to push some refs to &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&amp;lt;repo here&amp;gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;repo&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

Hmm. This has always worked for me before, what gives?

When I took a look at my remote branches:
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;35&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;33&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;git branch &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;r
  origin&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;master
&lt;/pre&gt;&lt;/code&gt;

I noticed that there's no HEAD pointer. I'm actually not certain of how that came about, but let's add it:

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;git symbolic&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;ref refs&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;remotes&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;origin&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;HEAD&lt;/span&gt; refs&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;remotes&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;origin&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;master
&lt;/pre&gt;&lt;/code&gt;

Now this looks a little better:
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;38&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;git branch &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;r
  origin&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;HEAD&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt; origin&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;master
  origin&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;master
&lt;/pre&gt;&lt;/code&gt;

And now git knows what do do when you try to branch off origin to a new remote branch:
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;20&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;41&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;14&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;git push origin origin&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;refs&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;heads&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;new_remote_branch
&lt;span class=&quot;Variable&quot;&gt;Counting&lt;/span&gt; objects: &lt;span class=&quot;Constant&quot;&gt;429&lt;/span&gt;, done.
&lt;span class=&quot;Variable&quot;&gt;Delta&lt;/span&gt; compression using up to &lt;span class=&quot;Constant&quot;&gt;2&lt;/span&gt; threads.
&lt;span class=&quot;Variable&quot;&gt;Compressing&lt;/span&gt; objects: &lt;span class=&quot;Constant&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;257&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;257&lt;/span&gt;), done.
&lt;span class=&quot;Variable&quot;&gt;Writing&lt;/span&gt; objects: &lt;span class=&quot;Constant&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt; (&lt;span class=&quot;Constant&quot;&gt;370&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;370&lt;/span&gt;), &lt;span class=&quot;Constant&quot;&gt;54.03&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;KiB&lt;/span&gt;, done.
&lt;span class=&quot;Variable&quot;&gt;Total&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;370&lt;/span&gt; (delta &lt;span class=&quot;Constant&quot;&gt;247&lt;/span&gt;), reused &lt;span class=&quot;Constant&quot;&gt;167&lt;/span&gt; (delta &lt;span class=&quot;Constant&quot;&gt;110&lt;/span&gt;)
&lt;span class=&quot;Variable&quot;&gt;To&lt;/span&gt; git@&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;repo_url_here&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;git&lt;/span&gt;
 &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt; [&lt;span class=&quot;Keyword&quot;&gt;new&lt;/span&gt; branch]      origin&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;HEAD&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt; new_remote_branch
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;repo_url_here&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

Great. Add it to your evernote and move on with your life :D
&lt;/p&gt;
&lt;/div&gt;
</description>
      <author>Daniel LaBare</author>
      <pubDate>Thu, 29 Oct 2009 00:30:01 +0000</pubDate>
      <link>http://elctech.com/articles/can-t-add-git-remote-branch</link>
      <guid>http://elctech.com/articles/can-t-add-git-remote-branch</guid>
    </item>
    <item>
      <title>Good Ruby Times</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;
  In the last few weeks I've had the chance to glance into several different codebases, some written years ago by devs in their Rails-infancy (rainfancy?).
&lt;/p&gt;
&lt;p&gt;Doing the travelling codes-man like that is a golden opportunity to see what people's stumbling blocks are and how a few easy tricks can improve the code substantially.
  
What follows is not your new cutting edge coffe making kitchen sink script-fu, but a rather dull list of everyday Ruby that I learned people need to learn.
&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;One-stop requires&lt;/h2&gt;
&lt;p&gt;
  This is a short one: requires go into the environment.rb. 
&lt;/p&gt;
&lt;p&gt;
Really, don't use it elsewhere. I've seen people reason along the lines of &quot;I keep the 'require hpricot' in my xe.com currency rates scraping class as to keep things local and closely knit&quot;. There is some truth to that argument and if a gem is only used by a rake task, maybe it even saves us a second during app startup and some RAM. Still, load order issues, poor readability and maintainability makes it a real pain to deal with down the road.
&lt;/p&gt;
&lt;p&gt;
Trust me: don't. Put it in environment.rb with a comment describing its purpose in your project.
&lt;/p&gt;
Whenever possible use the &quot;config.gem&quot;. Advantages:
&lt;ul&gt;
  &lt;li&gt;allows you to specify the lib name even if the gem name is different (e.g. for github gems)&lt;/li&gt;
  &lt;li&gt;allows you to require sub libs&lt;br /&gt;
  &lt;p&gt;Not used very often perhaps but put to good use by e.g. the right_aws gem where you can choose to load just the SQS part with:&lt;/p&gt;
        &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;config.&lt;span class=&quot;Entity&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;right_aws&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;lib&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;sqs/right_sqs&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
      &lt;p&gt;or maybe you just wanted the SDB part?&lt;/p&gt;
         &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;config.&lt;span class=&quot;Entity&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;right_aws&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;lib&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;sdb/right_sdb_interface&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
      
    &lt;p&gt;
      I personally believe this particular feature is more confusing than helpful, but it's good to know it's there.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;allows you to specify the library version&lt;br /&gt;
    &lt;p&gt;
      Towards the end of the development cycle, before rolling out to production, gems should generally be frozen. An alternative is to define exact versions in the config. I generally advise doing both as having the environment.rb as the one-stop source for gem requirements is a boon for everybody involved, capistrano scripts or new devs on your team.
    &lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;all in one place, easy to find out requirements&lt;/li&gt;
&lt;/ul&gt;
   
&lt;h2&gt;Singleton methods (creation)&lt;/h2&gt;
    &lt;p&gt;Ruby provides three (common) ways to define a singleton method:&lt;/p&gt;

    &lt;ol style=&quot;list-style-type: lower-alpha&quot;&gt;
      &lt;li&gt;&lt;p&gt;Explicitly name the class&lt;/p&gt;
        &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;RapidInterventionGroupTeam&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;RapidInterventionGroupTeam.load_group_allocations_and_teams&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;project_id&lt;span class=&quot;Variable&quot;&gt;,&lt;/span&gt; curr_user&lt;/span&gt;)
&lt;span class=&quot;Comment&quot;&gt;    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;/code&gt;      
      &lt;p&gt;
        PROs: hmm, dunno. Makes it easy to know what class you're looking at if the source code file is very long?
      &lt;/p&gt;
      &lt;p&gt;
        CONs: long, ugly
      &lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Use self&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;RapidInterventionGroupTeam&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.load_group_allocations_and_teams&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;project_id&lt;span class=&quot;Variable&quot;&gt;,&lt;/span&gt; curr_user&lt;/span&gt;)
&lt;span class=&quot;Comment&quot;&gt;    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;/code&gt;      
      &lt;p&gt;
        PROs: easy to spot here-comes-a-singleton-marker. Some people like to use the 'self' keyword. I call them self-ish people. Sorta short.
      &lt;/p&gt;
      &lt;p&gt;
        CONs: I think it's ugly. For more than two singletons that repeating 'self' annoys me.
      &lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Use the metaclass&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;      
&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;RapidInterventionGroupTeam&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; ==========================&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; = Class methods go here! =&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; ==========================&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; self&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;load_group_allocations_and_teams&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;project_id&lt;span class=&quot;Variable&quot;&gt;,&lt;/span&gt; cur_user&lt;/span&gt;)
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;Entity&quot;&gt;team_allocations&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;Entity&quot;&gt;group_allocations&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;      &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; ============================&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; = Instance methods go here =&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; ============================&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;beef_cow_and_fowl&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;/code&gt;      
      &lt;p&gt;
        PROs: shortest. Encourages devs to gather singletons in one spot, and perhaps they will notice when it gets out of hand and start creating mixins. Maybe. Also allows devs to show off their Ruby metaclass knowledge at bars. Maybe.
      &lt;/p&gt;
      &lt;p&gt;
        CONs: that class &lt;&lt; self &lt;em&gt;is&lt;/em&gt; funky and if funky doesn't rub well with you (or your boss) then I guess it's no good.
      &lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
      
  &lt;p&gt;
    I personally favor c) whenever the number of class methods goes above two or three; b) is fine when there are just a few of them.
  &lt;/p&gt;
&lt;h2&gt;Invoking singleton methods&lt;/h2&gt;
  &lt;p&gt;In Ruby there are many ways to invoke a class method. A few common ones:&lt;/p&gt;
  &lt;ol style=&quot;list-style-type: lower-alpha&quot;&gt;
    &lt;li&gt;
      &lt;p&gt;Name the class explicitly:&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;user &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;User&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;123&lt;/span&gt;)
&lt;span class=&quot;Support&quot;&gt;Predators&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;feed_to_wolves&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;, user)
      
&lt;/pre&gt;&lt;/code&gt;
    &lt;/li&gt;
    
    &lt;p&gt;When used from an instance of the class, use the context: self.class&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;Predators&lt;span class=&quot;EntityInheritedClass&quot;&gt; &lt;span class=&quot;EntityInheritedClass&quot;&gt;&amp;lt;&lt;/span&gt; ActiveRecord::Base&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.feed_to_wolves&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;pack_id&lt;span class=&quot;Variable&quot;&gt;,&lt;/span&gt; meat&lt;/span&gt;)
&lt;span class=&quot;Comment&quot;&gt;    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; code&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
  
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; we know how we were born...&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;feed_us!&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;meat&lt;/span&gt;)
    &lt;span class=&quot;Variable&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;class&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;feed_to_wolves&lt;/span&gt;(id, meat)
  &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;/code&gt;
    &lt;li&gt;
      &lt;p&gt;Use a helper instance method &lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;    
&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;Steak&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.logger&lt;/span&gt;
    &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;logger&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Logger&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;log/steak.log&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;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;logger&lt;/span&gt;
    &lt;span class=&quot;Variable&quot;&gt;self&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;class&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;logger&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;Entity&quot;&gt;beef&lt;/span&gt;
    logger.&lt;span class=&quot;Entity&quot;&gt;debug&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;MONDAY BEEF!&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
    &lt;span class=&quot;Entity&quot;&gt;beef_for!&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;monday&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;/code&gt;
      &lt;p&gt;
        Using an instance method this way to invoke a class level method is of course useful only if you invoke it very often and readability becomes very important. In the above example we're also memoizing (caching) the class level Logger object for fast access.
      &lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
      
  &lt;p&gt;
    I personally try 1) to avoid singletons altogether, 2) use method b) whenever possible and 3) start asking myself hard and awkward questions when doing a) more than 3 times a day. Too many singletons might be a codesmell.
  &lt;/p&gt;
    
    
&lt;h2&gt;Multiple return values&lt;/h2&gt;
  &lt;p&gt;First an example of how people often fake multiple value returns in Ruby:&lt;/p&gt;
  &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;Something&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;many&lt;/span&gt;
    [calc_monday_beef, calc_total_beef]
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

s &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Something&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
retval &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; s.&lt;span class=&quot;Entity&quot;&gt;many&lt;/span&gt;
  
&lt;/pre&gt;&lt;/code&gt;
  &lt;p&gt;
    DON'T: when coding a method and you realize you need to return more than one value from a method, you should stop and think. You're probably doing something wrong.&lt;br /&gt;
This is actually the reason why Ruby does not provide a way to return multiple values.
  &lt;/p&gt;  
  &lt;p&gt;
    If you're sure you know what you're doing and want to return more than value here are some tips:
  &lt;/p&gt;
  &lt;ol style=&quot;list-style-type: lower-alpha&quot;&gt;
    &lt;li&gt;
      &lt;p&gt;do NOT do what I did in the example.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt; use descriptive variable names. &quot;retval&quot; above sucks. Use Ruby multiple value assignments like so:&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; cows, sheep, fish &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; [&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;5&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;]
=&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;5&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;]
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; cows
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; sheep
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;5&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; fish
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;3&lt;/span&gt;
      
&lt;/pre&gt;&lt;/code&gt;
      &lt;p&gt;Use this to assign multiple return values to local variables with helpful names:&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;      
s &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Something&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
monday_beef, total_beef &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; s.&lt;span class=&quot;Entity&quot;&gt;many&lt;/span&gt;
      
&lt;/pre&gt;&lt;/code&gt;
    &lt;/li&gt;

      
    &lt;li&gt;
      &lt;p&gt;
        c) if you're returning many values and you don't know beforehand how many values are coming back, use the splat operator (*):
      &lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; me, &lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;others &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;abe&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;bob&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;caesar&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;donald&lt;/span&gt;]
=&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;abe&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;bob&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;caesar&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;donald&lt;/span&gt;]
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; me
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;abe&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; others
=&amp;gt; [&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;bob&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;caesar&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;donald&lt;/span&gt;]
      
&lt;/pre&gt;&lt;/code&gt;  
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;d) avoid using array indexes and prefer using Array#first, Array#last:&lt;/p&gt;
      &lt;ul&gt;
        &lt;li&gt;
          &lt;p&gt;BAD:&lt;/p&gt;
          &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;  
s &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Something&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
retval &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; s.&lt;span class=&quot;Entity&quot;&gt;many&lt;/span&gt;
&lt;span class=&quot;Support&quot;&gt;Beef&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find&lt;/span&gt;(retval[&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;], &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;limit&lt;/span&gt; =&amp;gt; retval[&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;])
          
&lt;/pre&gt;&lt;/code&gt;        
        &lt;/li&gt;
        &lt;li&gt;
          &lt;p&gt;STILL BAD SOMEWHAT BETTER:&lt;/p&gt;
          &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;s &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Something&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
retval &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; s.&lt;span class=&quot;Entity&quot;&gt;many&lt;/span&gt;
&lt;span class=&quot;Support&quot;&gt;Beef&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find&lt;/span&gt;(retval.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;limit&lt;/span&gt; =&amp;gt; retval.&lt;span class=&quot;Entity&quot;&gt;last&lt;/span&gt;)
          
&lt;/pre&gt;&lt;/code&gt;        
      
          &lt;p&gt;Why better? Because you communicate to the reader that that 'retval' variable only have two values. (Yeah, it still sucks I know)
          &lt;/p&gt;      
      
        &lt;/li&gt;
        &lt;li&gt;        
          &lt;p&gt;ALSO BAD BUT SOMEWHAT-ER BETTER STILL:&lt;/p&gt;
          &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;s &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Something&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
monday_beef, beef_count &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; s.&lt;span class=&quot;Entity&quot;&gt;many&lt;/span&gt;
&lt;span class=&quot;Support&quot;&gt;Beef&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find&lt;/span&gt;(monday_beef, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;limit&lt;/span&gt; =&amp;gt; beef_count)
          
&lt;/pre&gt;&lt;/code&gt;
      
        &lt;/li&gt;
        &lt;li&gt;        
          &lt;p&gt;GOOD:&lt;/p&gt;
          &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;s &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Something&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
&lt;span class=&quot;Support&quot;&gt;Beef&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find&lt;/span&gt;(s.&lt;span class=&quot;Entity&quot;&gt;monday_beef&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;limit&lt;/span&gt; =&amp;gt; s.&lt;span class=&quot;Entity&quot;&gt;total_beef_count&lt;/span&gt;)
          
&lt;/pre&gt;&lt;/code&gt;
          
        &lt;/li&gt;
      &lt;/ul&gt;
    &lt;/li&gt; 
  &lt;/ol&gt;
&lt;h2&gt;Drop the return&lt;/h2&gt;
&lt;p&gt;
  Use the fact that Ruby methods return the value of the last expression. The only place where I think an explicit return is legit is when we want to return early and that's a performance optimization and as we know, premature optimization is the root of all evil, so unless you have benchmarks at hand proving the need for speed, just don't user 'return'.
&lt;/p&gt;
  
  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;Instead of:&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;course_description&lt;/span&gt;
  retval &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; course_shortname 
  retval &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; course_shortname &lt;span class=&quot;Keyword&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;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;project&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;shortname&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&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;Keyword&quot;&gt;if&lt;/span&gt; project
  &lt;span class=&quot;Keyword&quot;&gt;return&lt;/span&gt; retval
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
      
&lt;/pre&gt;&lt;/code&gt;
    &lt;/li&gt;  
    &lt;li&gt;
      &lt;p&gt;Do:&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;      
&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;course_description&lt;/span&gt;
  course_shortname &lt;span class=&quot;Keyword&quot;&gt;+&lt;/span&gt; (project &lt;span class=&quot;Keyword&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;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;project&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;shortname&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&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;'&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
      
&lt;/pre&gt;&lt;/code&gt;
    &lt;/li&gt;
  &lt;/ul&gt;

&lt;h2&gt;Enumerable&lt;/h2&gt;
&lt;p&gt;Learn to use and love ruby Enumerable module. It's really really useful.&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Instead of:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;      
&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;Vacation.holidaytype_selectbox&lt;/span&gt;
  types &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Array&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; vt &lt;span class=&quot;Keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;VacationTypes&lt;/span&gt;
    types &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; vt[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&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;holidaytype_selectbox_model&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;||=&lt;/span&gt; types
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    
&lt;/pre&gt;&lt;/code&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Use:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;    
&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;self.holidaytype_selectbox&lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;holidaytype_selectbox_model&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;VacationTypes&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;map&lt;/span&gt;(&lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;name&lt;/span&gt;)
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    
&lt;/pre&gt;&lt;/code&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Instead of:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; result &lt;span class=&quot;Keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;candidate&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do&lt;/span&gt;
  result.&lt;span class=&quot;Entity&quot;&gt;destroy&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    
&lt;/pre&gt;&lt;/code&gt;
  &lt;/li&gt;      
  &lt;li&gt;
    &lt;p&gt;Use:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;candidate&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;results&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;each&lt;/span&gt;(&lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;destroy&lt;/span&gt;)
&lt;/pre&gt;&lt;/code&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Instead of:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;approved&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;do_it&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;nil?&lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;events&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Event&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;hourreporting_entries&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;user_id&lt;/span&gt;, params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;projectid&lt;/span&gt;], &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;week&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;date&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;week&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;last&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;date&lt;/span&gt;)

  &lt;span class=&quot;Keyword&quot;&gt;for&lt;/span&gt; e &lt;span class=&quot;Keyword&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;events&lt;/span&gt;
    &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; e.&lt;span class=&quot;Entity&quot;&gt;approved&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
      &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;approved&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&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;end&lt;/span&gt;
    
&lt;/pre&gt;&lt;/code&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Do:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;    
&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;do_it&lt;/span&gt;
  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;events&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Event&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;hourreporting_entries&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;user_id&lt;/span&gt;, params[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;projectid&lt;/span&gt;], &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;week&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;date&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;week&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;last&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;date&lt;/span&gt;)
  &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;approved&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;events&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;sum&lt;/span&gt;{|&lt;span class=&quot;Variable&quot;&gt;e&lt;/span&gt;| e.&lt;span class=&quot;Entity&quot;&gt;approved&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;?&lt;/span&gt; e.&lt;span class=&quot;Entity&quot;&gt;approved&lt;/span&gt; : &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;}
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    
&lt;/pre&gt;&lt;/code&gt;
    &lt;p&gt;The Array#sum method is a Rails addition.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;      
      
&lt;p&gt;
  In the app where I spotted the above, the default value for the 'approved' field is set to NULL. Had the default value been 0 instead, we could have written the above in an even shorter way:
&lt;/p&gt;
  &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;events&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;sum&lt;/span&gt;(&lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;approved&lt;/span&gt;)
&lt;/pre&gt;&lt;/code&gt;
        
&lt;h2&gt;Truth&lt;/h2&gt;
&lt;p&gt;In Ruby, everything except false and nil evaluates to true. For realz.&lt;/p&gt;
  
&lt;ul&gt;
  &lt;li&gt;  
    &lt;p&gt;Instead of:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;  
&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; options[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;add&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; check_id.&lt;span class=&quot;Entity&quot;&gt;to_i&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
  meanie &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;MeanGuy&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find&lt;/span&gt;(check_id)
  &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; meanie.&lt;span class=&quot;Entity&quot;&gt;reason&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;!=&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; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;!&lt;/span&gt;meanie.&lt;span class=&quot;Entity&quot;&gt;reason&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;nil?&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; meanie.&lt;span class=&quot;Entity&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;MeanGuy&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;allowed_types&lt;/span&gt;[&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;]
&lt;span class=&quot;Comment&quot;&gt;    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;/code&gt;
  &lt;/li&gt;    
  &lt;li&gt;    
    &lt;p&gt;Do:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;  
&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; options[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;add&lt;/span&gt;] &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;!&lt;/span&gt;check_id.&lt;span class=&quot;Entity&quot;&gt;zero?&lt;/span&gt;
  meanie &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;MeanGuy&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;find&lt;/span&gt;(check_id)
  &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;!&lt;/span&gt;meanie.&lt;span class=&quot;Entity&quot;&gt;reason&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;blank?&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; meanie.&lt;span class=&quot;Entity&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;MeanGuy&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;allowed_types&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&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;/code&gt;    
  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
  When chaining conditional checks like above with &quot;&amp;&amp;&quot;, remember that Ruby will stop the checks at the first failure, so always put the 'cheapest' checks first (e.g. put any checks that require a database query last).
&lt;/p&gt;

&lt;p&gt;
  In the above snippet we see the very common &quot;!something.blank?&quot; idiom. I personally really don't like the prepended &quot;!&quot; and always try to avoid it. Hurts my eyes and makes me stumble while reading. Ideally the above should be:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; meanie.&lt;span class=&quot;Entity&quot;&gt;reason&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; meanie.&lt;span class=&quot;Entity&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;MeanGuy&lt;/span&gt;.allowed_type
&lt;/pre&gt;&lt;/code&gt;
        
&lt;p&gt;
  but if the meanie reason is allowed to be the empty string -- which Ruby will consider True -- then we need the explicit blank?-check.
&lt;/p&gt;    
  
    &lt;p&gt;Unrelated neat trick using &amp;&amp;:&lt;/p&gt;
    &lt;ul&gt;
      &lt;li&gt;
        &lt;p&gt;Instead of:&lt;/p&gt;
        &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;safe_death&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;dude&lt;/span&gt;)
  &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; dude
    &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; dude.&lt;span class=&quot;Entity&quot;&gt;destroy&lt;/span&gt;
      &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;DudeMailer&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;deliver_destruction_notification&lt;/span&gt;
        &lt;span class=&quot;Support&quot;&gt;Call&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;his_mum&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;end&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Entity&quot;&gt;safe_death&lt;/span&gt;(&lt;span class=&quot;Support&quot;&gt;Dude&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;)
      
&lt;/pre&gt;&lt;/code&gt;
    &lt;/li&gt;
    
    &lt;li&gt;
      &lt;p&gt;Do:&lt;/p&gt;
      &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;safe_death&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;dude&lt;/span&gt;)
  dude &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; dude.&lt;span class=&quot;Entity&quot;&gt;destroy&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;DudeMailer&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;deliver_destruction_notification&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Call&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;his_mum&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Entity&quot;&gt;safe_death&lt;/span&gt;(&lt;span class=&quot;Support&quot;&gt;Dude&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;)
      
&lt;/pre&gt;&lt;/code&gt;
    &lt;/li&gt;
&lt;p&gt;
  This works well only if you don't care about handling any error conditions
and success depends on *all* method calls being successful.
&lt;/p&gt;    
    
&lt;p&gt;
  To improve readability in general create as many predicate methods as possible. They are short, 
cheap and really helps readability.
&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;Instead of:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;  
&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;active&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;true&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;projects&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;include?&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;beef_on_monday&lt;/span&gt;) &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; (&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;human&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;type&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;dog&lt;/span&gt;)
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;        
    
&lt;/pre&gt;&lt;/code&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Do:&lt;/p&gt;
    &lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;Person&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;active_monday_beefer?&lt;/span&gt;
    actvive? &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;member_of?&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;beef_on_monday&lt;/span&gt;) &lt;span class=&quot;Keyword&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; (human? &lt;span class=&quot;Keyword&quot;&gt;||&lt;/span&gt; dog?)
  &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;if&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;person&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;active_monday_beefer?&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Code&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
    
&lt;/pre&gt;&lt;/code&gt;
  &lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Method naming&lt;/h2&gt;
&lt;p&gt;
  When naming your methods, avoid prepending &quot;get_&quot; or &quot;set_&quot;. The Ruby convention is that getters are just the value name and the setter has the &quot;=&quot; postfix. Avoid the quasi-get_'s  too: load_, retrieve_, store_, put_. Sometimes they're ok, but just stop a second and think if:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;store_incoming_beef&lt;/span&gt;()
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;is really really better than&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;more_beef_in_the_holds&lt;/span&gt;()
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;beefers_keepers&lt;/span&gt;()
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;not_pork_not_sheep_not_fowl_but?&lt;/span&gt;()
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;As always rules are made to be broken, judiciously. ;)&lt;/p&gt;
    
&lt;p&gt;DON'T:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;get_premium, #get_unix_time_stamp, #load_dates, #retrieve_mums etc&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;Do:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;premium, #unix_timestamp, #dates, #mums, #beefs&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
  
&lt;p&gt;DON'T:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Support&quot;&gt;Server&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;set_clock&lt;/span&gt;(&lt;span class=&quot;Support&quot;&gt;Time&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;now&lt;/span&gt;)
&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;doc&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;store_signer&lt;/span&gt;(&lt;span class=&quot;Support&quot;&gt;Dude&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;)
&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;tellus&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;put_fire&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;wild&lt;/span&gt;)
&lt;span class=&quot;Support&quot;&gt;Time&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;set_back&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;year&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;ago&lt;/span&gt;)
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;Do:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Support&quot;&gt;Server&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;clock&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Time&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;now&lt;/span&gt;
&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;doc&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;signer&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Dude&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;@&lt;/span&gt;tellus&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;fire!&lt;/span&gt;(&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;wild&lt;/span&gt;)
&lt;span class=&quot;Support&quot;&gt;Time&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;now&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;year&lt;/span&gt;.ago
&lt;/pre&gt;&lt;/code&gt;
      
&lt;p&gt;
  Keep method names short: e.g. #shorten_timespaces_because_of_special_holiday is too long. Long method names are often a sign of complex methods. Complex methods are often a sign we should refactor the code into smaller pieces.
&lt;/p&gt;
     
&lt;p&gt;
  Sometimes the work done by a method is simply too complicated to be expressed properly
by a short and self-explanatory method name. If so, don't even try. Leave the method name
short and cryptical. It becomes a marker for the reader of &quot;hey, wanna understand this one?
Sorry but you really really have to go read the code!&quot;.
&lt;/p&gt;     
&lt;p&gt;DON'T:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;shorten_timespaces_because_of_special_holiday&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;DO:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;holiday_adjustment&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
      
&lt;p&gt;
  Use the &quot;?&quot; for predicates (should *always* return true/false or at least something that evaluates to true false, such as &quot;abc&quot;/nil)
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;JEntityNameType&quot;&gt;Session&lt;/span&gt;
  &lt;span class=&quot;Keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;Entity&quot;&gt;finished?&lt;/span&gt;
    finished_at
  &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

sess &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Session&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;
sess.&lt;span class=&quot;Entity&quot;&gt;finished_at&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;Time&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;now&lt;/span&gt;
sess.finished?
&lt;/pre&gt;&lt;/code&gt;        
&lt;p&gt;GOOD:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; sess.&lt;span class=&quot;Entity&quot;&gt;finished?&lt;/span&gt; 
  coffee!
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;BAD:&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; sess.&lt;span class=&quot;Entity&quot;&gt;finished_at&lt;/span&gt;
  coffee!
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;h2&gt;Use rdoc!&lt;/h2&gt;
&lt;p&gt;
  User rdoc for your rails apps. It's actually nice. When your mum asks you what it is you actually do you can show her the rdocs with links and text and colors and lists and it will make her happy too. And very useful for people trying to read your code (ok, they can run the freakin' rake task themselves, but you should do it too!).
&lt;/p&gt;  
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;  rake doc&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;app&lt;/span&gt;
  open doc&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;app&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;index
&lt;/pre&gt;&lt;/code&gt;&lt;/ul&gt;</description>
      <author>David Palm</author>
      <pubDate>Tue, 27 Oct 2009 13:01:21 +0000</pubDate>
      <link>http://elctech.com/articles/good-ruby-times</link>
      <guid>http://elctech.com/articles/good-ruby-times</guid>
    </item>
    <item>
      <title>Amazon's MySQL in the Cloud (RDS)</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Amazon just released the &lt;strong&gt;&quot;public beta of Amazon Relational Database Service (Amazon RDS), a new web service that makes it easy to set up, operate, and scale relational databases in the cloud.&quot;&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;Great! So what is it?&lt;/h2&gt;
&lt;p&gt;RDS today is an EC2 instance running MySQL 5.1. Instead of starting an EC2 instance with RightScale or EC2 commandline tools, you start an RDS instance with the RDS commandline tools (and I'm sure RightScale will support RDS shortly).&lt;/p&gt;&lt;p&gt;
&lt;/p&gt;&lt;p&gt;The RDS instance accepts parameters such as root database username and password, db space to allocate, initial instance size (note there are new instances), db backup periods, among others. Amazon's RDS layer configures MySQL in a proven configuration based on the parameters you specify.&lt;/p&gt;
&lt;p&gt;RDS instances cost 10% more than a vanilla EC2 instance for Small, Large and XL instances. For Double and Quadruple DB instances the pricing is higher:
&lt;img src=&quot;http://elccore.s3.amazonaws.com/5/899/Screen shot 2009-10-27 at 09.40.26.png&quot; alt=&quot;Screen shot 2009-10-27 at 09&quot; /&gt;&lt;br /&gt;
Note that EC2 pricing is about to change and you will want to recalculate that 10% if RDS does not shift as well.&lt;/p&gt; 
&lt;h2&gt;And why do we want it?&lt;/h2&gt;
&lt;p&gt;If you run MySQL in EC2 for reasonably large properties, this service effectively provides a substantial reduction in undifferentiated system administration overhead within your organization. That is, if your deployment is small--you probably run your DB on the same machine as your application--you could use RDS to reduce your SysAdmin costs, but you probably value your time less than AWS costs at this stage of deployment. If your deployment is huge--you probably run your DB on EBS (RAID striped) with hot replication to other instances (for performance and failover) and automated offsite backups. You have a large AWS bill and a large SysAdmin cost to implement, monitor and maintain the configuration. RDS could potentially greatly reduce your SysAdmin bill, but today you cannot hot replicate nor run an RDS DB across multiple underlying instances--and therefore RDS is not for you.&lt;/p&gt;
&lt;h2&gt;So who is it for?&lt;/h2&gt; 
&lt;/div&gt;
&lt;p&gt;RDS as it stands today is ideal for deployments that have scale to warrant a separate DB. These are midsize deployments--or smaller deployments that follow best-practices in deployment and scalability over instance cost savings. These deployments may have mid-to-large EC2 instances powering their DB today, and don't need hot replication for performance nor uptime. Note that with the new double and quad instance sizes, the performance ceiling on a single instance has been greatly raised.&lt;/p&gt;
&lt;p&gt;These deployments will benefit from a proven DB configuration, out of the box automated backups, one command time-and-date restores, auto instance failover (some downtime would be associated), monitoring (accessible via CloudWatch), and autoscaling of their DB instance (yes--as load increases, your instance is seamlessly migrated to a larger instance).&lt;/p&gt;
&lt;p&gt;Our team routinely deploys the midsize and huge DB configurations described here. We have the highest SysAdmin cost on our huge deployments, but also the highest budgets :-). We have been using RDS as the staging DB for several of our midsized deployments. So far we have seen no real usage difference in using an RDS DB vs our own EC2-hosted DB. We do notice that we don't worry about whether our DB backup script is working. That alone is worth 10% of our instance cost. The reduction in DB instance deployment time and SysAdmin cost is also a win--but we won't see those savings until our next deployment--as all our deploys are RightScripted and already include a configured DB. Finally--the autoscale, fine-grained restore and other features sound great, but we won't have more to say until we use them in practice.&lt;/p&gt; 
&lt;h2&gt;Other Observations&lt;/h2&gt;
&lt;ul&gt;
    &lt;li&gt;Logs are accessible within a MySQL table exposed within the RDS insance.&lt;/li&gt;
    &lt;li&gt;In the future it appears that other DB types (non MySQL 5.1) will be supported.&lt;/li&gt;
    &lt;li&gt;DB allocated storage must be declared in advance. Think of this as allocating the EBS volume connected to your instance. Going to need 50GB for your DB? Allocate 50GB. If it grows? Monitor DB size on CloudWatch and make sure you bump the allocated space. Will the RDS team email you to let you know this is an issue? Try it and find out. :-P&lt;/li&gt;
    &lt;li&gt;New instances were released coincident with the launch. 64GB and 32GB high-memory instances.&lt;/li&gt;
    &lt;li&gt;A new Small 64 bit instance is available, but only for RDS. This would be a nice-to-have for EC2 as well to minimize rebuilding templates when going from Small (32bit) to other sizes (64bit).&lt;/li&gt;
&lt;/ul&gt;</description>
      <author>Jonathan Siegel</author>
      <pubDate>Tue, 27 Oct 2009 10:08:41 +0000</pubDate>
      <link>http://elctech.com/articles/amazon-s-mysql-in-the-cloud-rds</link>
      <guid>http://elctech.com/articles/amazon-s-mysql-in-the-cloud-rds</guid>
    </item>
    <item>
      <title>RightSignature hits the Press on ReadWrite Enterprise</title>
      <description>&lt;div class=&quot;preface&quot;&gt;

&lt;p&gt;&lt;a href=&quot;http://www.readwriteweb.com&quot; target=&quot;_blank&quot;&gt;ReadWrite Enterprise&lt;/a&gt; &lt;a href=&quot;http://www.readwriteweb.com/enterprise/2009/10/rightsignature-sign-awaywith-y.php&quot; target=&quot;_blank&quot;&gt;says&lt;/a&gt; &quot;RightSignature user interface is pretty elegant. It has a flow that makes it simple to complete the signing of documents through the automation of tasks such as adding initials to each page, a requirement of most contracts.&quot; They also comment that &quot;Part of RightSignature's appeal is in its overall change to the workflow and the efficiencies that result.&quot; RightSignature is entering the Software-as-a-Service market and is headed to the top with other ecosystems like Salesforce.com and Google Wave.

&lt;/p&gt;&lt;p&gt;ELC Technologies continues to launch &lt;a href=&quot;http://www.elctech.com/services#our_products&quot;&gt;cutting edge products&lt;/a&gt; on the web.&lt;/p&gt; 

&lt;p&gt;Read more at &lt;a href=&quot;http://www.readwriteweb.com/enterprise/2009/10/rightsignature-sign-awaywith-y.php&quot;&gt;http://www.readwriteweb.com/enterprise/2009/10/rightsignature-sign-awaywith-y.php&lt;/a&gt;&lt;/p&gt;

&lt;img src=&quot;http://elccore.s3.amazonaws.com/4/893/ReadWriteRightSignPress.jpg&quot; alt=&quot;Readwriterightsignpress&quot; /&gt;

&lt;/div&gt;

</description>
      <author>ELC</author>
      <pubDate>Wed, 21 Oct 2009 22:17:55 +0000</pubDate>
      <link>http://elctech.com/articles/rightsignature-hits-the-press-on-readwrite-enterprise</link>
      <guid>http://elctech.com/articles/rightsignature-hits-the-press-on-readwrite-enterprise</guid>
    </item>
    <item>
      <title>How to remove trailing slashes to get better analytics on your page views</title>
      <description>&lt;div class=&quot;preface&quot;&gt;

&lt;p&gt;
    I noticed when viewing my google analytics report that I had several duplicate entries for the same that looked like /page, and then /page/ (a trailing slash).
&lt;/p&gt;

&lt;p&gt;
    Obviously I'd like these two to be combined to get one statistic for those page views. There are a couple of ways to do this.
&lt;/p&gt;

&lt;p&gt;
1) The particular project in question is using nginx. We can use a rewrite to get rid of the slash.
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;server {
    server_name example.&lt;span class=&quot;Entity&quot;&gt;com&lt;/span&gt;;

    ...

    rewrite &lt;span class=&quot;Keyword&quot;&gt;^&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;(.&lt;span class=&quot;Keyword&quot;&gt;*&lt;/span&gt;)&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;$ &lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;$&lt;/span&gt;1&lt;/span&gt; permanent;

    location &lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt; {
    ...
    }
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
2) You can also get creative with a little rack fun. 
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;sudo gem install rack&lt;span class=&quot;Keyword&quot;&gt;-&lt;/span&gt;rewrite

&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; then slip the following in your environment.rb&lt;/span&gt;

config.&lt;span class=&quot;Entity&quot;&gt;gem&lt;/span&gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;rack-rewrite&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&gt;~&amp;gt; 0.1.2&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;rack-rewrite&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
config.&lt;span class=&quot;Entity&quot;&gt;middleware&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;insert_before&lt;/span&gt;(&lt;span class=&quot;Support&quot;&gt;Rack&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;Lock&lt;/span&gt;, &lt;span class=&quot;Support&quot;&gt;Rack&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;Rewrite&lt;/span&gt;) &lt;span class=&quot;Keyword&quot;&gt;do&lt;/span&gt;
  r301 &lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;%r{&lt;/span&gt;^/&lt;span class=&quot;StringRegexp&quot;&gt;&lt;span class=&quot;StringRegexp&quot;&gt;(&lt;/span&gt;.*&lt;span class=&quot;StringRegexp&quot;&gt;)&lt;/span&gt;&lt;/span&gt;/$&lt;span class=&quot;StringRegexp&quot;&gt;}&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;/$1&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
3) Other ways? Leave me some feedback.
&lt;/p&gt;

&lt;p&gt;
Now you should start to see only /page hits in your google analytics and no more /page/
&lt;/p&gt;

&lt;p&gt;Cool.&lt;/p&gt;
&lt;/div&gt;</description>
      <author>Daniel LaBare</author>
      <pubDate>Wed, 14 Oct 2009 01:42:54 +0000</pubDate>
      <link>http://elctech.com/articles/how-to-remove-trailing-slashes-to-get-better-analytics-on-your-page-views</link>
      <guid>http://elctech.com/articles/how-to-remove-trailing-slashes-to-get-better-analytics-on-your-page-views</guid>
    </item>
    <item>
      <title>Custom Validations for Polymorphic Associatied Models</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;I recently needed custom validations for a polymorphically associated model, but only for certain polymorphic parents. Lets looks at an example, take the &lt;a href=&quot;http://robots.thoughtbot.com/post/159808315/a-compromise&quot; target=&quot;_blank&quot;&gt;acts_as_addressable plugin&lt;/a&gt;, an oldie but a goodie, it lets you attach addresses to all sorts of models. That is a great and extremely useful pattern, I use it all the time. But requirements can't always stay nice and polymorphic freindly. So we have to know when and how to extend the associations features and when to split the models. But all I needed was different validations for different models, so no need to split. Its simple, just utilize the if option on the validations and the model name stored in the addressable_type column.&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Variable&quot;&gt;SKIP_VALIDATIONS_FOR&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;[&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;Widget&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&gt;Sprocket&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;]

validates_presence_of &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;street1&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;city&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;postal_code&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;country&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;if&lt;/span&gt;=&amp;gt; &lt;span class=&quot;Support&quot;&gt;Proc&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt; {|&lt;span class=&quot;Variable&quot;&gt;obj&lt;/span&gt;| &lt;span class=&quot;Keyword&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;Variable&quot;&gt;SKIP_VALIDATIONS_FOR&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;include?&lt;/span&gt;(obj.&lt;span class=&quot;Entity&quot;&gt;addressable_type&lt;/span&gt;)}
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;This is a pretty simple example, but could easily be expanded to fit different requirements.&lt;/p&gt;
&lt;/div&gt;</description>
      <author>Nicholaus</author>
      <pubDate>Tue, 13 Oct 2009 18:25:31 +0000</pubDate>
      <link>http://elctech.com/snippets/custom-validations-for-polymorphic-associatied-models</link>
      <guid>http://elctech.com/snippets/custom-validations-for-polymorphic-associatied-models</guid>
    </item>
    <item>
      <title>Floodgates opened to iPhone development</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;
For as active as iPhone application development community is, achieving success in iTunes has been an elusive affair for those who participate in this vertical.  The two main obstacles presented to anyone who wants to create an iPhone applications are: one, finding resources/developers with the right skill set; and two, marketing the application after the application has been submitted.  The bad news is Apple keeps iTunes a black box.  Unless your application has been reviewed or mentioned on review sites or blogs, no one will be able to find your application outside of iTunes.  This makes marketing your application relatively difficult.  Here's the good news: the cost to build an iPhone application should come down substantially as it no longer requires a developer with an exclusive knowledge to a specific technology to build an application for iPhone.
&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;
When Apple first announced to openly accept applications from developers, the prerequisite for the developer is a somewhat extensive knowledge in a language called &quot;Objective-C.&quot;  For a short while, it would seem as though the developers who could produce Objective-C codes were superstars that also came with a superstar price tag.  Such stardom, however, did not last.  When 
&lt;a href=&quot;http://phonegap.com&quot;&gt;PhoneGap&lt;/a&gt;
 was introduced as an open source development tool for iPhone via JavaScript, the web development community devoured it like salmon to a hungry bear.  Shortly after PhoneGap's success, 
&lt;a href=&quot;http://www.mono-project.com/&quot;&gt;Mono framework&lt;/a&gt;  
was released in the commercial sector that provided the necessary development tools to the vast number of C# developers across multiple platforms.  And to unhinge the final bar from the floodgates, Adobe has 
&lt;a href=&quot;http://www.informationweek.com/news/internet/webdev/showArticle.jhtml?articleID=220301118&quot;&gt;just announced&lt;/a&gt; 
that the next release of Flash is capable of compiling a flash project directly into native iPhone application.  Simply put, a project can go from design to finish without even being touched by a developer.
&lt;/p&gt;
&lt;p&gt;
The implication for this phenomenon is a curious one: how will Apple respond to the rush of new applications when the floodgates are finally open?  Will Apple still be able to keep its manual review process intact?  When the market is saturated with developers and applications, will Apple be able to to maintain iTunes exclusive distribution channel and continue to motivate merchants to participate? 
&lt;/p&gt;
&lt;p&gt;
How all of this will affect Apple or iPhone developers is yet to be seen.  However, one thing that seems to be true is that when given enough demands, people will find ways to liberate a technology regardless of how businesses are structured around it. 
&lt;/p&gt;</description>
      <author>Rick</author>
      <pubDate>Mon, 12 Oct 2009 18:35:54 +0000</pubDate>
      <link>http://elctech.com/articles/floodgates-opened-to-iphone-development</link>
      <guid>http://elctech.com/articles/floodgates-opened-to-iphone-development</guid>
    </item>
    <item>
      <title>Make your buttons look super awesome</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;
  Back in April, &lt;a href=&quot;http://www.zurb.com&quot; target=&quot;_blank&quot;&gt;ZURB&lt;/a&gt; published &lt;a href=&quot;http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba&quot; target=&quot;_blank&quot;&gt;the super awesome buttons&lt;/a&gt; to showcase what can now be done with CSS and RGBA.  They are so awesome!  They still look like images but loading speed and maintainability continues to benefit from normal HTML buttons.  Below is what they look like:
&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://www.zurb.com/blog_uploads/0000/0485/buttons-02.html&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://elccore.s3.amazonaws.com/29/876/super-awesome-buttons-all.png&quot; alt=&quot;Super-awesome-buttons-all&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;
I started using these buttons in some of our projects and extended them to improve the cross browser compatibility.  I added a nicer design for when the buttons get clicked, and removed the necessity to set to different background colors for different states of the buttons.
&lt;/p&gt;
&lt;p&gt;
Here is how the even more awesome buttons look like, click'em!
&lt;/p&gt;

&lt;link href=&quot;http://elccore.s3.amazonaws.com/awesome_buttons/awesome-buttons.css&quot; rel=&quot;stylesheet&quot; media=&quot;all&quot; type=&quot;text/css&quot; /&gt;
	&lt;style type=&quot;text/css&quot;&gt;  		
  	.awesome.blue {
      background-color: #0A50FF !important;
      }
      .awesome.red {
      background-color: #e33100 !important;
      }
      .awesome.green {
      background-color: #3ACC00 !important;
      }
a.awesome {
text-decoration: none !important;
}
    &lt;/style&gt;

&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot;&gt;
    
      awesome_buttons = awesome_links = [
        ['now I\'m awesome', 'awesome medium button'],
        ['wow, huge!', 'awesome large button'],
        ['small but awesome', 'awesome small button'],
        ['so much color', 'awesome green button'],
        ['end even more', 'awesome blue button'],
        ['I could do it all day long', 'awesome huge red button'],
        ['Let\'s do it again!', '']
      ]
      awesome_buttons_index = awesome_links_index = 0
    
      function awesome_button(o) {
        o.value = awesome_buttons[awesome_buttons_index][0]
        o.className = awesome_buttons[awesome_buttons_index][1]
        awesome_buttons_index++
        if (awesome_buttons_index == awesome_buttons.length) awesome_buttons_index = 0
        return false
      }
      function awesome_link(o) {
        o.innerHTML = awesome_buttons[awesome_links_index][0]
        o.className = awesome_links[awesome_links_index][1]
        awesome_links_index++
        if (awesome_links_index == awesome_links.length) awesome_links_index = 0
        return false
      }
    &lt;/script&gt;

		  &lt;p style=&quot;margin: 2em 0; text-align: center&quot;&gt;
		    &lt;input name=&quot;some_name&quot; type=&quot;button&quot; value=&quot;I'm just a button - Click me&quot; onclick=&quot;return awesome_button(this)&quot; /&gt; | &lt;a href=&quot;#&quot; onclick=&quot;return awesome_link(this)&quot;&gt;I'm just a link - Click me&lt;/a&gt;
		  &lt;/p&gt;
&lt;/div&gt;

&lt;h2&gt;This is how the css magic looks like&lt;/h2&gt;
&lt;code language=&quot;css&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; set an awesome color for the buttons &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;, 
&lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;, 
&lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt; {
  &lt;span class=&quot;CssPropertyName&quot;&gt;background-color&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt;#&lt;/span&gt;111&lt;/span&gt;;
}
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; Touch the rest at your onw risk. &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;,
&lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;,
&lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt; { 

  &lt;span class=&quot;CssPropertyName&quot;&gt;font&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;inherit&lt;/span&gt;;
  &lt;span class=&quot;CssPropertyName&quot;&gt;background-repeat&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;repeat-x&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;color&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt;#&lt;/span&gt;fff&lt;/span&gt;;
  &lt;span class=&quot;CssPropertyName&quot;&gt;text-decoration&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;none&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;position&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;relative&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;cursor&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;pointer&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;border&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;font-style&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;normal&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;font-weight&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;bold&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;line-height&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;1&lt;/span&gt;; 
  
  &lt;span class=&quot;CssPropertyName&quot;&gt;padding&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 10&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 6&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;;
  &lt;span class=&quot;CssPropertyName&quot;&gt;font-size&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;13&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;;
  
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; IE only stuff &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;CssPropertyName&quot;&gt;border-bottom&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt; &lt;span class=&quot;CssPropertyValue&quot;&gt;solid&lt;/span&gt; &lt;span class=&quot;CssPropertyValue&quot;&gt;transparent&lt;/span&gt;\&lt;span class=&quot;CssAdditionalConstants&quot;&gt;9&lt;/span&gt;;
  
  
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; not all browser support these, but who cares? &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;CssPropertyName&quot;&gt;text-shadow&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;CssAdditionalConstants&quot;&gt;-1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt; rgba(&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0.25&lt;/span&gt;), &lt;span class=&quot;CssAdditionalConstants&quot;&gt;-2&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt; rgba(&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0.25&lt;/span&gt;); 
  &lt;span class=&quot;CssPropertyName&quot;&gt;border&lt;/span&gt;-radius: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; 
  -moz-&lt;span class=&quot;CssPropertyName&quot;&gt;border&lt;/span&gt;-radius: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; 
  -webkit-&lt;span class=&quot;CssPropertyName&quot;&gt;border&lt;/span&gt;-radius: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; 
  -moz-box-shadow: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt; rgba(&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0.5&lt;/span&gt;); 
  -webkit-box-shadow: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt; rgba(&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0.5&lt;/span&gt;);
  
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; one image for all states &lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;     see http://www.alistapart.com/articles/sprites &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;CssPropertyName&quot;&gt;background-image&lt;/span&gt;: &lt;span class=&quot;SupportFunction&quot;&gt;url&lt;/span&gt;(&lt;span class=&quot;Variable&quot;&gt;awesome-overlay-sprite.png&lt;/span&gt;);
  &lt;span class=&quot;CssPropertyName&quot;&gt;background-position&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 0&lt;/span&gt;;
  
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; cross browser inline block hack &lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;     see http://blog.mozilla.com/webdev/2009/02/20/cross-browser-inline-block/ &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;CssPropertyName&quot;&gt;display&lt;/span&gt;: -moz-&lt;span class=&quot;CssPropertyValue&quot;&gt;inline&lt;/span&gt;-stack;
  &lt;span class=&quot;CssPropertyName&quot;&gt;display&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;inline-block&lt;/span&gt;;
  &lt;span class=&quot;CssPropertyName&quot;&gt;vertical-align&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;middle&lt;/span&gt;;
  *&lt;span class=&quot;CssPropertyName&quot;&gt;display&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;inline&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;!important&lt;/span&gt;;
  &lt;span class=&quot;CssPropertyName&quot;&gt;position&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;relative&lt;/span&gt;;
  
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; help IE to calm down a bit &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  zoom: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;1&lt;/span&gt;;
  
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt;disable text selection (Firefox only)&lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  -moz-user-select: &lt;span class=&quot;CssPropertyValue&quot;&gt;none&lt;/span&gt;;
}
&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; hide selection background color &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;::&lt;/span&gt;selection&lt;/span&gt; {
	&lt;span class=&quot;CssPropertyName&quot;&gt;background&lt;/span&gt;: &lt;span class=&quot;CssPropertyValue&quot;&gt;transparent&lt;/span&gt;;
}

&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;hover&lt;/span&gt;,
&lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;hover&lt;/span&gt;,
&lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;hover&lt;/span&gt; {
  &lt;span class=&quot;CssPropertyName&quot;&gt;background-position&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;CssAdditionalConstants&quot;&gt;-50&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; 
  &lt;span class=&quot;CssPropertyName&quot;&gt;color&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt;#&lt;/span&gt;fff&lt;/span&gt;;
}
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;,
&lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;,
&lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;	{ 
  &lt;span class=&quot;CssPropertyName&quot;&gt;background-position&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 100&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;%&lt;/span&gt;; 
  -moz-box-shadow: &lt;span class=&quot;CssPropertyValue&quot;&gt;inset&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 0&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 2&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt; rgba(&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;,&lt;span class=&quot;CssAdditionalConstants&quot;&gt;0.7&lt;/span&gt;); 
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; unfortunately, Safari seems not to support inset yet &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  -webkit-box-shadow: &lt;span class=&quot;CssPropertyValue&quot;&gt;none&lt;/span&gt;;
  
  &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; IE only stuff &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;CssPropertyName&quot;&gt;border-bottom&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;0&lt;/span&gt;\&lt;span class=&quot;CssAdditionalConstants&quot;&gt;9&lt;/span&gt;;
  &lt;span class=&quot;CssPropertyName&quot;&gt;border-top&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt; &lt;span class=&quot;CssPropertyValue&quot;&gt;solid&lt;/span&gt; &lt;span class=&quot;CssAdditionalConstants&quot;&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt;#&lt;/span&gt;666&lt;/span&gt;\&lt;span class=&quot;CssAdditionalConstants&quot;&gt;9&lt;/span&gt;;
}

&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;small&lt;/span&gt;,         &lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;small&lt;/span&gt;,          &lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;small&lt;/span&gt; 	        { &lt;span class=&quot;CssPropertyName&quot;&gt;padding&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 7&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; &lt;span class=&quot;CssPropertyName&quot;&gt;font-size&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; }
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;small&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;,  &lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;small&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;,   &lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;small&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;	  { &lt;span class=&quot;CssPropertyName&quot;&gt;padding&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 7&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 4&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; }
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;medium&lt;/span&gt;,        &lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;medium&lt;/span&gt;,         &lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;medium&lt;/span&gt;         { &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;/*&lt;/span&gt; default &lt;span class=&quot;Comment&quot;&gt;*/&lt;/span&gt;&lt;/span&gt; }
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;medium&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;, &lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;medium&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;,  &lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;medium&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;	{ &lt;span class=&quot;CssPropertyName&quot;&gt;padding&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 10&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 5&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; }
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;large&lt;/span&gt;,         &lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;large&lt;/span&gt;,          &lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;large&lt;/span&gt; 	        { &lt;span class=&quot;CssPropertyName&quot;&gt;padding&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 14&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 9&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; &lt;span class=&quot;CssPropertyName&quot;&gt;font-size&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; }
&lt;span class=&quot;CssTagName&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;large&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;,  &lt;span class=&quot;CssTagName&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;large&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;,   &lt;span class=&quot;CssTagName&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;awesome&lt;/span&gt;&lt;span class=&quot;CssClass&quot;&gt;&lt;span class=&quot;CssClass&quot;&gt;.&lt;/span&gt;large&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;:&lt;/span&gt;active&lt;/span&gt;	  { &lt;span class=&quot;CssPropertyName&quot;&gt;padding&lt;/span&gt;: &lt;span class=&quot;CssAdditionalConstants&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 14&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;&lt;span class=&quot;CssAdditionalConstants&quot;&gt; 8&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;px&lt;/span&gt;; }
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Turn a &lt;button&gt;button&lt;/button&gt; or a &lt;a href=&quot;#&quot;&gt;Link&lt;/a&gt; just by adding the 'awesome button' classes:&lt;/p&gt;

&lt;code language=&quot;html&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;button before&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;&amp;amp;&lt;/span&gt;rarr&lt;span class=&quot;Constant&quot;&gt;;&lt;/span&gt;&lt;/span&gt; 
&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;button&lt;/span&gt; &lt;span class=&quot;MetaTagInline&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;awesome button&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;button after&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;br&lt;/span&gt; /&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;MetaTagInline&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;awesome button&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;MetaTagInline&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;submit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;MetaTagInline&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;submit before&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; /&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;&amp;amp;&lt;/span&gt;rarr&lt;span class=&quot;Constant&quot;&gt;;&lt;/span&gt;&lt;/span&gt; 
&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;MetaTagInline&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;submit&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;MetaTagInline&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;submit after&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; /&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;br&lt;/span&gt; /&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;MetaTagInline&quot;&gt;href&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;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Link before&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;&amp;amp;&lt;/span&gt;rarr&lt;span class=&quot;Constant&quot;&gt;;&lt;/span&gt;&lt;/span&gt; 
&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;MetaTagInline&quot;&gt;href&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;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;MetaTagInline&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;awesome button&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Link after&lt;span class=&quot;MetaTagInline&quot;&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;MetaTagInline&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p style=&quot;text-align: center&quot;&gt;&lt;button&gt;button before&lt;/button&gt; &amp;rarr;  &lt;button class=&quot;awesome medium button&quot;&gt;button after&lt;/button&gt;&lt;br /&gt;
&lt;input type=&quot;submit&quot; value=&quot;submit before&quot; /&gt; &amp;rarr; &lt;input class=&quot;awesome medium button&quot; type=&quot;submit&quot; value=&quot;submit after&quot; /&gt;&lt;br /&gt;
&lt;a href=&quot;#&quot;&gt;Link before&lt;/a&gt; &amp;rarr; &lt;a href=&quot;#&quot; class=&quot;awesome medium button&quot;&gt;Link after&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Awesome Blueprint Plugin&lt;/h2&gt;

&lt;p&gt;These super awesome buttons play well together with &lt;a href=&quot;http://www.blueprintcss.org/&quot; target=&quot;_blank&quot;&gt;the blueprint css framework&lt;/a&gt;. Simply &lt;a href=&quot;http://github.com/gr2m/awesome-buttons&quot;&gt;get the files from github&lt;/a&gt; and put them in you blueprint/plugins folder. Works awesome.&lt;/p&gt;

&lt;h2&gt;Demo&lt;/h2&gt;

&lt;p&gt;You can find the latest version of the demo in &lt;a href=&quot;http://github.com/gr2m/awesome-buttons&quot; target=&quot;_blank&quot;&gt;the git repository&lt;/a&gt; or you can open it &lt;a href=&quot;http://elccore.s3.amazonaws.com/awesome_buttons/demo.html&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Let us know what you think!&lt;/p&gt;</description>
      <author>Gregor Martynus</author>
      <pubDate>Fri, 09 Oct 2009 16:24:41 +0000</pubDate>
      <link>http://elctech.com/snippets/make-your-buttons-look-super-awesome</link>
      <guid>http://elctech.com/snippets/make-your-buttons-look-super-awesome</guid>
    </item>
    <item>
      <title>grepping the logs with your ears</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;This is a simple obvious idea, but for some reason I had never done it until recently.  My problem, I had a callback that I thought was firing way too often, but I didn't want to grep the logs constantly looking back and forth from the app to the console.  So I took advantage of the OSX 'say' command.&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Entity&quot;&gt;system&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;say &amp;quot;in here&amp;quot;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;)
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;
Just jam that in the code you want to monitor and listen for the noise.  There are many &lt;a href=&quot;http://www.gabrielserafini.com/archives/2008/08/19/mac-os-x-voices-for-using-with-the-say-command/&quot; target=&quot;_blank&quot;&gt;voices.&lt;/a&gt;  Also, it can also be a fun easter egg for your teammates by checking git author name and presenting them with a special message... but I would never recommend that :)
&lt;/p&gt;
&lt;/div&gt;</description>
      <author>John Eberly</author>
      <pubDate>Thu, 08 Oct 2009 17:45:04 +0000</pubDate>
      <link>http://elctech.com/articles/grepping-the-logs-with-your-ears</link>
      <guid>http://elctech.com/articles/grepping-the-logs-with-your-ears</guid>
    </item>
    <item>
      <title>Copying files between S3 accounts</title>
      <description>&lt;div class=&quot;preface&quot;&gt;
&lt;p&gt;Recently, I had to transfer a all files from one S3 account to another one. Since I didn't like to bother Amazon with my petty problems. I decided to use a ruby script to do it. Here's the script and some steps I took to do it.&lt;/p&gt;
&lt;/div&gt;

&lt;h2&gt;Setup&lt;/h2&gt;
&lt;div&gt;
&lt;p&gt;First thing we need to do is to get a list of the buckets we're using. Since each bucket has to be uniquely named, we need to figure out what to name our corresponding buckets in the new S3 account. 
&lt;/p&gt;
&lt;p&gt;
 Start up irb. Time for some digging.
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;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;
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;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;right_aws&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; s3&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Support&quot;&gt;RightAws&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;S3Interface&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;(old_aws_id, old_aws_key)
=&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;rightaws::s3interface:0x1a56490 ...stuff...&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; buckets&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;s3.&lt;span class=&quot;Entity&quot;&gt;list_all_my_buckets&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;collect&lt;/span&gt;{|&lt;span class=&quot;Variable&quot;&gt;b&lt;/span&gt;| b[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;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;old_bucket1&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;old_bucket2&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;]
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;rightaws::&lt;span class=&quot;Entity&quot;&gt;s3interface&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;0x1a56490&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt; Looks like we have 2 buckets to copy: &lt;strong&gt;old_bucket1&lt;/strong&gt; and &lt;strong&gt;old_bucket2&lt;/strong&gt;. Let's make new buckets for our new account: &lt;strong&gt;new_bucket1&lt;/strong&gt; and &lt;strong&gt;new_bucket2&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;
Back in console: 
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; s3_new&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Support&quot;&gt;RightAws&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;S3Interface&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;(new_aws_id, new_aws_key)
=&amp;gt; &lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;&amp;lt;rightaws::s3interface:0x1a5649a ...stuff...&amp;gt;&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; s3_new.&lt;span class=&quot;Entity&quot;&gt;create_bucket&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;new_bucket1&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;location&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;us&lt;/span&gt;)
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; s3_new.&lt;span class=&quot;Entity&quot;&gt;create_bucket&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;new_bucket2&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;location&lt;/span&gt; =&amp;gt; &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;us&lt;/span&gt;)
=&amp;gt; &lt;span class=&quot;Constant&quot;&gt;true&lt;/span&gt;
&lt;span class=&quot;Keyword&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;/&lt;/span&gt;rightaws::&lt;span class=&quot;Entity&quot;&gt;s3interface&lt;/span&gt;:&lt;span class=&quot;Constant&quot;&gt;0x1a5649a&lt;/span&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;/div&gt;

&lt;div&gt;
&lt;p&gt;
	Now, we need to peek at the ACL settings for the files so we'll know how to modify the permissions for the new bucket. 
&lt;/p&gt;
&lt;p&gt;
	In console:
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; key&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;s3.&lt;span class=&quot;Entity&quot;&gt;list_all_my_buckets&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;
=&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;owner_display_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;my.old.name&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;creation_date&lt;/span&gt;=&amp;gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;2009-08-06T23:32:38.000Z&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;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;old_bucket1&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;owner_id&lt;/span&gt;=&amp;gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000001&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;
Make note of the old &lt;strong&gt;owner_display_name&lt;/strong&gt; and &lt;strong&gt;owner_id&lt;/strong&gt;: &lt;strong&gt;my.old.name&lt;/strong&gt;, &lt;strong&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000001&lt;/strong&gt;. 
We will need to replace these with our new ones during the process.
&lt;/p&gt;

&lt;p&gt;
Now we get our new owner_id and owner_display_name, the same way.
&lt;/p&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Keyword&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; s3_new.&lt;span class=&quot;Entity&quot;&gt;list_all_my_buckets&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;first&lt;/span&gt;
=&amp;gt; {&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;owner_display_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;my.new.name&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;creation_date&lt;/span&gt;=&amp;gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;2009-08-06T23:32:38.000Z&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;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;new_bucket1&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;owner_id&lt;/span&gt;=&amp;gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000002&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;}
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;
Here's our new owner_display_name and owner_id: &lt;strong&gt;my.new.name&lt;/strong&gt;, &lt;strong&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000002&lt;/strong&gt;. 
&lt;/p&gt;
&lt;/div&gt;

&lt;h2&gt; The Code &lt;/h2&gt;
&lt;div&gt;
&lt;p&gt; Now here's the script to run. I recommend doing this on an EC2 machine, because Amazon won't charge for bandwidth within the EC2 and S3 networks. I also suggest running it on a screen session so you can leave the script alone on the server.&lt;/p&gt; 
&lt;ul&gt;&lt;li&gt;The script will loop through each item in your buckets.&lt;/li&gt; 
	&lt;li&gt;Copy the item over to the new corresponding bucket.&lt;/li&gt;
	&lt;li&gt;Strip out the ACL from the old one and reformat it for the new owner. 
	&lt;li&gt;Update the ACL permissions on the new file.&lt;/li&gt;
&lt;/li&gt;&lt;/ul&gt;

&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;!/usr/bin/ruby&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;right_aws&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;

oldAWS &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;RightAws&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;S3Interface&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;(old_aws_id, old_aws_key)
newAWS &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;RightAws&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;S3Interface&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;new_aws_id, new_aws_key)&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;newS3=RightAws::S3.new(new_aws_id, new_aws_key)&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;bucket_mapping={&amp;quot;old_bucket1&amp;quot; =&amp;gt; &amp;quot;new_bucket1&amp;quot;,&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;&amp;quot;old_bucket2&amp;quot; =&amp;gt; &amp;quot;new_bucket2&amp;quot;&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 class=&quot;String&quot;&gt;# ACL property differences&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;old_owner_id=&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000001&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;new_owner_id=&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000002&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&gt;
&lt;span class=&quot;String&quot;&gt;old_disp_name=&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;my.&lt;span class=&quot;Entity&quot;&gt;old&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;name&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;new_disp_name=&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;my.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;name&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&gt;
&lt;span class=&quot;String&quot;&gt;bucket_mapping.each do |old_bucket, new_bucket|&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;  # get all keys for old bucket by looping through sets of max keys (1000) amazon gives&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;  newS3Bucket=newS3.bucket(new_bucket)&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;  oldAWS.incrementally_list_bucket(old_bucket) do |key_set|&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;    # loop through content of key_set which contains keys&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;    key_set[:contents].each do |key|&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;      # if key already exists, don&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;t copy over
      &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; newS3Bucket.&lt;span class=&quot;Entity&quot;&gt;key&lt;/span&gt;(key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;]).&lt;span class=&quot;Entity&quot;&gt;exists?&lt;/span&gt;
        puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;new_bucket&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;key&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; already exists. Skipping...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
      &lt;span class=&quot;Keyword&quot;&gt;else&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;        &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; download data and header from old bucket&lt;/span&gt;
        puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Copying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;old_bucket&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;key&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
        retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
          data&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;oldAWS.&lt;span class=&quot;Entity&quot;&gt;get_object&lt;/span&gt;(old_bucket,key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;])
        &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
          puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot download, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
          retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
          &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
     
        retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
          headers&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;oldAWS.&lt;span class=&quot;Entity&quot;&gt;head&lt;/span&gt;(old_bucket,key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;])
        &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
          puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot get header, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
          retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
          &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;Comment&quot;&gt;        &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; upload key to bucket&lt;/span&gt;
        puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Putting to &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;new_bucket&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;key&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
        retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
          newAWS.&lt;span class=&quot;Entity&quot;&gt;put&lt;/span&gt;(new_bucket, key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;], data, headers)
        &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
          puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot put object, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
          retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
          &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;Comment&quot;&gt;        &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; copy permissions to new Bucket&lt;/span&gt;
        retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
          acl_prop&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;oldAWS.&lt;span class=&quot;Entity&quot;&gt;get_acl&lt;/span&gt;(old_bucket, key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;])
        &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
          puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot get ACL, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
          retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
          &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
     
&lt;span class=&quot;Comment&quot;&gt;        &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Replace Owner ID and Display name for new bucket&lt;/span&gt;
        puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;old ACL &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;acl_prop&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
        acl_prop[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;].&lt;span class=&quot;Entity&quot;&gt;gsub!&lt;/span&gt;(old_owner_id,new_owner_id)
        acl_prop[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;].&lt;span class=&quot;Entity&quot;&gt;gsub!&lt;/span&gt;(old_disp_name,new_disp_name)
        puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new ACL &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;acl_prop&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
   
        puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;changing ACL&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
     
        retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
        &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
          newAWS.&lt;span class=&quot;Entity&quot;&gt;put_acl&lt;/span&gt;(new_bucket, key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;], acl_prop[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;])
        &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
          puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot update ACL, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
          retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
          &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&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;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;/code&gt;
&lt;/div&gt;

&lt;p&gt; That's basically all there is to it. If you want to do a check if all the files are there, use &lt;a href=&quot;http://www.elctech.com/snippets/counting-total-number-of-objects-in-s3&quot;&gt;this script&lt;/a&gt;. Now I'm going to explain each part of the script. So you probably don't want to stay for this part. &lt;/p&gt;

&lt;h2&gt; Breakdown &lt;/h2&gt;
&lt;div&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;&lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt;!/usr/bin/ruby&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;right_aws&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;

oldAWS &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;RightAws&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;S3Interface&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;(old_aws_id, old_aws_key)
newAWS &lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;Support&quot;&gt;RightAws&lt;/span&gt;::&lt;span class=&quot;Entity&quot;&gt;S3Interface&lt;/span&gt;.&lt;span class=&quot;Entity&quot;&gt;new&lt;/span&gt;(&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;new_aws_id, new_aws_key)&lt;/span&gt;
&lt;span class=&quot;String&quot;&gt;newS3=RightAws::S3.new(new_aws_id, new_aws_key)&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Initialize connections to S3. I used RightAws::S3 object to able to access the bucket individually.
&lt;/p&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;bucket_mapping&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;{&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;old_bucket1&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new_bucket1&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;old_bucket2&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new_bucket2&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
}
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Map the old buckets to the new corresponding ones.&lt;/p&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;old_owner_id&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000001&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
new_owner_id&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;123abcdefghijklmnoprxyz45600000000000000000000000000000000000002&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;

old_disp_name&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;my.old.name&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
new_disp_name&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;my.new.name&lt;span class=&quot;String&quot;&gt;'&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Store the ACL credentials for the old and new accounts. &lt;/p&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;bucket_mapping.&lt;span class=&quot;Entity&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;old_bucket&lt;/span&gt;, &lt;span class=&quot;Variable&quot;&gt;new_bucket&lt;/span&gt;|
&lt;span class=&quot;Comment&quot;&gt;  &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; get all keys for old bucket by looping through sets of max keys (1000) amazon gives&lt;/span&gt;
  newS3Bucket&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;newS3.&lt;span class=&quot;Entity&quot;&gt;bucket&lt;/span&gt;(new_bucket)
	...
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;We loop through each of the buckets in our hash, grab the new corresponding bucket&lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;  oldAWS.&lt;span class=&quot;Entity&quot;&gt;incrementally_list_bucket&lt;/span&gt;(old_bucket) &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;key_set&lt;/span&gt;|
    key_set[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;contents&lt;/span&gt;].&lt;span class=&quot;Entity&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;do &lt;/span&gt;|&lt;span class=&quot;Variable&quot;&gt;key&lt;/span&gt;|
	...
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Since Amazon only lets you get 1000 keys max at one time, we use right_aws's incrementally_list_bucket method to get eventually loop through all the keys in that bucket. Then we loop through each set of keys. &lt;/p&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;	  &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; newS3Bucket.&lt;span class=&quot;Entity&quot;&gt;key&lt;/span&gt;(key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;]).&lt;span class=&quot;Entity&quot;&gt;exists?&lt;/span&gt;
	    puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;new_bucket&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;key&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; already exists. Skipping...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
	  &lt;span class=&quot;Keyword&quot;&gt;else&lt;/span&gt;
&lt;span class=&quot;Comment&quot;&gt;	    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; download data and header from old bucket&lt;/span&gt;
	    puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Copying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;old_bucket&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;key&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
	    retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
	    &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
	      data&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;oldAWS.&lt;span class=&quot;Entity&quot;&gt;get_object&lt;/span&gt;(old_bucket,key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;])
	    &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
	      puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot download, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
	      retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
	      &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
	    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

	    retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
	    &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
	      headers&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;oldAWS.&lt;span class=&quot;Entity&quot;&gt;head&lt;/span&gt;(old_bucket,key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;])
	    &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
	      puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot get header, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
	      retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
	      &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
	    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;Comment&quot;&gt;	    &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; upload key to bucket&lt;/span&gt;
	    puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;Putting to &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;new_bucket&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;key&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
	    retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
	    &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
	      newAWS.&lt;span class=&quot;Entity&quot;&gt;put&lt;/span&gt;(new_bucket, key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;], data, headers)
	    &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
	      puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot put object, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
	      retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
	      &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
	    &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
	...
&lt;/pre&gt;&lt;/code&gt;

&lt;p&gt;Now, we only copy over the file if it's not there, and we copy over the header from the old file to the new one. &lt;/p&gt;
&lt;/div&gt;

&lt;div&gt;
&lt;code language=&quot;ruby&quot;&gt;&lt;pre class=&quot;sunburst&quot;&gt;       retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
       &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
         acl_prop&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;oldAWS.&lt;span class=&quot;Entity&quot;&gt;get_acl&lt;/span&gt;(old_bucket, key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;])
       &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
         puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot get ACL, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
         retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
         &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
       &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;Comment&quot;&gt;       &lt;span class=&quot;Comment&quot;&gt;#&lt;/span&gt; Replace Owner ID and Display name for new bucket&lt;/span&gt;
       puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;old ACL &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;acl_prop&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
       acl_prop[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;].&lt;span class=&quot;Entity&quot;&gt;gsub!&lt;/span&gt;(old_owner_id,new_owner_id)
       acl_prop[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;].&lt;span class=&quot;Entity&quot;&gt;gsub!&lt;/span&gt;(old_disp_name,new_disp_name)
       puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;new ACL &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;acl_prop&lt;span class=&quot;StringEmbeddedSource&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;&lt;span class=&quot;StringConstant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;

       puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;changing ACL&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;

       retries&lt;span class=&quot;Keyword&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;Constant&quot;&gt;0&lt;/span&gt;
       &lt;span class=&quot;Keyword&quot;&gt;begin&lt;/span&gt;
         newAWS.&lt;span class=&quot;Entity&quot;&gt;put_acl&lt;/span&gt;(new_bucket, key[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;key&lt;/span&gt;], acl_prop[&lt;span class=&quot;Constant&quot;&gt;&lt;span class=&quot;Constant&quot;&gt;:&lt;/span&gt;object&lt;/span&gt;])
       &lt;span class=&quot;Keyword&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;Variable&quot;&gt;Exception&lt;/span&gt; =&amp;gt; e
         puts &lt;span class=&quot;String&quot;&gt;&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;cannot update ACL, &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;e&lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;Entity&quot;&gt;inspect&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;StringConstant&quot;&gt;\n&lt;/span&gt;retrying &lt;span class=&quot;StringEmbeddedSource&quot;&gt;&lt;span class=&quot;StringEmbeddedSource&quot;&gt;#{&lt;/span&gt;retries&lt;span class=&quot;StringEmbeddedSource&quot;&gt;}&lt;/span&gt;&lt;/span&gt; out of 10 times...&lt;span class=&quot;String&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;
         retries &lt;span class=&quot;Keyword&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;1&lt;/span&gt;
         &lt;span class=&quot;Keyword&quot;&gt;retry&lt;/span&gt; &lt;span class=&quot;Keyword&quot;&gt;if&lt;/span&gt; retries &lt;span class=&quot;Keyword&quot;&gt;&amp;lt;=&lt;/span&gt; &lt;span class=&quot;Constant&quot;&gt;10&lt;/span&gt;
       &lt;span class=&quot;Keyword&quot;&gt;end&lt;/span&gt;
...
&lt;/pre&gt;&lt;/code&gt;
&lt;p&gt;Finally, we get the old ACL, which is an XML file. We then gsub the old values with the new values and replace the new file's ACL.&lt;/p&gt;
&lt;/div&gt;

&lt;p&gt;Wash, rinse, repeat.&lt;/p&gt;
</description>
      <author>Alex Chee</author>
      <pubDate>Thu, 08 Oct 2009 01:42:52 +0000</pubDate>
      <link>http://elctech.com/tutorials/copying-files-between-s3-accounts</link>
      <guid>http://elctech.com/tutorials/copying-files-between-s3-accounts</guid>
    </item>
  </channel>
</rss>
