“2008-03-30”.to_date.to_time.tomorrow == “2008-03-30”

I wrote a very nice routine which would iterate over a few days.
Today I found my loop never ending !?! And this is very scary because the routine is a background process that needs to iterate over the last x-days.

But there's a problem when you're living in The Netherlands and you have to use daylight savings.

Try this code:


>> "2008-03-30".to_date.to_time.tomorrow.to_date
=> Sun Mar 30

WTF !! 2008-03-30 => Tomorrow => 30 March 2008 ?!?

I indeed complained, that time was passing so quickly. But I didn't mean to keep it stuck at 30 March!
Oh.. I'ts only my Rails Application...

How's this possible?

>> "2008-03-30".to_date.to_time.tomorrow
=> Sun Mar 30 23:00:00 +0200 2008

At 30-03-2008 the clock has been set back for daylight savings. Well I assume rails simply adds 24 hours with the method tomorrow. And yesterday we had 25 hours.

More info about this bug: http://dev.rubyonrails.org/ticket/2353

My temporary solution is to add some hours to tomorrow.


>> tomorrow_time = "2008-03-30".to_date.to_time.tomorrow + 12*60*60
=> Mon Mar 31 11:00:00 +0200 2008
>> tomorrow_time.to_date
=> Mon, 31 Mar 2008

Sometimes I hate Ruby on Rails!

why don't we collectively protest agianst the oppression of daylight saving time?
Well Tijn, I agree!

Choosing a direction for Rich Internet Applications

Currently we're at the point of a big shift/hype of (Web) Application Development. The development of Rich Internet Applications. (RIA). A RIA is an application that runs via the web, probably via a webbrowser though this isn't a requirement.
The idea is that RIA makes this application work like a local desktop application. This could mean the application should be capable of running offline and online.

There are severy solutions for this purpose:

  • Ajax Based ~ This is wat I'm used to, but it has it's limitations.
  • Google Gears ~ Browser Plugin Based. Look Nice, browser plugin offline application use
  • Adobe FLEX/Flash ~ Via the Flash plugin that's installed on almost every PC
  • Adobe Air ~ To run applications from the desktop
  • Microsoft Silverlight ~ Microsoft attempt to join the club
  • JavaFX ~ Beta, Looks nice. unfortunally I'm not a big fan of the large overhead the Java plugin has.
  • Ajax isn't an ideal solution because it never gives me access to the local user's PC and doesn't work offline.

    Now is my Problem, what direction should I choose?! Staying with Ajax for now seems like a safe choice, because it will run probably on the most platforms..

    This is something that requires some good Research!

    Apache Authentication and Mongrel Cluster

    Currently I'm running a mongrel cluster for my rails application. This works much nicer then the FastCGI version.
    There was only one problem, I had an .htaccess file to restrict access to the public directory.


    AuthName "Somewhere"
    AuthType Basic
    AuthUserFile /home/nobody/.htpasswd
    Require valid-user

    The problem was I needed to enter this login data 2 times.
    Well after doing some google research I found out the problem was the location of the authorizationcode. I think the .htaccess file is used by every Process of the ProxyBalancer... But I'm not sure...

    The solution for this problem was to place the authorization code in the proxy balancer:



    BalancerMember http://rails_site:5532
    BalancerMember http://rails_site:5533
    AuthName "Somewhere"
    AuthType Basic
    AuthUserFile /home/nobody/.htpasswd
    Require valid-user

    That's all ;-)

    Closing an IE popup two times while busy with Ajax request hangs IE

    Closing an IE popup (twice) while a XmlHttpRequest is running, uses up all available connections.

    To reproduce this:
    - create a slow XmlHttpRequest (xhr). (Running about a minute or so)
    - Open a popup window which executes this xhr. Close it while it's still running
    - Open this same popup again. (Second request). Directly close it while the xhr is running.
    - Open another popup... et voila... IE Hangs..

    This problem is what I was experiencing. After hours of frustrations we found a workaround:
    In the onunload of the body tag you must call the "open" method on the same XmlHttpRequest object.
    The call of "open" disconnects and stops the old request. Appearently abort doesn't do this

    Working code:










    WARNING: This solution has only be tested with IE7!

    Update 23-01-2008:

    Solution for this problem with prototype is. Just put this code in an seperate javascript file. Include this file after prototype.js call iefix_runGarbageControl() in the onunload and the bug is fixed ;-)


    // IE TCP/IP Connection Leak FIX, with prototype
    if( Prototype.Browser.IE )
    {
    var iefix_xhrs = new Array();
    function iefix_runGarbageControl() {
    for(var i=0; i

    Update 24-04-2008:
    Added: place 'iefix_runGarbageControl()' in the onunload