<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>paolodona.com - Home</title>
  <id>tag:paolodona.com,2008:mephisto/</id>
  <generator version="0.8.0" uri="http://mephistoblog.com">Mephisto Drax</generator>
  <link href="http://paolodona.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://paolodona.com/" rel="alternate" type="text/html"/>
  <updated>2008-11-01T16:29:41Z</updated>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-10-15:17</id>
    <published>2008-10-15T21:38:00Z</published>
    <updated>2008-11-01T16:29:41Z</updated>
    <category term="import_with_load_data_in_file"/>
    <category term="rails"/>
    <category term="ruby"/>
    <link href="http://paolodona.com/2008/10/15/import_with_load_data_in_file-not-only-local" rel="alternate" type="text/html"/>
    <title>import_with_load_data_in_file: not only LOCAL</title>
<content type="html">
            &lt;p&gt;If you&#8217;re using the &lt;a href=&quot;http://github.com/paolodona/import_with_load_data_in_file&quot;&gt;import_with_load_data_in_file&lt;/a&gt; plugin and your database sits on the same box of your rails application, you can speed up things a bit using a new &lt;code&gt;:local =&amp;gt; false&lt;/code&gt; option.&lt;/p&gt;


	&lt;p&gt;Let&#8217;s explain it better:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
class User &amp;lt; ActiveRecord::Base
  include ImportWithLoadDataInFile
end

cols = [:name, :surname]
vals = [[&quot;paolo&quot;, &quot;dona&quot;], [&quot;james&quot;, &quot;dean&quot;]]
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;What you usually do is:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
User.import_with_load_data_infile(cols, vals)
# generates a LOAD DATA LOCAL INFILE statement
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Which means: we generate a local temp file containing the data we need to import (where your Rails app is running) and send it to the database machine over the network (using the open database connection). The file is then imported by mysql.&lt;/p&gt;


	&lt;p&gt;If the database sits on the same box, we can avoid the network overhead letting mysql load the file straight away:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
User.import_with_load_data_infile(cols, vals, :local =&amp;gt; false)
# generates a LOAD DATA INFILE statement
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;This won&#8217;t sent the file using the connection but will tell mysql to load it by itself.
This is obviously faster, just make sure your database user has the &lt;span class=&quot;caps&quot;&gt;FILE&lt;/span&gt; permission correctly set up.&lt;/p&gt;


	&lt;p&gt;Enjoy the speed improvement!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-10-06:16</id>
    <published>2008-10-06T19:08:00Z</published>
    <updated>2008-10-15T21:45:49Z</updated>
    <category term="bulk insert"/>
    <category term="import_with_load_data_in_file"/>
    <category term="load data infile"/>
    <category term="mysql"/>
    <category term="rails plugin"/>
    <link href="http://paolodona.com/2008/10/6/mysql-load-data-in-file-ruby-on-rails-plugin" rel="alternate" type="text/html"/>
    <title>Rails bulk insert at the speed of light!</title>
<content type="html">
            &lt;p&gt;For a project I&#8217;m working on I needed to bulk insert a large amount of data into a MySql table from a rails app.&lt;/p&gt;


	&lt;p&gt;I usually rely on the &lt;a href=&quot;http://www.continuousthinking.com/tags/arext&quot;&gt;ar-extensions&lt;/a&gt; plugin&#8217;s import feature but this time I really needed to be as quick as possible so I started looking for alternatives.&lt;/p&gt;


	&lt;p&gt;Given that I&#8217;m using MySql and that it provides a pretty good &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/load-data.html&quot;&gt;&lt;span class=&quot;caps&quot;&gt;LOAD DATA INFILE&lt;/span&gt;&lt;/a&gt; statement, it seemed pretty stupid not to use it.&lt;/p&gt;


	&lt;p&gt;That&#8217;s why I&#8217;m intoducing a brand new Rails plugin that allows you to bulk insert records at the speed of light: &lt;a href=&quot;http://github.com/paolodona/import_with_load_data_in_file&quot;&gt;import_with_load_data_in_file&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;You can find it on Github:&lt;/p&gt;


	&lt;p&gt;&lt;a href=&quot;http://github.com/paolodona/import_with_load_data_in_file&quot;&gt;http://github.com/paolodona/import_with_load_data_in_file&lt;/a&gt;&lt;/p&gt;


	&lt;h4&gt;1. How to install it?&lt;/h4&gt;


&lt;code&gt;&lt;pre&gt;
$ cd vendor/plugins
$ git clone git://github.com/paolodona/import_with_load_data_in_file.git
&lt;/pre&gt;&lt;/code&gt;

	&lt;h4&gt;2. How to use it?&lt;/h4&gt;


	&lt;ul&gt;
	&lt;li&gt;include the &lt;code&gt;ImportWithLoadDataInFile&lt;/code&gt; module in your AR model, say &lt;code&gt;MyModel&lt;/code&gt;. &lt;/li&gt;
		&lt;li&gt;call the &lt;code&gt;MyModel.import_with_load_data_infile(cols, vals)&lt;/code&gt; method, as you would with ar-extensions import.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h4&gt;3. Example&lt;/h4&gt;


&lt;code&gt;&lt;pre&gt;
# Table name: users
#
# id :integer(11) not null, primary key
# name :string(20)
# surname :string(32)
#
class User &amp;lt; ActiveRecord::Base
  # you need to include this module
  include ImportWithLoadDataInFile
end

cols = [:name, :surname]
vals = [[&quot;paolo&quot;, &quot;dona&quot;], [&quot;james&quot;, &quot;dean&quot;]]
User.import_with_load_data_infile(cols, vals)&lt;/pre&gt;&lt;/code&gt;
&lt;/pre&gt;&lt;/code&gt;

	&lt;h4&gt;4. Disclaimer&lt;/h4&gt;


	&lt;p&gt;This works &lt;strong&gt;only&lt;/strong&gt; on MySql if the &#8220;LOAD &lt;span class=&quot;caps&quot;&gt;DATA LOCAL INFILE&lt;/span&gt;&#8221; is enabled on both the client and the server. See the page &lt;a href=&quot;http://dev.mysql.com/doc/refman/5.0/en/load-data-local.html&quot;&gt;Security Issues with &lt;span class=&quot;caps&quot;&gt;LOAD DATA LOCAL&lt;/span&gt;&lt;/a&gt; for more info.&lt;/p&gt;


	&lt;h4&gt;5. Benchmarks&lt;/h4&gt;


	&lt;p&gt;Unofficial benchmarks say it&#8217;s up to 30% faster than ar-extensions import. There is still room for improvements as I could use unix named pipes instead of a physical file and string escapings could be cached.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-08-04:15</id>
    <published>2008-08-04T21:59:00Z</published>
    <updated>2008-08-04T22:07:06Z</updated>
    <category term="Various"/>
    <category term="london"/>
    <link href="http://paolodona.com/2008/8/4/i-moved-to-london" rel="alternate" type="text/html"/>
    <title>I moved to London</title>
<content type="html">
            &lt;p&gt;Hi guys, this blog has been very quiet lately&#8230; I know.&lt;/p&gt;


	&lt;p&gt;What is keeping me busy at the moment is my relocation to London. 
Well, yes&#8230; after spending some time thinking about it (admittedly, not too much) Francesca and I decided to move and enjoy a new experience abroad.&lt;/p&gt;


	&lt;p&gt;This is something I used to dream of, and now it&#8217;s reality! There&#8217;s no plan to get back in the short term&#8230; I mean, it&#8217;s not a vacation, we want to live here for a while and see what happens, improving our poor English in the meanwhile.&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://paolodona.com/assets/2008/8/4/Photo_4.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;If you want to see me in Italy, you now need to book me in advance :-)&lt;/p&gt;


	&lt;p&gt;If you happen to be in London, just give me a call and I&#8217;ll be more than happy to meet you!&lt;/p&gt;


	&lt;p&gt;If you&#8217;re wondering what&#8217;s going on at SeeSaw&#8230; well, just stay tuned and everything will be explained in a couple of weeks.&lt;/p&gt;


	&lt;p&gt;Hugs and kisses.&lt;/p&gt;


	&lt;p&gt;PS: I&#8217;ve tried to eat &#8220;Spagetti alla Carbonara&#8221; here and got badly sick&#8230; I promise I&#8217;ll never eat Italian food again!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-07-06:14</id>
    <published>2008-07-06T18:57:00Z</published>
    <updated>2008-07-07T22:26:43Z</updated>
    <category term="Tips &amp; Tricks"/>
    <category term="redgreen"/>
    <category term="rspec"/>
    <category term="ruby"/>
    <link href="http://paolodona.com/2008/7/6/colorize-rspec-stories-output" rel="alternate" type="text/html"/>
    <title>Colorize RSpec stories output</title>
<content type="html">
            &lt;p&gt;&lt;small&gt;
&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;: This approach is no longer necessary as you can pass &lt;code&gt;--colour&lt;/code&gt; to your story runner. You can still use the script for plugging in growl support.
&lt;/small&gt;&lt;/p&gt;


	&lt;p&gt;If you&#8217;re into &lt;a href=&quot;http://www.zenspider.com/ZSS/Products/ZenTest&quot;&gt;autotest&lt;/a&gt; and &lt;a href=&quot;http://rubyforge.org/projects/redgreen&quot;&gt;redgreen&lt;/a&gt; you probably miss your colored test output while running your &lt;a href=&quot;http://blog.davidchelimsky.net/articles/tag/stories&quot;&gt;Rspec Stories&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;A standard story output looks like this:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://paolodona.com/assets/2008/7/6/plain.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;You can pipe it to this &lt;a href=&quot;http://github.com/paolodona/scripts/tree/master/colorize&quot;&gt;simple colorize script&lt;/a&gt; and get:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://paolodona.com/assets/2008/7/6/pending.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;... yellow pending messages, or:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://paolodona.com/assets/2008/7/6/failure.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;... red failures.&lt;/p&gt;


	&lt;p&gt;That helps me spot where pendings and failures are when running large stories.
PS: this script eats up lines if you&#8217;re running the debugger. Feel free to improve it and send back patches to me.
&lt;span class=&quot;caps&quot;&gt;PPS&lt;/span&gt;: the color stuff has been ripped off from redgreen.&lt;/p&gt;


	&lt;p&gt;This script plug nicely in growl support if found in your path.&lt;/p&gt;


	&lt;p&gt;Paolo&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-07-02:13</id>
    <published>2008-07-02T19:47:00Z</published>
    <updated>2008-07-02T19:48:06Z</updated>
    <category term="Tips &amp; Tricks"/>
    <category term="rails"/>
    <category term="timezone"/>
    <link href="http://paolodona.com/2008/7/2/check-the-database-timezone-at-startup" rel="alternate" type="text/html"/>
    <title>Check the database timezone at startup</title>
<content type="html">
            &lt;p&gt;If your application is dealing with different time zones and code which relies on them, it could be handy to ensure the database is using the time zone you expect it to.&lt;/p&gt;


	&lt;p&gt;drop something like this in a rails initializer:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
#
# Check that that database is running in UTC
# and stop if it's not.
#
db_now = ActiveRecord::Base.connection.execute( 
    &quot;select now() as now&quot; ).fetch_hash['now']
utc_now = Time.now.utc.to_s(:db)

if db_now != utc_now
  raise LoadError, &quot;ERROR: Database is not in UTC&quot; 
end
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;btw: you should thank &lt;a href=&quot;http://roninonrails.blogspot.com&quot;&gt;david&lt;/a&gt;, not me.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-06-12:12</id>
    <published>2008-06-12T15:21:00Z</published>
    <updated>2008-06-12T18:44:02Z</updated>
    <category term="Tips &amp; Tricks"/>
    <category term="gmail"/>
    <category term="gtd"/>
    <link href="http://paolodona.com/2008/6/12/gtd-how-to-manage-your-todos-and-next-actions-with-gmail" rel="alternate" type="text/html"/>
    <title>GTD: how to manage your todos and next actions with GMail</title>
<content type="html">
            &lt;p&gt;About a year ago I posted about &lt;a href=&quot;http://blog.seesaw.it/articles/2007/05/07/todo-list-and-next-action-with-gmail&quot;&gt;a way to manage your todo list with GMail&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;The concept is simple: label your emails as &lt;span class=&quot;caps&quot;&gt;TODO&lt;/span&gt; and search through them. Next actions are just starred TODOs.
Labelling and filtering your email with GMail is a snap, but in order to have cool &#8220;todo&#8221; and &#8220;next action&#8221; links available through the interface I had to use &lt;a href=&quot;https://addons.mozilla.org/firefox/addon/748&quot;&gt;greasemonkey&lt;/a&gt; and &lt;a href=&quot;http://code.google.com/p/gmail-greasemonkey&quot;&gt;saved searches&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;Nowadays, with google updating GMail and me switching to osx/safari, that solution doesn&#8217;t work anymore.
Luckily enough I noticed that GMail searches are now bookmarkable&#8230; so here I recap the steps for setting up your minimal todo list:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;create a new contact named &lt;em&gt;todo&lt;/em&gt; whose email is &lt;em&gt;your_account_name+todo@gmail.com&lt;/em&gt; (eg: &lt;em&gt;paolo.dona+todo@gmail.com&lt;/em&gt;)&lt;/li&gt;
		&lt;li&gt;create a label named &lt;em&gt;todo&lt;/em&gt;&lt;/li&gt;
		&lt;li&gt;create a filter matching &lt;em&gt;to:(your_account_name+todo@gmail.com)&lt;/em&gt; and flag: &lt;i&gt;Skip Inbox, Apply label “todo”&lt;/i&gt;.&lt;/li&gt;
		&lt;li&gt;now search your mail for &lt;em&gt;label:todo&lt;/em&gt; and bookmark the page as [todo]&lt;/li&gt;
		&lt;li&gt;search your mail for &lt;em&gt;label:todo is:starred&lt;/em&gt; and bookmark the page as [next action]&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;you should get something like (todo):&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://lh3.ggpht.com/paolo.dona/SFEdHKS92KI/AAAAAAAACyg/8Uyc5ntUrvs/s400/todo.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;and (next action):&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://lh3.ggpht.com/paolo.dona/SFEdPS-0RiI/AAAAAAAACyo/aHXHoSil0H8/s400/nextaction.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Have you noticed the [todo] and [next action] bookmarks I put in my Bookmarks Bar? 
I know this is not a solution that suits everyone&#8217;s needs, but it brings a couple of pros:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;I can add filters that automatically populate my todo list from incoming emails.&lt;/li&gt;
		&lt;li&gt;I can play with labels and easily let todo items belong to projects, locations etc (GTD style).&lt;/li&gt;
		&lt;li&gt;I do not have to implement my own todo list manager as most rails programmers do :)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Happy GTDing!&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-05-21:8</id>
    <published>2008-05-21T00:10:00Z</published>
    <updated>2008-06-11T00:23:38Z</updated>
    <category term="Motorbike"/>
    <link href="http://paolodona.com/2008/5/21/motorbike-riding-training-in-adria" rel="alternate" type="text/html"/>
    <title>Motorbike riding training in Adria</title>
<content type="html">
            &lt;ul&gt;
&lt;li&gt;Do you love to ride your motorbike?&lt;/li&gt;
&lt;li&gt;Are you willing to improve your handling skills?&lt;/li&gt;
&lt;li&gt;Do you live in north-eastern Italy?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There&#8217;s a nice opportunity for you! check out &lt;a href=&quot;http://www.corsoguidasicura.com/news/date-2008-iscrizioni/&quot;&gt;this cool no-profit initiative&lt;/a&gt; from a couple of friends of mine! &lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-05-05:9</id>
    <published>2008-05-05T00:14:00Z</published>
    <updated>2008-06-11T00:23:59Z</updated>
    <category term="Various"/>
    <link href="http://paolodona.com/2008/5/5/from-dvd-to-youtube" rel="alternate" type="text/html"/>
    <title>From DVD to YouTube</title>
<content type="html">
            &lt;p&gt;As maybe someone of you already know, I have a &lt;a href=&quot;http://www.domenicomenini.com&quot;&gt;close friend&lt;/a&gt; who is an opera singer. Yesterday I had to extract and convert a few excerpts of his &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt; and put them on YouTube. Here the steps it took me:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Convert the &lt;span class=&quot;caps&quot;&gt;DVD&lt;/span&gt; to .mp4 file with &lt;a href=&quot;http://handbrake.fr/&quot;&gt;Handbrake&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Cut out the excerpts with &lt;a href=&quot;http://www.aeroquartet.com/SimpleMovieX/info.html&quot;&gt;SimpleMovieX&lt;/a&gt; (it allows me to use precise pointcuts times, i had eg to extract from 1:50:23s to 1:52:25s) and save them.&lt;/li&gt;
&lt;li&gt;Import the excerpt in &lt;a href=&quot;http://www.apple.com/ilife/imovie/&quot;&gt;iMovie 08&lt;/a&gt; and add titles and transitions. Normalize audio (DVD audio level is usually very low).&lt;/li&gt;
&lt;li&gt;Export resulting video to a YouTube friendly format (.m4v)&lt;/li&gt;
&lt;li&gt;Upload to YouTube.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;You can see the final result on &lt;a href=&quot;http://www.youtube.com/domenicomenini&quot;&gt;Domenico Menini&#8217;s YouTube Channel&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Are there better/faster ways to achieve the same result?&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://paolodona.com/">
    <author>
      <name>paolo.dona</name>
    </author>
    <id>tag:paolodona.com,2008-02-22:10</id>
    <published>2008-02-22T23:59:00Z</published>
    <updated>2008-06-12T00:21:25Z</updated>
    <category term="Tips &amp; Tricks"/>
    <link href="http://paolodona.com/2008/2/22/textmate-filter-through-command" rel="alternate" type="text/html"/>
    <title>TextMate Filter Through Command</title>
<content type="html">
            &lt;p&gt;Sometimes I have to deal with messy html like this:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://lh3.ggpht.com/paolo.dona/R78lAyfAa2I/AAAAAAAACf8/2E_gL-mHMEo/s400/messy-html.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;As you know, indenting it manually is a pain&#8230; but I just found out this cool TextMate feature, Filter Through Command:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://lh6.ggpht.com/paolo.dona/R78lvifAa3I/AAAAAAAACgE/TwVW6YmubgA/s400/filter-menu.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;You can filter your file through a shell command and substitute the content&#8230; here I&#8217;ve chosen the osx built-in &lt;a href=&quot;http://tidy.sourceforge.net/&quot;&gt;tidy&lt;/a&gt; to clean up my html:&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://lh5.ggpht.com/paolo.dona/R78maSfAa4I/AAAAAAAACgM/31cLwASJcAU/s400/ftc.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;And voilà, your html gets pretty formatted in a snap&#8230;&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://lh4.ggpht.com/paolo.dona/R78nACfAa5I/AAAAAAAACgU/F9_8R6oiovE/s400/pretty-html.jpg&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;I just need now to find out a way to automatically strip tidy&#8217;s comments at the top of my document&#8230; but the annoying part has been done. Pretty simple but clever stuff.&lt;/p&gt;


	&lt;p&gt;If you know better ways to do this&#8230; let me know!&lt;/p&gt;
          </content>  </entry>
</feed>
