November 7, 2011

Creating .mp3 from .ogg with metadata

Filed under: Software

Over the years I gathered a lot of music on my ubuntu system (ripping my cd’s, digitalizing my lp’s). Sometimes I created .ogg files, sometimes .mp3 files. In order to be able to play this music on devices that don’t understand .ogg, I wrote a bash script that traverses my music folder and depending on the file format either copies (mp3) or transforms (ogg) the files to a new folder. During this process it is checking on the presence of metadata and it also extracts the metadata from the .ogg files and puts it in the .mp3 files. The script is available here.

October 18, 2011

Controlling usb-serial devices

Filed under: Software

There are still a lot of instruments/devices out there that can only communicate via a classic 9-pins serial interface, but our laptops don’t have this interface anymore. Luckely there are usb-serial converters that allow us to connect these devices to our laptop. A challenge I encountered is how to know from within your software which device name to use to address a device connected via a usb-serial converter. When you connect such a cable, the first one will get the name /dev/ttyUSB0, the second one /dev/ttyUSB1, etc… . So it depends on the order of connecting AND at reboot the assignment will be random.

Several posts (https://bugs.launchpad.net/ubuntu/+source/udev/+bug/107208, http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/) suggest to use udev rules based on the serial number of the usb-serial converter. I tried that, but all the cables I bought from different stores did not have a serial number. One could decide to base the rules on the vendor or product id, but this isn’t a future-proof solution: are there more vendors than devices you have to connect?

Another way is to create udev rules based on the physical port of your laptop/computer (implication is that you need to connect a device to the same physical port). To find out the identifier of the physical port, you can issue the command (after having connected a usb-serial cable):

 udevadm info -a -n /dev/ttyUSB0|grep "KERNELS" 
  KERNELS=="ttyUSB0"
  KERNELS=="3-4:1.0"
  KERNELS=="3-4"
  KERNELS=="usb3"
  KERNELS=="0000:05:00.0"
  KERNELS=="0000:00:1c.5"
  KERNELS=="pci0000:00"

 The identifier of the physical port is ‘3-4:1.0′, so now you could add a udev rule:

 SUBSYSTEMS=="usb", KERNELS=="3-4:1.0",  SYMLINK+="ttyUSB100"

which will create a symbolic link from /dev/ttyUSB100 to the device (/dev/ttyUSB0, /dev/ttyUSB1, whatever) that will be connected to that specific physical usb port.

Note on RxTx: if you are using RxTx to access the serial itf from java, you need to know that RxTx is making some assumptions on device names that can represent serial interfaces. There are workarounds to this limitation which are described very nicely at  http://www.capybara.org/~dfraser/archives/29

 

August 24, 2010

Where have all the free dns services gone?

Filed under: Software

During the last couple of years I have been using zoneedit.com and everydns.org as free dns servers, but none of them can be used anymore to add new domains. Zoneedit even decreased the number of free domains from 5 to 2. So I was looking around for alternatives. There is freedns.afraid.org, but they have the disadvantage of other people being able to associate secondary domains to your domain. Another one is dnsexit.com, so I am trying that one out now.

August 10, 2010

Watch out with Locale.getDefault() and ssh

Filed under: Software

In one of my webapps I was using Locale.getDefault(), assuming it would take the values in /etc/sysconfig/i18n, but this turned out to work differently. When I logged in via ssh from a terminal with another locale to restart the webapp, the locale of the ssh client was used in Locale.getDefault(). This behaviour can be avoided as described in this excellent article.

July 16, 2010

sudo: sorry, you must have a tty to run sudo

Filed under: Software

when I was starting a script containing the sudo command in a cron job, I received the message ’sudo: sorry, you must have a tty to run sudo’. to avoid this message one can comment out the line ‘Defaults requiretty’ in /etc/sudoers.

January 20, 2010

Supermicro IPMI applet in Firefox/Ubuntu

Filed under: Software

I thought I could run applets in my Firefox 3.0.17 on Ubuntu, but yesterday I encountered an applet that did not run, namely the applet that is used to acces the Supermicro IPMI card (AOC-SIM1U-3B+). After removing the Icedtea plugin and adding the sun java plugin (sudo apt-get install sun-java6-plugin) the applet started working.

 

November 3, 2009

Coriolis for sailors

Filed under: Science

Last weekend we had an excellent sailing trip from Nieuwpoort to Ramsgate and back again. And as it happens on such occasions, conversation touched the subject of Coriolis forces, which is important - for sailors - to understand the deviations of air flows when they move from high to low pressure areas (deviation to the right in the Northern hemisphere, deviation to the left in the Southern hemisphere).

Often these conversations get needlessly complex.  So here is my stab at it. The Coriolis force is a pseudo force, just as the centrifugal force is a pseudo force. You only need these pseudo forces to explain things if you are an observer on Earth who is not able to imagine how things would look from a distance. I was told a sailor must be able to see his boat from a bird’s perspective, so sailor, just fly a bit higher and watch the Earth from a few thousand (nautic) miles and you can forget about Coriolis and rely on more basic physics:

1. Newtonian inertia: tendency of an object to maintain its state of uniform motion (unless acted on by an external force).

2. The velocity of an object making a rotational movement (e.g. a rock on the surface of the Earth) is the ‘rotational velocity’ times the distance to the rotational axis. This means that a rock on the equator moves faster than a rock on the Tropic of Capricorn or the Tropic of Cancer.

3. Context: air moves in a thin layer around the Earth.

So what happens to an air particle that moves from South to North in the Northern hemisphere: since it is stuck in this thin layer around Earth, it moves to an area where the Earth’s velocity is lower than the velocity of the particle, and since it wants to keep its velocity, it moves along a line that curves to the right. The same reasoning can be applied for moving from North to South and for the equivalent cases in the Southern hemisphere.

When moving from West to East in the Northern hemisphere the reasoning is as follows: the (air) particle’s speed is larger than the speed of the underlying surface of the Earth. Because of its higher tangential speed the particle has the tendency to get thrown out of its orbit and move away from the Earth’s axis, but since it is locked in this thin layer, it can only do so by deflecting to the South, thus making a curve with a deviation to the right. Again, similar reasonings can be made for East to West and for the cases on the Southern hemisphere.

So no talking about Coriolis or other pseudo forces needed to understand air movements on Earth.

 

 

October 31, 2009

A commercial

Small commercial on a product we are offering to veterinarians in an attempt to enhance its google ranking. Sorry for the noise. Software voor dierenartsen, praktijkbeheer, logiciel veterinair, application pour vétérinaires, Tierärzte, Webanwendung für Tierärzte.

 

Sonetas Sonetas

October 27, 2009

Creating a movie from pictures

Last weekend, I was trying to create a ‘Lego City Movie’ (together with my son): taking many pictures of slightly moving Lego objects. I was surprised how easy it was to create a movie from this stack of pictures. It was just down the man page of mencoder:

 Encode all *.jpg files in the current directory:
 mencoder "mf://*.jpg" -mf fps=2 -o output.avi -ovc lavc -lavcopts vcodec=mpeg4

I was lucky that in my camera the time order of the pictures is the same as the alphabetic order of the picture names. So everything was ordered as desired. Very neat …

October 23, 2009

Those without ambition

Filed under: Science

Those who state that some areas/fields can NEVER be the subject of science are without ambition, which is not too terrible in itself, but what is worse: they condemn the ambition of others to increase knowledge.

Get free blog up and running in minutes with Blogsome
Theme based on a design by Jay of onefinejay.com