Saturday, 30 August 2008

Monty Python - Always Look on the Bright Side of Life (My epitaph)

Now that's what I call eudemonics! When life sucks, just purse your lips and whistle! Probatum est! That's also what William James, the famous philosopher and psychiatrist, said. We think that action follows sentiment, that is I sing because I'm happy. But this causal link is uncertain. It can be the other way round, so we can improve our mood by singing, dancing, watching a MP's movie etc. as those are actions, and unlike feelings, they are controlled by our will (Schopenhauer perhaps wouldn't agree).

Sunday, 24 August 2008

Monty Python Sub Ita: The Funniest Joke in the World (Gep)

Words are the most powerful weapons. Read this, if you can, and you're dead. "Wenn ist das Nunstruck git und Slotermeyer? Ja!
Beiherhund das Oder die Flipperwaldt gersput!"

Thursday, 21 August 2008

John Williams n' Julian Bream - spanish dance no.1

Listening to this music is one of the greatest pleasures in life and makes me agree with Nietzsche who said that "life without music would be a mistake".

Wednesday, 2 July 2008

Subversion client too old

This is a workaround to fix a problem I had with my svn client after upgrading to Eclipse Ganymede and Subclipse plugin last week. It is based on scattered information I found on the web and that I managed to put together. Hopefully it will save someone some time (somewhere... something... somehow...).
Basically, I had ended up with an svn client 1.4 on my system (ubuntu 8.04) whereas subclipse used a somehow bundled latest version 1.5. So everything went fine, as long as I did my svn work from within eclipse. Until one day (today) I had to do an

svn up
from the shell (we use maven modules and this time I had to update from the parent pom location). Then I got this message
This client is too old to work with working copy '.'; 
please get a newer Subversion client.
This was baffling, as
apt-get install subversion
told me that I had the latest package installed. After some googling, it turned out that svn 1.5 upgrades your working (local) files in a way that it's incompatible with svn client 1.4. To cut it short, I decided to upgrade my svn client.

Here are the steps to follow:

  • At the moment, subversion 1.5 deb package is still considered experimental, so you'll need to add a line to your
    /etc/apt/sources.list
    like this:
    deb http://ftp.it.debian.org/debian experimental main
    (You can choose a different mirror here http://packages.debian.org/experimental/i386/subversion/download)

  • Then do
    apt-get update
    to update your deb repositories

  • Finally
    apt-get install subversion
    to update your svn client to version 1.5. I gladly ignored the warnings about some non authenticable packages (those coming from the experimental repository).

Now everything is working fine.

Sunday, 29 June 2008

Monty Python - Finale di Filosofia (sottotitoli in Italiano)

Is Leibnitz's Monadology better than Plato's Theory of Forms? Was Aristotle smarter than Kant? Let these and other questions be settled by a soccer game, rather than by philosophical argument! A Monthy Python's classic which I felt compelled to translate and subtitle in Italian, because the official dubbing and translation really don't do it justice.

Saturday, 10 May 2008

Tutorial: how to export an MBean in Grails

This is a cookbook tutorial I wrote while working-playing-learning (I guess I'm lucky that I am doing for a living something where these three things often get along) with Grails.
It shows how to export Hibernate's StatisticsService MBean by leveraging Spring's JMX support through Grails's BeanBuilder, a class that uses dynamic Groovy to construct bean definitions.

http://docs.codehaus.org/display/GRAILS/MBean+export+the+Groovy+way

Sunday, 20 April 2008

Flickr horizontal menu with Prototype

Last week, while looking for a drop-down menu for a Grails application, I came across this one which is very nice but uses jQuery. As Grails comes with Prototype as the default javascript framework and I didn't want to add another dependency, nor mess up with jQuery and Prototype incompatibilities, I decided to port it to Prototype. To set up the menu and download the images and the css, please refer to the original menu post, then substitute the jQuery code with the Prototype one below.

/*
* Flickr-like menu ported from jQuery to Prototype.
* The original is at http://www.candesprojects.com/downloads/flickr-horizontal-menu/
*
* @requires prototype 1.6
*
*/
document.observe("dom:loaded", function() {

$$("#nicemenu img.arrow").invoke("observe", "click", function(e){
headMenu = e.findElement('span.head_menu');
//div.sub_menu
submenu = e.findElement('li').down(3);

if(submenu.getStyle('display')=='block'){
headMenu.removeClassName("active");
submenu.hide();
this.writeAttribute('src','arrow_hover.png');
} else {
headMenu.addClassName("active");
submenu.setStyle({'display': 'block'});
this.writeAttribute('src','arrow_select.png');
}

$$("div.sub_menu:visible").each(function(e){
if(e!=submenu){
e.setStyle({'display': 'none'});
}
});

$$("#nicemenu img.arrow").each(function(e) {
if(e != this){
e.writeAttribute('src','arrow.png');
}
});


$$("#nicemenu span.head_menu").each(function(e) {
if(e != headMenu){
e.removeClassName('active');
}
});

});

$$("#nicemenu img.arrow").invoke("observe", "mouseover", function(e){
this.writeAttribute('src','arrow_hover.png');
});

$$("#nicemenu img.arrow").invoke("observe", "mouseout", function(e){
submenu = e.findElement('li').down(3);
if(submenu.getStyle('display')!='block'){
this.writeAttribute('src','arrow.png');
} else {
this.writeAttribute('src','arrow_select.png');
}
});

$$("#nicemenu span.head_menu").invoke("observe", "mouseover", function(){
this.addClassName('over');
});

$$("#nicemenu span.head_menu").invoke("observe", "mouseout", function(){
this.removeClassName('over');
});

document.observe("click", function(e) {
var elt = e.findElement('#nicemenu');
if (elt == undefined){
$$("#nicemenu span.head_menu").invoke('removeClassName','active');
$$("#nicemenu div.sub_menu").invoke('hide');
$$("#nicemenu img.arrow").invoke('writeAttribute','src','arrow.png');
}});

});