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!