History always repeats itself and sometimes that's good. Here's a second chance to be part of it: tmdtc.com

Thursday 23 October 2008

google.com/ads in my dreams?

Did I dream that there was an URL for Google Adwords and Adsense at www.google.com/ads? 'cause now all I get is an error page:

Profoss on twitter

I've not been a Twitter user until now, so I'm curious what impact this will have.
Follow Profoss at http://twitter.com/profoss

Saturday 11 October 2008

Ruby flexibility to the rescue

In the development of UploadForMe, I had a chain of methods called, each of which possibly returning nil. I really didn't want to check at each step if the returned value was nil, as I would have ended up with something like

if (o!=nil and o.first_call!=nil and o.first_call.second_call!=nil)

I quickly created a class which would help me get around this problem, and I think (I haven't checked further, honnestly) this goes in the direction of monads, which are well known in Haskell.

The solution is to have a class of which an instance is returned in place of nil. This instance responds to all methods by returning an instance of the same class, in turn responding to all methods. However such an instance responds to the method #nil? with true.

class SimpleMonad
def initialize(h={:is_nil => true})
@is_nil = h[:is_nil]

def method_missing(m, *args)
return SimpleMonad.new
def nil?

And I'm using this class as return value in a class derived from Hash. method_missing returns either the value in the hash for which the key is the method name just called, or an instance of the class above:

class ServicesKeys < Hash
def method_missing(m, *args)
if keys.include?(m)
return self[m]
return SimpleMonad.new

That way, we can chain calls as we want:

#define the object we will work on
h = ServicesKeys[ :uploadforme => ServicesKeys[:login => 'rb', :username => 'rb']]

#we can easily access the values in there:
=> "rb"
#if we try to access values for an undefined service, we don't get in trouble:
=> true

You have to be cautious in naming your keys to avoid clashes, but in my case this is an acceptable trade-off.

There might also be better and more advanced solutions out there. Don't hesitate to mention them in the comments.

Sunday 5 October 2008

Why use Chrome when you have Arora?

When Google's Chrome came out, I was rather surprised by the move, and was eager to try it. But when I saw it was Windows only, I andandoned the idea even if I could have tried with Wine: I couldn't see any good reason to use a non-native browser. Reading Kris's blog post about his test of Chrome on wine only confirmed my opinion.

I was interested to test a browser with the Webkit engine though, and was surprised there wasn't an open source browser based on Webkit available on my platform of choice (GNU/Linux). The Epiphany developers had announced a switch to webkit some time ago, but it still isn't effective it seems.

A search on the internet returned Midori, build with GTK2. I'm not a fan of GTK, and I was surprised there was no Qt based browser, as Webkit is now integrated to Qt (from Qt4.4). Finally, this week I discovered Arora, which was originally a demo browser integrated to Qt4.4.

Installing Arora was easy once I had installed Qt4.4 from sources. I had originally tried with a Qt4.5 snapshot through git, but it wouldn't compile. Compiling Arora itself was so fast I thought I had forgotten to do something.

And Arora is fast too. Using it is also a good experience (eg I'm writing this blog post with Arora).

I don't think it will replace Firefox as my primary browser just yet, but it will take an important place on my desktop as I expect it to become the fast browser without any plugins or extensions I'll keep running in the corner to access the web-based tools I run continuously. And yes, MyOwnDB runs great in Arora!