This weekend I encountered a weird problem during programming C extension modules for Python. For some obscure reason floats from my C extension modules were formatted with a comma as separater (e.g. 123,456) instead of with the more familiar point (e.g. 123.456). Obviously some locale related problem. Most of my desktop and applications are set up for Dutch (my native language), but when I'm programming/working I use English and scientific conventions (e.g. a point as decimal separator). After isolating the problem I found out it was related to importing the pylab (aka Matplotlib) module (which I started using for plotting graphs and figures from Python). The following situation illustrates the problem.
linux
a clash between locale settings, C extension Python modules and pylab (aka matplotlib)
fun with reflective linux commands
Man, this is heavy linux/unix commandline fun:
which which locate locate man man help help info info whatis whatis echo echo touch touch yes yes whereis whereis
Last.fm player on Linux
Today I bothered to intall the Last.fm player just to give it a try. The installation (on my Kubuntu 5.10 Linux laptop) was very easy. I just downloaded a tarball with the Linux binary from the Last.fm player download page and extracted it to a local folder in my home directory. Next I had to tell my webbrowser (firefox) to use this player for links with the lastfm:// protocol (like explained here). That was all to make it work.
Bash: the difference between $* and $@ and what that means for working with filenames containing spaces
Lets's start with a citation about the special parameters $* and $@ from the bash manual:
Easily accessible calculator in KDE
With the shortcut alt+F2 in KDE you invoke the "run command" dialog (also accessible from the start menu if it's not hidden of course). It is a fast and easy way to launch an application if you know its command line name (which is mostly the same as its normal name, except for things like OpenOffice.org).
cat with rot13 encoding
If you're familiar with the Unix or Linux commandline you probably know cat for printing files to standard output. Rot13 is a simple text encryption/cyphering/obfuscation (or whatever you want to call it) technique. It replaces each letter with the letter 13 places further in the alphabet. For example: 'a' becomes 'n', 'z' becomes 'm' and 'n' becomes 'a' (which illustrates the fact that the rot13 operation and its inverse are the same).
shell redirection of standard output and standard error to the same file
Consider a program hello_and_error that writes to both stdout and to stderr. To redirect both to stdout:
hello_and_error 2>&1
If you want to redirect both to the same file hello.txt you can do in bash the following:
hello_and_error &> hello.txtIf you want to do this in a more obvious (but longer) way you should do
hello_and_error 1>hello.txt 2>&1
and not
hello_and_error 2>&1 1>hello.txt
Easy moving and resizing application windows on the Linux desktop (KDE, Gnome, IceWM, ...)
If you work in a Linux desktop environment/windows manager like KDE, Gnome, IceWM (and probably many others), you definitly should try the following mouse trick: click/drag while holding <alt> above a (not maximized) application window. Depending on the mouse button and the windows manager this should move or resize the window. It's way easier than aiming at those thin window headers and borders.
For example in KDE and IceWM you can do the following:
- holding <alt> + left mouse button drag: move the window
moving files to the (KDE) trash can from the command line
When you want get rid of some files, but fully deleting them is bit drastic, a trash can is an handy option. In a graphical environment the tools are there to do it (drag and drop, right mouse button on a file, etc.), but on the command line it is not something very handy to do. In the old days there was a directory ~/Desktop/Trash that acted as the trash can. But nowadays, KDE and Gnome implement the freedesktop.org trash specification, which is more advanced than a simple directory with files.
Bash: about .bashrc, .bash_profile, .profile, /etc/profile, etc/bash.bashrc and others
Ever wondered what's the difference between ~/.bashrc, ~/.bash_profile, ~/.profile, /etc/profile, /etc/bash.bashrc (and maybe others) and what their purposes are? I do.
Some interesting excerpts from the bash manpage: