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

Konban-wa!

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'

client.ProgrammaticLogin()

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

inbetween

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.