Thursday, 11 March 2010

delete all the images that are not in a specific format

Ok, I'm writing this because it may be useful to me again in the future, as well as to somebody else.

Problem: suppose you have a bunch of jpeg files, with names such as .jpg. Then, you open some of these, and unfortunately enough some of them aren't actually JPEG, but say PNG with the wrong extension. You may want to move them, rename them, or do something to fix the problem (many image viewers won't complain, but some will). In my case I just wanted to remove them.

The command uses ImageMagick, it is for linux and it goes as
identify -format "%f %m\n" * | grep -v JPEG | awk '{ print $1 }' | xargs rm
Identify is an ImageMagick program that retrieves information about the image file, the -format option tells what to print (filename and format, as detected by the magic number).

The grep command takes all the lines that do *not* match "JPEG".

the awk takes the first word in the line (the filename).

The xargs concatenates the word to the command "rm" (REMOVE, again, pay attention!).

Tuesday, 1 December 2009

[LaTeX] rubber and bibtopic

The freezing temperature of today made me think that this post can be potentially useful to other people out there, sooner or later. I've been struggling, recently, with some missing support for bibtopic in rubber. Let me explain.
  • We are talking about the LaTeX typesetting system.
  • bibtopic is a LaTeX package to insert multiple bibliographies.
  • rubber is an automated builder for LaTex (called, in this case, by the gedit LaTeX plugin).
OK. Now the problem: rubber does not support bibtopic. In particular, the presence of bibtopic requires BibTeX to be called not on the main files (e.g. main.aux), but on several other files (e.g. main1.aux, main2.aux, etc). So the build will always fail.

For some days, I decided to tweak the bibtopic support inside of rubber, a python program that, unfortunately, knows little about object-oriented programming, information hiding, encapsulation, single-responsibility-rule, and so on. Basically, it is almost impossible to modify.

The final solution? Use multibib instead of bibtopic. It's supported by rubber, more modern than bibtopic, and, on top of that, more neatly designed, more flexible, and ultimately easier to use. It took me minutes to switch from the one to the other.

Monday, 18 May 2009

Academy and the (non-travelling) salesman problem

It's difficult to me to stand the pressure, typical in my academic experience, to focus on "selling" your product rather than make it better, up to some paradoxical point in which one may want to convince somebody about the goodness of something in which he's the first not to believe.

I'm completely the opposite: I like to work on real problems, as a scientist, and to present real solutions, contributions that I consider worthy. Adding white noise around is of no use for anybody. There is already too much around. Unfortunately, apparently this is often not possible. It is a pity, because the research activity (real research, I mean, not writing papers, editing papers, writing rebuttals, re-editing papers...) appeals me indeed. I'm sure I can do it somehow how I like to, after the PhD.

Thursday, 19 March 2009

Career planning

I went to a career orientation event yesterday. There was free lunch (sandwiches&fruit) and some few former research students, now grown-up, describing how their career evolved and describing their job in different areas. Interesting at times, but not useful nor inspiring. The first thing I noticed is, none of them had planned his/her career path, that has been shaped mostly by them being made redundant, being sick with their current job, or being offered a new job out of the blue.

I left at the tea-break. Yet another proof that career orientation days aren't useful but for the free lunch and for you to think a bit about your career, but not for orienting you nor for giving you useful information.

Friday, 20 February 2009

How to detect the presence of links within a PDF file - linux

This is again somehow related to the conference organisation tasks in which I'm sometimes involved. IEEE does not accept for inclusion in IEEEXplore PDF files that contain links. Therefore, it's useful to have a way to check quickly if the bunch of submitted camera-ready is compliant before sending them over to IEEE.

If you have all your PDFs in a certain directory, from there you simply perform a:
egrep -l "/Link" *.pdf


All the non-compliant filenames will pop out.

Thursday, 1 January 2009

About querulousness

It's good and healthy to discuss our own troubles with people close to us, our family and those ones that we call friends. Nonetheless, the sensibility is required to find suitable moments and ways to do so, in order not to become peevish. Yet, many people just wouldn't care, throwing up to you all their "sicknesses" at the first available opportunity. Failure in interfacing with people that care about you results in becoming isolated, damaging oneself on the first place.
It looks something so obvious, yet a number of people make this error and either do not realise it or confuse it with being honest and open. Good luck to them.

Tuesday, 2 December 2008

Convert all the images of a format into another format

So, you have a lot of images to be converted into EPS format in order to be included in you LaTeX file, don't you? OK, then the following is right for you

mogrify -format eps *.png


Once again, thanks, ImageMagick!

Thursday, 13 November 2008

Useful notes about writing properly technical documents n LaTeX

For you guys out there that, for passion or just for work, write technical papers in LaTeX, I just found a page that points out common mistakes in (LaTeX) technical writing. Even though I discovered I was already complying with some of the guidances, it has been useful to me, so I share.

(from http://www.ece.ucdavis.edu/~jowens/commonerrors.html)


test

Wednesday, 10 September 2008

mloss

At http://mloss.org/software/ it is possible to find a good collection of Open Source Machine Learning software. In my experience, this kind of resource is very valuable since the availability of good software is fundamental both not to "reinvent the wheel", and to have a quick "bootstrap" into the real problems of machine learning that are not connected with implementation of algorithms that are, by themselves, quite complex both in theory and for numerical considerations.

I gave a look quickly since I'm not needing any new algorithm now, and I saw some good projects that I had the opportunity to use in my past work:
in addition to other things that I didn't use but I know by fame.

Sunday, 7 September 2008

oh shit, the Pope...

I've been lucky to come back to London recently. Sure, Im under the rain while down there there are 30 degrees and people is laying on the beach, but at least I avoided the Pope visit in Cagliari! What a curse. And apparently, pope Benedict "Palpatine" XVI, going up and down by the city with his "papa-mobile" (not quite a bat-mobile, but still...) has been warmly greeted. For the event, also Berlusconi was there (plagues never come alone). Some facts:
  • the Pope arrived this morning with a personal Italian Army airplane: guess who's paying the fuel bill?
  • according to the newspaper: "three girls, Chiara, Valeria, and Giorgia, gave to the Pope a bunch of flowers, receiving in return a wide smile and a caress." Then I ask to myself... WHO IN THE HELL GIVES A FUCK?!? ARE THESE ONES THE FUCKING NEWS FROM THE COUNTRY?
I'm disconcerted, I don't know what's going on here. Depression.

Thursday, 28 August 2008

I can hear Righeira in the background...

For those who didn't have the luck of being born and grown in Italy in my times, I'm referring to "L'estate sta finendo" (the summer is ending, yes Zuppa, that was AFTER our performance at the beach), historical hit of our 80s charts. It's a bit sad, but I really enjoyed these holidays (long ones, something more than three weeks) in town. Nothing too complex, I simply stayed in the city seeing friends and spending a bit of time at the beach and with my family.

Anyway, I relly couldn't stand anymore that old post "Adieu my crappy bike", I bought a new one after two weeks, that is twenty times better! See the picture on the side. Yes, it's a racing one, and I like it! Of course, you cannot quite jump on the footpaths and do things like that, but it's very fast and light. Very good to go to school in the morning (at least during summer, I'm afraid I'm about to end this nice habit for this year).

In London, I started doing skateboarding (no pics, I'm afraid) a couple of times with Paulo, with disastrous results for my body, but I have to admit that I enjoyed it, compatibly with my skills (I'm a public threat basically). Here in Cagliari I had to stop but I made up for it by windsurfing, activity that I love. I'm also a bit envious of Marco's new board (F2 Xantos 08 124L) and sail (Naish Sprint 2008), that is an amazing equip that I used a couple of times this year with great fun.

Well that's it. I was staying in Castello in these holiday days and I have to say when you cycle via Buoncammino at around half-past-eight in the summer you cannot avoid falling in love with the place (well, I cannot). Let's see what is going to happen in the future. OK, now I'm satisfied since for a while I'll have a nice memory of this summer looking at the home of my blog, instead that reminding the stealth of my old, crappy bike!

Sunday, 25 May 2008

Adieu, my crappy bike

This last days haven't been plenty of good news. Nothing horrible, fortunately! At first, I had my £80-worth dodgy bike stolen. Not a big loss, for the bike itself was a failure, but it hurts having something unfairly taken away. It hurts less than the first time, though. Now, I already bought on-line a proper lock, for it was partially my bad, and my toy-lock one's, if the thief considered it was so straightforward to steal the bike that it was worth doing within the college premises, under the eye of a (useless) CCTV. As soon as it arrives, I'll decide which bike to buy next (possibly new, since now I fear to aliment the stolen bike market by buying a used one).

Second thing, we are yet other victims of the house market, because the landlady decided to sell, fearing the plummeting house prices, and the mortgage market turmoil (I noticed that scattering here and there terms like plummeting and turmoil makes my sentence sound like the Economist!). Moral: we may be kicked out in a couple of months, and no similar houses are available in this gloomy period on the market. Who knows... Anyway, the perspective buyers that came yesterday seemed very nice and I'd be relatively happy for them to buy the house.

Tuesday, 6 May 2008

Embedding fonts in PDF with GhostScript

In a period in which I hardly have the time to breath, after having spent my birthday working, the only thing I have to annotate here is a very useful link to solve a bad problem of conference organisers: font embedding in pdfs.

http://colinm.org/tips/latex

In practice, the command to embed fonts is:
gs -dSAFER -dNOPLATFONTS -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sPAPERSIZE=letter -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dMaxSubsetPct=100 -dSubsetFonts=true -dEmbedAllFonts=true -sOutputFile=figures/Mprime-new.pdf -f figures/Mprime.pdf
and it works perfectly.

Saturday, 29 March 2008

Italian elections

Where am I?



details: http://www.voisietequi.it/risultato_utente/1a219a96.html

go go go! If you are Italian, take the test now! ;-)

Sunday, 23 March 2008

Why people believe in God

I've been reading an article in the Economist about Scientific Research being financed by the European Union on the relation between religion and evolution, trying to understand why so many people in the world believe in the existence of a supreme being, despite the obvious absence of any support whatsoever. The article was describing some "scientific" experiments that in my view are just ridiculous, but one of the underlying theories was the one of the "natural selection". This point of view, that in some way is hilarious for this Darwinian theory is so uncomfortable for children of God, is more or less consistent with my idea on the matter. I have this belief, that peoples' life is meaningless. When, on top of that, you have to live a miserable life of restraints and despair, either you find a reason to keep going or what's the purpose? And there it comes, God, the heaven, the promises after life, and so on. Faith helps you going on, fair enough. That's also why religiosity is more widespread where populations are poor and uneducated.

A consequence of this is that, at least in my perception, religious people is usually advantaged in finding reasons to be happy and things to enjoy in life. They are less likely to spend Easter day home alone in front of a PC screen, too. This is not exactly the sort of things that help preserving your DNA and your culture. By the way, today it snows.

Friday, 7 March 2008

Delete Junk Messages in Thunderbird

Today I improved the quality of my life. I've been wondering why in the Hell in Thunderbird there is an option to mark the junk messages as "junk", to move all the junk messages in a particular folder, but... there is NO command to EMPTY that dumb folder!

Sometimes the Thunderbird and Firefox (but particularly the Thunderbird) programmers lose a lot for small defiances. Fortunately, somebody else thought about it, and he came out with an add-on, that I found extremely useful: "Delete Junk Context Menu".

Wednesday, 5 March 2008

The Conformist

I went to see the Conformist at BFI Southbank yesterday. Amazing film, hyperbolic representation of the fascist mentality, with an artistic mixture of politics, ideals, religion and sexuality. And everything so well disposed, every excess so well integrated into the plot... it is definitely a masterpiece.

I was confident since I'd read very enthusiastic comments on the net before, but after having seen it I have to admit that this is one of the films that you have to be Italian to fully appreciate. It is not just a matter of language, subtitles, and so on. It's a matter of national identity: it tells you a story that is part of our history, if it's not your own history, you can still understand it, but you will miss the passion in it. You won't feel it as your own.

Tuesday, 19 February 2008

Classical Music

Yahoo!! I'm going to listen to some classical music tonight! I'm very excited about it!

Well, the event I'm going to is this one:
http://www.southbankcentre.co.uk/music/productions/the-night-shift-38443

It seems actually a nice and easy-going environment, very cheap (£4, even my friend Zuppa would come!), and the pieces of music, although short, are very promising, being famous and definitely beautiful (and, I would add, easy to appreciate for a non-expert ear like mine).

There will be the Coriolan, overture of the Beethoven's op. 62:


Then two movements from the Mozart's piano concerto No.21 in C, K.467, which is among the most well-known ones:

and


Let's see!

Saturday, 16 February 2008

Cycling London!

Done. Bought a bike. Again.

Well, my initial idea was to buy a cheap used one, but in the last weeks I realised that last time I've been quite lucky. I still remember that day. At first, I went to a shop, where a crappy 2nd handed bike was £60. I was almost resigned, but I decided to try Brick Lane market, a place in which people try to sell their rubbish to other people, basically a real life (RL) ebay. I found a bike seller... the prices were better than the shop, even though still quite high for me. Suddenly, a guy showed up, claiming that one of the bikes on sale was its own, that he'd had stolen few days before. Understandably enough, I wasn't quite in the mood to buy from that guy anymore. Everything appeared to be lost, when, in a dark corner of the street, I saw a est-european seller with a bike of the 50s. Acceptable. He could barely speak English... £35! I have £30! OK, £30! Taken. My subconscious tried to let me think about the "dubious" origin of that bike, but I was new in London too, I wasn't supposed to know. So I bought an acceptable bike at a good price, last time (I had it stolen a couple of months after... fair enough).

Anyway, now I'm not new in London anymore, I can't say "oh, in Brick Lane people sell stolen bikes? Oh boy, I didn't know, I swear!"... so my consciousness told me "go to a shop". And again, normal bikes for 250 quid and for "merely" £60 a little choice of crappy rusty skeletons. I was resigned, but, then.. "Don't shop for it! Argos it!" Good deal, £90 (+5 delivery, +2 to have it delivered on Saturday...). So, today, at 9.30, it comes! It's half unmounted, the quality of the nuts is crap, I can't unscrew most of them... not to mention the spanners... I was swearing a lot, while mounting, and a lot more afterwards! It's a crap!! Not professional at all, heavy, slow.. an abortion. After a while, I went for a second test-ride and I I reconsidered the matter: for a leasure ride from time to time it's OK, people won't steal it (not as a 250 one!), and if they take it I won't cry for a long time. The deal has been not good, but certainly fair. Ah, btw, in the second photo it's how it looks like in the RL (it's photogenic, it seems actually better than what it is...).

Anyway, today I couldn't ride it for a long time. Too cold. Let's see tomorrow.

Tuesday, 15 January 2008

Wagamama cookbook! Banzai!



Yep. I've been curious about Japanese cuisine for a while, and finally I put my hands on the wagamama cookbook, that hopefully will give me the opportunity to try some ramen, yakisoba, okonomiyaki and all the other cool things that we use to see in Ranma 1/2 and other similar animes.

The first hurdle, though, will be to gather the ingredients. I don't know if Sainsbury's and Morrisons will provide me with the necessary stuff. I'll try to manage.

BTW, during the weekend I uploaded the pictures of my trip in Umbria with my family. I shall add a short captions to the photos to comment them.