<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Sam Lown's Blog</title>
    <link>http://www.samlown.com/blog</link>
    <description>Sam Lown's personal blog on technology, rails, linux and Madrid.</description>
    <language>en-GB</language>
    <ttl>40</ttl>
    <item>
      <title>Ruby: Handling fixed string lengths and UTF-8</title>
      <link>http://www.samlown.com/posts/2009/6/8/ruby-handling-fixed-string-lengths-and-utf8?locale=en</link>
      <guid>http://www.samlown.com/posts/2009/6/8/ruby-handling-fixed-string-lengths-and-utf8?locale=en</guid>
      <description>&lt;p&gt;Until Ruby 1.9 is supported by your favorite plugins and gems, proper &lt;span class="caps"&gt;UTF&lt;/span&gt;-8 support in your ruby code is a serious challenge. If, like me, you don&amp;#8217;t have time to wait, the following really simple code snippet should help you to at least fix the &lt;code&gt;sprintf&lt;/code&gt; problem of fixing the lengths of strings with unicode characters.&lt;/p&gt;
&lt;pre&gt;
&lt;code&gt;
  # UTF-8 safe operations for setting a string width
  # Aligns to left by default and pads with spaces. Options include:
  #
  #   :align =&amp;gt; :left (default), :right
  #   :pad =&amp;gt; ' '
  #
  def string_to_width(string, width, options = {})
    options.reverse_merge!(
      :pad =&amp;gt; ' ', :align =&amp;gt; :left
    )
    new_string = ""
    i = 0
    string.each_char do |c|
      break if i == width
      new_string += c
      i += 1
    end
    # add padding
    if new_string.jlength &amp;lt; width
      padding = (options[:pad] * (width - new_string.jlength))
      new_string = options[:align] == :left ? new_string + padding : padding + new_string
    end
    new_string
  end
&lt;/code&gt;
&lt;/pre&gt;
&lt;p&gt;I place that in my &lt;code&gt;application_helper.rb&lt;/code&gt; and ensure &lt;code&gt;require 'jcode'&lt;/code&gt; is included in the Rails &lt;code&gt;environment.rb&lt;/code&gt; file.&lt;/p&gt;</description>
      <pubDate>Mon, 08 Jun 2009 19:28:00 +0000</pubDate>
    </item>
    <item>
      <title>Migrating to acts_as_taggable_on from acts_as_taggable_on_steroids</title>
      <link>http://www.samlown.com/posts/2009/5/25/migrating-to-acts_as_taggable_on-from-acts_as_taggable_on_steroids?locale=en</link>
      <guid>http://www.samlown.com/posts/2009/5/25/migrating-to-acts_as_taggable_on-from-acts_as_taggable_on_steroids?locale=en</guid>
      <description>&lt;p&gt;The &lt;a href="http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroids"&gt;Acts As Taggable On Steroids&lt;/a&gt; plugin for Rails has certainly been around the block a few times, I indeed have been using it in many of my projects for a few years. Now the time has come however where the lack of &lt;code&gt;named_scope&lt;/code&gt; support is more than a minor irritation, and its time to move on: &lt;a href="http://github.com/mbleigh/acts-as-taggable-on/tree/master"&gt;Acts As Taggable On&lt;/a&gt; is a fine replacement with all the named scope magic and additional context support which might be useful in some situations.&lt;/p&gt;
&lt;p&gt;Out of the box, the new plugin is not table compatible with the old, so if you have an older project you need to upgrade without loosing the old taggings we need to perform a migration. &lt;a href="http://sprint.inspiresynergy.com/2008/08/migrate-from-acts-as-taggable-on-steroids-to-acts-as-taggable-on/"&gt;tkwong mentioned&lt;/a&gt; a similar process, but there seems to be the solution wasn&amp;#8217;t very clear to me, so I wrote my own.&lt;/p&gt;
&lt;p&gt;Firstly, you need to grab the plugin and move the old one out the way:&lt;/p&gt;
&lt;pre&gt;
script/plugin install git://github.com/mbleigh/acts-as-taggable-on.git
mv vendor/plugins/acts_as_taggable_on_steroids /tmp
&lt;/pre&gt;
&lt;p&gt;Then we add a new empty migration to handle the table changes:&lt;/p&gt;
&lt;pre&gt;
script/generate migration acts_as_taggable_on_migration
&lt;/pre&gt;
&lt;p&gt;The contents of the migration should look like the following:&lt;/p&gt;
&lt;pre&gt;
class ActsAsTaggableOnMigration &amp;lt; ActiveRecord::Migration
  def self.up
    remove_column :tags, :reference_count
    rename_column :taggings, :created_on, :created_at
    add_column    :taggings, :tagger_id, :integer
    add_column    :taggings, :tagger_type, :string
    add_column    :taggings, :context, :string

    remove_index  :tags, :name
    remove_index  :taggings, [:taggable_id,:taggable_type]

    add_index     :taggings, [:taggable_id, :taggable_type, :context]

    Tag.connection.execute("UPDATE taggings SET context = 'tags'")
  end

  def self.down
  end
end
&lt;/pre&gt;
&lt;p&gt;I&amp;#8217;ve been lazy and not included the reverse migration to save a bit of space. Note the last bit of manual &lt;span class="caps"&gt;SQL&lt;/span&gt; code, this will ensure all of the old tagging associations are defined in the &lt;code&gt;:tags&lt;/code&gt; context.&lt;/p&gt;
&lt;p&gt;All the old models using the old &lt;code&gt;acts_as_taggable&lt;/code&gt; call can be modified to the following:&lt;/p&gt;
&lt;pre&gt;
acts_as_taggable_on :tags
&lt;/pre&gt;
&lt;p&gt;And thats it! You can now fully enjoy the benefits of named scopes:&lt;/p&gt;
&lt;pre&gt;
Artifact.tagged_with('rosas', :on =&amp;gt; :tags).paginate :page =&amp;gt; 1, :per_page =&amp;gt; 10
&lt;/pre&gt;
&lt;p&gt;Fantastic!&lt;/p&gt;</description>
      <pubDate>Mon, 25 May 2009 22:27:22 +0000</pubDate>
    </item>
    <item>
      <title>Update: Waiting for an iMac, with style... the wave</title>
      <link>http://www.samlown.com/posts/2008/10/10/update-waiting-for-an-imac-with-style-the-wave?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/10/10/update-waiting-for-an-imac-with-style-the-wave?locale=en</guid>
      <description>&lt;p&gt;I could help share but share this minor extension to the story as a tribute to our long suffering doorman. I&amp;#8217;d told him the night before about the camera so he wouldn&amp;#8217;t be alarmed, but I still found the following quite amusing.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.samlown.com/uploads/images/imac/wave1.jpg"&gt;&lt;img src="http://www.samlown.com/uploads/images/imac/wave1_350x350.jpg" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;About to turn the light off with a smile.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.samlown.com/uploads/images/imac/wave2.jpg"&gt;&lt;img src="http://www.samlown.com/uploads/images/imac/wave2_350x350.jpg" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;A quick wave.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.samlown.com/uploads/images/imac/wave3.jpg"&gt;&lt;img src="http://www.samlown.com/uploads/images/imac/wave3_350x350.jpg" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And the door is closed.&lt;/p&gt;
&lt;p&gt;I don&amp;#8217;t expect there are many places in the world where this happens, but then, this is Madrid!&lt;/p&gt;</description>
      <pubDate>Fri, 10 Oct 2008 16:05:35 +0000</pubDate>
    </item>
    <item>
      <title>Waiting for an iMac, with style</title>
      <link>http://www.samlown.com/posts/2008/10/10/waiting-for-an-imac-with-style?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/10/10/waiting-for-an-imac-with-style?locale=en</guid>
      <description>&lt;p&gt;Few things are as taxing as waiting for an iMac to arrive. It doesn&amp;#8217;t help when your &lt;a href="http://www.lorena.com.es"&gt;girlfriend&lt;/a&gt; drags you away for the weekend to go to a wedding&amp;#8230; &amp;#8220;I have friday off, so you can work from my mother&amp;#8217;s house&amp;#8221;, &amp;#8220;yes, but I&amp;#8217;m expecting the iMac on Friday&amp;#8230; ugh&amp;#8221;. What is a modern man to do in such situations?&lt;/p&gt;
&lt;p&gt;Set up a video surveillance system using a &lt;a href="http://www.logitech.com/index.cfm/webcam_communications/webcams/devices/4267"&gt;web cam&lt;/a&gt;, a 2m &lt;span class="caps"&gt;USB&lt;/span&gt; 2.0 extension lead plugged into the home multimedia &lt;a href="http://www.ubuntu.com"&gt;Ubuntu&lt;/a&gt; system, with &lt;a href="http://www.lavrsen.dk/twiki/bin/view/Motion/WebHome"&gt;motion detection&lt;/a&gt;, of course!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.samlown.com/uploads/images/imac/arrival-200810101029.jpg"&gt;&lt;img src="http://www.samlown.com/uploads/images/imac/arrival-200810101029_350x350.jpg" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thats the doorman showing in the &lt;span class="caps"&gt;UPS&lt;/span&gt; delivery guy this morning with the iMac and no doubt commenting on how much of a paranoid freak the resident is to have set up a video camera!&lt;/p&gt;
&lt;p&gt;Now its just a question of working out how to cope with the rest of the weekend ahead knowing that the box is sitting there in the darkness just waiting to be opened, not to mention the &lt;a href="http://www.notesfromspain.com/2008/09/10/how-do-spanish-weddings-work/"&gt;spanish wedding&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Sadly, they left the box &lt;a href="http://www.samlown.com/uploads/images/imac/03-20081010114500-snapshot.jpg"&gt;just outside the view&lt;/a&gt; of the camera, and the lighting is rather poor so I can only take solace with the fact that any suspicious activity will be immediately sent to my server.&lt;/p&gt;</description>
      <pubDate>Fri, 10 Oct 2008 09:53:00 +0000</pubDate>
    </item>
    <item>
      <title>Nokia's iPhone beater... Is that a pen?</title>
      <link>http://www.samlown.com/posts/2008/10/3/nokias-iphone-beater-is-that-a-pen?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/10/3/nokias-iphone-beater-is-that-a-pen?locale=en</guid>
      <description>&lt;p&gt;&lt;a href="http://www.theregister.co.uk"&gt;The Register&lt;/a&gt; have shared the news of &lt;a href="http://www.reghardware.co.uk/2008/10/03/tube_unveiled/"&gt;Nokia&amp;#8217;s iPhone beater&lt;/a&gt;, here&amp;#8217;s a picture which pretty much sums up what to expect:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.samlown.com/uploads/images/nokia5800xpressmusic_01_350x350.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Yes, that is a plastic tipped pen.&lt;/p&gt;
&lt;p&gt;I like Nokia hardware, modest, enduring, and quite reliable, but including a pen clearly shows that they haven&amp;#8217;t quite grasped the touch screen concept or indeed usability. No doubt the OS takes full advantage of tiny virtual keyboards and frustrating menus also seen in the Nokia N800 and most of the mobile phone range.&lt;/p&gt;
&lt;p&gt;I think the last time I enjoyed the Symbian OS was when its great-great-granddad was around in the &lt;a href="http://members.surfeu.at/org2/org2.htm"&gt;Psion Organiser II&lt;/a&gt; in the early 90s, but then, &lt;span class="caps"&gt;BASIC&lt;/span&gt; for me was its major feature :-)&lt;/p&gt;</description>
      <pubDate>Fri, 03 Oct 2008 12:22:26 +0000</pubDate>
    </item>
    <item>
      <title>Today I'm a Freelancer!</title>
      <link>http://www.samlown.com/posts/2008/6/24/today-im-a-freelancer?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/6/24/today-im-a-freelancer?locale=en</guid>
      <description>&lt;p&gt;The decision was made in May and is now finally reality, the 30th of June was my official leaving date from my morning job at &lt;a href="http://www.internet21.es"&gt;Internet21&lt;/a&gt; and I&amp;#8217;ve now become a fully fledged freelancer!&lt;/p&gt;


	&lt;p&gt;I&amp;#8217;ve been working with the company since I first arrived in Madrid just over two years ago, and its been a great launch pad for discovering Madrid and the Ruby on Rails scene, and I thank everyone in the office for the great time I spent there. But now I think the right time to move onto something I&amp;#8217;ve wanted to do for a while; free myself from timetables and work schedules decided by others and jump into the freelance bandwagon.&lt;/p&gt;


	&lt;p&gt;As part of the new lifestyle, and as a substitute from walking to an office, I&amp;#8217;ve even started running in the mornings&amp;#8230; a bit of a shock to the system I must say as its been 3 years since the last time I was in the habit of running in the morning. I&amp;#8217;m optimistic the effort will pay off though.&lt;/p&gt;


	&lt;p&gt;Planetaki:http://www.planetaki.com is still my main project in the afternoons, and no doubt will continue be a for a while to come, but my focus for the mornings will be taking on smaller short-term objectives. I&amp;#8217;ve outlined some of my intentions in the &lt;a href="http://www.samlown.com/en/page/Profile"&gt;Profile&lt;/a&gt; section of this site.&lt;/p&gt;


	&lt;p&gt;Finally, now that I&amp;#8217;m open for bookings, &lt;a href="http://www.samlown.com/es/page/Contact"&gt;please get in touch&lt;/a&gt; if you think your project could benefit from a skilled &lt;a href="http://www.samlown.com/es/page/Profile"&gt;Ruby on Rails developer and information architect in Madrid&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Tue, 01 Jul 2008 12:15:00 +0000</pubDate>
    </item>
    <item>
      <title>Rails: NilClass no longer extended with a &lt; method in Rails 2.1</title>
      <link>http://www.samlown.com/posts/2008/6/11/rails-nilclass-no-longer-extended-with-a--method-in-rails-21?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/6/11/rails-nilclass-no-longer-extended-with-a--method-in-rails-21?locale=en</guid>
      <description>&lt;p&gt;I discovered a strange change in Rails 2.1 today when I found a bit of faulty code that used to work in Rails 2.0. Rather than try to describe it, here&amp;#8217;s a quick example:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;planetaki@Planetaki1:&lt;sub&gt;/Planetaki$ ./script/console 
Loading production environment (Rails 2.0.2)
&amp;gt;&amp;gt; @x &amp;lt; 10
=&amp;gt; false&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;And in Rails 2.1:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;sam@dell-desktop:&lt;/sub&gt;/workspace/Planetaki$ ./script/console 
Loading development environment (Rails 2.1.0)
&amp;gt;&amp;gt; @x &amp;lt; 10
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.&amp;lt;
      from (irb):1&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;After a quick search I&amp;#8217;ve not managed to find anything specific that would cause this in the Rails libraries, and on both systems performing the test on the standard irb console will cause an exception as expected. Very strange. Let me know if you have any ideas!&lt;/p&gt;</description>
      <pubDate>Wed, 11 Jun 2008 15:57:47 +0000</pubDate>
    </item>
    <item>
      <title>Big Update to Planetaki!</title>
      <link>http://www.samlown.com/posts/2008/5/20/big-update-to-planetaki?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/5/20/big-update-to-planetaki?locale=en</guid>
      <description>&lt;p&gt;We&amp;#8217;ve just made a major release for Planetaki! Its taken a lot of effort to get here and there are quite a few changes, the major two being Badge support and internationalisation support!&lt;/p&gt;


	&lt;p&gt;Click the following badge to see what happens!&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.planetaki.com/subscription/add?url=http://www.samlown.com/posts"&gt;&lt;img src="http://www.planetaki.com/images/badges/big_tall_white.gif" style="border:0px;;" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;I would go into more detail, but I&amp;#8217;m rather tired after spending all afternoon getting it to work, and tomorrow &lt;a href="http://www.planetaki.com/about"&gt;we&amp;#8217;re&lt;/a&gt; off to &lt;a href="http://www.startup2.eu"&gt;startup2.eu&lt;/a&gt; in Barcelona to strut Planetaki&amp;#8217;s stuff with a few other European Startups&amp;#8230; expect more info soon!&lt;/p&gt;


	&lt;p&gt;Finally, just in case I don&amp;#8217;t get chance to comment beforehand, if you&amp;#8217;re in Spain, don&amp;#8217;t forget to acquire a copy of &amp;#8220;El Pa&#237;s&amp;#8221; on Thursday. It should have a technology supplement in it and mention Planetaki!&lt;/p&gt;


	&lt;p&gt;All good stuff!&lt;/p&gt;</description>
      <pubDate>Tue, 20 May 2008 23:14:00 +0000</pubDate>
    </item>
    <item>
      <title>BBC HD Free-to-air Satellite TV Service Starting</title>
      <link>http://www.samlown.com/posts/2008/5/6/bbc-hd-freetoair-satellite-tv-service-starting?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/5/6/bbc-hd-freetoair-satellite-tv-service-starting?locale=en</guid>
      <description>&lt;p style="float:right"&gt;&lt;img src="http://www.freesat.co.uk/img/logo_freesat.gif" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;News today that the &lt;a href="http://news.bbc.co.uk/1/hi/entertainment/7384928.stm"&gt;&lt;span class="caps"&gt;BBC&lt;/span&gt; and &lt;span class="caps"&gt;ITV&lt;/span&gt; has started a free-to-air satellite TV service&lt;/a&gt; for UK residents. According to the article:&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;It broadcasts 80 digital TV and radio channels including the main ones, and will rise to 200 by the end of 2008.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;blockquote&gt;
		&lt;p&gt;Users make a one-off payment for a dish, set-top box and installation, but will not pay a monthly subscription.&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;A quick google suggests that the service is provided by &lt;a href="http://www.freesat.co.uk/"&gt;Freesat&lt;/a&gt; although their website still says things like &amp;#8220;once freesat launches&amp;#8221; so its clearly still pretty new. There is no mention yet as to which Satellite cluster they are using (although I&amp;#8217;m guessing it will be the Astra 2D service), with a bit of luck the signal might just be strong enough to reach Spain and Madrid! (Although clearly illegal by ridiculous, outdated distribution rights.)&lt;/p&gt;


	&lt;p&gt;This is a great step for &lt;span class="caps"&gt;HD TV&lt;/span&gt; and for lessening the strong-arm of Rupert Murdock and Sky. An example for many of the other over-priced European satellite TV providers.&lt;/p&gt;</description>
      <pubDate>Tue, 06 May 2008 11:04:00 +0000</pubDate>
    </item>
    <item>
      <title>Free Flash = Open Screen Project</title>
      <link>http://www.samlown.com/posts/2008/5/1/free-flash--open-screen-project?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/5/1/free-flash--open-screen-project?locale=en</guid>
      <description>&lt;p&gt;A really astounding peice of news came up on my &lt;a href="http://www.planetaki.com/sam"&gt;planet&lt;/a&gt; this morning; &lt;a href="http://ajaxian.com/archives/adobe-lifts-swfflv-restrictions-and-creates-open-screen-project"&gt;Adobe lifts &lt;span class="caps"&gt;SWF&lt;/span&gt;/FLV restrictions and creates Open Screen Project&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Indeed, the main objectives of Adobe&amp;#8217;s &lt;a href="http://www.openscreenproject.org/"&gt;Open Screen Project&lt;/a&gt; appear to include the opening up of the Flash standard, and the removal of all licensing in order to support the use of Flash in set-top boxes and mobiles. &lt;a href="http://www.adobe.com/aboutadobe/pressroom/pressreleases/200804/050108AdobeOSP.html"&gt;The official press release&lt;/a&gt; clearly states their intentions.&lt;/p&gt;


	&lt;p&gt;Wow. If they go ahead with this it will really put the nail in the coffin for Microsoft&amp;#8217;s Silverlight. My vision of Adobe finally releasing their suite of products for Linux is just a little bit closer.&lt;/p&gt;</description>
      <pubDate>Thu, 01 May 2008 10:48:03 +0000</pubDate>
    </item>
    <item>
      <title>When Ruby doesn't clean up after itself: tempfile leftovers</title>
      <link>http://www.samlown.com/posts/2008/4/15/when-ruby-doesnt-clean-up-after-itself-tempfile-leftovers?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/4/15/when-ruby-doesnt-clean-up-after-itself-tempfile-leftovers?locale=en</guid>
      <description>&lt;p&gt;Today, Planetaki went down for a few minutes as the master reaper server ran out of hard drive space. The first thing you do when you run out of space is remain calm and try to find out whats using it all up. In this particular case where the database is the only real space user (and its not that bad) everything was fine and the log files where all within limits. It didn&amp;#8217;t take long to figure out that the temporary directory had turned into a 30GB monster and was locking up the system.&lt;/p&gt;


	&lt;p&gt;We use the ruby open-uri library to download content from the web which stores everything it downloads in temporary files. Normally, these are supposed to be destroyed as soon as the object that is using the temp file is removed. It turns out however that these files are not destroyed correctly if the Garbage collector does not get chance to run before the program terminates.&lt;/p&gt;


	&lt;p&gt;In the case of our Planetaki backend, we are opening new sites constantly and downloading files and use forking to download from lots of feeds at the same time. The tempfile library it seems has a problem with forking, and will not correctly remove the tempory files when each instance terminates.&lt;/p&gt;


	&lt;p&gt;The solution, take the garbage out before going to bed:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;spawn do
  open('http://website.com') do | f |
    # do stuff with data
  end
  GC.start
end&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;The &amp;#8220;GC.start&amp;#8221; at the end there is vital it seems to ensure your temp files don&amp;#8217;t cause you system to run out of hard disk space.&lt;/p&gt;</description>
      <pubDate>Tue, 15 Apr 2008 23:16:29 +0000</pubDate>
    </item>
    <item>
      <title>Migrating a MySQL database from one character set to another with the same data.</title>
      <link>http://www.samlown.com/posts/2008/3/17/migrating-a-mysql-database-from-one-character-set-to-another-with-the-same-data?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/3/17/migrating-a-mysql-database-from-one-character-set-to-another-with-the-same-data?locale=en</guid>
      <description>&lt;p&gt;My &lt;a href="http://www.samlown.com/posts/2007/9/26/fixing-the-rails-to-mysql-character-set"&gt;previous post&lt;/a&gt; on the issue of MySQL character sets addressed the problem when the data in the database has been stored incorrectly by the encoding of the connection. This time, I&amp;#8217;d like to cover what to do when the connections are okay, but the table definitions are wrong.&lt;/p&gt;


	&lt;p&gt;Normally, this isn&amp;#8217;t a problem, by the &amp;#8220;rubbish in, same rubbish out&amp;#8221; principal, whereby even though the database doesn&amp;#8217;t understand the data as long as goes in and comes out the same there will not be a problem. This has worked for me in the past, but it turns out it doesn&amp;#8217;t work when you start dealing with Cyrillic and symbolic languages such as Russian and Chinese. (I have yet to discover exactly why, but I suspect it has something to do with the range of the bits in &lt;span class="caps"&gt;UTF&lt;/span&gt;-8 encoding.)&lt;/p&gt;


	&lt;p&gt;Continue reading for my solution.&lt;/p&gt;&lt;p&gt;Firstly, we&amp;#8217;re going to create a new database to hold the properly formated data, so enter the mysql console and &lt;a href="http://dev.mysql.com/doc/refman/5.0/en/create-database.html"&gt;create a new database&lt;/a&gt; with the following command:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;CREATE DATABASE new_database CHARACTER SET utf8;&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Unfortunately, MySQL does not allow us to rename a database, so the new name must be permanent and all the permissions that use the database name will need to be modified. The old and new databases for this miniguide are distinguished as &lt;ins&gt;old_database&lt;/ins&gt; and &lt;ins&gt;new_database&lt;/ins&gt; respectively. There are hacks to get around the renaming issue, and solutions to this can be found elsewhere. Phpmyadmin also makes renaming pretty straight forward by copying the database.&lt;/p&gt;


	&lt;p&gt;Back on the command line, we need to copy and modify the table definitions to use the new character set. At this point, you might want to stop your website to ensure nothing else gets written, and in this instance so that the autonumber fields do not loose track. Dump just the definitions of the original database as follows:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;mysqldump --no-data -u root -p old_database &amp;gt; /tmp/tables.sql&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;The resulting file must be opened, and everything that says &amp;#8220;latin1&amp;#8221; must be converted to &amp;#8220;utf8&amp;#8221;. (&lt;a href="http://www.linux.com/articles/55316"&gt;Vim search and replace&lt;/a&gt; might help with this.) Also, you might want to remove any of the &lt;ins&gt;&lt;span class="caps"&gt;COLLATE&lt;/span&gt;&lt;/ins&gt; commands, as they will default to something reasonable if the character set is correct.&lt;/p&gt;


	&lt;p&gt;With the tables corrected, we need to dump just the data, including the default character set of course.&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;mysqldump --no-create-info --default-character-set=utf8 -u root -p old_database &amp;gt; /tmp/data.sql&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Lets now dump this back into the new database:&lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;cat /tmp/tables.sql | mysql -u root -p new_database
cat /tmp/data.sql | mysql -u root -p new_database&lt;/code&gt;&lt;/pre&gt;


	&lt;p&gt;Thats it! The new database should running completely using utf-8 and you shouldn&amp;#8217;t have corrupted any of the data that was already in use. Let me know if you find this useful or come up with a problem!&lt;/p&gt;</description>
      <pubDate>Mon, 17 Mar 2008 13:24:10 +0000</pubDate>
    </item>
    <item>
      <title>Planetaki.com - ready for thrashing</title>
      <link>http://www.samlown.com/posts/2008/3/6/planetakicom--ready-for-thrashing?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/3/6/planetakicom--ready-for-thrashing?locale=en</guid>
      <description>&lt;p style="float:right"&gt;&lt;img src="/uploads/images/Planetaki-beta1.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Its official, &lt;a href="http://www.planetaki.com"&gt;Planetaki.com&lt;/a&gt; is now officially ready to be broken by more than just &lt;a href="http://www.programavostok.com"&gt;javier&lt;/a&gt; and myself (&lt;a href="http://www.planetaki.com/about"&gt;amongst others&lt;/a&gt;)! Clearly, we are still in early Beta, and most people who glimpse at this blog probably already know about it, but this milestone nonetheless deserves recognition for the amount of effort taken to get here.&lt;/p&gt;


	&lt;p&gt;The startup wasn&amp;#8217;t without its setbacks, indeed, there was a short period this afternoon where the site dropped to modem speed as the Ruby on Rails Mongrel servers began to gobble up all the memory and the swap space (causing thrashing). As soon as I figured out what was going on (with the help of the very helpful &lt;a href="http://www.slicehost.com"&gt;slicehost.com&lt;/a&gt; people) the server returned to acceptable response levels though I expect we&amp;#8217;ll be doing some upgrades soon!&lt;/p&gt;


	&lt;p&gt;My Planet can &lt;a href="http://www.planetaki.com/sam"&gt;be found here&lt;/a&gt; and you may also find &lt;a href="http://www.planetaki.com/lolz"&gt;this one amusing&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;If you haven&amp;#8217;t looked already, please check it out and let us know how it goes!&lt;/p&gt;</description>
      <pubDate>Thu, 06 Mar 2008 01:20:40 +0000</pubDate>
    </item>
    <item>
      <title>Pixmania: Need help in Spain? Call England!</title>
      <link>http://www.samlown.com/posts/2008/3/3/pixmania-need-help-in-spain-call-england?locale=en</link>
      <guid>http://www.samlown.com/posts/2008/3/3/pixmania-need-help-in-spain-call-england?locale=en</guid>
      <description>&lt;p&gt;Last June we bought a 42&amp;#8221; Toshiba &lt;span class="caps"&gt;LCD&lt;/span&gt; television from the seemingly popular online store PIXmania.com. Last November it stopped working. Initially, we made the mistake of using the guarantee with Toshiba, they picked up the TV, made us wait two months, we complained, then told us they wouldn&amp;#8217;t repair it because we bought it from Pixmania in France and they have no legal obligation to complete the warranty. Thanks &lt;a href="http://www.toshiba.es"&gt;Toshiba you incompetent losers&lt;/a&gt;!&lt;/p&gt;


	&lt;p style="float:right"&gt;&lt;img src="http://www.samlown.com/uploads/images/pixmania_logo.gif" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;So, after calling Pixmania they told us to send it to their local store in Madrid, and they&amp;#8217;ll sort it out. One month later we tried to contact them to find out what the status is. Trying to call their expensive Spanish support line resulted futile, they either just hung-up or a message came on saying they were closed. With my patience wearing thin, I decided &amp;#8220;these guys are in France, what difference does it make what country I call from!&amp;#8221;, so I grabbed my internet phone and proceeded to call far cheaper UK support line. They answered instantly, explained the problem precisely, and guaranteed within three weeks we&amp;#8217;ll have the TV. They even blamed Toshiba for the delay and apologised.&lt;/p&gt;


	&lt;p&gt;There are several morals to the story here when buying over the internet:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Always call the store first, despite what their website says&lt;/li&gt;
		&lt;li&gt;Be prepared to wait&lt;/li&gt;
		&lt;li&gt;If the Spanish support line sucks, call the English one&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;At least the weathers nice here!&lt;/p&gt;</description>
      <pubDate>Mon, 03 Mar 2008 17:46:56 +0000</pubDate>
    </item>
    <item>
      <title>The Pacman Christmas Tree</title>
      <link>http://www.samlown.com/posts/2007/12/22/the-pacman-christmas-tree?locale=en</link>
      <guid>http://www.samlown.com/posts/2007/12/22/the-pacman-christmas-tree?locale=en</guid>
      <description>&lt;p&gt;&lt;a href="http://www.samlown.com/uploads/images/20071221.jpg"&gt;&lt;img src="http://www.samlown.com/uploads/images/20071221_350x350.jpg" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;Finally, I&amp;#8217;ve managed to find the allusive &lt;a href="http://technabob.com/blog/2007/12/05/pac-man-christmas-tree-hits-madrid/"&gt;pacman christmas tree&lt;/a&gt; right next to the Torre Picasso here in the business district of Madrid.&lt;/p&gt;


	&lt;p&gt;Its rather cool!&lt;/p&gt;


	&lt;p&gt;(Picture taken with my mobile, so quality not so hot.)&lt;/p&gt;</description>
      <pubDate>Sat, 22 Dec 2007 00:57:15 +0000</pubDate>
    </item>
    <item>
      <title>Indignation: The New Website for Mariano Rajoy</title>
      <link>http://www.samlown.com/posts/2007/12/21/indignation-the-new-website-for-mariano-rajoy?locale=en</link>
      <guid>http://www.samlown.com/posts/2007/12/21/indignation-the-new-website-for-mariano-rajoy?locale=en</guid>
      <description>&lt;p&gt;&lt;img src="http://www.samlown.com/uploads/images/RajoyPP.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;There are so many things wrong with &lt;a href="http://www.pp.es"&gt;Mariano Rajoy&amp;#8217;s&lt;/a&gt; (Spanish president candidate) new website I just don&amp;#8217;t know where to begin. Firstly though, as many readers may already know, I&amp;#8217;ve had a lot of involvement with the PP website although not directly through one of my client companies (out of chance rather than political bias) and I can safely say we had &lt;strong&gt;nothing&lt;/strong&gt; to do with this disastrous piece of work. I&amp;#8217;d be long gone if that was the case!&lt;/p&gt;


	&lt;p&gt;As if the site couldn&amp;#8217;t be worse, it seems the &lt;a href="http://www.bluebacking.com/"&gt;creators&lt;/a&gt; even forgot to protect the &lt;a href="http://www.latejedora.es/?p=1112"&gt;administration area&lt;/a&gt;, just insane for one of Spain&amp;#8217;s largest political parties, and a clear sign of complete incompetence, you can almost smell the nepotism in the air.&lt;/p&gt;


	&lt;p&gt;Here&amp;#8217;s a quick run down of what made me so sad about it:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Accessibility &amp;#8211; simply not there, not even a style sheet! There is &lt;strong&gt;no&lt;/strong&gt; way a visually disabled person could navigate this site. Frankly, I don&amp;#8217;t think this should even be legal for public site of this scale.&lt;/li&gt;
		&lt;li&gt;Doesn&amp;#8217;t show correctly in Firefox &amp;#8211; layers are all messed up, and the flash uses up 100% of the &lt;span class="caps"&gt;CPU&lt;/span&gt; (due to poor looping.)&lt;/li&gt;
		&lt;li&gt;Dreamweaver code &amp;#8211; see also accessibility and a sign of lazy authors.&lt;/li&gt;
		&lt;li&gt;Links as pop-ups &amp;#8211; rule 101 of web programming, no pop-ups to access other parts of the same site, ever! Especially not from a Flash animation that causes Firefox to block access!&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;I hope the Spanish public bring attention to how unacceptable this is, it saddens me greatly.&lt;/p&gt;</description>
      <pubDate>Fri, 21 Dec 2007 00:57:48 +0000</pubDate>
    </item>
    <item>
      <title>Yet Another Stupid Web 2.0 Video</title>
      <link>http://www.samlown.com/posts/2007/12/4/yet-another-stupid-web-20-video?locale=en</link>
      <guid>http://www.samlown.com/posts/2007/12/4/yet-another-stupid-web-20-video?locale=en</guid>
      <description>&lt;p&gt;I wouldn&amp;#8217;t normally post web 2.0 video on my blog, oh no, not I, but I&amp;#8217;m making an exception. This one is too good not to watch a couple of times!&lt;/p&gt;


&lt;object width="425" height="373"&gt;&lt;param name="movie" value="http://www.youtube.com/v/I6IQ_FOCE6I&amp;#38;rel=1&amp;#38;border=1"&gt;&lt;/param&gt;&lt;param name="wmode" value="transparent"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/I6IQ_FOCE6I&amp;#38;rel=1&amp;#38;border=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="373"&gt;&lt;/embed&gt;&lt;/object&gt;

	&lt;p&gt;(I&amp;#8217;m also after some embedded flash video for testing Planetaki. ;-)&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: Seems there were some &lt;a href="http://kara.allthingsd.com/20071218/here-come-another-another-bubble/"&gt;copyright issues with the last video&lt;/a&gt; but it should work now hopefully.&lt;/p&gt;</description>
      <pubDate>Tue, 04 Dec 2007 18:35:12 +0000</pubDate>
    </item>
    <item>
      <title>Sam Inside</title>
      <link>http://www.samlown.com/posts/2007/11/28/sam-inside?locale=en</link>
      <guid>http://www.samlown.com/posts/2007/11/28/sam-inside?locale=en</guid>
      <description>&lt;p&gt;&lt;img src="http://www.samlown.com/uploads/x-ray-bronchitis1.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Check out the cool photo! The area highlighted in red is &lt;a href="http://en.wikipedia.org/wiki/Acute_bronchitis"&gt;Acute Bronchitus&lt;/a&gt; (as opposed to chronic), the white stuff around it, is me. Bugger.&lt;/p&gt;


	&lt;p&gt;Looks like I&amp;#8217;ll be staying at home for a few days to come. At least I&amp;#8217;m fortunate enough to have a job that I can do from my nice warm home without problem!&lt;/p&gt;


	&lt;p&gt;The waiting areas and general internal appearance of the &amp;#8220;Hospital de la Paz&amp;#8221; in Madrid leaves a lot to be desired, but the equipment they have for making these photos is very modern and seriously impressive!&lt;/p&gt;</description>
      <pubDate>Wed, 28 Nov 2007 12:10:14 +0000</pubDate>
    </item>
    <item>
      <title>Git!</title>
      <link>http://www.samlown.com/posts/2007/11/26/git?locale=en</link>
      <guid>http://www.samlown.com/posts/2007/11/26/git?locale=en</guid>
      <description>&lt;p&gt;Finally, I&amp;#8217;ve given up with &lt;a href="http://subversion.tigris.org/"&gt;subversion&lt;/a&gt; and moved to a &lt;a href="http://en.wikipedia.org/wiki/Distributed_revision_control"&gt;distributed revision control&lt;/a&gt; system, &lt;a href="http://git.or.cz/"&gt;git&lt;/a&gt;. Developed initially by Linus Torvalds (who apparently named it after himself!?), git does not depend on a central location for managing changes, and instead relies on a distributed model where each &amp;#8220;clone&amp;#8221; of the repository is completely independent.&lt;/p&gt;


	&lt;p&gt;The reason for my move away from subversion which I&amp;#8217;ve been using now for several years is pretty much based on frustration. I&amp;#8217;ve found myself wanting to do more and more with revision control and subversion just started getting in the way far too much. The final straw was when I wanted to merge two separate repositories for a project with a shared base, turns out its impossible with subversion without some serious messing about.&lt;/p&gt;


	&lt;p&gt;There are several other distributed version control systems out there, some of the most popular open source versions being &lt;a href="http://bazaar-vcs.org/"&gt;bizaar&lt;/a&gt; or &lt;a href="http://www.selenic.com/mercurial/"&gt;Mercurial&lt;/a&gt;. They both look really great and have some important backers, but I decided on git on the end with its C back-end and simplicity. It really does just work and gets out your way! The only possible disadvantage is that getting it to work in Windows is complicated to say the least, but after a bit of thought I decided this is probably a benefit :-)&lt;/p&gt;</description>
      <pubDate>Mon, 26 Nov 2007 18:46:59 +0000</pubDate>
    </item>
    <item>
      <title>Conferencia Rails 2007 Ponente</title>
      <link>http://www.samlown.com/posts/2007/11/20/conferencia-rails-2007-ponente?locale=en</link>
      <guid>http://www.samlown.com/posts/2007/11/20/conferencia-rails-2007-ponente?locale=en</guid>
      <description>&lt;p&gt;Apparently, I&amp;#8217;m supposed to stick this on my blog with pride, so I have:&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://www.conferenciarails.org/images/badges/ponente.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;The title, for the less astute, means &amp;#8220;Rails Conference 2007 Speaker&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://www.conferenciarails.org/archivo/2007/11/19/chapas_para_asistentes_y_ponentes/"&gt;Badges for attendees and speakers&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 20 Nov 2007 10:29:50 +0000</pubDate>
    </item>
  </channel>
</rss>
