<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Space Babies &#187; ruby</title>
	<atom:link href="http://www.spacebabies.nl/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.spacebabies.nl</link>
	<description>extraterrestrialicious web apps</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:52:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>The value of continuous integration</title>
		<link>http://www.spacebabies.nl/2011/08/11/the-value-of-continuous-integration/</link>
		<comments>http://www.spacebabies.nl/2011/08/11/the-value-of-continuous-integration/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 21:27:34 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=1759</guid>
		<description><![CDATA[It took a sweet while, but I am finally beginning to see the value in Continuous Integration. My Zelda gem is now being tested by Travis every time I push code into the repository and I can release my software &#8230; <a href="http://www.spacebabies.nl/2011/08/11/the-value-of-continuous-integration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.spacebabies.nl/wp-content/uploads/2011/08/Schermafbeelding-2011-08-11-om-23.32.21.png"><img class="alignright size-thumbnail wp-image-1762" title="Schermafbeelding 2011-08-11 om 23.32.21" src="http://www.spacebabies.nl/wp-content/uploads/2011/08/Schermafbeelding-2011-08-11-om-23.32.21-150x150.png" alt="" width="150" height="150" /></a>It took a sweet while, but I am finally beginning to see the value in <a href="http://en.wikipedia.org/wiki/Continuous_integration">Continuous Integration</a>. My <a href="https://github.com/tilsammans/zelda">Zelda</a> gem is now <a href="http://travis-ci.org/#!/tilsammans/zelda">being tested by Travis</a> every time I push code into the repository and I can release my software with confidence.<br />
<span id="more-1759"></span></p>
<p>As a Ruby programmer, a CI tool always struck me very C/Java-esque. There is no real build process in a scripting language, right? Well, turns out CI has other useful properties.</p>
<p>My gem has a (small, but thourough) spec suite. Travis runs this suite every time I make significant changes. A few minutes later I get the results in my e-mail. When everything&#8217;s OK, I know the software is good to go.</p>
<p>The true value dawned on me just now, where (frustratingly) Travis would report an error, but my local tests ran fine. Travis (on an older version of Ruby by default) didn&#8217;t like my use of method_missing much. And to be honest I didn&#8217;t either. So I yanked that out and replaced it with more well-behaving code. Travis passed right away! A clear example of a CI tool improving the code internals.</p>
<p><img class="alignnone" title="Zelda build status" src="http://travis-ci.org/tilsammans/zelda.png" alt="" width="89" height="13" /></p>
<p>I am now much more confident that Zelda will play nice with all the Ruby versions out there. I will definitely add my other gems to Travis as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2011/08/11/the-value-of-continuous-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random Active Record</title>
		<link>http://www.spacebabies.nl/2011/08/03/random-active-record/</link>
		<comments>http://www.spacebabies.nl/2011/08/03/random-active-record/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 13:05:31 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=1754</guid>
		<description><![CDATA[There is no method provided in Active Record to return a random record (to my knowledge). In the past I have used the ever so easy order by rand() for my random record needs. Problem: this is MySQL specific. Since &#8230; <a href="http://www.spacebabies.nl/2011/08/03/random-active-record/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There is no method provided in Active Record to return a random record (to my knowledge). In the past I have used the ever so easy <em>order by rand()</em> for my random record needs. Problem: this is MySQL specific.</p>
<p><span id="more-1754"></span>Since we now hate MySQL this had got to stop. Enter <a title="Randomizr" href="https://github.com/tilsammans/randomizr">Randomizr</a>. Include that in your Rails project and you&#8217;re golden. Just use <strong>Model.randomizr</strong> and you will receive one random record provided using ANSI SQL. Now you can migrate to PostgreSQL too! Like the big boys.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2011/08/03/random-active-record/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Grab the popcorn</title>
		<link>http://www.spacebabies.nl/2011/05/26/grab-the-popcorn/</link>
		<comments>http://www.spacebabies.nl/2011/05/26/grab-the-popcorn/#comments</comments>
		<pubDate>Thu, 26 May 2011 21:16:28 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=1734</guid>
		<description><![CDATA[Intense debate. Warring factions. Constructive criticism. Fiasco. Unproductive nerd rage. Does this sound intriguing to you? It&#8217;s about the current state of Rubygems, a system that distributes Ruby software. TL;DR version: the Rubygems maintainers keep breaking their system and Ruby &#8230; <a href="http://www.spacebabies.nl/2011/05/26/grab-the-popcorn/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><em>Intense debate. Warring factions. Constructive criticism. Fiasco. Unproductive nerd rage.</em> Does this sound intriguing to you? It&#8217;s about the current state of Rubygems, a system that distributes Ruby software. TL;DR version: the Rubygems maintainers keep breaking their system and Ruby developers are pissed off.</p>
<p><a href="http://blog.majesticseacreature.com/tag/rubygems">Sea creature&#8217;s blog</a> explains what&#8217;s happening in greater detail and it&#8217;s fascinating to see unfold in real time. For instance: follow @seacreature, @wycats, @JEG2 and @rbates instead of going to a movie! It&#8217;s just as entertaining and you can enjoy it from the couch. Fascinating stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2011/05/26/grab-the-popcorn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing ASCII-8BIT encoding for Rails 2.3 ERB</title>
		<link>http://www.spacebabies.nl/2011/02/22/fixing-ascii-8bit-encoding-for-rails-2-3-erb/</link>
		<comments>http://www.spacebabies.nl/2011/02/22/fixing-ascii-8bit-encoding-for-rails-2-3-erb/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 11:05:20 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=1711</guid>
		<description><![CDATA[The combination of Ruby 1.9 and Rails is so much fun when it comes to character encoding. Words to adequately describe the sheer joy it gives me are hard to find. They are often four-letter though. Maybe that&#8217;s significant, I &#8230; <a href="http://www.spacebabies.nl/2011/02/22/fixing-ascii-8bit-encoding-for-rails-2-3-erb/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The combination of Ruby 1.9 and Rails is so much <em>fun</em> when it comes to character encoding. Words to adequately describe the sheer joy it gives me are hard to find. They are often four-letter though. Maybe that&#8217;s significant, I don&#8217;t know.</p>
<p>What I do know is this: ERB in Ruby 1.9 and Rails 2.3 will happily force all your templates to ASCII-8BIT while your database strings are most likely UTF-8. Hilarity ensues. There is no way to change this behaviour besides monkeypatching a bunch of internals.</p>
<p>So without further ado here are the monkeypatches: <a href="https://gist.github.com/838489">gist</a>.</p>
<p>Drop in config/initializers and enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2011/02/22/fixing-ascii-8bit-encoding-for-rails-2-3-erb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why Ruby is so charming</title>
		<link>http://www.spacebabies.nl/2011/02/19/why-ruby-is-so-charming/</link>
		<comments>http://www.spacebabies.nl/2011/02/19/why-ruby-is-so-charming/#comments</comments>
		<pubDate>Sat, 19 Feb 2011 13:31:16 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=1705</guid>
		<description><![CDATA[Part of why the Ruby community is so great is that it seems to attract quirky, ironic, playful and creative people. Can you imagine .NET programmers posting Friday Hugs or Lolcats on their blog? Or libraries named &#8220;can haz something&#8221;. &#8230; <a href="http://www.spacebabies.nl/2011/02/19/why-ruby-is-so-charming/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Part of why the Ruby community is so great is that it seems to attract quirky, ironic, playful and creative people. Can you imagine .NET programmers posting Friday Hugs or Lolcats on their blog? Or libraries named &#8220;can haz something&#8221;. Nope. It&#8217;s why I am extra grateful a person named Avdi has now created a completely serious <a href="http://avdi.org/devblog/2011/02/18/nonesuch-the-greatest-ruby-gem-evar/">gem to end all gems</a>. I use it in my production system and it rocks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2011/02/19/why-ruby-is-so-charming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing MySQL encoding issues with Ruby 1.9.2</title>
		<link>http://www.spacebabies.nl/2010/12/23/fixing-mysql-encoding-issues-with-ruby-1-9-2/</link>
		<comments>http://www.spacebabies.nl/2010/12/23/fixing-mysql-encoding-issues-with-ruby-1-9-2/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 13:53:46 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[rants]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=1686</guid>
		<description><![CDATA[There have been tens, hundreds, thousands blogs posts related to Latin1/UTF8 encoding issues. So here is yet another, this time related to upgrading from Ruby 1.8.6 + mysql gem to Ruby 1.9.2 + mysql2 gem.Here&#8217;s the thing: ever since Rails &#8230; <a href="http://www.spacebabies.nl/2010/12/23/fixing-mysql-encoding-issues-with-ruby-1-9-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>There have been tens, hundreds, thousands blogs posts related to Latin1/UTF8 encoding issues. So here is yet another, this time related to upgrading from Ruby 1.8.6 + mysql gem to Ruby 1.9.2 + mysql2 gem.<span id="more-1686"></span>Here&#8217;s the thing: ever since Rails 2.1 I was under the assumption that all strings in my app were UTF-8 throughout. Wrong. Depending on your database settings, HTML HEAD, database driver and Ruby version you might will have a mix of character sets. Jay!</p>
<p>A recent upgrade of <a href="http://www.zappelin.nl/">www.zappelin.nl</a> brought this to light:</p>
<ol>
<li>utf-8 present in HTML HEAD;</li>
<li>generated Rails app with all utf-8 defaults present;</li>
<li>mysql database still had latin1 as default character set;</li>
<li>same for the table;</li>
<li>using the old mysql driver gem.</li>
</ol>
<p>The above combination led to strings still being stored as latin1 in the database.</p>
<p>MySQL documentation mentions charset conversions using ALTER TABLE. These did not work &#8212; the offending characters remained in their original character set. In the MySQL console these were printed fine: for instance ë was visible in the correct places. However in the Ruby world this was displayed as Ã«. Wuh?</p>
<p>I briefly considered dropping down to unix and using iconv on the database dump.</p>
<p>Luckily I was just too lazy today. Turns out you can convert the offending column to BLOB first and then to the correct character set. This worked! So if you have this problem the query below might fix things.</p>
<blockquote><p>ALTER TABLE tbl_name MODIFY col1 BLOB;</p>
<p>ALTER TABLE tbl_name MODIFY col1 VARCHAR(255) CHARACTER SET utf8;</p></blockquote>
<p>However, it still needed a bit of magic with regards to the default charset on the table. My best combination was to first convert the entire table to use latin1 by default, then run the conversion, then set the default to utf8. However, this didn&#8217;t work always.</p>
<blockquote><p>ALTER TABLE tbl_name CONVERT TO CHARACTER SET latin1;</p></blockquote>
<p>Keep in mind to always use the <a href="https://github.com/brianmario/mysql2">mysql2</a> gem when running under Ruby 1.9.2. Anything else is rubbish since this will not know how to deal with UTF-8 and you app will break and you will cry.</p>
<p>My wish for 2011: a definitive end to character set issues plz. This really is no fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2010/12/23/fixing-mysql-encoding-issues-with-ruby-1-9-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>UPC Customer service FAIL</title>
		<link>http://www.spacebabies.nl/2010/11/10/upc-customer-service-fail/</link>
		<comments>http://www.spacebabies.nl/2010/11/10/upc-customer-service-fail/#comments</comments>
		<pubDate>Wed, 10 Nov 2010 21:35:12 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=875</guid>
		<description><![CDATA[Honest to God, actual autoreply from UPC (our cable company, possibly the worst customer support in the world): Let op: onderstaande link verwijst naar een pagina die op dit moment niet in gebruik is. Onze excuses hiervoor. http://vragen.upc.nl/app/account/profile Which translates &#8230; <a href="http://www.spacebabies.nl/2010/11/10/upc-customer-service-fail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Honest to God, actual autoreply from UPC (our cable company, possibly the worst customer support in the world):</p>
<blockquote><p>Let op: onderstaande link verwijst naar een pagina die op dit moment niet in gebruik is. Onze excuses hiervoor.<br />
<a href="http://vragen.upc.nl/app/account/profile">http://vragen.upc.nl/app/account/profile</a></p></blockquote>
<p>Which translates to:</p>
<blockquote><p>Please note: the link below points to a page which does not exist. Our apologies for this.</p></blockquote>
<p>Which is just fucking sad. UPC, you suck.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2010/11/10/upc-customer-service-fail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nerd humor</title>
		<link>http://www.spacebabies.nl/2010/09/11/nerd-humor/</link>
		<comments>http://www.spacebabies.nl/2010/09/11/nerd-humor/#comments</comments>
		<pubDate>Sat, 11 Sep 2010 12:19:41 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=786</guid>
		<description><![CDATA[Specifically: Ruby humor. Thanks lenmeister.]]></description>
			<content:encoded><![CDATA[<p>Specifically: <a href="http://bash.org/?925050">Ruby humor</a>. Thanks lenmeister.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2010/09/11/nerd-humor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing ImageMagick on Snow Leopard</title>
		<link>http://www.spacebabies.nl/2009/12/11/installing-imagemagick-on-snow-leopard/</link>
		<comments>http://www.spacebabies.nl/2009/12/11/installing-imagemagick-on-snow-leopard/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 11:11:08 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=457</guid>
		<description><![CDATA[Getting ImageMagick onto your computer would be so incredibly difficult I would often just forgo the entire thing and pray that image manipulation would sort of work on the server. Well, no more. Claudio Poli has written a great bash &#8230; <a href="http://www.spacebabies.nl/2009/12/11/installing-imagemagick-on-snow-leopard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Getting ImageMagick onto your computer would be so incredibly difficult I would often just forgo the entire thing and pray that image manipulation would sort of work on the server. Well, no more. Claudio Poli has written a great bash script to install the whole thing with one command. Clone <a href="http://github.com/masterkain/ImageMagick-sl">this repo</a> and execute it. Works perfectly!<br />
<span id="more-457"></span><br />
Afterward I had to add this to my Rails development.rb file:<br />
<code lang="ruby">Paperclip.options[:command_path] = "/usr/local/bin"</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2009/12/11/installing-imagemagick-on-snow-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveResource Twitter client</title>
		<link>http://www.spacebabies.nl/2009/12/01/activeresource-twitter-client/</link>
		<comments>http://www.spacebabies.nl/2009/12/01/activeresource-twitter-client/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 22:09:28 +0000</pubDate>
		<dc:creator>joost</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.spacebabies.nl/?p=447</guid>
		<description><![CDATA[Every tech blog should have a post about a Twitter client. Here&#8217;s mine. To be fair, my client has only eight seven lines of code, so it rocks. To update a Twitter status in a Ruby on Rails app, you &#8230; <a href="http://www.spacebabies.nl/2009/12/01/activeresource-twitter-client/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Every tech blog should have a post about a Twitter client. Here&#8217;s mine. To be fair, my client has only <del datetime="2009-12-03T20:41:15+00:00">eight</del> seven lines of code, so it rocks.<br />
<span id="more-447"></span><br />
To update a Twitter status in a Ruby on Rails app, you might resort to using some kind of plugin or library. You link that library, maybe include a parser or two, an http lib, who knows what. After you know your Tweet has ballooned into 1200 lines of code and is a mess to manage.<br />
It can be so much simpler, provided you&#8217;re inside a Ruby on Rails application.<br />
RoR has a RESTful service builtin, called ActiveResource. Turns out it is quite capable of tweeting:<br />
<code lang="ruby">class Tweet < ActiveResource::Base<br />
  self.site = "http://twitter.com/"<br />
  self.element_name = 'status'<br />
  self.timeout = 5</p>
<p>  self.user = USER<br />
  self.password = PASS<br />
end</code></p>
<p>To tweet, simply execute this line:<br />
<code lang="ruby">Tweet.post(:update, :status => "7 LOC Twitter API client FTW") if Rails.env.production?</code></p>
<p>Did you notice the check for production environment? That's just how leet this client is. Also, you might want to put a rescue block after it. Twitter tends to timeout, which raises an exception in ActiveResource.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.spacebabies.nl/2009/12/01/activeresource-twitter-client/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

