Script for downloading bibtex file using DOI

Digital Object Identifier (DOI) and bibtex files are common for anyone citing scientific articles. The DOI is used to uniquely identify any object, such as an electronic document, while bibtex is used to cite an article in Latex environment.

An article can be found on the internet via the address dx.doi.org/ followed by the DOI, e.g. http://dx.doi.org/10.1016/j.ocemod.2004.08.002. However, it takes a while to browse the publishers website, locate the appropriate bibtex file and save it to disk.

Here is a very handy Python script that fetches a bibtex file from NASA’s Astrophysics Data System using the article’s DOI.

It requires Python Beautiful Soup XML/HTML parser.
In Ubuntu-like linux distributions it can be installed easily:
sudo apt-get install python-beautifulsoup

Example:

>>doi2bibtex.py 10.1016/j.ocemod.2004.08.002
@ARTICLE{2005OcMod...9..347S,
author = {{Shchepetkin}, A.~F. and {McWilliams}, J.~C.},
title = "{The regional oceanic modeling system (ROMS): a split-explicit, free-surface, topography-following-coordinate oceanic model}",
journal = {Ocean Modelling},
year = 2005,
volume = 9,
pages = {347-404},
doi = {10.1016/j.ocemod.2004.08.002},
adsurl = {http://adsabs.harvard.edu/abs/2005OcMod...9..347S},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Fixing screen brightness keys in MacBook + Ubuntu 10.10

After upgrading to Ubuntu 10.10 natty, the keyboard backlight keys and screen brightness keys did not work in macbook pro.

Solution:
Make sure that Mactel-support PPA repository in enabled. It is usually deactivated during the upgrade process.
Install nvidia-bl-dkms package:
sudo apt-get update 
sudo apt-get install nvidia-bl-dkms

Installing 32-bit MATLAB on 64-bit Linux (Ubuntu)

Currently 64-bit Linux distributions are stable and well established so there are virtually no problems in opting for a 64-bit system.
However, some MATLAB Linux versions, notably the student version, only exists in 32-bit and it is not so obvious to get it installed in 64-bit Linux environment.

Here’s how I got it done (MATLAB R2009a in Ubuntu 10.04 Lucid):
1) Install some 32-bit libraries:
sudo apt-get install ia32-libs lib32ncurses5
2) Mount the CD (e.g. open the content in a file manager)
3) Install MATLAB, force to use the 32-bit executable:
sudo /media/cdrom0/install_unix.sh -glnx86
Install matlab to some convenient place, typically /usr/local/matlab (assumed here).
The installation will fail, complaining about 64-bit java.
4) Fix the java problem (change the path according to your installation):
sudo ln -s /usr/local/matlab/sys/java/jre/glnx86/ /usr/local/matlab/sys/java/jre/glnxa64
5) Register your matlab
sudo /usr/local/matlab/bin/activate_matlab.sh
6) You can now run MATLAB:
matlab -glnx86

KDE touchpad configuration disabled in Kubuntu Maverick

After upgrade from Kubuntu Lucid 10.04 to Maverick 10.10 the touchpad configuration was disabled in KDE system settings (System settings -> Input devices -> Touchpad). All the controls were disabled, the “Informations” section reading “Touchpad Name: Device not found”.

I have Apple Macbook Pro (macbook5,5) which uses bcm5974 driver. Apparently the driver is included in the recent linux kernels, but it can also be installed from the Mactel Support repository. First thing to do is to check if the drive is loaded in the kernel:
lsmod | grep bcm5974
If the command doesn’t print anything, you need to install the driver.

If the driver is installed, like in my case, but the KDE configuration is still disabled, check if xserver synaptics package is installed:
sudo apt-get install xserver-xorg-input-synaptics

The KDE touchpad configuration module is provided by the package kde-config-touchpad.

Linux audio: Device or resource busy

Usually audio playback causes no problems in Linux, but sometimes audio vanishes suddenly and you cannot get playback until you logout/restart the system. Here’s how you can restore audio playback without restarting.

Usually the problem is caused by a crashed program that is still using the audio device preventing other processes accessing it. If you run a playback software from the command line (e.g. vlc foo.mp3) you typically see an error like:
/dev/dsp: Device or resource busy

The solution is simple, you just need to identify the runaway process and kill it. Command
lsof | grep snd
gives a list of candidates that might be occupying the audio device. These can be terminated by
killall program_name or kill PID, where PID is the process ID shown in the second column of lsof output.

Duplex printing for HP Color printers in Ubuntu

In office we have this fast HP Color LaserJet CP3505 printer, that should be able to print on both sides. I installed the driver using some GUI (system-config-printer I think) and everything worked like a charm, except the duplex printing. Trying to enable duplex printing in kprinter, for example, resulted an error “Some options selected are in conflict” as the Duplex Unit was not installed.

The printer setup can be changed (as instructed in this thread) in the CUPS HTML interface, accessible via any browser:

http://localhost:631

1) Choose Manage Printers and Set Printer Options of the printer at hand.

2) In Options Installed change radio button to Duplex Unit : Installed.

3) Click Set Printer Options.
You may be asked for a user name and password. Type in your local login user name and password. Sometimes, as in my case, you may need to input root and the superuser password.

Presumably the same configuration can be done in the GUIs as well, for example:
sudo system-config-printer and tick Duplex Unit in Installable Options tab. (In KDE use kdesu instead of sudo.)

Floppy drive access in Ubuntu Hardy Heron

For those who still need to use floppies, it seems that floppy drives are not fully supported in Ubuntu anymore as there is no out-of-the-box solution that would work.

However, you can always mount the floppy manually:
1) Make sure that the floppy drive is properly connected to motherboard and that (internal) floppy access is enabled in system BIOS.
2) Start Ubuntu and create directory /media/floppy or something similar.
3) Mount the floppy by sudo mount /dev/fd0 -t auto /media/floppy.

You should be able to access the floppy either trough terminal or GUI programs.
Make sure to unmount manually when you’re done to prevent data loss: sudo umount /media/floppy.

Note that the GUI access *does not* work so do not try to access the floppy via Nautilus or Konqueror or such before mounting manually (step 2).

Recovering files from ext3 filesystem with foremost

So you accidentally removed some files on Linux ext3 partition and you want them back.
Here’s a procedure that worked for me:

1) Get foremost recovery tool. In Ubuntu it is in the universe repositories.
2) Unmount the partition where the files were. If it’s the root partition (say, /dev/sda1) , you cannot unmount it. In this case use Ubuntu Live CD or such to reboot into a system that does not mount the /dev/sda1.
3) Run (note that you must run with sudo):
sudo foremost -i /dev/sda3.

foremost will create a directory called output where all the recovered files are stored, separated in subdirectories according to filetype. If you need to recover only certain files, use the -t option:
sudo foremost -t jpeg,gif -i /dev/sda3
would only recover jpeg and gif files.

Follow

Get every new post delivered to your Inbox.