Saturday, 18 August 2012

Dear Hollywood, are you trying to tell me something?

IMDB's home page. Do you notice anything?

Today I bumped upon IMDB as I came to know that a fourth chapter of Toy Story is in production: a sad commercial move. Anyway, when I loaded the home page, something has flashed before my eyes, something that should be self-evident by my screenshot above.

Hollywood's approach with violence - and guns in a particular way - clashes with many recent crime news and even with recent President Obama's words.

How do you expect that people stop killing each other, even without plausible reasons, if movies and culture promote the use of guns? As long as the coolness of characters remains proportional to the size of their weapons, it is no surprise that we won't do any progress.

However, this probably is not a problem for the lobbyists and I'm pretty sure that weapon producers are rubbing their hands for this kind of brain-shaping.

Sunday, 15 July 2012

Giornalismo italiano e copia/incolla

Qual è la probabilità che due redattori di due testate indipendenti e teoricamente concorrenti scrivano due articoli completamente identici, parola per parola? Diciamo zero?

Al di là dell'assoluta inutilità della notizia, è interessante che RaiNews24 e Repubblica.it abbiano pubblicato lo stesso identico testo, la cui unica differenza è nel titolo vagamente differente. Nella migliore delle ipotesi, l' articolo è stato offerto ad entrambe le testate da un freelancer ed è stato riversato online senza troppi complimenti.

Non conosco la produzione di RaiNews24, ma so per certo che la qualità degli articoli di Repubblica è totalmente in picchiata — con punte di autentico orrore quando vengono trattati argomenti scientifici — il che mi porta a pensare che questo tipo di approccio al risparmio usato per gli articoli di contorno venga applicato anche a quelli principali. Tristezza.

Monday, 11 June 2012

Meta-programming in Python

Python gives the programmer a plethora of facilities for the meta-programming, for instance the introspection of objects, modules, and such. Moreover, like many other interpreted languages, it allows the execution of generated code.

Which is cool, obviously, if you like algorithms that manipulate other algorithmic-generated algorithms.

http://xkcd.com/917/
This is definitively my case, for I need to generate, at run-time, some data structures and methods that shall be given as an input to an ODE integrator. As both things must be visible from the calling module I need to put them into the global namespace. Piece of cake:
exec open(PATH).read() in globals()
where PATH points to the program-generated file that contains the data structures and the functions I need. Again, the elegance and conciseness of Python are astonishing: exec command checks the syntax and interprets the content of the file, after having it read with read() method, and all the variables are kept in globals namespace.

One-liner power!

Thursday, 26 April 2012

Python, my first time

When it comes to learning a new technology I need some starting project that pushes me and gives me "momentum". In particular, it was years that I wanted to learn Python. I touched this language two years ago, at CINECA's SciViz course, and I toyed around with Django, but they have been momentary encounters and I was waiting for some small-sized, not too trivial problem to solve with it.

Recently, a friend of mine was experiencing problems with some visual representations of temporal series, stochastic in nature and very irregular as number of points. The dataset was huge (in the order of gigabytes) therefore an automatic solution was needed.

Probably PERL would have been a better choice, but I have taken the chance and, this morning, in a couple of hours I've completed my first Python project. It took a while to learn the syntax for dictionaries, lambda functions and some useful I/O classes, but the rest was really piece of cake. My final implementation works as follows:
  • a brief preprocessing, in order to determine the length of each temporal series, done with regular expressions and a dictionary;
  • some filtering on the dictionary, in order to remove spurious results;
  • reading the file again while skipping, in every time series, as many rows as are needed to make the time series uniform.
The final code is about 50 rows long (comments included); an equivalent C++ implementation, probably, would have been much longer and complex. For sure, files I/O is much more verbose than the Python's with open(...) as descriptor syntax. 

I'm very far from a serious knowledge of Python's potential, but I'm impressed: the learning curve is astonishing, as is the clarity of the source code. I'm pretty sure that my future implementations that will not require some low-level functionality (eg., CUDA) or extreme performances will be Python-based.

Monday, 2 April 2012

From Protein Data Bank to... Blender!


Visual Molecular Dynamics (VMD) is a stunning piece of software. Not only it is a powerful tool for molecules visualization and rendering, but it is very useful tool for converting PDB structures into other formats that 3D modeling programs can read. In particular, VMD exports into OBJ, which probably is the most common interchange format.

Moreover, it is usable! A+