Wednesday, August 23, 2006

You know you've been tagging pages with "toread" on too much when ...

... you start to wonder if a human lifetime is gonna be enough to actually read them.

Does that also happen with you ?

Saturday, August 19, 2006

Extract PDF title from all files on a directory

Got a directory full of PDF files with file names that have nothing to do with their title and want to generate a text listing ?

Try this Python script. You need to have pyPdf installed.

# pyPdf available at
from pyPdf import PdfFileWriter, PdfFileReader
import os

for fileName in os.listdir('.'):
if fileName.lower()[-3:] != "pdf": continue
input1 = PdfFileReader(file(fileName, "rb"))

# print the title of document1.pdf
print '##1', fileName, '##2', input1.getDocumentInfo().title
print '##1', fileName, '##2'

Example output:

##1 00317565.pdf ##2 A framework for the specification of SCADA data links - Power Systems, IEEE Transactions on
##1 00363299.pdf ##2 Advanced SCADA concepts - IEEE Computer Applications in Power
##1 00392026.pdf ##2 Routing SCADA data through an enterprise WAN - IEEE Computer Applications in Power
##1 00500696.pdf ##2 INTEGRATION OF SCADA AND DA/DMS ACROSS A LARGE DISTRIBUTION SYSTEM - Energy Management and Power Delivery, 1995. Proceedings of EMPD '95., 1995 International Conferenc
##1 00515274.pdf ##2 THE DESIGN OF NEXT GENERATION SCADA SYSTEMS - Power Industry Computer Application Conference, 1995. Conference Proceedings., 1995 IEEE
##1 00517471.pdf ##2 THE ROLE OF MEDIUM ACCESS CONTROL PROTOCOLS IN SCADA SYSTEMS - Power Delivery, IEEE Transactions on

Saturday, August 12, 2006

Differences between sexes

Just in case you're as interested on this topic as I am, here are some updates on researches about this topic:

Here's an interesting piece from the Economist The mismeasure of woman (a pun on a book from Stephen Jay Gould), which sheds light on many myths. One that caught my attention is:

Female is the default brain setting. Until the eighth week of gestation every human fetal brain looks female. The brain, like the rest of the human body, becomes male as a result of surges of testosterone—one during gestation and one shortly after birth.

On Why Do Beautiful Women Sometimes Marry Unattractive Men?, Dubner and Levitt talk about a new study by Satoshi Kanazawa, an evolutionary psychologist at the London School of Economics, suggesting that it may be a simple supply-and-demand issue: there are more beautiful women in the world
than there are handsome men.

This BBC report references a UK research suggesting that hungry men were attracted to heavier women and explains that how full a man's stomach is can dictate the type of woman he will fancy.

Sunday, August 06, 2006

Word of caution: Distutils, SWIG, STL

This one made me waste some precious time so here it is in chance Google picks it up.

Python's Distutils got a little smart and can now run Swig for you but if you have any STL datatypes (vectors, maps, etc) on your wrapped functions, remember to add the undocumented swig_opts=['-c++'] option to your Extension module definition on

Otherwise, you may end up with Swig spitting errors like

/usr/share/swig1.3/std/std_common.i:109: Error: Syntax error in input(1).

which if you take a look at the mentioned line of std_common.i, it's an unrecognized "%}" swig-pre-processor-thingy.

Here's how a module definition would look like:

#standard setup stuff left out
ext_modules = [Extension('pyCOMHook._mouse', ['mouse.i'],
libraries=libs, include_dirs=includes, define_macros=macros,
extra_compile_args=compilerArgs, language=lang, swig_opts=['-c++'])],

Other than that, if you get the dreaded

ImportError: dynamic module does not define init function (initimymodule)

error when importing your module, try renaming to

Saturday, August 05, 2006

Gah, I hate blogs !

TechCrunch on More Stats on, This Time Positive:

This is an update on the post I wrote about earlier today that showed massively decreasing traffic on the site according to Comscore, and flat traffic from Alexa.


At the end of this process, after reviewing the public data (deeply flawed, but neutral) and Yahoo internal data (presumably accurate, but selectively disclosed), I’ve come to the conclusion that I have no idea what’s up at I’m going to go with my gut and trust Yahoo.
And this is what I have to say: Wow, really interesting... Another example of the classic blog post “there is a rumor and I was unable to confirm the rumor, so let’s just keep spreading”. That’s what I call relevant news.

Thursday, August 03, 2006

Installing mplayer on Ubuntu

Ok, it took me more than it should to find the right way for getting mplayer to work on Ubuntu Dapper Linux, so I thought I should post it here so others can find it quicker than I managed to.

You must do the following actions as root (super user) so you will need to supply your user password.

Here's the two lines you must add to the file /etc/apt/sources.list:

deb dapper multiverse
deb-src dapper multiverse

(for other Ubuntu versions, replace "dapper" with "gutsy" on the lines above for example)

And after saving the file, run these two commands on a console:

sudo apt-get update
sudo apt-get install mplayer