<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Wuputah</title>
    <link>http://wuputah.com</link>
    <language>en</language>
    <webMaster>hi@wuputah.com (Wuputah, LLC)</webMaster>
    <copyright>Copyright 2008-2009</copyright>
    <ttl>60</ttl>
    <pubDate>Sat, 06 Dec 2008 06:01:17 GMT</pubDate>
    <description>The Soapbox</description>
    <item>
      <title>Premailer: compatible HTML emails without the hassle</title>
      <link>http://wuputah.com/archives/2008/12/6/premailer_compatible_html_emails_without/</link>
      <pubDate>Sat, 06 Dec 2008 05:40:00 GMT</pubDate>
      <guid>http://wuputah.com/archives/2008/12/6/premailer_compatible_html_emails_without/</guid>
      <author>jd@wuputah.com (JD)</author>
      <description>&lt;p&gt;If you&amp;#8217;ve ever dealt with &lt;span class="caps"&gt;HTML&lt;/span&gt; emails, you know the pain of dealing with various mail client and webmail compatibility issues. One of the biggest issues is &lt;span class="caps"&gt;CSS&lt;/span&gt;: for instance, only inline &lt;span class="caps"&gt;CSS&lt;/span&gt; (via the &lt;code&gt;style="..."&lt;/code&gt; attribute) is compatible will GMail.&lt;/p&gt;&lt;p&gt;Enter &lt;a href="http://code.google.com/p/premailer/"&gt;premailer&lt;/a&gt;. Premailer converts a standard HTML+CSS page (supporting both &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags) into inline &lt;span class="caps"&gt;CSS&lt;/span&gt; to the best of its ability. If you&amp;#8217;re willing to take a performance hit, you can even transform your emails on the fly, allowing you to  re-use your regular views for your emails.&lt;/p&gt;&lt;p&gt;Using the code in Rails requires a bit of tweaking. Personally, I put &lt;code&gt;premailer.rb&lt;/code&gt; and &lt;code&gt;html_to_plain_text.rb&lt;/code&gt; in the &lt;code&gt;lib/&lt;/code&gt; folder in my project. I also wanted to be able to pass in a string (not a filename) to the library, so I changed line 192 from &lt;code&gt;Hpricot(open(uri))&lt;/code&gt; to &lt;code&gt;Hpricot(uri)&lt;/code&gt;.&lt;/p&gt;&lt;p&gt;In order to transform the email, I captured the entire body of the email using Rails&amp;#8217;s &lt;code&gt;capture&lt;/code&gt; method, then outputted &lt;code&gt;Premailer.new(body).to_inline_css&lt;/code&gt; at the bottom. Alternately, you can write a helper to clean it up slightly, but you&amp;#8217;ll still need to wrap your entire email in a call to your helper:&lt;/p&gt;&lt;pre&gt;def premailer(&amp;amp;block)&lt;br/&gt;  concat(Premailer.new(capture(&amp;amp;block)).to_inline_css)&lt;br/&gt;end&lt;/pre&gt;&lt;p&gt;Premailer can also convert your emails to plain text if you want to avoid maintaining a separate plain text alternative.&lt;/p&gt;&lt;p&gt;Credit for premailer goes to &lt;a href="http://dunae.ca/"&gt;Alex Dunae&lt;/a&gt;. Thanks for creating this excellent script!&lt;/p&gt;</description>
      <category domain="http://wuputah.com/archives/tags/css">css</category>
      <category domain="http://wuputah.com/archives/tags/email">email</category>
    </item>
    <item>
      <title>Basecamp time reporting script</title>
      <link>http://wuputah.com/archives/2008/12/6/basecamp_time_reporting_script/</link>
      <pubDate>Sat, 06 Dec 2008 05:27:00 GMT</pubDate>
      <guid>http://wuputah.com/archives/2008/12/6/basecamp_time_reporting_script/</guid>
      <author>jd@wuputah.com (JD)</author>
      <description>&lt;p&gt;I wrote up a simple but handy time reporting tool for Basecamp. It&amp;#8217;s a command line tool that generates a plain text report. It&amp;#8217;s still somewhat crude &amp;#8211; I&amp;#8217;d like to make it into a gem, but haven&amp;#8217;t had the chance yet.&lt;/p&gt;&lt;p&gt;Naturally, the code is &lt;a href="http://github.com/wuputah/basecamp-timereport"&gt;up on Github&lt;/a&gt;. :)&lt;/p&gt;</description>
      <category domain="http://wuputah.com/archives/tags/api">api</category>
      <category domain="http://wuputah.com/archives/tags/basecamp">basecamp</category>
    </item>
    <item>
      <title>DHH Addresses Ruby on Rails Myths</title>
      <link>http://wuputah.com/archives/2008/11/15/dhh_addresses_ruby_on_rails/</link>
      <pubDate>Sat, 15 Nov 2008 15:36:00 GMT</pubDate>
      <guid>http://wuputah.com/archives/2008/11/15/dhh_addresses_ruby_on_rails/</guid>
      <author>jd@wuputah.com (JD)</author>
      <description>&lt;p&gt;&lt;span class="caps"&gt;DHH&lt;/span&gt; is working on &lt;a href="http://www.loudthinking.com/posts/29-the-rails-myths"&gt;debunking many of the Rails myths&lt;/a&gt; that float around. If you have any questions about Rails, these are all worth reading. However, the one myth that is missing is Rails doesn&amp;#8217;t scale. While &lt;span class="caps"&gt;DHH&lt;/span&gt; rightly pointed out that he &lt;a href="http://www.loudthinking.com/arc/000479.html"&gt;debunked that years ago&lt;/a&gt;, he&amp;#8217;s &lt;a href="http://twitter.com/d2h/status/1007499302"&gt;agreed to address the myth&lt;/a&gt; as part of the series. I think the Rails community as a whole will look forward to having an authoritative reference we can use to end this myth once and for all.&lt;/p&gt;</description>
      <category domain="http://wuputah.com/archives/tags/dhh">dhh</category>
      <category domain="http://wuputah.com/archives/tags/rails">rails</category>
      <category domain="http://wuputah.com/archives/tags/scale">scale</category>
    </item>
    <item>
      <title>Conference Prices</title>
      <link>http://wuputah.com/archives/2008/10/22/conference_prices/</link>
      <pubDate>Wed, 22 Oct 2008 02:25:00 GMT</pubDate>
      <guid>http://wuputah.com/archives/2008/10/22/conference_prices/</guid>
      <author>jd@wuputah.com (JD)</author>
      <description>&lt;p&gt;Why does RailsConf or the Professional Ruby Conference here in Boston cost $800-$1200 while Paris on Rails costs just &#8364;80? RubyFringe, too, was C$650. Sure, Paris on Rails is just one day, but &#8364;80/day does not compare to the US conference prices. Why? Supply and demand? Profit?&lt;/p&gt;&lt;p&gt;(As an aside, &lt;a href="http://mtnwestrubyconf.org/"&gt;some conferences&lt;/a&gt; are actually reasonably priced. Amazing!)&lt;/p&gt;</description>
      <category domain="http://wuputah.com/archives/tags/railsconf">railsconf</category>
    </item>
    <item>
      <title>A Great Season Draws to its Close</title>
      <link>http://wuputah.com/archives/2008/10/22/a_great_season_draws_to/</link>
      <pubDate>Wed, 22 Oct 2008 01:08:00 GMT</pubDate>
      <guid>http://wuputah.com/archives/2008/10/22/a_great_season_draws_to/</guid>
      <author>jd@wuputah.com (JD)</author>
      <description>&lt;p&gt;A quick (and belated) shout out to the Boston Red Sox who lost game 7 to the Rays on Sunday. Watching the amazing comeback in game 5 was more than any fan could hope for.&lt;/p&gt;&lt;p&gt;As far as the World Series, I am going for the Rays. It would be amazing last-to-first championship. For next year, though, I think there will be a new rivalry to watch.&lt;/p&gt;</description>
      <category domain="http://wuputah.com/archives/tags/redsox">redsox</category>
    </item>
    <item>
      <title>Copying a MySQL Database, Ruby Style - Part 2</title>
      <link>http://wuputah.com/archives/2008/10/17/copying_a_mysql_database_ruby/</link>
      <pubDate>Fri, 17 Oct 2008 00:05:00 GMT</pubDate>
      <guid>http://wuputah.com/archives/2008/10/17/copying_a_mysql_database_ruby/</guid>
      <author>jd@wuputah.com (JD)</author>
      <description>&lt;p&gt;First, the new script: &lt;a href="http://gist.github.com/17372"&gt;it&amp;#8217;s pretty sweet&lt;/a&gt;. &lt;code&gt;mysql&lt;/code&gt;-style command line options, non-echo password support, the works. The most common usage is probably:&lt;/p&gt;&lt;p&gt;&lt;code&gt;$ ./mysql-copydb.rb -u username -p from_db to_db&lt;/code&gt;&lt;/p&gt;&lt;p&gt;This will prompt you for your password, just like the &lt;code&gt;mysql&lt;/code&gt; command line client does.&lt;/p&gt;&lt;p&gt;The code is organized into two classes: CopyDatabaseController, which handles option parsing and whatnot, and CopyDatabase, which does the work itself. It uses a few nice tricks, like using &lt;a href="file:///Users/jd/Documents/reference-docs/ruby/classes/Kernel.html#M005729"&gt;Kernel.at_exit&lt;/a&gt; to make sure your database connection is closed at program termination, and some yielding wrappers for locking tables and disabling keys. The functionality is nice, but in the end, the code is not all that special.&lt;/p&gt;&lt;p&gt;I have to retract something I said: sometimes it &lt;em&gt;is&lt;/em&gt; better to stop. Writing a 158-line script to copy a database is probably not the best use of your time &amp;#8211; sometimes, a procedural script is good enough.&lt;/p&gt;&lt;p&gt;And there are some downsides to a big script like this one: I&amp;#8217;ve added two additional dependencies on top of the Ruby/MySQL library: Highline and optparse. Optparse is part of the Ruby standard library, but Highline is a gem that you&amp;#8217;ll need to have to run the script. (Note that you&amp;#8217;ll already have it if you use Capistrano.)&lt;/p&gt;&lt;p&gt;However, that was not really my point. My point was your code should always be your best work: you should always design software the best you possibly can. This may not be so important when copying a database where your software is unlikely to modified or maintained, but in Rails apps, you should always think before you code.&lt;/p&gt;&lt;p&gt;That said, I learned something by writing this: my familarity with Ruby/MySQL, optparse, and Highline improved as a result. What else could I do? Well, I&amp;#8217;ve never made a Ruby gem before&amp;#8212;maybe that would be a good next step.&lt;/p&gt;</description>
      <category domain="http://wuputah.com/archives/tags/cli">cli</category>
      <category domain="http://wuputah.com/archives/tags/mysql">mysql</category>
      <category domain="http://wuputah.com/archives/tags/ruby">ruby</category>
    </item>
    <item>
      <title>Copying a MySQL Database, Ruby Style - Part 1</title>
      <link>http://wuputah.com/archives/2008/10/14/copy_tables_in_mysql_ruby_style/</link>
      <pubDate>Tue, 14 Oct 2008 00:09:00 GMT</pubDate>
      <guid>http://wuputah.com/archives/2008/10/14/copy_tables_in_mysql_ruby_style/</guid>
      <author>jd@wuputah.com (JD)</author>
      <description>&lt;p&gt;It is fairly standard practice to copy a database using mysqldump, e.g.:&lt;/p&gt;&lt;p&gt;&lt;code&gt;$ mysqldump something_production | mysql something_development&lt;/code&gt;&lt;/p&gt;&lt;p&gt;However, one realizes this is not exactly the best way to do things &amp;#8211; you&amp;#8217;re copying the data out of the database into a pipe and feeding it back in. Not to mention that if you need to provide password credentials, you are stuck either piping the output to a file first, or putting your password on the command line (which is never a good idea).&lt;/p&gt;&lt;p&gt;Out of curiosity, I Googled for a script to do what I knew was easily possible: copy the database using a few queries and a loop. I stumbled upon &lt;a href="http://www.xobni.com/bryan/2008/06/16/copy-tables-from-one-mysql-database-to-another/"&gt;this script written in &lt;span class="caps"&gt;PHP&lt;/span&gt;&lt;/a&gt;. &lt;span class="caps"&gt;PHP&lt;/span&gt; is fine, but the script left something to be desired.&lt;/p&gt;&lt;p&gt;I started to work on a Ruby version, and so far have written a basic, procedural version. It works, but it is clunky, much like the &lt;span class="caps"&gt;PHP&lt;/span&gt; script &amp;#8211; you have to open it up, type in the source and destination databases, and provide your username and password. Not to mention it is an unstructured procedural script.&lt;/p&gt;&lt;p&gt;I provide this not as a way to copy MySQL tables, but primarily as an exercise in software evolution and refactoring &amp;#8211; starting simple like this is not a bad thing, but you should never stop here. In my next post, I&amp;#8217;ll aim to make this code look as Matz intended.&lt;/p&gt;&lt;p&gt;The code is embedded below the fold, or you can get the gist on Github: &lt;a href="http://gist.github.com/16684"&gt;http://gist.github.com/16684&lt;/a&gt;&lt;/p&gt;&lt;script src="http://gist.github.com/16684.js"&gt;&lt;/script&gt;</description>
      <category domain="http://wuputah.com/archives/tags/cli">cli</category>
      <category domain="http://wuputah.com/archives/tags/mysql">mysql</category>
      <category domain="http://wuputah.com/archives/tags/ruby">ruby</category>
    </item>
  </channel>
</rss>
