<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Buci on Rails</title>
	
	<link>http://bucionrails.com</link>
	<description>Ruby, Rails, TDD, programming</description>
	<pubDate>Wed, 28 Oct 2009 22:01:09 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/bucionrails" type="application/rss+xml" /><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbucionrails" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbucionrails" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbucionrails" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/bucionrails" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbucionrails" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fbucionrails" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fbucionrails" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>Rubygems under the hood: hooking into require</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/QzQK2Uk2TlU/</link>
		<comments>http://bucionrails.com/2009/10/28/rubygems-under-the-hood-hooking-into-require/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 21:54:12 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=64</guid>
		<description><![CDATA[(See the introduction to the series.)
When you want to pull in a Ruby library, you require it. The library you require has to be on Ruby&#8217;s load path ($LOAD_PATH) in order to succeed. So let&#8217;s see how Rubygems hooks into this process. 
The secret lies in custom_require.rb. You&#8217;ll see a nice comment near the top.

When [...]]]></description>
			<content:encoded><![CDATA[<p>(See <a href="http://bucionrails.com/2009/10/20/rubygems-under-the-hood-introduction/">the introduction</a> to the series.)</p>
<p>When you want to pull in a Ruby library, you require it. The library you require has to be on Ruby&#8217;s load path ($LOAD_PATH) in order to succeed. So let&#8217;s see how Rubygems hooks into this process. </p>
<p>The secret lies in custom_require.rb. You&#8217;ll see a nice comment near the top.</p>
<blockquote><p>
When you call &#8220;require &#8216;x&#8217;&#8221;, this is what happens:<br />
  * If the file can be loaded from the existing Ruby loadpath, it is.<br />
  * Otherwise, installed gems are searched for a file that matches.<br />
If it&#8217;s found in gem &#8216;y&#8217;, that gem is activated (added to the loadpath).
</p></blockquote>
<p>In fact, that explanation looks so straightforward to me that I doubt if I can add more words to precise it, so let&#8217;s look at the code together:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">&nbsp;
<span style="color:#9966CC; font-weight:bold;">module</span> <span style="color:#CC00FF; font-weight:bold;">Kernel</span>
  <span style="color:#9966CC; font-weight:bold;">alias</span> gem_original_require <span style="color:#CC0066; font-weight:bold;">require</span>
  <span style="color:#006600; font-weight:bold;">&#40;</span>...<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#CC0066; font-weight:bold;">require</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;"># :doc:</span>
    gem_original_require path
  <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">LoadError</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> load_error
    <span style="color:#9966CC; font-weight:bold;">if</span> load_error.<span style="color:#9900CC;">message</span> =~ <span style="color:#006600; font-weight:bold;">/</span><span style="color:#008000; font-style:italic;">#{Regexp.escape path}\z/ and</span>
       spec = Gem.<span style="color:#9900CC;">searcher</span>.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">then</span>
      Gem.<span style="color:#9900CC;">activate</span><span style="color:#006600; font-weight:bold;">&#40;</span>spec.<span style="color:#9900CC;">name</span>, <span style="color:#996600;">&quot;= #{spec.version}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      gem_original_require path
    <span style="color:#9966CC; font-weight:bold;">else</span>
      <span style="color:#CC0066; font-weight:bold;">raise</span> load_error
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#006600; font-weight:bold;">&#40;</span>...<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>Aliasing a method, redefining it and calling the original version from the redefined method is a very familiar pattern if you have read Rails source code (called method chaining). </p>
<p>So, just as the above description says, if the file can be loaded &#8220;without Rubygems&#8221; it is and Rubygems never comes into the picture. If not, we make sure that the load error comes from the file not found on the load path and then find the gemspec for that file and activate it. </p>
<p>Activating it adds it to the load path, so we can call the original require safe in the knowledge that it will now succeed and we won&#8217;t get another load error this time around (and go into an infinite loop). Clever, heh?</p>
<p>This is one of the cases when the code is so simple for a moment I think I could have written it myself. With its <10 lines of code Rubygems is empowered to load a myriad of useful Ruby libraries. Isn&#8217;t this wonderful?</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=QzQK2Uk2TlU:s3PwVsVKXEM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=QzQK2Uk2TlU:s3PwVsVKXEM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=QzQK2Uk2TlU:s3PwVsVKXEM:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/QzQK2Uk2TlU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/10/28/rubygems-under-the-hood-hooking-into-require/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/10/28/rubygems-under-the-hood-hooking-into-require/</feedburner:origLink></item>
		<item>
		<title>RubyGems under the hood: Introduction</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/1HQhJQpQcOo/</link>
		<comments>http://bucionrails.com/2009/10/20/rubygems-under-the-hood-introduction/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 13:52:13 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=63</guid>
		<description><![CDATA[I am not sure about you, but one thing I keep bumping into while developing ruby applications is rubygem version conflicts. If you have ever come across &#8220;can&#8217;t activate activesupport (= 2.3.4, runtime) for [], already activated activesupport-2.3.3 for []&#8221; type of errors, you might be sympathetic to the cause.
Since rubygems was and is being [...]]]></description>
			<content:encoded><![CDATA[<p>I am not sure about you, but one thing I keep bumping into while developing ruby applications is rubygem version conflicts. If you have ever come across &#8220;can&#8217;t activate activesupport (= 2.3.4, runtime) for [], already activated activesupport-2.3.3 for []&#8221; type of errors, you might be sympathetic to the cause.</p>
<p>Since <a href="http://rubygems.org/">rubygems</a> was and is being written by some <a href="http://chadfowler.com">excellent</a> <a href="http://richkilmer.blogs.com/">Ruby</a> <a href="http://onestepback.org/">minds</a> I knew the fault probably lies with me and not with the tool. Being a <a href="http://manifesto.softwarecraftsmanship.org/">motivated and proud craftsman</a> I felt like I needed to know my tools and rubygems is probably the number one tool most of us Ruby developers use on a daily basis.</p>
<p>I intend to write a mini-series of Rubygems posts. A post will be added to the series when I explore some murky corner of rubygems inner mechanics. Some of the time this will come from a particular problem I come across while coding while on other occasions I might just look into the source code and try to understand what a particular piece of code does.</p>
<p>Now, I realized that when I read on a blog: &#8220;I will go into more detail about X in a forthcoming post&#8221;, it is the surest sign that you will never read about X again. At least not on that very blog. And I am not saying this in a mean way, I think it is very natural for our plans to change (&#8221;evolve&#8221; may sound better) even on the short term. So I am aiming low and hoping to give you more than you expected. (Notice I wrote &#8220;mini-series&#8221; which may just mean a couple of posts.)</p>
<h2>Do not set your expectations high</h2>
<p>I am absolutely not a Rubygems expert so please do not be fooled by the &#8220;under the hood&#8221; title. This will not be commensurate to <a href="http://weblog.jamisbuck.org/2006/10/2/under-the-hood-rails-routing-dsl">Jamis Buck&#8217;s series on Rails routing</a>. I do not -yet?- have a deep insight and I am not even a contributor to Rubygems.</p>
<p>The forthcoming :) series is just a humble attempt to gain an understanding of a very important part of the Ruby arsenal. I hope to understand it better by explaining to you how it works and I hope you will understand it better by reading my explanation. And last, but not least, I hope we&#8217;ll both spend less time debugging those tricky issues.</p>
<p>Having said that, I encourage you to participate in the series. Tell me about a particular problem you had with Rubygems. Correct me if I am wrong. Point me to an article where all this is already explained, and much better. Give feedback so this might evolve to be a discussion rather than an academic lecture. Thank you.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=1HQhJQpQcOo:rGLeWyEnKhU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=1HQhJQpQcOo:rGLeWyEnKhU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=1HQhJQpQcOo:rGLeWyEnKhU:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/1HQhJQpQcOo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/10/20/rubygems-under-the-hood-introduction/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/10/20/rubygems-under-the-hood-introduction/</feedburner:origLink></item>
		<item>
		<title>Cucumber meets Selenium meets Integrity</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/w00Ko0qeBrs/</link>
		<comments>http://bucionrails.com/2009/09/25/cucumber-meets-selenium-meets-integrity/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 13:08:03 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=62</guid>
		<description><![CDATA[Continuous integration (CI) is a basic building block of any project done in TDD style. In brief, having a CI server properly set up guarantees that developers can rest assured that the application passes all its tests and can thus be deployed at any moment. It does this by sending some kind of a warning [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://martinfowler.com/articles/continuousIntegration.html">Continuous integration</a> (CI) is a basic building block of any project done in TDD style. In brief, having a CI server properly set up guarantees that developers can rest assured that the application passes all its tests and can thus be deployed at any moment. It does this by sending some kind of a warning if something is broken so it can be fixed immediately.</p>
<p>Now I noticed that if a CI server is not in the mix right from the beginning of project, chances are it will never be, that was one of the first things I installed on a new Rails project. My server of choice is <a href="http://integrityapp.com">Integrity</a> mostly because it is so easy to set up and quite straightforward to use.</p>
<p>Ok, so next we need some tests that Integrity will run at each commit and make sure the app can still be built. As a high-level acceptance test framework, I use <a href="http://cukes.info">Cucumber</a>, which plays very nicely with <a href="http://seleniumhq.org/">Selenium </a>for automated in-browser testing. Since nowadays even the most basic web application will have some amount of client-side scripting code (that is, javascript) if you really want to test the features of your application you&#8217;ll need Selenium tests.</p>
<p>That&#8217;s when matters get a bit more complicated when it comes to integrating these with the Integrity server. Why? Because on the server you usually don&#8217;t have the &#8220;desktop environment&#8221; which is available on the machine you do the development on. By default, you don&#8217;t run a desktop manager and have a graphic display on a server. A tool called <a href="http://linux.about.com/cs/linux101/g/xvfb.htm">xvfb</a> comes into a picture that emulate a dumb framebuffer so you can still programs that need a graphic display.</p>
<p>To have some practical guidance, here&#8217;s what I did on an Ubuntu server to enable all of the above:</p>
<p>Install java since Selenium runs in the JVM:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> java-common sun-java6-jre</pre></div></div>

<p>Install firefox since that&#8217;s what Selenium runs by default and that&#8217;s a very good choice.</p>

<div class="wp_syntax"><div class="code"><pre class="bash">apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> firefox</pre></div></div>

<p>Install X since that&#8217;s what the xvfb launches and Xvfb itself.</p>

<div class="wp_syntax"><div class="code"><pre class="bash">apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> xorg xserver-xorg
&nbsp;
apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> xvfb</pre></div></div>

<p>Next I found a <a href="http://wiki.openqa.org/display/SRC/Selenium-RC+and+Continuous+Integration">wiki</a> that describes how to launch the Xvfb correctly. Log into the server and do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">startx -- `<span style="color: #c20cb9; font-weight: bold;">which</span> Xvfb` :<span style="color: #000000;">1</span> -screen <span style="color: #000000;">0</span> 1024x768x24 <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></div>

<p>So Xvfb will run on the DISPLAY :1. So far so good. But something was still not quite right. When integrity launched the test suite that included some Cucumber-Selenium tests I received an error message basically saying that no browser sessions could be started. And the solution to that, in fact, is where this post wants to get at.</p>
<p>After a decent amount of head-scratching and code mining I realized that the Selenium server starts the browser on the same display where the server itself (the jar file) runs. I have found the relevant code that assembles the command that starts the Selenium server in the selenium-client gem and figured it was not meant to be run in graphic hardware-less environment since I saw no options to define which display it should run on. So as an <a href="http://github.com/balinterdi/selenium-client/commit/37094df174b5c52cb68d041f7dc940e501b3e438">easy hack I added the hardcoded &#8220;DISPLAY=:1&#8243; before it</a> and crossed my fingers.</p>
<p>Bingo, it worked and I had a green build again! What&#8217;s more surprising is that it still runs perfectly on my Macbook so it seems to run in (some) graphical environments, too. It seems a bit strange to me to have found so little information on this subject since Rails, Cucumber, Selenium and CI are all en vogue so it is possible that I missed something obvious and there is an easier way to do all this. I am very eager to hear how others set up their CI to run automated-browser features. Do you use another tool, not Selenium? Do you use a CI server with a monitor?</p>
<p>Anyway, I certainly hope my hackish solution will prove to be useful for some of you TDD-minded developers out there who run their CI on a simple &lt;name of your favorite provider here&gt; slice.</p>
<p><strong>UPDATE: </strong>As <a href="http://lackac.hu/">a fellow developer</a> and <a href="http://github.com/ph7">the author of the selenium-client gem himself</a> pointed out library code is not the place for enviroment specific settings. Rather, it should go into the application&#8217;s code. I guess that leaves the choice of putting it into the code of the application you are building or the configuration of the CI server. This latter seemed more clean to me so I put the following line into config.ru in Integrity&#8217;s directory:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">env<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;DISPLAY&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;:1&quot;</span></pre></div></div>

<p>There is still something left, though. When integrity -or, to be precise, the selenium process that was launched from integrity- wants to access display :1, it will be denied. You need to explicitly enable local connections by putting &#8220;localhost&#8221; in a file:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'localhost'</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>X99.cfg</pre></div></div>

<p>, and then using that file as the access records list when you launch the server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">xinit -- `<span style="color: #c20cb9; font-weight: bold;">which</span> Xvfb` :<span style="color: #000000;">1</span> -screen <span style="color: #000000;">0</span> 1024x768x24 -auth <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>X99.cfg <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&amp;</span></pre></div></div>

<p>(Note that I launch xinit and not startx as before. startx somehow adds another -auth option which messes things up)</p>
<p>There, that should do it. It works and there is no code where it does not belong.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=w00Ko0qeBrs:soLi_eIuwTM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=w00Ko0qeBrs:soLi_eIuwTM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=w00Ko0qeBrs:soLi_eIuwTM:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/w00Ko0qeBrs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/09/25/cucumber-meets-selenium-meets-integrity/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/09/25/cucumber-meets-selenium-meets-integrity/</feedburner:origLink></item>
		<item>
		<title>A prime example of not eating your own dog food</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/UPXD02tg17I/</link>
		<comments>http://bucionrails.com/2009/07/14/a-prime-example-of-not-eating-your-own-dog-food/#comments</comments>
		<pubDate>Tue, 14 Jul 2009 16:49:51 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[misc]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=61</guid>
		<description><![CDATA[I realized how 20th century (plus boring and error-prone) it is to write one&#8217;s invoices by hand. So I went looking for an invoicing application. My expectations were quite low: I wanted one which can be used from my MacBook, has some basic functions that cut down on typing (e.g a client &#8220;database&#8221;), has a [...]]]></description>
			<content:encoded><![CDATA[<p>I realized how 20th century (plus boring and error-prone) it is to write one&#8217;s invoices by hand. So I went looking for an invoicing application. My expectations were quite low: I wanted one which can be used from my MacBook, has some basic functions that cut down on typing (e.g a client &#8220;database&#8221;), has a decent design and UI, can make out invoices in different currencies and did not cost more than ~$100.</p>
<p>It seemed like I have found <a href="http://www.native.hu">one</a>, which, though it had several minor bugs, seemed acceptable, so I purchased the Basic version. Everything went reasonably well until I had to make out my first invoice in euros. It turned out that the Basic version can only make invoices in Hungarian forints in spite of having a couple of other functionalities (e.g set the VAT rate to 0% automatically on invoices made out to EU companies) which made me think it could make it in euros, too.</p>
<p>Ok, so accounting hell got me again. I sighed and asked the <a href="http://www.awasoft.hu/">company</a> how much it would cost to have this funcionality. I was informed I had to buy the upgrade to the Business version which costs ~$120 more, roughly the double of the original price I paid! That was too much to take, so I went looking for another invoicing application. After all, it should not be an insurmountable task to write such an app, I murmured to myself.</p>
<p>I did find a <a href="http://lessaccounting.com">couple of</a> <a href="http://billingsapp.com">very good</a> applications which even overdo what I want them to accomplish. However, the Hungarian homologue of the IRS basically shuts out any foreign competitors by regulating very heavily which conditions must be fulfilled by an invoicing application for a Hungarian company to be able to use it. Bummer.</p>
<p>&#8220;There is still a glimmer of hope.&#8221; - I thought. I checked the Hungarian scene still thinking it could not be that difficult to meet my expectations. Well, apparently I was wrong. The <a href="http://szamlazz.hu">ones</a> <a href="http://cipo.hu">I</a> <a href="https://symbion.eu/">found</a> are either overcomplicated to use, look like home pages in the 80s or are way too expensive. Sometimes all of these. So I put off the challenge of finding an acceptable piece of software and got back of writing invoices manually.</p>
<p>Now you might wonder where <a href="http://en.wikipedia.org/wiki/Eating_one%27s_own_dog_food">the dog food</a> is in the story. Well, today I received the invoice from the company of my purchase of the Basic version of the application. It was written manually on an invoice sheet :) That&#8217;s tantamount of Steve Jobs using a PC with Windows Vista.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=UPXD02tg17I:nWsLIS7K5NU:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=UPXD02tg17I:nWsLIS7K5NU:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=UPXD02tg17I:nWsLIS7K5NU:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/UPXD02tg17I" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/07/14/a-prime-example-of-not-eating-your-own-dog-food/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/07/14/a-prime-example-of-not-eating-your-own-dog-food/</feedburner:origLink></item>
		<item>
		<title>John Doe is dull: the importance of choosing good user names in tests</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/fcIk4209HCs/</link>
		<comments>http://bucionrails.com/2009/07/12/john-doe-is-dull-the-importance-of-choosing-good-user-names-in-tests/#comments</comments>
		<pubDate>Sun, 12 Jul 2009 07:00:23 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[productivity]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=59</guid>
		<description><![CDATA[We, developers, have to come up with user names all the time. In this glorious, pioneer era of TDD, more than ever we have to not only enter them into text fields but write them in test files that are part of the code and thus are clearly visible and permanent.
So it is important to [...]]]></description>
			<content:encoded><![CDATA[<p>We, developers, have to come up with user names all the time. In this glorious, pioneer era of TDD, more than ever we have to not only enter them into text fields but write them in test files that are part of the code and thus are clearly visible and permanent.</p>
<p>So it is important to give good names, but what is a good name like? I am not thinking about the semantics of the name (whether it has accented letters, or if it has two or three parts, etc.) but look at them from a very personal point of view: whether it makes you, the programmer, satisfied with your choice of names or bored with repeating the same old names you used in other projects and even in those projects, you had copied them from somewhere.</p>
<p>So when writing your first test where a user is needed, stop for a moment and imagine a world which you like and which is amusing in the context of your application&#8217;s domain (like <a href="http://www.youtube.com/watch?v=F2kAnTZBnTg">philosophers playing soccer</a>, Luddites attending a technology conference, etc.). Pick some names and let the feeling that you have created something instead of just using old, boring names fill you with contentment. Whenever you need an other name, take one from your world. If you need further data (e.g date of birth) about your test users you can even do a little bit of research.</p>
<p>Though investing energy in this may reduce the time you spend writing code, compared to all the hours you put into a project, it is negligible. Nurturing this &#8220;subculture&#8221; in your tests can be very entertaining so you have a good time developing and are less prone to boredom. I think it pays off. We, Ruby programmers all know how important it is to be happy while programming and the effect it has on our productivity.</p>
<p>And besides, do you know of anyone who is called John Doe?</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=fcIk4209HCs:sUiO4bF-odc:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=fcIk4209HCs:sUiO4bF-odc:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=fcIk4209HCs:sUiO4bF-odc:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/fcIk4209HCs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/07/12/john-doe-is-dull-the-importance-of-choosing-good-user-names-in-tests/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/07/12/john-doe-is-dull-the-importance-of-choosing-good-user-names-in-tests/</feedburner:origLink></item>
		<item>
		<title>The hashtag (HRT) retweet bot gemified</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/rAEBfWR4ccE/</link>
		<comments>http://bucionrails.com/2009/07/10/the-hashtag-hrt-retweet-bot-gemified/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 16:48:10 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=60</guid>
		<description><![CDATA[A very simple twitter bot that retweeted everything that was tagged by a certain tag was put together for Scotland on Rails &#8216;09. Then, Jaime Iniesta adapted it for Euruko &#8216;09. I then forked from his repository, made a few simplifications and minor improvements and DRY-d its configuration.
Maybe most importantly I then turned it into [...]]]></description>
			<content:encoded><![CDATA[<p>A very simple twitter bot that retweeted everything that was tagged by a certain tag was put together for Scotland on Rails &#8216;09. Then, <a href="http://www.jaimeiniesta.com/">Jaime Iniesta</a> adapted it for Euruko &#8216;09. I then forked from his repository, made a few simplifications and minor improvements and DRY-d its configuration.</p>
<p>Maybe most importantly I then turned it into <a href="http://github.com/balinterdi/hashtag_retweet_bot">a gem</a> so that configuration files (including the bot&#8217;s which has the credentials for the twitter account) do not have to be included in the repository.</p>
<p>I also set up <a href="http://twitter.com/budapestrb">a twitter account for the budapest.rb</a> group where an instance of the HRT  bot will post any tweets that have been tagged with #budapestrb. So, my fellow budapest.rb programmers, if you have anything to say about the budapest.rb, just make sure you include the #budapestrb tag in your tweet and watch the HRT bot repeat it.</p>
<p>To launch your own hashtag retweet bot, just follow the instructions in <a href="http://github.com/balinterdi/hashtag_retweet_bot/tree/master">the README</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=rAEBfWR4ccE:MExxzO2el70:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=rAEBfWR4ccE:MExxzO2el70:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=rAEBfWR4ccE:MExxzO2el70:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/rAEBfWR4ccE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/07/10/the-hashtag-hrt-retweet-bot-gemified/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/07/10/the-hashtag-hrt-retweet-bot-gemified/</feedburner:origLink></item>
		<item>
		<title>Pragmatic Thinking and Learning on Twitter</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/wX1epjUDez8/</link>
		<comments>http://bucionrails.com/2009/07/03/pragmatic-thinking-and-learning-on-twitter/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 19:20:54 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=58</guid>
		<description><![CDATA[Some of you may be aware of my grandiose plans with my twitter mini-framework named twuckoo. For my part I am constantly thinking about -hopefully reasonable- ways that it could be used for the better of mankind :)
The other part of the story is my enthusiasm with Pragmatic Programmers books. I have recently started Pragmatic [...]]]></description>
			<content:encoded><![CDATA[<p>Some of you may be aware of my grandiose plans with my twitter mini-framework named <a href="http://bucionrails.com/2009/06/22/twuckoo/">twuckoo</a>. For my part I am constantly thinking about -hopefully reasonable- ways that it could be used for the better of mankind :)</p>
<p>The other part of the story is my enthusiasm with Pragmatic Programmers books. I have recently started <a href="http://pragprog.com/titles/ahptl/pragmatic-thinking-and-learning">Pragmatic Thinking and Learning</a> by Andy Hunt which is also a very good one and found the familiar &#8220;resuming card&#8221; at the end. This card sums up the wisdom of the book in short phrases just so that you can recall what you read quickly. It is a great idea and can be found in other PP books, too.</p>
<p>So I asked at a PP email address which seemed to be closest to copyright questions whether I have the right to do this. To my surprise, it was the author himself, <a href="http://blog.toolshed.com/">Andy Hunt</a>, who answered me and kindly gave me permission for the book in question. (Once again, thank you, Andy!)</p>
<p>So there you have it, <a href="https://twitter.com/pragthinklearn">a twitter account that will serve you an advice each day</a> just so that you can &#8220;refactor your wetware&#8221; (the subtitle of the book) and hopefully help you be a better craftsman.</p>
<p>And now, my little twuckoo, on to world domination!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=wX1epjUDez8:W0BaQN5-YrI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=wX1epjUDez8:W0BaQN5-YrI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=wX1epjUDez8:W0BaQN5-YrI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/wX1epjUDez8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/07/03/pragmatic-thinking-and-learning-on-twitter/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/07/03/pragmatic-thinking-and-learning-on-twitter/</feedburner:origLink></item>
		<item>
		<title>installing ruby on a linode slice</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/aJNyPTzv2vA/</link>
		<comments>http://bucionrails.com/2009/07/02/installing-ruby-on-a-linode-slice/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 20:35:22 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=56</guid>
		<description><![CDATA[To be able to experiment freely and find a store for my twuckoos and other goodies I have recently purchased a Linode 360 slice and had Ubuntu 9.04 installed on it. Next thing was setting up ruby (ruby 1.8.6, to be precise).
When deciding about how to install ruby, in part I wanted to have flexibility [...]]]></description>
			<content:encoded><![CDATA[<p>To be able to experiment freely and find a store for my <a href="http://bucionrails.com/2009/06/22/twuckoo/">twuckoos</a> and other goodies I have recently purchased a Linode 360 slice and had Ubuntu 9.04 installed on it. Next thing was setting up ruby (ruby 1.8.6, to be precise).</p>
<p>When deciding about how to install ruby, in part I wanted to have flexibility but mostly I wanted to feel like I am a professional sysadmin for some hours so I balked at pre-built ruby packages and went with the roll-your-own approach. I&#8217;ll summarize below the process and some pitfalls I encountered so it might help someone.</p>
<h2>Some basic tools</h2>
<p>First, you will need wget (or curl) to download the sources you will need along the way, so:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">wget</span></pre></div></div>

<p>Also, before you stare dumbly at the screen (like I did) wondering why can&#8217;t the stupid machine run make when the Makefile is clearly there in the directory , don&#8217;t forget to install make:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<h2>Updating the package repos</h2>
<p>Plus, since we&#8217;ll be installing packages that are found in the &#8220;universe&#8221; namespace (or whatever it is called) you should uncomment the below two lines in /etc/apt/sources.list :</p>

<div class="wp_syntax"><div class="code"><pre class="bash">deb http:<span style="color: #000000; font-weight: bold;">//</span>us.archive.ubuntu.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span> jaunty universe
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>us.archive.ubuntu.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span> jaunty universe</pre></div></div>

<p>&#8230; and then update your package index:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-get update</pre></div></div>

<h2>Installing some packages ruby needs</h2>
<p>Before we download and build ruby, however, it is recommendable to have the zlib and openssl libraries so ruby can already bind to them. This is one of the things that is a lot easier to see with hindsight, but here I am, blogging this to you:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> zlib1g zlib1g-dev zlibc
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> openssl</pre></div></div>

<p>It turns out from <a href="http://www.ruby-forum.com/topic/71774">this thread</a>, that the zlib bindings are part of ruby since 1.8.6 so you will not need the libzlib-ruby package.</p>
<p>Now, on to ruby itself.</p>
<h2>Ruby &amp; Rubygems</h2>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #c20cb9; font-weight: bold;">ftp</span>:<span style="color: #000000; font-weight: bold;">//</span><span style="color: #c20cb9; font-weight: bold;">ftp</span>.ruby-lang.org<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000;">-1.8</span><span style="color: #000000;">.6</span>-p369.<span style="color: #c20cb9; font-weight: bold;">tar</span>.bz2
<span style="color: #7a0874; font-weight: bold;">&#40;</span>untar and <span style="color: #7a0874; font-weight: bold;">cd</span> to new directory<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
configure: error: no acceptable C compiler found <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$PATH</span></pre></div></div>

<p>Piece of cake:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
configure: error: <span style="color: #000000; font-weight: bold;">in</span> `<span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>balint<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000;">-1.8</span><span style="color: #000000;">.6</span>-p369<span style="color: #ff0000;">':
configure: error: C compiler cannot create executables
See `config.log'</span> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">more</span> details.</pre></div></div>

<p>A bit harder, but I have quickly found the answer <a href="http://ubuntuforums.org/showthread.php?t=17033">here</a>, and then did:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apt-get <span style="color: #c20cb9; font-weight: bold;">install</span> libc6-dev <span style="color: #c20cb9; font-weight: bold;">g++</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ ruby -e <span style="color: #ff0000;">&quot;p 'hello from linode slice'&quot;</span>
<span style="color: #ff0000;">&quot;hello from linode slice&quot;</span></pre></div></div>

<p>Rolling!</p>
<p>However, we all know that a ruby installation without gems is a toothless tiger (lion?) so we&#8217;ll install rubygems last, first downloading the source, and then installing it:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>frs<span style="color: #000000; font-weight: bold;">/</span>download.php<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">57643</span><span style="color: #000000; font-weight: bold;">/</span>rubygems<span style="color: #000000;">-1.3</span><span style="color: #000000;">.4</span>.tgz
<span style="color: #7a0874; font-weight: bold;">&#40;</span>untar and <span style="color: #7a0874; font-weight: bold;">cd</span> to new directory<span style="color: #7a0874; font-weight: bold;">&#41;</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> ruby setup.rb</pre></div></div>

<p>If you want to use gems stored on github (and you probably do) it is convenient to add the gem github repository to your gem sources:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ gem <span style="color: #7a0874; font-weight: bold;">source</span> -a http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> balinterdi-twuckoo</pre></div></div>

<p>Ok, that&#8217;s all. I hope you have found this useful.</p>
<hr /><em>Note:</em></p>
<p>If you receive an error message similar to the following when trying to install a gem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>site_ruby<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>rubygems<span style="color: #000000; font-weight: bold;">/</span>custom_require.rb:<span style="color: #000000;">31</span>:<span style="color: #000000; font-weight: bold;">in</span> `gem_original_require<span style="color: #ff0000;">': no such file to load -- zlib (LoadError)</span></pre></div></div>

<p>Then you need to install the appropriate lib package and recompile ruby. Go to the directory where you unpacked the ruby source to and do:</p>

<div class="wp_syntax"><div class="code"><pre class="bash">$ <span style="color: #c20cb9; font-weight: bold;">make</span> clean
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=aJNyPTzv2vA:DPvgDRNgcJA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=aJNyPTzv2vA:DPvgDRNgcJA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=aJNyPTzv2vA:DPvgDRNgcJA:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/aJNyPTzv2vA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/07/02/installing-ruby-on-a-linode-slice/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/07/02/installing-ruby-on-a-linode-slice/</feedburner:origLink></item>
		<item>
		<title>twuckoo - my twitter mini framework</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/MRhQFEcijXs/</link>
		<comments>http://bucionrails.com/2009/06/22/twuckoo-my-twitter-mini-framework/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 20:01:40 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=53</guid>
		<description><![CDATA[I am reading Andy Hunt&#8217;s excellent Pragmatic Thinking and Learning book. There is a section about so called &#8220;oblique strategies&#8221;, short, mysterious phrases that exercise your mind and make you look at problems from another perspective (e.g &#8220;repetition is a form of change&#8221;).
The suggested intake was once a day and there was a free application [...]]]></description>
			<content:encoded><![CDATA[<p>I am reading Andy Hunt&#8217;s excellent Pragmatic Thinking and Learning book. There is a section about so called &#8220;oblique strategies&#8221;, short, mysterious phrases that exercise your mind and make you look at problems from another perspective (e.g &#8220;repetition is a form of change&#8221;).</p>
<p>The suggested intake was once a day and there was a free application that did just this for Apple computers. However, the application was so outdated that I could no longer run it on my laptop. So, I set out to write that application and after a bit of thinking decided to make a twitter account where I (&#8221;I&#8221; meaning a script that I wrote :) ) would post an oblique strategy each day and then just follow that account. This way, I can also spread the knowledge around.</p>
<p>Thus <a title="Twuckoo" href="http://github.com/balinterdi/twuckoo/tree/master">Twuckoo</a> was born. Twuckoo is a simple program (relying on <a href="http://github.com/cjohansen/twibot/tree/master">twibot</a> for communication with twitter) that lets you periodically post a message on a twitter account. It can fetch the messages from a file, from a database, from the web or whereever you want it to retrieve them from. Its very modular in nature so it delegates the task of getting the next message to twitter and storing the posts to the module. here is currently one generic module, the one that fetches them from a file, and one that fetches them from wikipedia&#8217;s main page. I strongly hope that it is very easy for you to write your own module for your own purpose. Twuckoo aims to follow the &#8220;provide-what&#8217;s-needed-and-then-just-get-out-of-the-way&#8221; principle. Go check out <a href="http://github.com/balinterdi/twuckoo/tree/master">the README</a> for further details.</p>
<p>It&#8217;s quite easy to install and run. You can find an example for the file-fetcher module at <a href="http://twitter.com/daily_oblique">http://twitter.com/daily_oblique</a> and <a href="http://twitter.com/wikipedia_tfa">http://twitter.com/wikipedia_tfa</a> grabs &#8220;Today&#8217;s Featured Article&#8221; from wikipedia and posts the title and the link so you can grow a little wiser each day :)</p>
<p>Since it is modular it&#8217;s very extensible. I kept the API very simple so writing modules should be a piece of cake. Each module has to define the following methods:</p>
<ol>
<li><strong>load_tweets</strong> Loads the messages that can be twittered.</li>
<li><strong>next</strong> Gets the next message that will be posted.</li>
<li><strong>store(tweet)</strong> Store the tweet after it had been posted.</li>
</ol>
<p>Once more, I encourage you to scan through <a href="https://github.com/balinterdi/twuckoo/">the README</a>, devise your own module and let me know about it. Any feedback is very welcome!</p>
<p>Note: For my Hungarian-speaking readers, I gave a <a href="http://docs.google.com/Presentation?id=dccxt9fm_3g8nf5fm5">lightning talk about twuckoo</a> at the latest budapest.rb meetup.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=MRhQFEcijXs:3LDnIfRNXDI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=MRhQFEcijXs:3LDnIfRNXDI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=MRhQFEcijXs:3LDnIfRNXDI:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/MRhQFEcijXs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/06/22/twuckoo-my-twitter-mini-framework/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/06/22/twuckoo-my-twitter-mini-framework/</feedburner:origLink></item>
		<item>
		<title>acts_as_trivia: would you like to play?</title>
		<link>http://feedproxy.google.com/~r/bucionrails/~3/VkJ95OLDjnI/</link>
		<comments>http://bucionrails.com/2009/05/18/acts_as_trivia-would-you-like-to-play/#comments</comments>
		<pubDate>Mon, 18 May 2009 06:44:36 +0000</pubDate>
		<dc:creator>balint</dc:creator>
		
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://bucionrails.com/?p=52</guid>
		<description><![CDATA[We all love playing games, from poker to soccer, from hide&#8217;n seek to &#8230; trivia! I am a great fan of this latter and also of Rails apps so it was kind of natural for me to come up with the idea of using all the data in your Rails app to serve as the [...]]]></description>
			<content:encoded><![CDATA[<p>We all love playing games, from poker to soccer, from hide&#8217;n seek to &#8230; trivia! I am a great fan of this latter and also of Rails apps so it was kind of natural for me to come up with the idea of using all the data in your Rails app to serve as the basis of trivia questions.</p>
<p>The ingredients are few and basic. You have a class with an attribute that is comparable and makes sense to compare (the population of states is a good example, the zip code of addresses is a counter-example).</p>
<h3>Installation</h3>
<h4>Install the gem</h4>
<ol>
<li>Install the gem through Rails&#8217;s config.gem</li>
<p>Put this: </p>
<pre code="bash">
    config.gem "balinterdi-acts_as_trivia", :source => "http://gems.github.com",
:lib => "acts_as_trivia"
</pre>
<p></p>
<p>in your environment.rb and then run <em>rake gems:install</em> or <em>rake gems:unpack</em>.</p>
<li>Install it system-wide with the gem command</li>
<pre code="bash">
  gem install acts_as_trivia --source http://gems.github.com
</pre>
</ol>
<h4>Make your app act as a trivia</h4>
<p></p>
<p>You just have to run the provided trivia from the root of your Rails application:</p>
<pre code="bash">
  ./script/generate acts_as_trivia
</pre>
<h4>Create trivia questions easily from the command line</h4>
<p></p>
<pre code="bash">
    ./script.generate acts_as_trivia_record country population name</pre>
</pre>
<p style="margin-top:20px">This trivia question will be about the <i>population</i> of <i>countries</i> and the  <em>name</em> of each will be used by the provided helpers for the sake of displaying something unique of each country.</p>
<h4>Create the pages to answer and assess trivia</h4>
<p></p>
<p>The acts_as_trivia gem only aims to provide a clean interface and the logic, so you will have to create the <em>new</em> controller action of the <em>TriviaAnswersController</em> and the corresponding view: </p>
<pre code="bash">
  /users/:user_id/trivias/:trivia_id/trivia_answers/new
</pre>
<p  style="margin-top:20px">However, you can take a look at these files in the <a href="=http://gist.github.com/raw/107361/f31caad451f0cca699288700aa3d98291a259fd1/gistfile1.rb">rails app generator</a> or just directly copy them.</p>
<h3>Get right in the game</h3>
<p>Instead of going through the above steps, you can use a rails app generator to set up a trivia app quickly: </p>
<pre code="bash">
rails my_shiny_app -m
http://gist.github.com/raw/107361/f31caad451f0cca699288700aa3d98291a259fd1/gistfile1.rb
</pre>
<p style="margin-top:20px">Once you go through the setup steps of the app generator, you have everything you need to have a functioning trivia app, so you can go to: </p>
<pre code="bash">
  /users/1/trivias/1/trivia_answers/new
</pre>
<p style="margin-top:20px">And if you created model instances you can already answer your first trivia question. For a more technical (and more complete) description, please see <a href="http://github.com/balinterdi/acts_as_trivia/tree/master">the README</a>. Also, since this is a beta version, please make sure to report any bugs you might come across.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/bucionrails?a=VkJ95OLDjnI:jiik1o7hDxs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/bucionrails?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/bucionrails?a=VkJ95OLDjnI:jiik1o7hDxs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/bucionrails?i=VkJ95OLDjnI:jiik1o7hDxs:F7zBnMyn0Lo" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/bucionrails/~4/VkJ95OLDjnI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://bucionrails.com/2009/05/18/acts_as_trivia-would-you-like-to-play/feed/</wfw:commentRss>
		<feedburner:origLink>http://bucionrails.com/2009/05/18/acts_as_trivia-would-you-like-to-play/</feedburner:origLink></item>
	</channel>
</rss>
