Thumbs.db viewer

Sometimes when images get accidentally deleted, even the thumbnails are already useful to view and might save you a recover operation. As you know, windows creates a hidden thumbs.db file in every directory where you viewed an image in thumbnail mode. When the file gets deleted, windows does not like to clean up (no surprise here), so you can still view them.
I found this nice free tool which simply does the job (.net framework required).


thumbs.db viewer

Securing mysql

Everyone knows, first thing you have to do after installing mysql, is setting its root password. I used to do this using the mysqladmin tool like this:

/usr/bin/mysqladmin -u root password 'new-password'

For starters, you should not forget to do the same command for your other host names (-h option), but also there are still some other tasks like disabling anonymous access and removing the test databases. Today, having another mysql install, I noticed that the install script mentions this neat tool packaged with mysql to do just all that. 🙂

Just run /usr/bin/mysql_secure_installation and you’re done!

FTP: copying outside chroot jail

Your typical ftp setup will allow your users to only copy/modify stuff in their own home dir (=chroot jail). Which makes sense. However, from time to time, you’ll want to access directories outside your home dir and then the following workaround can come in handy. Concretely, I have a few hard disks in my box, so, from time to time, I want to write directly to another partition than my home partition because of space constraints.

Obviously, you can allow root to access ftp, but we’d like to avoid that if possible, right? Simply making a symbolic link in our home dir also doesn’t work because of the chroot jail.

What you can do however, is mount a directory in another place. Suppose I have a /dev/sdb1 which is mounted to /mnt/data. I want to have access to the download dir on that drive. Then I can do:

mount --bind /mnt/data/download /home/mattie/download

to access this from my home dir. you can use the -r option to make it read-only if you wish (though doesn’t make much sense in my scenario). I suppose it might also work using hard links but I didn’t try that as I didn’t need a permanent link. Using mount, the link simply disappears on the next reboot.

Controlling XMMS using a gamepad

On windows I used to control winamp using global shortcuts. Since I didn’t immediately find this plugin on linux (although google seems to suggest it exists), I tried the joystick control plugin. But I never used a joystick before on linux.. 🙂

I plugged in my Logitech Dual Action Gamepad and a cpu spike indicated something got detected. 😉 I didn’t have high hopes it would work in XMMS though, since that’s about as archaic as one can get with a gui app. 😉 I enabled the libjoy.so plugin and set the path right to /dev/input/js0 instead of the default /dev/js0. I tried some button and some joystick. It didn’t do anything.

Let’s have a look at Yast. Yes, it has a joystick module, but it didn’t seem to list my gamepad. But then I read in the side column that you don’t have to configure anything if you use an USB gamepad. So next thing was to try KDE’s control center which turns out to also have joystick module. Indeed, the gamepad with all its axes and buttons was properly detected! While I was there, I also did a calibration, mostly for fun, as it didn’t seem necessary. So why didn’t it work with XMMS, because it was just too old?

In a final attempt, I tried testing a “general analog joystick” in yast, which triggered a package install (don’t remember which one). I don’t know if it was the package that did the trick, but after that, it worked in XMMS! It was just a matter of finding out the right buttons by trial and error (the mapping didn’t correspond to KDE’s mapping).

Setting a process’ processor affinity in linux

Sometimes, people like me like to run stuff on a dedicated cpu instead of using all available cpu’s. The key to success here is this nifty tool: schedtool. Unfortunately, I didn’t find it anywhere in suse’s package database, nor the build service (if you know a repo or util package, please let me know).

But don’t worry, I guess nobody cares to make a separate package as it is such a small util. Just download the source from the website and make/make install (configure isn’t even needed).

Then, to run a process, in this case a dir listing, on CPU0, use:

schedtool -a 0x1 -e ls -la

-e specifies the command to execute
-a is followed by a bitmask in which each bit represents a CPU.

I have found that somehow it is best to always use the hexadecimal notation, even if your number is less than 10.

Extract audio from AV container

A while back, I posted a link to a program for splitting off the audio of an FLV file.

The linux equivalent would be to use mplayer, your video swiss army tool 😉

I’ve put it into a convenient KDE (3) service menu entry (copy paste in a file in $HOME/.kde/share/apps/konqueror/servicemenus):

[Desktop Entry]
Encoding=UTF-8
ServiceTypes=video/*
Actions=extractaudio

[Desktop Action extractaudio]
Name=ExtractAudio
Name[en]=Extract audio
Exec=mplayer -dumpaudio %u -dumpfile %u.dump
Icon=sound

Now you should have an action “Extract audio” when you right click on a video file. It should work on all mplayer supported video files.

4GB tuning

By default, on a 4GB 32-bit system, windows only gives 2GB to the application. To increase the amount of total user virtual address space, edit your boot.ini and include the /3GB option. With the /USERVA you can tweak the amount between 2 and 3 gigabyte. So you can not allocate more than 3GB for applications.

Furthermore, you must relink your application with the /LARGEADDRESSAWARE option to make use of this ‘4GT’ feature. You can also modify an existing binary by using editbin.

source: MSDN

Lirc on openSUSE 10.3

I somehow always procrastinated the installation of my Hauppauge WinTV PVR 150 IR remote because it somehow didn’t work out of the box, but today I took another shot at it and was surprised how easy it all turned out to be!

The first thing you need to realize, is that you need to install a kernel module: lirc_i2c. Unfortunately, due to a string length being shortened in recent kernel, the suse provided kernel module does not work! Instead, grab a freshly compiled one from here. After having this installed, you should already have a working remote! (you might want to tweak your /etc/sysconfig/lirc : choose the hauppauge driver and the lirc_i2c module, but the defaults seemed to work too). You can test your remote by doing a cat /dev/lirc and pressing some remote buttons.

Easy, no? 🙂 The rest is application specific configuration 😉 Be sure to have a look at KDE’s infra-red app, IRKick, which does a great job at binding through DCOP!

One thing to note though, is that the default lirc config is supposed to create a device /dev/lircd from /dev/lirc when starting lircd, but in my case, it wouldn’t do that until I specifically told it to create that one through the –output param (only had to do this once).

I was greatly helped by the following sources: mythtv 1, 2

Redirecting error output on windows console

I thought I already blogged this, but I can’t find it back, so let me try one more try as I seem to need this from time to time and then fail to remember the correct syntax! 🙂

The scenario is: you have this huge error output on your console (for example a very long compiler error). Since it is quite long, console history is not big enough to see the beginning. You could of course increase the history size, but it’s not a real solution. Everyone knows how to redirect console output to a file, simply like this:

type myhugefile.txt > output.txt

This is all nice and dandy, except, it doesn’t capture the error output (stderr) (which is exactly what we’re interested in ;)). You have to do some win32 console-fu as follows:

mingw32-make 1> output.txt 2>&1

This tells the shell to redirect standard output (stdout) to output.txt and redirect error output to standard output.

You can read all this information in a nice collegebook format on MS’s KB.