Friday, January 25, 2008

Linux streaming audio HOWTO: triplej over the Internet

You will pick up a link like this off the website:

Which if you download it just is a redirector to:

So, make sure your firewall is going to allow the wacky port and you are off:


Update: Saving the stream

This is how you can save the audio stream and listen at the same time! You can also get mplayer to parse the playlist file for you:

mplayer -playlist -dumpstream -dumpfile /home/greg/mp3/hottest_100.mp3
mplayer hottest_100.mp3

Mplayer, I love you.

Thursday, January 24, 2008

MySQL commands I always forget

I always forget these, don't know why:

show full processlist

show table status

show index from [tablename]

mysqdump --no-data [dbname]

Thursday, January 17, 2008

Things I don't like about MySQL

Generally I really like MySQL, have used it for a number of different projects, and I will continue to do so. However, recently I have started working with larger databases and using some of the more advanced features and am running into some annoying problems.

Passing a table name as a parameter

The number one gripe I have actually turned out to be just as ugly using Postgres and Oracle as well, so I can't hold this one against MySQL.

I have found myself wanting to pass table names as parameters to stored procedures, but this makes the code really nasty with string concatenations as below:

SET @sql = CONCAT('SELECT MAX(ID) FROM ', pTableName, ' INTO @max');
PREPARE stmt FROM @sql;

Now imagine a complex stored procedure that needs to reference that table name a lot. Yick. I'm going to try and avoid this situation by putting the logic in the application until MySQL brings out something like a format string :P

I can't raise an error inside a stored procedure

This sucks. I do some sanity checking inside my stored procedure but there is no way to fire an error. Well, no convenient/useful way anyway. Apparently this has been addressed in 5.2, which is not soon enough.

No foreign key enforcement in MyISAM

This is a shame, and I know I can choose InnoDB if I want FK support, but what I really want is the speed of MyISAM with the option of having my FK constraints enforced. I want to be able to turn it on, see how fast it is, and if it is too slow turn it off again.

Can't build cursors from dynamic SQL

This is annoying. The workaround is to use a temporary table, but that is messier than I would like.

No Partition Pruning on Timestamps

This is pretty sucky and MySQL doesn't seem to be in a hurry to fix it. You can't get partition pruning optimisation on timestamps - so partitioning is pretty mcuh useless. You have to workaround it by using unsigned int's and UNIX_TIMESTAMP and FROM_UNIXTIME. You can partition on Date fields but they are twice the size, which is a big disadvantage for large databases.

Wasn't a real database before 5.1

MySQL just doesn't seem to have been a real database before version 5.1. I guess everything has to start somewhere, but this is a bit too recent for my liking and I seem to be hitting plenty of 5.0 installs that just don't have the advanced features I want.

Worst for security according to David Litchfield

At AusCERT 2007 I asked David Litchfield, database security ninja, which of the popular databases had the worst security - he said MySQL :( I tried to push for some specifics but he didn't give me any solid information.

Sunday, January 13, 2008

Yubnub - quick searches and more 'quicklinks' style

Yubnub rocks. It gives you a search box in Firefox that lives to the right of the URL bar. Here is some example usage:

Google yubnub: g yubnub
Google maps search: gm bicycle stores boston
Wikipedia search: wp monkey

This is only scratching the surface, there are hundreds of different shortcuts.


I stopped using yubnub because I didn't like the idea that one guy knew my IP address and everything I ever search for. This is worse than google knowing everything I search for because by its nature it ties everything together: flickr, delicious, wikipedia, etc.

Apt update notifier - automatic package installation

Why doesn't anyone talk about the inbuilt apt update notifier? There is no end of scripts for downloading/notifying of package updates that duplicate update-notifier functionality. On feisty to get my apt package updates downloaded and installed automatically, I edited /etc/apt/apt.conf.d/10periodic to include:

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "1";

And then run apt-config dump to verify the results.

In Hardy, take a look at this file:
I uncommented hardy-updates to allow those to be automatically applied as well. The unattended upgrade is performed by a python script:
which logs to
You can run this script manually with -d to get it to write debug info to the log.

Ripping and converting CDs/MP3s on Linux

To go from mp3s to WAV to make an audio CD, use mplayer:
for nam in *.MP3; do nice mplayer -ao pcm "$nam" -ao pcm:file="$nam.wav"; done

To rip CDs to mp3 I use GRip with these settings (variable bit rate encoding):
/usr/bin/lame --preset standard %w %m

Encode file format:

Creating a self-signed ssl certificate for Apache2

For some reason I always forget this command. To create a self-signed ssl certificate for your Apache2 webserver use:

apache2-ssl-certificate --days 1095

This will give you a certificate in /etc/apache2/ssl/apache.pem that is valid for three years.