31 December 2008

2009 "Year of the Aquarius"

Planet Jupiter moves to the Aquarius sector in 2009, and this is supposed to be a good thing for people born (like me) between 21th January and 19th February. Or so my mother says, in her crazy Italian way where "everybody knows" these things are b*llocks but they still believe them "just in case" (exactly like they do with Catholicism and Hell, by the way).

It certainly won't be an easy year for me, with the new "cryware/nappieware" scheduled for release around July. Things will get pretty hectic, I guess.

On a less personal note, lots of people said 2008 was "The Year of Obama", "The Year of the Crisis" or even "The Year of YouTube". They are Wrong. Sorry Barack, 2008 was "The Year of ABBA".

See you in 2009, perverts.

29 December 2008

Guido van Rossum on speed and the array module

Giulio (through his feed on Delicious.com) pointed me to a nice post from "benevolent Python-dictator" Guido van Rossum. The essay describes a few general rules for improving performance of Python programs, and it also reminds us of "an odd corner of Python", the array module. Go and read it, it's worth it.

It also made me discover "an odd corner" of the Python website: the collection of Guido's essays. As demonstrated by the original post, this page is much more interesting than Guido's own blog, and so it's very disappointing that it doesn't have a feed to monitor. Mmhh... Edit: well, stuff there looks a bit stale, I guess Guido doesn't use it very much anymore. Still, it's the sort of thing that should have a feed. Maybe python.org should move to django? ;)

19 December 2008

La mia Italia

Libertà e giustizia sociale, che sono poi le mete del socialismo, costituiscono un binomio inscindibile. Se a me socialista offrissero la riforma più radicale sul piano sociale, ma privandomi della libertà, io la rifiuterei. [...] Ma la libertà senza giustiza sociale può anche essere una conquista vana. Lei può considerare veramente libero un uomo che ha fame, che è nella miseria, che non ha lavoro, che è umiliato perché non sa come mantenere i suoi figli e educarli? Questo non è un uomo libero; sarà libero di bestemmiare e di imprecare, ma questa non è la libertà che intendo io. -- Alessandro Pertini

12 December 2008

On the Manchester Congestion Charge Referendum

Residents of Greater Manchester were recently called to vote on a proposal, which would have seen the introduction of a London-style "congestion charge" in exchange for improvements in public transport.

The results were announced today, and the plans were rejected by 79% of the voters. Turnout was about 53%, which is closer to recent General Elections turnout (about 60%) than Local Elections (about 35%).

I'd say this was a clear result. Consider this: the plans were strongly supported by all Labour-dominated councils, and opposed only by the few LiberalDemocrats- and Conservative-controlled councils (Trafford and Stockport). It's only because of LibDem and Tory opposition that the referendum was called, and even them were more or less persuaded to support the proposal (after obtaining the referendum).

When 80% of your own electorate votes against your proposals, it's clear that something doesn't work. The Greater Manchester area is a solid Labour stronghold, and it's been for generations. If the totality of local Labour councillors support a scheme which their own electorate so overwhelmingly despises, then there's something broken in the relationship between public opinion and elected representatives.

I used to live in a city with a similar situation; it used to be called "The Red Bologna", a city where communists and socialists dominated the political debate for more than 50 years. And then, "all of a sudden", a conservative mayor was voted in, to the shock of political elites only. They were now separated, arrogant, completely unable to understand their own voters and persuaded that they knew better than anyone else. It clearly was a long process, in a city so ideologically rooted in socialist ideology, but they didn't see it coming until too late.

I hope the local Labour councillors will get the message. Their progressive electorate will not tolerate new, wide-ranging regressive taxes which would only benefit a few private bus companies.

Please don't force us to vote you out; we'd rather not do it, if only you listened to us a bit more.

11 December 2008

Yes, I'm schizo

The last two posts show complete opposite attitudes. The one on Python shows my better self: rational, positive, calm. The one on Amarok shows my "bad" self: melodramatic, irrational, sarcastic.

Maybe I seriously need medication...?

On Amarok 2, Or: How You Can Always Find A Way Of Shooting Yourself In The Foot

At the beginning, it was WinAmp. And Linux people saw it was good, and lo, XMMS was born. But then XMMS grew old, as it was built with obscure graphic libraries for X-server that no-one knew anymore, and its interface was kludged by too many broken skins. So the desktop-people spawned dozens of their own players, all broken in one way or the other, and the Linux people grew sad.

One day, from the sky a new player fell, and it had excellent playlist and collection management, and it would read your mind and find music you didn't even know you had anymore. They called it Amarok, and started spreading the good news to the unfaithful, and lo, even the barbarian "windowsers" started being converted by the power of the Loved Wolf.

But in their hearts, people knew that the good times would end sooner or later. Because it was written that decent programs, when condemned to upgrade cycles, will inevitably be subject to feature creep and unneeded refactoring. And so it was, once again: Amarok 2 was unleashed onto the world, and people could see its brokenness. The program had been corrupted (like many before) by the temptation of integrating "with the web", renouncing playlists and smart features in order to pander to brainless chavs -- people more interested in seeing an album sleeve or reading about the sex life of boybands than listening to the actual music. And the Linux masses were left stranded, once again, without a decent media player, condemned to wander forever in the land of sadness and broken players.

(All this to say that Amarok 2 sucks -- they've taken away good features in exchange for eye-candy which reminds me of the terrible Windows Media Player. I'm staying on Amarok 1.x forever.)

Update: a year later...

06 December 2008

If only we could re-use stop-energy...

I confess: I'm a whiner, a moaner, a reactionary bitch. I like to pundit and joke about new things, it's actually much easier than making new things, isn't it... You can just wait there and shoot from the hip, it'll make you feel all righteous and smart, and it's free!

Italians are champions at moaning.
Fat lot of good it does to our GDP.

You probably already know that Python 3.0 was released a couple of days ago. After the first 24 hours of joy, the inevitable wave of stop-energy hit the crap-blogo-sphere, mostly in the form of classic concern-trolling or uninformed criticism. Now, this is inevitable; for every big action (and releasing Py3k was a huge step) produces a reaction.

The transition to Python 3 was announced eight years ago, discussed in detail for ages and eventually implemented in the last two years. Dedicated tools helping the porting effort have been developed and work pretty well, certainly better than most VB6-to-.NET wizards released by Microsoft around 2001. The old codeline will be maintained and updated for well over a year from now, with at least another major release planned, so there's no hurry to upgrade, no pressure whatsoever. Documentation of the changes is pretty exhaustive. Major third-party apps and libs have been ported already or are in the process of being ported.

So, what's left to moan about? Breaking backward compatibility. The very first thing that was announced 8 years ago, and since discussed in the most excruciating details, to the point where the "major changes" seem almost banal.

"Yeah, we got great Unicode support and the with statement, but so what? print is now a function! That's it, I'm switching to Ruby!"
"Wait, did you ever actually use Python? Do you know how much painful it was to work with Unicode? Or all that crap about new-style and old-style classes?"
"Well, I don't really know the language much..."

Stop-energy is for losers and trolls. Ignore the bitching, Python 3 will rock.

(now, if only I can manage to compile the flipping thing...)

30 November 2008

A Big F*** You to Paul Graham, From Worldwide Software-Support People

Paul Graham: "They'd have sacrificed hundreds of thousands of dollars, perhaps millions, just to be able to deliver more software to users. And you know what? It would have been perfectly safe to let them."

I'm sorry Paul, as a representative of tech-support people worldwide, I have to say: f*** you.

Developers, even fantastically smart ones, don't test enough as it is. If you let them have "push-button release" privileges, the software industry would have an even worse reputation for terrible reliability than it already has, and companies would have to spend millions more in order to support all that crappy code that couldn't wait for two more weeks of testing and certification.

The world would be a better place if developers had to wait two weeks more than they do now, or even two months; maybe there would be less s**t around for others to pick up afterwards.

How to disable access keys in Konqueror

Well, this suggestion by Dimitri on how to disable access keys in Konqueror made my day:

kwriteconfig --file khtmlrc --group "Access Keys" --key Enabled --type bool false

"Now press enter and voilà the access keys are sent to the eternal lands of /dev/null."

Failure of imagination

I really wish I knew what to do.

For the last week, I really wanted to code something up, something new and fresh, and I couldn't figure out what. I periodically feel like this, and I'm reminded that there's tons of things (started and never finished) which would need attention... and even finished ones, like kdelicious, really need some maintenance. But these are boring things; since coding for me is just a hobby, I should really spend it on something fun, right?

Eventually, I decided to install dbxml, something I had postponed for a long time. Following Zeth's excellent guide, I avoided the horrendous pitfalls (typos in testing code? Left there for months?) and managed to set it up properly, even though checkinstall failed to debianize it. (BTW, why don't we have a .deb somewhere? It was originally released in 2003, one would expect that in 5 years somebody would have come forward...)

The good thing about Oracle products is that they come with plenty of documentation; it can be terse, but it's there. (b)dbxml is no exception, so I went through the (excellent) introductory tutorial in a few minutes. Fine. Then I thought "this seems cool, I wonder how could I use it for, maybe some webservice or something"... and the thought died there. My mind had a complete (and utter) failure of imagination. So now I have a very cool xml storage engine with good python bindings, and I don't know what to do with it.

I ended up playing MAME for much of the day.

Bring on Christmas, I need a reboot.

20 November 2008

Python "global" weirdness

I'm sure there's a rational explanation for this behaviour, but at the moment is slightly baffling.

class SomeObj:
 def __init__(self):
  self.prop = 1

class SomeClass:
 global objInst
 def __init__(self):
  self.reference = objInst
  self.reference.prop += 1
if __name__ == '__main__':
 global objInst
 objInst = SomeObj()
 clsInst = SomeClass()
 print "original:" + str(objInst.prop)
 print "clsInst:" + str(clsInst.reference.prop)

# output:
# >>> x:2
# >>> y:2

This is all good, and expected: you get a reference to a global object and manipulate it. But what happens if you try to rebind that global name straight in the __init__ method?

class SomeClass:
 global objInst 
 def __init__(self):  
  self.reference = objInst
  self.reference.prop += 1
  objInst = SomeObj()
# output:
Traceback (most recent call last):
  File "test.py", line 16, in 
    clsInst = SomeClass()
  File "test.py", line 9, in __init__
    self.reference = objInst
UnboundLocalError: local variable 'objInst' referenced before assignment

And it gets even more weird! If you move the "global objInst" declaration inside the __init__ method, it works as expected: objInst is bound to a new object with a different state from the one in self.reference. But if you keep the declaration at class level, and simply move the rebinding out in a new method (separated from __init__), you don't get an error but python does not bind the global to a new object.

I guess it's somehow all a matter of context, and it probably makes perfect sense to programming-language scientists; it just doesn't to me :)

16 November 2008

I'm impressed

Finally we have a Linux system where suspend/resume and even HIBERNATE work out of the box. AND the X-server works as it should, including console-switching. AND it comes with a polished KDE (with a properly-configured kdm), plus an easy upgrade path to KDE4.

Thanks, Kubuntu.

15 November 2008

KMyMoney "proper" builds

Just found out that Clay Weber maintains a lovely personal archive of KMyMoney .deb builds, very up-to-date and (more importantly) packing several optional plugins that standard Ubuntu and Debian builds don't carry -- in particular, the all-important OFX importer. Thanks Clay!

Oh, and I moved to Kubuntu Hardy. Feels nice.

13 November 2008

Please stop spamming FB apps

Seriously, this is getting ridiculous:

Every time you add a FB application, a third party gets access to your data, so I stopped accepting all invitations.

09 November 2008

Crunching Numbers

During the last couple of day, I spent my free time trying to sort out the family finances; big (good) changes are on the horizon, we need to plan a bit better from now on, and it's amazing how "bad" expenses stick out straight away when you aggregate them, instead of relying just on rough day-by-day cash-flow estimates ("how much money is still in my account?").

I tried to use KMyMoney for this sort of thing several times in the past, but I was always inevitably thwarted by the effort required to copy records one-by-one from online bank statements, because the sort of bank accounts I use don't allow any desktop clients to automatically pull data. So this time I thought I'd fix it once and for all, and set down to write a few scripts to do that, albeit in a somehow indirect way.

KMyMoney can natively import transactions in the legacy (and wildly non-standard) QIF format, while OFX requires a plugin (why? No idea). Unfortunately, on my Debian Etch, the bloody plugin somehow never gets installed correctly, but hey, maybe one day it will, and OFX is the way of the future anyway (it's XML-based and much more exactly specified than the old plaintext-based, informal QIF). So I wrote a Python script to convert the HTML or CSV produced by my online accounts to OFX, then passed the output to ofx2qif, a handy script included in the libofx-dev package (at least in the 0.8.2 version I'm using). The result is ready to be imported in KMyMoney. Slightly cumbersome, but it does the trick. I need to add a bit more intelligence to the scripts, to speed up the categorisation effort that follows (which is the whole point of the exercise), e.g. "LINK xxxxxx" payees should all be set to "cash machine" etc, but it's already working fairly well.

The effect was startling; finally, all my expenses are tracked and I can properly budget and forecast. (...How the hell I'm spending so much on mobile-phone calls??)

I'm actually slightly pissed off that cash transactions are now so opaque; I've no idea why £50 were withdrawn from an ATM on that January day (even though I'm sure it made sense when I first checked the statement 6+ months ago), but I know for a fact that those £37.68 from last December were for a delicious Japanese dinner, as I paid for it with my debit-card.
In a way, this goes against the "classic" principle that "by using plastic, you never really know how much money you don't have" (so you tend to spend more). I still believe in that principle, and I'm slightly baffled by the evidence.

I'd strongly recommend this sort of exercise to everyone, anyway. You don't need to use a dedicated program like KMyMoney (even though it helps), Excel might be enough, as long as you can easily add transactions from your online account (via CSV or cut&paste).

05 November 2008

The American Dream is back

I left the office at the beginning of October saying "When I'm back, Obama will be the President Elect!"; people laughed and said it was too early to call. Well, I called the Democratic primaries for Obama in February; that was difficult.

Note: I'm slightly pissed off that the BBC is giving space to John Bolton.

Back to the cold shores of England...

... and jet-lagged enough to follow yet another USA presidential show. After two episodes with villains winning, it's about time for the good guys to score one, or it will become a cliché.

Someone is liveblogging on dailykos, if you can't stand the usual round of useless TV pundits.

24 October 2008

Kanazawa blues

Weather yesterday turned to a very Mancunian-style rain, so our days in Kanazawa feel a bit sad.

I love tatami rooms, I want one in my next house.

(oh, and the japanese keyboard is hell.)

18 October 2008

in Kyoto


We've been in Japan for just five days but it feels like we've packed in a lot, mainly thanks to my wife's perfect organization, I mainly stroll around carrying bags and saying "Oishi-ne", "lovely food"!

We spent the first few days in Tokyo, breathing in modern Japan, with skyscraping malls "bolted on" the immense train stations. People in every directions, but everything flows so smoothly, and it's so incredibly clean everywhere, I have no idea how they do it. It's "organized delirium" to a level Europeans cannot really comprehend, I think.

We are now in Kyoto, the "old capital", ready for a smorgasbord of "classical Japanese style" (temples, castles, Zen gardens etc), then we'll hit the road to see some rural areas in the northern mountains before going back to Tokyo for the final souvenir-shopping experience.

"Unfortunately", the food here is so good that I won't be able to lose any weight during this trip. Well, too bad, eh ;)

11 October 2008

Notes on Google Finance API

I recently started dabbling in shares (yeah, I know, I like swimming against the flow), and so I looked around for good stock-price trackers for KDE3. To my surprise, I couldn't find anything apart from the usual KMyMoney (which I like and use, but it's not really something you can keep open all day on your desktop). I had already put my stock info on Google Finance, and lo, the service has a GData API, so I decided to write a small script in Python to retrieve my portfolio and the daily variations.

The good thing about GData APIs is that they are all the same at a basic level, so even when client libraries don't explicitly expose new features (like in this case, as Finance is quite a new service), you can still use the APIs to get easy authentication and feed-parsing. So I went and downloaded the official (and excellent) gdata-python-client package, which is dead-easy to use:

from gdata.service import GDataService

client = GDataService()
client.email = 'your_email@gmail.com'
client.password = 'your_password'
client.service = 'finance'


baseURL = "http://finance.google.com/finance/feeds/%(email)s/" % {'email':client.email}

# to get all data in one go:
#  bigFeed = client.GetFeed(baseURL + "portfolios?positions=true&returns=true")
# and then positionsFeed is included in each Entry
#  positionsFeed = gdata.GDataFeedFromString(bigfeed.entry[0].FindExtensions('feedLink')[0].children[0].ToString())

# ... but I really just want the first portfolio
positionsFeed = client.GetFeed(baseURL + "portfolios/1/positions?returns=true")

for entry in positionsFeed.entry:
 details = entry.FindExtensions('symbol')[0] 
 symbol = details.attributes['symbol']
 name = details.attributes['fullName']
 data = entry.FindExtensions('positionData')[0]
 totalReturn = round(float(data.attributes['returnOverall']) * 100,2)
 gainPerc = round(float(data.attributes['gainPercentage']) * 100,2)
 print name + " (" + symbol + ") Return: " + str(totalReturn) + "% - Gain: " + str(gainPerc) + "%" 

One should really make an applet or something for KDE, but I'm leaving for Japan in about six hours so I can't be bothered...

05 October 2008

Horrible Hack to get Python 2.6 on Debian or Kubuntu

I wanted to try out the newly-released 2.6 version of our beloved Python, but unfortunately Debian didn't have a package for it yet (and it still doesn't). I wasn't too afraid of screwing up my laptop, as it's probably going to be formatted very soon anyway, and I didn't want to mess around with deb build scripts, so this is what I've done:

  1. got the official source distribution, untarred and cd in the resulting dir Python2.6
  2. got some additional packages: apt-get install tk8.4-dev libgdbm-dev libdb-dev libreadline-dev libsqlite3-dev libncurses5-dev (and possibly a few others)
  3. ./configure --prefix=/usr --enable-ipv6
  4. make
  5. checkinstall -D --pkgname=python2.6 --pkgversion=2.6 --maintainer=g.lacava@gmail.com --inspect --backup=yes --install=no make altinstall
    This command allowed me to review the package contents and remove what I didn't need, which is basically everything outside the "python2.6" directories and which might already exist on my system (so I didn't want to overwrite it).
    I took out the lines /usr/bin/pydoc, /usr/bin/idle and /usr/share/man/man1/python.1
    UPDATE: when checkinstall asks if you want to create a default set of docs, say "yes", or you might get an error about ranlib further down (see comments).
  6. installed the produced .deb package
  7. copied back pydoc and idle (from the build directory) and /usr/share/man/man1/python.1 (from the Misc directory), all with "2.6" appended. I then set up alternatives with update-alternatives --install symlink name alternative priority (mainly in order to "redebianize" my impure karma); UPDATE: well, using alternatives (a 100% Debian solution which works perfectly well for loads of other multi-version script engines) will break your system, because some developers absolutely must reinvent the wheel every 5 minutes and then proudly announce that bugs won't be fixed. The stupidity of it all is staggering.

First impressions: 2.6 seems fast as hell. I don't know if this is due to the custom compilation though, rather than improvements in the runtime.

04 October 2008


A man travels the world over in search of what he needs and returns home to find it. -- George Moore

Apologies for not posting much recently. It so happens that I was posted to Egypt for a few weeks (what a crazy place), and in a few days I'll be on a plane to Tokyo (purely for pleasure, this time). Despite the lovely Egyptian hospitality, I came back from Cairo with a tonsillitis (ouch), let's hope Japan will be less troublesome.

16 September 2008

on PyconUK 2008

Great conference, like last year. Interesting talks, nice people, spotless organization. Go to the PyconUK wiki if you want slides and (in a few days) recorded audio.

Next year the same bunch of great guys will host EuroPython, in June. I'm sure it will be fantastic, but I don't know whether I'll be able to attend, as it will happen during weekdays and I probably couldn't justify the absence from work. Apparently it's all because the French don't go to conferences during weekends; it's always their fault, isn't it ;)

Anyway, it was all good energy to start messing again with Django on a magnatune-inspired project. Also, we'll try to "reboot" Python North-West and see if we can stabilise it a bit. It's all fun :)

14 September 2008


Jacob Kaplan-Moss looks like a young Robin Williams.

11 September 2008

Off to PyconUK

So, tomorrow night I'm off to Birmingham to attend Pycon UK. I don't think I'll liveblog like last year, I'll try to be more social. To be honest, I'm not as excited as last year, probably because the conference was so good in 2007 that I doubt they'll be able to top it. This said, let's hope I'm wrong (as usual).

06 September 2008

Goodreads Collapse Folders

This is yet another greasemonkey script for Goodreads, this time to deal with a minor annoyance.

A GR group (basically a forum) can have "folders" of topics (basically different areas/sub-forums). When you look up a group, you will get a list of all folders, with the last 4 discussions for each folder; on a group with dozens of folders (e.g. the SciFi and Fantasy Book Club) it means you might have to scroll quite a bit to get the (small) link to the folder you're interested in.

So this script will make the folders "expandable", and collapse them by default if they are more than a certain amount (by default 2, but you can customize this threshold). Preview:

02 September 2008

Goodreads Exploder

Another little script for fellow GoodReaders: GoodReads Exploder will add a link to "Explode" all the books on the shelf in different tabs. It saves having to CTRL-click on each book or losing the original shelf page while you browse the books.

Since this might be a bit dangerous with lots of books, if the shelf contains more than 10 books, the script will warn you and give you the option to cancel the operation before your browser "melts". You can change the limit to suit your machine.

This script uses several of the most recent Greasemonkey features (GM_openInTab, getValue, setValue...). It was a lot of fun to write, Greasemonkey really is a fabulous toolkit; the FF Extensions framework is, in comparison, very complicate and burdensome (which I guess is the trade-off for all the power they give developers).

01 September 2008

a question of Snopes

Somebody you love (or in your family) forwards one of those email-chains. It's not even too bad, the content is not racist or virulently conservative, even though it might be interpreted as a veiled anti-Muslim piece. Quite a few people are CCed in the email. What do you do?

  1. You just ignore the email. Nobody "on the net" pays attention to those anyway.
  2. You reply only to the sender, pointing to the relevant Snopes link, and admonishing on the perils of forwarding this sort of chain.
  3. You hit "reply to all", pointing to the Snopes link. The level of "flamin' & shamin'" in the reply will depend on your willingness to maintain a friendship with the original person.

This just happened to me, and the sender was... my mother, who increasingly uses email (without being particularly techno-inclined).

After careful consideration, I went for option 3, keeping the tone as soft as possible. I have to say I've done it because it explicitly mentioned "UK schools" in a negative tone for something they are not, in fact, doing at all. I also thought this might teach my mom never to forward this sort of things, no matter how good they seem, in a stronger way than just admonishing "behind the scenes". However, I now feel a bit guilty.

What would you have done in my situation?

(This is clearly material for a comedy sketch...)

Amazon-to-Goodreads Greasemonkey script

This is a little Greasemonkey script that will add a link to Amazon item pages to see the reviews on Goodreads (if the book is available there). The result will look like this:

You can download it from here: Amazon-to-Goodreads Greasemonkey script 2.0. Note that you will need to install Greasemonkey first, if you haven't already.
I also put the script on Userscripts.org as well.

28 August 2008

Nigella's Caramel Croissant Pudding

This is good, I made it last night. A bit heavy, but quick and easy. I think you could probably add raisins to have a bit more flavour.

26 August 2008

Shelfari bought by Amazon

I just noticed this blog post; so Amazon finally bought one of the new wave of literary social-networking sites I recently listed. I wonder whether they'll now do with Shelfari the sort of thing I suggested for aNobii.

I guess this might be a blow for LibraryThing, GoodReads and aNobii (but it might actually be the kiss of death for Shelfari if it's reduced to an Amazon shopwindow). However, as these things go, we might now see a move from an Amazon competitor to buy or partner with one of the other services.

Me, I don't care: the only service with a serious API is GoodReads, so I'll stick with it :)

GrEstimator - the web version

I finally bit the bullet and put online an interactive version of my GrEstimator script (which will soon see a new release, by the way).

The GrEstimator Web Service is currently very basic. You provide an email, a GoodReads ID and a shelf (or tag) you want to estimate, and the system will email the result (expressed in a currency of your choice, calculated with exchange rates from WebserviceX's Currency Converter).

The tool is beta ("almost alpha" really), so be gentle and let me know if it dies on you :)

Known issues:

  • you have to provide a numerical GoodReads ID, which is the one appearing at the end of the URL when you look up a user (e.g. "http://www.goodreads.com/user/show/1383164"). I've asked to be authorized to look up an ID by providing an email, and I'm waiting for the response; once I'm allowed, you'll be able to just provide the email you use with GR.
  • you cannot estimate more than 200 books on a shelf; this is a limitation of the GoodReads API.
  • books not listed on Amazon will be ignored.
  • it currently spawns a thread for each estimate. I have to implement a system of queues to limit the amount of threads running at any given time, just in (the remote) case the service becomes popular.
  • you cannot choose the output currency, it's USD only. This will be fixed soon with a new option. Fixed.
  • the result is based on average prices. I'll soon add an option to say if you want that or rather the maximum potential price (which really tends to be funny). Fixed.
  • the service does go through all the Amazon locales (.com, .co.uk, .de, .fr, .ca, .jp in this order) but only if item lookup fails on the previous locale. This means that, if I find a book on .com marked as unavailable, I will still consider it as "found" and won't repeat the lookup on a different locale. I actually just realized this as I was writing the post, it will be fixed very soon. Fixed.
Also on my TODO list:
  • producing a "blog badge".
  • pulling prices from somewhere else than Amazon.
  • an "update" feature of some sort would be nice.

24 August 2008

Bookmarklet to search Stockport Library (LibraryLookup)

I've always been a fan of the LibraryLookup project; it's a simple tool that, given an address containing a ISBN (e.g. an Amazon page), it will search your local library catalogue so that you can see if the book is available.

Unfortunately, the Bookmarklet Generator option for Talis-based systems doesn't work for my local library in Stockport (UK), so I googled a bit and found this post on a Talis blog, which gave me the correct syntax.

So, here's the resulting bookmarklet (drag and drop the link on your bookmark toolbar, check this link if you don't know how to): Stockport Library.

23 August 2008

The aNobii API is just a joke.

With the aNobii API, you can't retrieve the ISBN of a book. Seriously. This means there is no chance to use it to develop any serious mashup, so I'm abandoning the service.

I feel for my Italian friends, locked in such a hacked-together platform.

21 August 2008

How much is your bookshelf worth?

Just for fun, I wrote a little python script that will pull a feed of books from GoodReads and calculate their total worth according to Amazon.


The script allows for shelf-specific filtering and supports different Amazon locales, with output configurable to be in any currency. Due to a limitation in the GoodReads API, it will estimate only the first 200 books.

You can see it in action using the web-based version

Download: GR_Estimator 1.1

  • Release 1.1
    • Added support for multiple currencies
    • fixed a few bugs
  • Release 1.0
    • Initial release

Note to self

If you ever have to implement a service that needs the user location, don't rely on the address (messy, error-prone due to misspelling, nonstandard across countries...). Just use a GoogleMap widget and then store the coordinates, plus a free-form text field if you really need the address (e.g. for mailing etc).

This system will scale effortlessly and it will be much simpler to implement lookups like "people near you in a 5-miles radius". You might want to store the country in a separate field for i18n purposes, but even with that, you will have 3 fields (coordinates, free-form address, country) vs umpteen (house/flat number, block name, two or three lines which might not even be enough for some users, town, city, district, postcode with format differing by country etc etc...) which are very hard to use in a geo-aware way.

(This presumes that you are starting from scratch; if you have to bidirectionally interface with legacy systems, chances are that you'll need to stick with the bad ol' stuff).

19 August 2008

A lil' script

Since my itch is now scratched, I might as well make the code available: GenBooks 1.0 is the little script I used to generate my list of books by pulling my "favourites" shelf on GoodReads. It works with python templates and even embeds your Amazon Associate ID. Requires Python 2.5 (because it uses the new ETree module) and the Python Imaging Library 1.1.x. There is no license, it's all public domain. Have fun.

My favourite books...

... are now listed here. I generated the list while playing around with the GoodReads API and the Python Imaging Library. I'm trying to think of something else to build with the GR API... any suggestions?

17 August 2008

Pythonaro, oh-oh-oh

As you might have noticed I've moved this blog under pythonaro.com, and to celebrate the event I'm abandoning the blogger-supplied template. Things will break for a few weeks, bear with me.

16 August 2008

Tag your f***ing books!

After a few days wandering around "literary" social-networking sites, I'm feeling a bit frustrated by how people interpret their participation in a very solipsistic way. Listing your own books is half the fun, I get it, but certainly the other half is hooking up with other like-minded bookworm geeks; you should put in a little effort to make your shelf accessible to them. Why then few can be bothered to tag their books? Without tags, I'm left to dig through hundreds of items I don't care about, whereas even a little classification (like separating novels and non-fiction, or fantasy and contemporary) would go a long way to help me define that you like the same sort of harrypotterish works I (might or might not) enjoy.

So please, if you are serious about this sort of sites, try to tag your books, even a little bit. Splitting your shelf in groups containing less than 100 items would already be enough, especially if your collection contains 200+ editions of books blatantly plagiarizing JRR Tolkien.

The uncommon reader

The Uncommon Reader One of the best short stories I've read in the last few years, The Uncommon Reader by Alan Bennett is an entertaining parable on the pros and cons of being a citizen of the "republic of letters", explored through the eyes of the modern monarch by definition, Elizabeth II, the Queen of England. What is "the act of reading"? Is it purely selfish? Does it really improve one's life? How would it affect a person, especially one who is the very embodiment of life and action of an entire country? Is the act of writing a necessary consequence? This little page-turner will entertain and engage even the casual reader, and would be perfectly suited for a couple of hours to spare between opening a swimming-bath and having luncheon with the Archbishop of Canterbury.

15 August 2008

django on jython

You can now run Django on Jython, as announced by Leonardo Muñoz. Lovely. I really should go back hacking django a bit.

14 August 2008

"Which social-literary networking site should I choose?"

After a few days wasted switching between various sites, I have to pick one (or two, max) and stick with it, so I tried to determine which one had more chances to survive in the long run.

Data from Compete.com seems to say that GoodReads is winning the battle on literary social networking.

Librarything, despite a huge head-start (years), seems to be in decline, even though attention data suggests that the remaining members spend a bit more time on the site than the average GR member.

Note how aNobii seems to be such a minor player, even though it's the dominant application in Italy and probably lists more books than its competitors; I wonder if Compete's data is skewed towards US/UK visitors. It has to be said that aNobii is showing more velocity though, so it will be interesting to see how things fare in a few months.

Shelfari is also in the mix, still below Librarything but growing fast. The site is very well presented, but I hated that it used Yet Another Format to import books (apparently, more oriented to listing the condition of your books, which I guess has to be expected from a site backed by ABEbooks), and I couldn't be bothered to try it.


Shelfari: "If you exported your file from another site and Shelfari failed to import your library and if the file has a different extension than .txt, please change the file extension to .txt."

... because we are too lazy to do it for you.

Export your books from aNobii to GoodReads

This is a quick & dirty hack to translate your book data from the CSV file produced by aNobii to the format accepted by GoodReads (and LibraryThing, apparently). The main advantages of this approach are that you will maintain your reviews and rating, and if GoodReads fails to find a book it will tell you the title (whereas if you just use a list of ISBNs, it won't).
Cons: I couldn't be bothered to mess with strptime, so you might lose your reading date; also, all your books will be imported with the default status ("read" for me).

You can download the script from here, it works with Python 2.4 and 2.5 (probably 2.3 as well). Feel free to improve it, I scratched my itch so I'm happy as it is.

UPDATE 2012-04-12: Alper Çugun updated and improved the script; if you plan to actually use it, please get his version from his Github repo.

This should have been a review of LibraryThing...

... but I discovered that the site will only allow "free" accounts to enter 200 books, which is peanuts. Unsubscribed.

12 August 2008

Amazon should buy aNobii and let people use their Associate ID

My wishlist is growing exponentially since I started browsing my friends' pages on aNobii. It works better than the usual "spookily accurate" recommendation systems you find on shopping sites, because your friends' ratings carry much more weight than the simple act of buying an object (which is over-rated by bookshops, since they often don't have actual feedback).

I guess aNobii tries to make its money acting as referral from those same bookshops, I wonder how much they actually make. It would be really powerful if they allowed people to have their own referral ID embedded in "buy" links, so that I make money if my friend buys a book I recommended. I guess that, for this to really happen, Amazon should buy out aNobii (a small Hong Kong startup, from what I understand) and possibly rewrite it from scratch, but it would be a fantastic move.

10 August 2008

aNobii vs GoodReads

I've recently signed up to two book-listing, social-networking, web-2.0 sites, aNobii and GoodReads. The fundamental idea is shared by the two: you list and rate your books, then hook up with friends and fellow readers. Thoughts:

  • GoodReads is quite English-oriented; despite being able to distinguish between languages, the amount of non-English books is quite small. aNobii's catalogue is much better, possibly because it's the biggest player and so it attracts a larger crowd. This is more or less why I switched from GR to aN: several books that I had to manually add to GR were already in aN, and my friends were also there already. As it turns out, this is just due to the specific audience: aNobii's population is overwhelmingly Italian, so Italian books are easier to find there because they have already been added.
  • Adding a book to your list is fairly easy in both systems, but aN has several different interfaces so it feels somehow more adaptable to your own style. However, if the book is not listed or you want to edit details for an existing book, it's a pain in the neck to do it in aN, whereas it's much more easy to do in GR.
  • Annoyingly, if you mass-import lists of books, both sites aNobii won't tell you which ones failed to be added, so finding them becomes a game of patience. I know there are at least 5 books which are now in my GR account but aN failed to identify. aN also has a webpage-scraping feature that fails miserably on GR's pages. GR will report the failed books, as long as you supply the books' titles in the uploaded file -- if you only send ISBNs, it will not tell you which ones failed.
  • Consistency in metadata is clearly a challenge for both. aN annoyingly differentiates between title and "subtitle", so "serial" books end up all over the place. For example, "Batman: The Killing Joke" (which is a self-contained graphic novel) could (and does) end up as "Batman"/"The Killing Joke", "The Killing Joke"/"Batman vol.XYZ", or "Batman: The Killing Joke"/"vol. XYZ" (and obviously "Vol.X", "vol. X", "Volume X"...). Since in several UI screens only the title is displayed, it can become difficult to differentiate (I have several "Batman" listed, but which is "The Killing Joke" and which is "The Dark Knight Returns"?). GR doesn't feature this split, so it's easier for users to self-enforce consistency, somehow. This said, GR encourages you to add random details in parentheses appended to the end of the title, for example the particular imprint (e.g. "Il Fu Mattia Pascal (Classici Moderni)"), or version, or what you feel like mentioning, so it also adds an unnecessary random element.
  • GR's metadata includes binding, but it's an arbitrary and case-sensitive field, so you can have "hardcover", "Hardcover" and "Hard Cover" as three different modes. It would be much more useful to have a pre-populated listbox with the most common values, plus an "Other" option that will allow you to enter an arbitrary value.
  • GR's rating is 6-levels deep (from 0 stars to 5), aN's is only 4-levels (from 1 to 4 stars).
  • They both allow you to tag books with arbitrary words. In GR, tagging (or "shelving") is everything: it's what you do to distinguish "read" from "unread", for example; there is no mass-tagging feature yet, which is annoying, but it's faster to tag a single book from the master ("your shelf") view than it is in aN. Vice-versa, aN is much better when you want to tag several books at once, but a bit laborious if you want to tag a book from the master view (you have to go in "book view" first). Also, you can see aN was not built on tags like GR, it's clearly a feature which was added later in the application life.
  • aN has loads of features to define how you got hold of the book (even listing shops and libraries), and has an in-built lending/trading exchange, whereas GR only has a generic checkbox to mark the book as "I'd be willing to send/swap".
  • Both allow you to review books. Somehow it feels a more central concept in GR, whereas in aN you are pushed to define when/how you read the book rather than reviewing it.
  • The "social" features are a bit different. In both you have groups and friends, but aN also has (presumably American) "Neighbors", which is an euphemism for "stalked": people you don't know but you want to track anyway. The social aspect seems really more "inbuilt" in aN, which will show your "compatibility level" with friends and try to match you with people with similar shelves.
  • GR gives more relevance to authors, who can have their own page (and presumably some extra features). Just to name one, Neil Gaiman uses GoodReads.
  • Both have some sort of facility for bloggers. aNobii lets you use your Amazon associate ID, which is nice; however it's up to you to do all the CSS magic to integrate the widget with the look&feel of the blog.
  • aNobii is broken in Konqueror. GoodReads doesn't officially support Konqueror, but it works nonetheless (probably because they tested it in Safari, which is very similar).
  • aNobii's API is ridiculously useless, it doesn't even return ISBNs. GoodReads' API is much better, easier to work with and more complete.
  • All in all, GR seems to be more about listing and tagging your books, whereas aN is more about matching you with people with similar books/tastes/favourite bookshop.
So hum, there is no clear winner. aN looks slightly more feature-rich than GR, but GR feels more "open" than aN. Currently, my profile on GoodReads is less complete than my page on aNobii, but I'll try to keep them synchronized as much as possible. I've abandoned aNobii, mainly because it's a dead-end: it's very difficult to get any info out of it, the API is just a joke, and feeds are incomplete.

01 August 2008

It Only Works Because You're Here

New MJ Hibbett! And "GRATE" as usual!

13 July 2008

Being a better typist

I confess: I am a "hunt'n'peck" typist. Like many, I didn't get lessons in typing, but thanks to my obsession for computers I developed my own particular form of "memory-touch-typing"; basically I'm fairly fast, but I only use 4-to-6 fingers, and I often have to stop and see where my hands ended up, which slows me down a lot and makes me lose concentration in what I was typing.

This means that periodically I get out a "learn to type" program and try to improve my typing skills. At the moment I'm working with KTouch, a nice GPL application belonging to the KDE Edutainment project. And I'm trying hard not to look at the keyboard while writing this!

17 June 2008

Fun with FIFA and the Home Nations

The FIFA Statutes and the accompanying regulations governing their implementation form the Constitution of football's international governing body.

I was just going through the FIFA Statutes, while debating why Britain should really get a unified team to have any real chance of regaining the World Cup (which they won't do: their loss!).

The "special status" granted to the Home Nations is huge:

  • they get to have 4 different leagues at the national level, a privilege that no other nation can have;
  • they get to appoint 4 of the 8 members of IFAB, the institution that makes (and changes) the rules. So basically no rule can be changed without British approval!
  • they get to appoint one of the 8 vice-presidents on the Executive Committee, at the same level as UEFA, CONMEBOL etc. So they are basically considered at the same level of the biggest football organisations when there's anything to be decided.

This said, they are hopeless at diplomacy, pretty much like Italy, with the result that for decades UEFA has been dominated by a French/German/northern countries block, and FIFA by south-American alliances with marginal federations.

Alan Moore for Wizard of England!

The Prime Minister recognises the achievements of Alan Moore and the widespread regard in which he is held.

Victory! What next? As Neil Gaiman suggested:

[...]but frankly I'm not interested unless they make him Official Wizard of England. Now that would be an honour. An MBE, on the other hand doesn't seem the sort of thing that Alan needs. He'd just put it down somewhere and it would wind up under the sofa. But if they made him Official Wizard he would wear a hat.

15 June 2008

Italian Football Folklore: "il biscotto"

The "Biscotto" (literally "biscuit") is a central concept in Italian football. It's a sum of Italian attitudes towards football institutions, honesty, fair play, and "dietrologia" (another very Italian concept, "the study of what might be hidden" -- from "dietro", behind).

This term comes from an ice-cream brand, as you would expect from such a food-obsessed culture; specifically, an ice-cream surrounded by two biscuits. The biscuits don't touch each other, but squeeze a dollop of ice-cream between them -- exactly like two contenders who won't hit each other, but will manage to squeeze out a third party standing in their way.

For example, imagine that two teams have to play a match in a tournament, and there is only one possible result that will qualify both of them to the next phase of the competition and eliminate a third party. They could come to an agreement to make sure the "right" result comes out; this would be a classic "biscotto". Or imagine that two teams have to play at the end of the season, and one club doesn't really have anything to play for, while the other needs points to avoid being relegated (hence pushing down another team)... you get the idea. It's basically a combine where a third-party gets hurt.

The Italian football team was (or it was perceived as being) on the wrong side of an alleged "biscotto" a few times in recent history, most infamously at Euro 2004 when Denmark and Sweden produced a 2-2 draw which qualified both Scandinavian nations and kicked out the "Azzurri". If you then consider the 2002 incident (when South-Korean hosts kicked out Italy in a match plagued by a terrible referee), and a penalty awarded in the first minutes of the 2006 World Cup final (on a dive by French player Malouda), you can understand why the Italian press is currently running wild with speculation of an upcoming "biscotto" between Romania and the Netherlands. The Oranje are already mathematically certain to win their group, whereas Romania needs a victory to stay in second place and kick out France and Italy... which is a result Holland might like, considering as these two (currently troubled) teams usually transform into tough competitors for the final stages of major tournaments.

The Italian people experienced a long history of political intrigue, stretching all the way back to Imperial Rome; we tend to see daggers hidden in every dark corner, conspiracies arranged for the most worthless situations, puppeteers pulling strings in the smallest of everyday occasions. For centuries our political landscape was defined elsewhere, with Italian city-states acting as proxies for various European powers, all the way up to the Cold War. As a result, we tend to be a little too suspicious, and assign responsibilities to others that should really be ours.

If we really wanted to qualify, we should have won (or drawn) against the Netherlands, and won fair and square against Romania. Instead, our men played badly (especially in the first game), and our "lethal" strikers couldn't score even given massive amounts of chances (a defender had to step up and do it). They shouldn't have put themselves in that position in the first place. Once you get to depend on the whims of somebody who doesn't owe you anything, you can't complain about what might happen. Life is tough.

(This said, my money is on Romania to win. It's hard to kick old habits, I guess. And the actual ice-cream is fantastic, and so difficult to find in Manchester -- anybody that can send a box over here?)

11 June 2008

Co-Operative Bank Defending Human Rights

Just a quick note to point any UK-based reader to the last campaign from The Co-Operative Bank: you can vote for a human-rights charity that will get money from the bank. The program is developed with Amnesty International, so all charities are very worthy; my vote this year went to The Medical Foundation for the Care of Victims of Torture, quite a topical subject in times of televised indoctrination on the "benefits of torturing people" (oh yes, I hate 24). There are only a few charities worldwide that do this sort of work (as far as I know, the other one is in Denmark).

08 June 2008

KDelicious 3.3 beta build

I'm going back to the old habit of uploading "beta" builds of KDelicious a few days before releasing. I had a lot of problems with Debian packages after I stopped doing that (for completely unrelated reasons), so I thought I'd summon a bit of old-times' luck... The files are in a little corner of the web. If you try them, please report any problems to me (g dot lacava on Gmail) or on the bugtracker at kdelicious.sf.net.

KDelicious documentation now online

I've just uploaded "the KDelicious Handbook", that is the documentation for all old (and new) KDelicious features.

This was the first time I used docbook to generate this sort of files, but I thought that it would have been nice to follow KDE guidelines, after all it's a KDE add-on!

Advantages of docbook: you write the docs once, then you can have as many stylesheets you want and get consistent output for different media. Using the KDE xsl files, it's really a snap.

Disadvantages: you have to write lots of markup, which can be painful; Emacs' SGML mode can help a bit there. Translation processes must be terrible, you have to re-write pretty much everything as there's no easy gettext-like method to keep style and content separated.

I've also written a small shell script to repeat the process, as I know tomorrow I'll forget everything I've learnt about meinproc and where the xsl templates are (/usr/share/apps/ksgmltools2/customization). The script also appends the Sourceforge logo to all pages meant for the web, as it's required by the SF policy (thanks to the wonders of sed). And of course it's all been put under version control. Am I "Pragmatic" or what?

05 June 2008

Early pythons get the bird -- book PyConUK now!

I just reserved my place at PyCon UK 2008, which will again be held at the Birmingham Conservatoire on the second weekend of September (12/13/14). If you like Python and you can make it, you should: the vibe last year was great, the talks interesting, and the organisers a nice bunch of geeks. The extra-early-bird offer expires on June 9, so be quick and you could save a few pounds!
If you come, take a minute to RSVP on the official PyConUK 2008 Facebook event page; the more people there, the better visibility (and credibility) we get. Also, if you are on other social networks, you can do something similar to aggregate interested people.

Unfortunately I can't make the Friday tutorials (I'm saving days for a big trip to Japan in October), but I'm sure Saturday and Sunday won't be disappointing. See you there!

02 June 2008

OSS development makes "surprising" users more difficult

Scenario: you have two competing products. One is fully developed "in the open" (online Trac, open mailing lists, etc); the other is 100% closed (main bugtracker/dev lists are "behind the firewall", no public nightly builds, etc). What does it happen when you introduce a new feature?

In the closed case, nobody will know. You can plan a big Steve-Jobs-like demo, or disseminate distracting rumours (and send competitors up the hills); as long as you can avoid leaks, you are in control.

With an "open" project, in a few minutes the word will be out. You can hide things in a wiki or a bugtracker, but version control checkins will "fess up" pretty fast (you could deliberately put in blank or disguised comments, but that would irremediably pollute your repository). Competitors will start efforts to match the feature, and your competitive advantage might be gone even before you had time to exploit it.

The element of surprise, with an open project, is not available. This might or might not be a big deal.

Personally, I'm finding it a bit of a nuisance, since I have a couple of new features in the pipeline for my little apps which, I hope, will be seen as fairly innovative for this sort of tools.

30 May 2008

this ain't the Boss, but...

... with Graduation he's dished out a top album. The world could do with quite a fewer rap acts, but this guy is a keeper.

29 May 2008

Don't worry, darlin'...

Reviewing a Springsteen gig is something no honest man can do.

How can you describe a three-hours-long rock'n'roll session delivered by 50-year-olds jumping around like they're 15? How can you write about the spirit, the energy, the *faith*? 50.000 people swarmed on Old Trafford under the gray Manchester rain, jumping and singing and clapping and crying until the weather didn't matter anymore, BRUCE AND THE E-STREET-BAND were there, everything would be alright.

The mix of old and new songs was unbelievable. I had never heard "Living in the future" before, and I was singing along after the first chorus. I had never heard "Long Walk Home" before, but I was crying while shouting it, a song so simple and so politically deep, a new "Born In The U.S.A.".

Not even a bad soundcheck could compromise this gig, because this was not a gig. This was a mass to the God of Rock'n'Roll. This was an American Celebration broadcast on Radio Nowhere. This was the Messiah of Rock announcing the Rising of November, when The Dream (battered and killed by eight years of fascism) will be reborn.

If you have the Faith, meet the Lord at Bruce's Place, you're gonna have a party.

P.S. Poor Dan Federici is gone, Patti Scialfa probably won't come to Europe anymore and "Big Man" Clemons clearly had trouble walking; go meet the Apostles of Soul while you can.

28 May 2008

tonight, the old man is in town...

I honestly can't listen too much to Springsteen, it usually ends up with me crying and smiling, people think I'm weird and I can't really explain.

But fuck rain and storms, tonight we're at Old Trafford to LISTEN. TO. THE. MAN. RISING.

Weezer Wins Teh Internet Tubes

Weezer just produced a tribute to the warholizer (aka YouTube) that is just fantastic, killer tune, spectacular video... even lightsabers!

16 May 2008

for everything else...

  • Do you need to convert WMA files to MP3?
    Just use the free PyMedia library.
  • Do you need to upload these files to an FTP?
    The ftplib module is included in the standard Python library.
  • Do you need to schedule this upload?
    The standard Python library gives you the sched module.
  • Do you need to persuade some people to pay you a (minimal) amount of money for the (minimal) effort of writing the script?
    I'm afraid you'll have to do that yourself...

There are things a computer cannot do.
For everything else, there's Python

14 May 2008

Shortsighted TLD policies

Old mindsets are hard to die.

Look at the policies for national TLDs; most of the time, you will not be able to register a domain with a TLD belonging to a foreign country, because "you need a contact based in the country". This old, national-State mindset is typical of the 20th century, and the soon it goes away, the better. For example, Italy had a fantastic opportunity to monetize its TLD: how many "Information Technology" companies would love to have a domain ".IT" rather than a bland ".com"? But no, can't have that, it would be way too profitable for a country that, as everyone knows, never had economic problems in the last 20 years </snark>.
Now look at Paraguay; its ".py" is perfect for python-related websites, but I can't register it either, because clearly Paraguay doesn't need my money.

Meanwhile, little Tuvalu makes loads of money from television producers desperate to get their own ".tv" corner of the Internet, and ICANN is pushing for "themed" TLD anyway (.biz, .aero etc)...

Partitioning cyberspace on geographical terms makes sense only from an administrative perspective (to make clear who is responsible for maintaining what); once that is established, every country should try to maximize the potential of its little corner of the Internet.

13 May 2008

KDelicious 3.2.1 is out

KDelicious 3.2.1 is a minor update, released in order to distribute the translations kindly provided by users (German, Spanish and Dutch, plus the original Italian and English). And obviously, the day after I released, a new translation (French) was sent... I'll probably push it out next month, I'd rather not release every other week if I'm not going to add new features.

It's worth mentioning that about half the downloads are for the debian package now, and the total downloads have increased since last time. I wonder how hard it would be to package for SuSE (the most popular KDE distribution), maybe that would give it a little boost as well.

28 April 2008

Notes on Emacs

I'm giving Emacs a serious chance, so here are a few notes, mainly for personal future use.

  • auto-indent an entire file:
    (defun iwb ()
    "indent whole buffer"
    (indent-region (point-min) (point-max) nil)
    (untabify (point-min) (point-max)))
  • find .emacs on Windows: C-x C-f ~/.emacs (I know, it's banal, but...)
  • set tab size to my favourite default (3):
    (setq-default tab-width 3)
    (setq-default c-basic-offset 3)
  • php-mode: haven't quite understood how to activate it yet. I get syntax highlighting for everything BUT php. D'oh. UPDATE: ahh, you have to byte-compile it yourself. What a lazy environment for a dynamic language! Anyway, thanks to this blog post, I now know how to do it: M-x byte-compile-file (and then point to php-mode.el)
    UPDATE: Oh, and you have to use the 1.2 version with emacs 21 and lower.
  • (UPDATE) To maximize it at startup, two options:
    • Easy one: in the registry (HKCU\Software\GNU\Emacs, which you have to create), set a String property called "Emacs.Fullscreen" with value "fullboth". Unfortunately this is calculated from the very bottom of the screen, so if you have the taskbar set to "always on top" and no "auto-hide" (like me), you will end up with the taskbar covering the minibuffer.
    • better one: do
      M-x : (frame-width)
      and write down the number that comes up (e.g. 155), then repeat with (frame-height). Then (in the same key as above) set a String property "Emacs.Geometry" set to these value, e.g. 155x59. If you have the same taskbar issue as above, reduce the second parameter until it's ok (I had to reduce it by 3).

Why Emacs? I'm doing a "good deed" which involves php, and since I have to churn out loads of useless "$" and "->" and brackets, maybe it's time I learn a proper power-tool for text editing.

27 April 2008

MySQL character set ("charset") options for UTF8

While dabbling with PhPeace, I found out a few things about how MySQL handles charset options.

There are several levels at which you can specify a charset, from top to bottom: server instance, database/schema, table/column and, finally, connection.
Usually, the lowest option will override the previous one, so if you specify the encoding at connection level (with a query like "SET CHARSET 'utf8'; SET NAMES 'utf8' COLLATE 'utf8_general_ci';") you should be safe. However, if you want to fix things "once and for all", you can add these options to your /etc/mysql/my.cnf file (or adding a /etc/mysql/conf.d/UTF8 in Debian with these options):


The *-server* options are instance-specific, while default-character-set is connection-specific. If you wonder what the "collation" stuff is, it's the method to use for sorting. I'm not sure if, as guideline, you should use utf8_unicode_ci rather than the default utf8_general_ci, but I didn't find out how to override the default option at connection level in the .cnf file, so I'll stick to utf8_general_ci to have a consistent environment.

08 April 2008

Google App Engine

Google App Engine. Write applications in Python using a WSGI-compatible application framework, then host them on Google’s highly scalable infrastructure.
(via Simon Willison's Links)

"Holy s**t" was Ryan Tomayko's comment, and my first thought as well. Google is realising the promises of WSGI, and what a sight it is.
On one hand, this is fantastic; it made me think of "J2EE done right". On the other hand, if you use GAE, you are handing your entire infrastructure and data (!) over to Google, which might not be the smartest move for lots of companies (any FTSE100 for example, and probably any NASDAQ-listed as well).

Anyway, Python rocks.

07 April 2008

Do The Indie Kid

I love MJ Hibbett & The Validators, and you should too. So here's his latest video.

15 March 2008

Notes from BubbleCity

Last day in California, blogging from a little cafe in the Fillmore area of San Francisco.

Silicon Valley is dead boring, I ran away from it on Friday afternoon, but I like the big city up here. Went to Berkeley (slightly disappointing), done the sightseeing thing downtown (Fisherman's Wharf, Russian Hill, Alamo Square, Chinatown, built-in-Milan cablecars, etc) which wasn't fantastic, much better just to walk around up&down the hills, Lower Haight, Octavia, Fulton, to get a feeling for the lovely (upscale) 'hoods.

Got lucky and landed in JapanTown on the first saturday of Cherry-Blossom Festival, so the entire district was all tarted up and in full swing (including long queues for the International Asian Film Festival), I really enjoyed it (but the hyashi-chuka was average).

It can be as seductive as NYC at times, even though the character is very different; NYC feels like the place where you go "to be the best", while you come to SF "to be yourself" or "to find what's next". It looks like a fundamentally mexican/asian city, rather than white, and this is fantastic. Whereas Santa Clara/Silicon Valley is such a whitey, middle-class, boring place, it's no wonder that waves of geeks are escaping to SF-SOMA (South-Of-MArket-street) and commute from there.

Been to the scenic SF Giants stadium (ahh, one day I have to see a live match) which was recently built on reclaimed land facing the bay and it's gorgeous. I still didn't see the western area, Golden Gate Park etc, but hey, you have to keep something for the next visit!

10 March 2008

Blogging does something to your mind

I am currently into a deeply technical internal training session, and the temptation to liveblog it is huge. Of course I won't (but if I could, I'm sure that my colleagues back in the UK would really like it).

07 March 2008

And now Frisco...

Just a few weeks after our fantastic trip to NYC, tomorrow my company puts me on a plane for San Francisco. I don't know anything about the place and I only have a day or so to spend there... I have to say, it's going to be hard to top what NYC gave me: walking on the bridge from Brooklyn to Manhattan, in a clear night of full moon, was so fantastic...

But hey Frisco, give us your best shot ;)

01 March 2008

Some Good News, For Once

Amnesty International has a list of Good News (with a feed). That's nice, newspapers should have this sort of thing on their front-pages every day, it would give us back some faith in humanity... but I forget that the papers' job is to keep you distracted, dispirited and depressed, so that their backers (investors and advertisers) will keep screwing you.

There's also a Call To Action page (again with feed). Some things you might find silly ("demonstration" is such a XIX century concept), but you can choose your preferred way to help. For example, I have a credit card that will donate 0.25% of every transaction to Amnesty. It seems such a little thing, but it raised £1.5million in the last 15 years; that's an average of £100.000 donated each year, just by shopping! I've had this card since I opened a current account here in the UK, six years ago -- which was (by the way) with an ethical bank, Cooperative, so I know that my money will not be invested in producing or dealing weapons (among other things). Oh, and did I say that my ADSL provider's profit help developing Free Software?

There are ways to make a difference, day by day, voting with your wallet. I'm no hippie (fuck, do I hate vegans and home-recycling schemes), but in all my laziness I try to help good people, a little bit. I just got a big bonus, and I think it's time to pay back some debts to my parents; i know that they will be happy to hear that I want half the money to be donated to a charity. Eh, I'm a bastard ;)

26 February 2008

KDED & me (& Python)

It's clear that KDelicious needs a background service to periodically synchronize with the server without user intervention. KDED seems the perfect answer to this, right? You can build modules that will be started and stopped with the desktop and managed with the "Service Manager" screen in the Control Center (KControl).

Unfortunately, KDED will only load a compiled shared library, not a script or a generic command (which would have been quite handy). I've no idea why, but I guess the KDE devs had their motives when they designed the system. The latest version of kdedistutils (in the pykdeextensions package, hosted on currently-down simonzone.org) only supports the creation of C++ "glue" modules for kparts and kpartplugins, so once again I'm a bit stuck. I guess what one would need is a stub similar to the one that pykdedistutils generates for KControl plugins, KParts and KPartPlugins... I'm not fluent in C++, but I'll see if I can hack my way through. If I manage, i'll send Simon a patch for pykdedistutils.

On a side note, I noticed a few issues with kdedistutils when building KControl modules:

  • it fails creating source distributions (but maybe it's me doing something daft)
  • when building a binary distribution (bdist), it doesn't do static linking, which means that the produced libs are not really portable and require libpythonize to be in the exact same position on the target host.

24 February 2008

Faster or bigger...? (safe for work!)

In the last few months, I've been living in fear that may laptop's HDD would die on me; it's now more than three years old, and has lived through pretty rough times (e.g. 14 months of Gentoo, and quite a few nights compiling KDE4). Half of the smartctl status codes say "Old_age" and the other half "Pre_fail"...

Last week I took a long-overdue full backup, and I'm now thinking about buying a spare replacement as soon as I can, before ATA-100 (also known as PATA or good ol'IDE) models disappear from the market, now dominated by SATA. My choice seems limited to two models:

  1. 100Gb 7200rpm, which is exactly what I have now, or...
  2. a more capable but slower 250Gb 5400rpm
In my experience, Linux likes that extra kick from the HDD much more than Windows, but recently I've had to fight with my filesystem for every spare Gb so I'd really fancy soem extra space. I would be happy to do with something in between (say, 160 or 200Gb 7200rpm), but I can't find anything of that sort anymore. For some reason, it seems like one has to choose between size and speed. What should I do?

23 February 2008

KDelicious 3.2 out

Just a minor release really, I added some translations (thanks to Oliver Bock for the German one) and fixed a few bugs. I'm still looking for new features to add. Apparently, it might soon be reviewed by a magazine, which would be sweet.

22 February 2008

kdepyuic essential patch

This little patch for kdepyuic just made my day.

kdepyuic is a small utility to produce python files from .ui files produced by QtDesigner, ready to be used in PyKDE applications; it basically adds KDE-specific stuff to the standard pyuic utility (a .ui-to-.py compiler included in the generic PyQt distribution).
This i18n patch (courtesy of Stephan Hermann) solves a few headaches with importing the correct i18n function to translate stuff, and I'd strongly recommend everyone writing KDE apps in python to apply it.

(... and this means that a kdelicious release is on its way...)

19 February 2008

on Alan Moore and YouTube

First, a must see for everyone that knows Alan Moore, "the Wizard of England" (via Neil Gaiman):

This guy is from MJ Hibbett & the Validators, which is a pretty geeky name already for a band. If you liked this, you probably want to see Payday and the (quite famous) Hey Hey 16K:

Then, a rant on YouTube. How is it possible that a service clearly built on the concept of feed and "web 2.0" makes it so hard to create an RSS/Atom feed to "republish" a compilation of clips? Officially, they only serve "generic" feeds, either by tag (so free for everyone to spam) or by user (as in uploaded-by a specific user). But internally they DO have "playlists" and "favourites" to which you can "subscribe"... they just don't publish the feed for them; you have to sign up, in a facebook-style lock-in. Very disappointing. Luckily, there are unofficial third-party services like this YouTube Favourites RSS republisher, so you can subscribe to my feed of YouTube Favourites anyway. Sad.

18 February 2008

on Atomic

The new version of Atomic is good. I can finally work properly with my blogspot feed, and the included WYSIWYG editor is good enough for my needs. I only wish it could do feed autodiscovery, at the moment you have to display the feed to trigger it; and pre-fillable automatic namespaces for categories would save a bit of time. UPDATE: uhm, it seems like there are still problems with remembering the configuration...

What else is it left in "feedland" to do? Oh yes, decent torrent integration; after the demise of WritTorrent, I don't see anyone properly doing this yet.

16 February 2008

Democracy 2

"Democracy 2 is the ultimate political strategy / simulation game. Based on a complex Neural network, the game simulates the motivations, loyalties and desires of everyone in the country. As president or prime minister, it's your job to balance the need for income from taxes against the demands of the voters. Do you want your country to be an eco-friendly green paradise? or a socialist utopia? Will you pander to the patriots, the liberals or the religious pressure groups? Can you keep crime under control without destroying the civil liberties of your citizens?"

I just bought it after playing the demo for a little bit. I'm a sucker for this sort of games.

UPDATE: Well, three hours later and I've won one of the several available scenarios, the "socialist agricultural" state that I led to excellence in technology, environmental bliss and fantastic economic growth... I even legalized cannabis to kill off organized crime! It's a simple but addictive game, really worth the money, and extremely educational. I wish there was an italian version to send to my father.

05 February 2008

The Italian Politics Club

  1. The first rule of politics in Italy is that you don't talk about real politics in Italy.
  2. The second rule of politics in Italy is that you DO NOT talk about real politics in Italy. You can talk about "parties" and have endless ideological debates, but absolutely DO NOT try to actually solve problems by enacting policies. People could get angry.
  3. The third rule of politics in Italy is that if someone can't pass a minor law on whatever minor useless subject, the Government is over.
  4. Fourth rule: at least three or four "parties" involved in any trivial discussion or commission. This guarantees instability and respect of the second rule.
  5. Fifth rule: try to fight at the same time with as many people as possible, especially if members of your own government. This will help to apply the second and third rule.
  6. Sixth rule: try to look and act the same as all your colleagues in politics. Otherwise you will be marked as "fesso" (stupid) and you will be ignored.
  7. Seventh rule: governments shouldn't last more than a couple of years at best. Again, this guarantees rule 2 and 3 are respected.
  8. Eighth and final rule: if this is the first time you try to understand Italian politics, you have to get dragged in endless arguments about the role of the Roman Catholic Church and the Mafia and the Big Money People, to conclude 5 hours later that you are absolutely powerless to change anything and the only answer is a south-american-style secular dictatorship that can kill the Pope, burn down the Vatican, put the Mafia in charge of enacting laws in the South, and nationalise all industry.

Note: this is my last post on the subject.

04 February 2008

NYC must be going crazy today

NY Giants won the Superbowl! When we were in NYC two weeks ago, they had just won the Conference (the "semifinal") and the local sport people were thrilled; the entire Madison Square Garden went crazy when it was announced that a couple of Giants players had come to see the Knicks. Now I'm waiting for Youtube to come back online just to see the final 32-yard and 83-yard actions, which must have been spectacular.

02 February 2008

Mandatory "Lost" Theories for Season 4

Fresh from watching the first new episode, I thought I would post a "you read it here first" list of what I think will be revealed or will happen this season...

  • The "freighter people" will be revealed as sent from the original DHARMA owner, Alvar Hanso, who was a weapon dealer and probably not the type of person that accepts to lose property (especially when it's such a property) just like that.
  • Hence, their original objective, of course, was to kill everyone on the island, as they are all deemed to be part of "the Hostiles" by now (and the island must be kept secret anyway). This is why Ben fears them.
  • For some reason (possibly the cover-up already in place, which was that Oceanic815 had been "found" near Bali and all people on board were dead; possibly because they'll end up in a "one helicopter only" scenario where only a few people can board) they will agree to rescue only 6 "losties" -- the confirmed Jack, Kate and Hurley, possibly the two "with-baby" ladies, and a third one who'll eventually die alone as seen in the Season3 finale.
    I would put money on Sawyer, who is smart enough to save his skin in all circumstances, or on Locke, who would probably have died alone in the Real World anyway.
    If Harold Perrineau really has come back not just to shoot flashbacks, then Michael is also an option (him and Walt come back to the island to save the others, Walt again gets trapped there while Michael is forced to escape); Jack tells Kate in S3 finale that they have some sort of debt with the dead man, this would be the one.
    (post-episode4: we now know Sayid is one of the six, which probably eliminates the two "family girls", no matter what Desmond said; as of now, the survivors are all involved in a big coverup-with-blackmail-cum-secretwar, so I don't see class-B characters as being part of that.)
  • From the mobisodes and this appearance in S4 episode 1, we now know for sure that Jack's father is really strolling around the island... probably as a host for Jacob, who will be revealed as a "Bob from Twin Peaks" kind of ghost.
  • We'll not see much of "Smokey" (the monster made of smoke) this year; since the only thing left to confirm is that it's just an artificial security system originally built by DHARMA, we might finally see how it is activated, but my guess is that the writers will keep this for Season 5.
  • Season 4 will end with the "Oceanic 6" flying away, after a struggle between losties and freighter people (plus the Jacob subplot); Season 5 will all be about them coming back for some sort of showdown. The writers very clearly stated, after the first season, that the original vision was for a 5-years story arc; I hope they're not tempted to backtrack and keep the series running after that, as it would be reduced to an endless war between losties+others and DHARMA/Hanso. (Update: it has since been confirmed that the series will end in season 6, so I guess the last showdown will be very long)
  • There's probably lots of space for a prequel that would tell the DHARMA story in detail (the initial project, the original colonization, the civil war with "the Hostiles", possibly even the post-purge struggle to regain the island); either a regular tv series, a movie, or more realisticly a few books. I guess it will depend on the ratings of Season 5.

28 January 2008


First, I upgrade the ATI drivers on my linux laptop and they break 3D. Then Nokia buys Trolltech, the company behind Qt and KDE. Is this God's way to tell me to switch to a GNOME-based distribution? Sigh.

27 January 2008

Thinking 'bout a distrolution

Debian 4.0 "Etch" is growing stale on my laptop. I can live with KDE and OpenOffice being backported only after a few months, but the amount of recent packages breaking on libc6 version (2.3.6, with 2.7 only available in the unstable "Sid" branch) is growing by the day. I basically can't update or add anything released in the last 6-to-12 months, which in linux-time is a lot; and God knows when the newer version ("Lenny") will be released.

I'm seriously thinking about giving Ubuntu another spin; maybe I could install LinuxMint, a polished Ubuntu clone which ships with media codecs/flashplugin/java out-of-the-box; I was positively impressed by the liveCD version, and being Ubuntu-compatible (and hence almost-Debian-compatible) it should have pretty much everything I need. Did anybody try other user-friendly distros, recently?

25 January 2008

What "taking control of the means of production" really means

BBC NEWS | Wales | Miners' proud march from colliery. 13 years ago, 240 miners bought out "their" mine from the incompetent and greedy management (who wanted to shut it down as "unprofitable"). They managed to be profitable just after a few months, and earned their families a comfortable living for 13 years, until the mine was really depleted.

When the workers control the means and ways of production, things will work. This is inspirational.

23 January 2008

Il grande Ratzinga

Torno da NYC e che mi trovo, un fantastico post di Simotrone che linka non solo La ballata del Programmatore, ma persino una bellissima versione di Il Grande Ratzinga!!!

Good one, Simo :)

14 January 2008

Here we come!

KDelicious now on public SVN

I migrated the KDelicious SVN repository to SourceForge, mainly to make it easier for people to volunteer translations. If you fancy having a go (as of today we'd really need de/fr/nn/nb/es, but feel free to add other ones!), just download the KDelicious .pot template, save it as yourlang.po (for example, fr.po), open it with a gettext-compliant tool like KBabel, translate the strings and then send the saved file to me (g dot lacava at gmail.com). Thanks a lot!