<?xml version='1.0'?><rss xmlns:admin='http://webns.net/mvcb/' version='2.0' xmlns:sy='http://purl.org/rss/1.0/modules/syndication/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
    <channel>
    <title>Explorations...</title>
    <link>http://www.kanthak.net/explorations</link>
    <description>Exploring technology and other stuff</description>
    <dc:language>en-us</dc:language>
    <dc:creator/>
    <dc:date>2006-02-06T18:19:45+00:00</dc:date>
    <admin:generatorAgent rdf:resource='http://hobix.com/?v=0.4'/>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase>
    <item><title>Canada On Rails</title><link>http://www.kanthak.net/explorations/blog/rails/canada_on_rails.html</link><guid isPermaLink='false'>blog/rails/canada_on_rails@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2006-02-06T18:18:52+00:00</dc:date><description>&lt;p&gt;&lt;a href=&quot;http://canadaonrails.com&quot;&gt;&lt;img src=&quot;http://canadaonrails.com/media/buttons/350x50_1.gif&quot; title=&quot;Canada on Rails&quot; alt=&quot;Canada on Rails&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;It&amp;#8217;s official. I&amp;#8217;m honored to be among the list of speakers for the upcoming
&lt;a href=&quot;http://canadaonrails.com&quot;&gt;Canada on Rails&lt;/a&gt; conference, which will be held on
April 13th-14th in beautiful Vancouver. Of course, the &amp;#8220;big names&amp;#8221; 
like &lt;span class=&quot;caps&quot;&gt;DHH&lt;/span&gt; or Thomas Fuchs and a bunch of other great people are
giving talks and keynotes as well, so be sure to reserve your ticket
as soon as possible. Hope to see you there, in April!&lt;/p&gt;


	&lt;p&gt;Just a quick note, why I have been silent for so long. I just
finished my master&amp;#8217;s thesis which can be a tedious and very
stressful job. Especially when it is concerned with Java Virtual
Machines, I should have picked a ruby-related topic. I&amp;#8217;m currently
preparing a new release of file_column with lots of goodies, so stay tuned!&lt;/p&gt;</description></item><item><title>Goto Dice.Com?</title><link>http://www.kanthak.net/explorations/blog/tech/goto_dice_com.html</link><guid isPermaLink='false'>blog/tech/goto_dice_com@http://www.kanthak.net/explorations</guid><dc:subject>blog/tech</dc:subject><dc:subject>blog/tech</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-11-29T19:14:23+00:00</dc:date><description>&lt;p&gt;The other day, I&amp;#8217;ve seen the following add from dice.com (a job portal).&lt;/p&gt;


	&lt;p&gt;&lt;img src=&quot;http://www.kanthak.net/explorations/blog/tech/dice-ad.jpg&quot; width=&quot;100%&quot; /&gt;&lt;/p&gt;


	&lt;p&gt;Looking at the language syntax used here (&amp;#8220;&lt;code&gt;goto = dice.com();&lt;/code&gt;&amp;#8221;??) it makes you wonder if
they really know all that much about tech jobs.&lt;/p&gt;</description></item><item><title>Migration Troubles</title><link>http://www.kanthak.net/explorations/blog/rails/migration_troubles.html</link><guid isPermaLink='false'>blog/rails/migration_troubles@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-11-05T22:41:03+00:00</dc:date><description>&lt;p&gt;I was always wondering why my migration files were numbered
1, 3, 5, 7, ... What is the secret reason behind choosing only
odd numbers? Does rails trie to only use prime numbers?&lt;/p&gt;


	&lt;p&gt;Well, the last possibility was ruled out quickly, as 1 is not
a prime number and 2 is one (Knuth once said: &amp;#8220;2 is the only
even prime number, but it is the oddets of all&amp;#8221;).&lt;/p&gt;


	&lt;p&gt;But wait, things became even more mysterious: Recently I wanted
to create a new migration for the first time after updating to
0.14.2 and rails generated a file with a number that already existed.&lt;/p&gt;


	&lt;p&gt;A quick look at the source and the 
&lt;a href=&quot;http://dev.rubyonrails.com/log/trunk/railties/lib/rails_generator/generators/components/migration/migration_generator.rb&quot;&gt;history&lt;/a&gt;
of the migrations generator explained everything:&lt;/p&gt;


	&lt;p&gt;Up to 0.14.2 the generator simply counted all the files in the migrations
directory and added one to this number. Since my &lt;a href=&quot;http://www.emacs.org&quot;&gt;editor&lt;/a&gt;
creates backup files by appending a &amp;#8221;~&amp;#8221; character, I always had twice as
many files as migrations and if you add one, you get an odd number.&lt;/p&gt;


	&lt;p&gt;Now, in 0.14.2 (or 0.14.1) they thanged this, to only count &amp;#8221;*.rb&amp;#8221; files.
Everything is great now, you think? Not at all! Now, rails correctly
recognized how many migrations I have, but the number it used for the
next migration simply was too low, as my migrations weren&amp;#8217;t numbered
consecutively in my case.&lt;/p&gt;


	&lt;p&gt;Luckily the trunk contains a new version that looks for the migration with
the biggest number and increments this by one. Finally, what should you do,
until this fix is included in a new release? Simply rename the migration file
generated by rails to a sane number.&lt;/p&gt;</description></item><item><title>Upgrading To Rails 1.0rc2</title><link>http://www.kanthak.net/explorations/blog/rails/upgrading_to_rails_1.0rc2.html</link><guid isPermaLink='false'>blog/rails/upgrading_to_rails_1.0rc2@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-10-29T23:36:50+00:00</dc:date><description>&lt;p&gt;In the past hours I have been upgrading my applications to the rails
1.0 release candidate that is available for several weeks already.
Can you guess what the biggest bummer was?&lt;/p&gt;


No, it was not that my tests stopped working because the default
settings for &lt;code&gt;use_transactional_fixtures&lt;/code&gt; and
&lt;code&gt;use_instantiated_fixtures&lt;/code&gt; have been changed. That was
well documented and easy to fix.

	&lt;p&gt;And yes, I had to edit my environment files again, because they were
replaced by new versions, but I was expecting this.&lt;/p&gt;


	&lt;p&gt;Another thing, was a change in the great prototype javascript library. 
I was 
using its &lt;code&gt;extend&lt;/code&gt; function in my own javascript code and 
the
calling convetion had been changed a bit. But that&amp;#8217;s fine, hey, we
haven&amp;#8217;t arrived at 1.0, yet.&lt;/p&gt;


	&lt;p&gt;However, when I deployed my application to the server, things went 
strange. Everything was really slow and most of the data was suddenly
missing. I was panicking and looking at the database. You probably
say: Dude, stay cool, it&amp;#8217;s only rails running in development mode
against your development database and you&amp;#8217;re right. But why?&lt;/p&gt;


	&lt;p&gt;Finally, I realized I had rails allowed to overwrite my &amp;#8221;.htaccess&amp;#8221; 
file but didn&amp;#8217;t look at the changes. And there it was: Rails was
running in &lt;span class=&quot;caps&quot;&gt;CGI&lt;/span&gt; mode, instead of Fast-CGI. That&amp;#8217;s why it didn&amp;#8217;t pick
up the environment setting for production mode and why everything
was so slow. D&amp;#8217;oh!&lt;/p&gt;


	&lt;p&gt;Now, everything is running nicely again. Time to get some sleep, I 
guess. So, don&amp;#8217;t be afraid of upgrading rails. It usually works
really well, as long as you&amp;#8217;re just a bit smarter than I was&amp;#8230;&lt;/p&gt;</description></item><item><title>File Column 0.3</title><link>http://www.kanthak.net/explorations/blog/rails/file_column_0.3.html</link><guid isPermaLink='false'>blog/rails/file_column_0.3@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-10-28T23:34:06+00:00</dc:date><description>&lt;p&gt;Here is the new 0.3 release of the
&lt;a href=&quot;http://www.kanthak.net/opensource/file_column/&quot;&gt;file_column library&lt;/a&gt; that makes handling
of file uploads in rails really easy.&lt;/p&gt;


	&lt;p&gt;So what&amp;#8217;s new? The most prominent new feature is an integration
of rmagick/imagemagick so that you can easily resize uploaded images and
create multiple versions in different sizes. Many thanks to Kyle Maxwell
for his ideas on this subject.&lt;/p&gt;


	&lt;p&gt;You certainly ask yourself how this works? It&amp;#8217;s very straightforward,
as always. Let me just show you an example:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
class Entry
  file_column :image, :magick =&gt; { :geometry =&gt; &quot;640x400&gt;&quot; }
end
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Just &lt;a href=&quot;http://www.kanthak.net/opensource/file_column/&quot;&gt;grab the release&lt;/a&gt;
and look at the docs for more details.&lt;/p&gt;


	&lt;p&gt;As an additional goodie, I converted file_column to a rails plugin,
so you can just drop it into your &amp;#8220;vendor/plugins&amp;#8221; directory and
you&amp;#8217;re done. This plugin thingie is certainly a cool new feature
in rails.&lt;/p&gt;


	&lt;p&gt;For all of you, interested in all the details: Here&amp;#8217;s a list of all
the changes since the last version straight from the changelog:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;fixed bug where empty file uploads were not recognized with some browsers&lt;/li&gt;
		&lt;li&gt;fixed bug on windows when &amp;#8220;file&amp;#8221; utility is not present&lt;/li&gt;
		&lt;li&gt;added option to disable automatic file extension correction&lt;/li&gt;
		&lt;li&gt;Only allow one attribute per call to file_column, so that options only
  apply to one argument&lt;/li&gt;
		&lt;li&gt;try to detect when people forget to set the form encoding to
  &amp;#8216;multipart/form-data&amp;#8217;&lt;/li&gt;
		&lt;li&gt;converted to rails plugin&lt;/li&gt;
		&lt;li&gt;easy integration with RMagick&lt;/li&gt;
	&lt;/ul&gt;</description></item><item><title>File Column 0.2</title><link>http://www.kanthak.net/explorations/blog/rails/file_column_0.2.html</link><guid isPermaLink='false'>blog/rails/file_column_0.2@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-10-13T08:25:22+00:00</dc:date><description>&lt;p&gt;I&amp;#8217;m happy to announce the release 0.2 of my &lt;a href=&quot;http://www.kanthak.net/opensource/file_column/&quot;&gt;file_column&lt;/a&gt;
extension that makes handling of file uploads in Ruby on Rails as easy as it should be. It is a major 
rewrite that results in cleaner, more maintaineable code and includes
some new features and a few bug fixes.&lt;/p&gt;


	&lt;p&gt;file_column now tries to auto-detect file-types (using unix&amp;#8217;s &amp;#8220;file&amp;#8221; 
utility) of uploaded files to fix the extension if it is not
set correctly. This ensures that the file is served with the correct mime-type by your web-server.
So for example, if a &lt;span class=&quot;caps&quot;&gt;JPEG&lt;/span&gt;-image is uploaded without an extension, it will be saved with a
&amp;#8221;.jpg&amp;#8221; extension, so that web-servers can send the correct mime tipe of &amp;#8220;image/jpeg&amp;#8221;. This feature
was mainly developed by Michael Raidel. Thanks for your work, Michael.&lt;/p&gt;


	&lt;p&gt;For the future I&amp;#8217;m planing to move file_column to &lt;a href=&quot;http://rubyforge.org/&quot;&gt;rubyforge&lt;/a&gt; and to work
with Kyle Maxwell to integrate this excellent imagemagick extensions. So stay tuned for more
good news!&lt;/p&gt;</description></item><item><title>File Column 0.1.3</title><link>http://www.kanthak.net/explorations/blog/rails/file_column_0.1.3.html</link><guid isPermaLink='false'>blog/rails/file_column_0.1.3@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-08-18T21:08:37+00:00</dc:date><description>&lt;p&gt;I have got a new release 0.1.3 of my 
&lt;a href=&quot;http://www.kanthak.net/opensource/file_column/&quot;&gt;file_column&lt;/a&gt; library. It fixes
a bug that occurs when declaring multiple columns as file_columns simultaneously
like this: &amp;#8220;&lt;code&gt;file_column :image, :another_image&lt;/code&gt;&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;Grab the new release for hassle-free file uploads in rails!&lt;/p&gt;


	&lt;p&gt;For all of you who are curious about the bug (I know you are!): I was iterating
through the list of arguments with code like this:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
def file_column(*args)
  for attr in args
    # a lot of meta-programming to define methods
    # that refer attr in their bodies.
  end
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Unfortunately, Ruby&amp;#8217;s &amp;#8220;&lt;code&gt;for ... in ...&lt;/code&gt;&amp;#8221; construct seems to be heavily
optimized so that every element of &lt;code&gt;args&lt;/code&gt; is copied into &lt;code&gt;attr&lt;/code&gt;
in a way that closures don&amp;#8217;t really work anymore. In the end, methods defined in
the second iteration of the loop refered to the first attribute.&lt;/p&gt;


	&lt;p&gt;The fix was easy: Just use &amp;#8220;&lt;code&gt;args.each do |attr|&lt;/code&gt;&amp;#8221; instead, which behaves
as expected even in the presence of closures.&lt;/p&gt;</description></item><item><title>3 Years Of Rails Experience</title><link>http://www.kanthak.net/explorations/blog/rails/3_years_of_rails_experience.html</link><guid isPermaLink='false'>blog/rails/3_years_of_rails_experience@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-08-18T16:19:54+00:00</dc:date><description>&lt;p&gt;Look at &lt;a href=&quot;http://article.gmane.org/gmane.comp.lang.ruby.rails/18834&quot;&gt;this message&lt;/a&gt;
on the Ruby on Rails maling list. A London based company is looking for
developers with a minimum of 3 years experience in &amp;#8220;Ruby/Rails&amp;#8221;. That&amp;#8217;s pretty
hard since even Rails&amp;#8217;s founder &lt;a href=&quot;http://www.loudthinking.com/&quot;&gt;DHH&lt;/a&gt; only has around
1.5 years of experience, I believe.&lt;/p&gt;


	&lt;p&gt;When will HR people learn that not everything is about how many years you are
doing something?&lt;/p&gt;</description></item><item><title>File Column 0.1.2</title><link>http://www.kanthak.net/explorations/blog/rails/file_column_0.1.2.html</link><guid isPermaLink='false'>blog/rails/file_column_0.1.2@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-08-13T08:44:22+00:00</dc:date><description>&lt;p&gt;I&amp;#8217;ve made a minor release of my file column library that provides even better
rails integration. You can just require the file &amp;#8220;rails_file_column.rb&amp;#8221; in your
&amp;#8220;environment.rb&amp;#8221;  and the FileColumn methods will be automatically available in
your models and your views.&lt;/p&gt;


	&lt;p&gt;You can grab &amp;#8220;file_column 0.1.2&amp;#8221; on the &lt;a href=&quot;http://www.kanthak.net/opensource/file_column/&quot;&gt;project&amp;#8217;s
homepage&lt;/a&gt;. Thanks to
&lt;a href=&quot;http://techno-weenie.net/&quot;&gt;Rick Olson&lt;/a&gt; for the hint.&lt;/p&gt;</description></item><item><title>Nasty File Column Bug</title><link>http://www.kanthak.net/explorations/blog/rails/nasty_file_column_bug.html</link><guid isPermaLink='false'>blog/rails/nasty_file_column_bug@http://www.kanthak.net/explorations</guid><dc:subject>blog/rails</dc:subject><dc:subject>blog/rails</dc:subject><dc:creator>Sebastian Kanthak</dc:creator><dc:date>2005-08-11T09:39:36+00:00</dc:date><description>&lt;p&gt;I just fixed a nasty little bug in my
&lt;a href=&quot;http://www.kanthak.net/opensource/file_column/index.html&quot;&gt;FileColumn&lt;/a&gt;
library, leading to a 0.1.1 release.&lt;/p&gt;


	&lt;p&gt;I had the following code in a helper method to generate an &lt;span class=&quot;caps&quot;&gt;URL&lt;/span&gt; where you can
access an uploaded file:&lt;/p&gt;


&lt;code&gt;&lt;pre&gt;
url = @request.relative_url_root.to_s
url &lt;&lt; object.send(&quot;#{method}_options&quot;)[&quot;base_url&quot;]
url &lt;&lt; &quot;#{method}/&quot; 
url &lt;&lt; object.send(&quot;#{method}_relative_path&quot;)
&lt;/pre&gt;&lt;/code&gt;

	&lt;p&gt;Looks pretty innocent, does it? What it made it even worse is that it worked in WebRick, but totally
broke when running on Apache. After the first request, I&amp;#8217;d only get &amp;#8220;Application error&amp;#8221;. So
what happened?&lt;/p&gt;


In WebRick, &lt;code&gt;@request.relative_url_root&lt;/code&gt; is &lt;code&gt;nil&lt;/code&gt;, so &lt;code&gt;to_s&lt;/code&gt; returns
a &lt;strong&gt;new&lt;/strong&gt; empty string object. On Apache, however, it is a string containing the &amp;#8220;installation path&amp;#8221; of your
webapp. So &lt;code&gt;to_s&lt;/code&gt; returns the string itself and now I modify &lt;strong&gt;this exact instance&lt;/strong&gt; of the
string. Unfortunately it is shared for performance reasons, so the next time I call
&lt;code&gt;@request.relative_url_to_root&lt;/code&gt;, I will get back the &lt;span class=&quot;caps&quot;&gt;URL I&lt;/span&gt; just generated, which obviously
is not a good idea&amp;#8230;

	&lt;p&gt;Lesson learned: Be careful with &lt;code&gt;String#&lt;&lt;&lt;/code&gt; as it modifies the string in place. Strings are
not immutable as (for example) in Java.&lt;/p&gt;</description></item></channel>
</rss>
