A fun little script

#!/bin/bash
if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$1" == "-v" ] || [ "$1" == "--verbose" ];then
  echo -e "http://xkcd.com/149\n"
fi

if [ $UID -eq 0 ];then
  echo "Okay."
else
  echo "What? Make it yourself."
fi

Tags: 

Today...

...I decided to tackle problem I recently found out about in fwbackups. If there is a large amount of stdout or stderr output in a short amount of time from the backup subprocesses, fwbackups hangs. That level of output should never normally happen while backing up user files, but if /proc or /dev is included in a backup for example then it could trigger the problem.

After 8 hours [1] of backup benchmarks, I've concluded that not only is python's tarfile module horrendously slow (with gzip compression enabled, it is consistently two times slower than calling "tar" from the command line as a subprocess) but that I unfortunately have to reverse the feature I added in 1.43.3rc3 that adds the display of the file currently being backed up in the GUI. Sorry in advance, but it was the only way to keep both performance and prevent fwbackups from hanging mid-backup in certain situations.

[1] which as it so happens, is also how many hours there are in the first season of How I Met your Mother. It's a hilarious show!

Tags: 

Fixing the iTunes 10 badness

I think many will agree that iTunes 10 was more of a marketing ploy than anything else... I found that iTunes 10.0 was worse than 9.x, primarily because of the "traffic light" style buttons in the window corner and graystyle icons. That was bearable though, and then the update to 10.0.1 came along made things even worse. No more Genius sidebar, and obnoxious "Ping" buttons every time a song is selected.

So I went on a quest to fix it, and found these commands on various forum threads and blogs:

(If you are unsure how to run these commands, quit iTunes and open Application > Utilities > Terminal. Copy/paste these commands in, hitting <Enter> after each to execute it.)

defaults write com.apple.iTunes hide-ping-dropdown 1
Disables the obnoxious "Ping" drop-down menu I mentioned earlier.

defaults write com.apple.iTunes show-store-link-arrows -bool TRUE
Restores the store arrow links present when a song is selected in 10.0 and earlier.

defaults write com.apple.iTunes disablePingSidebar 1
Disables the ping sidebar. Sadly, I haven't found a way to re-enable the Genius sidebar.

defaults write com.apple.iTunes full-window -boolean YES
Puts iTunes in "full window" mode, removing the traffic light window controls.

Now, the last thing is to restore color in iTunes. To do this, download the iTunes.rsrc file linked to in comment #7 on this thread. Next, right-click on iTunes in the Applications folder and select Show Folder Contents. Inside the Contents/Resources folder, copy the downloaded iTunes.rsrc file and opt to replace existing files when prompted. Restart iTunes and you should have coloured icons!

Note: If you're reading this but you're running iTunes on Windows, a user on Apple Discussions has posted how to do the same on Windows.

Cryptic MySQL error

Today as I was attempting to test one of my PHP applications, I received this error after attempting to connect to a MySQL database:

Warning:  mysql_connect() [function.mysql-connect]: OK packet 6 bytes shorter
than expected in index.php on line 29

Warning:  mysql_connect() [function.mysql-connect]: mysqlnd cannot connect to
MySQL 4.1+ using old authentication in index.php on line 29

The script giving the error was running on OS X 10.6.4 with the stock PHP 5.3.1. After doing a bit of searching and reading the MySQL documentation on the old password format, I was a bit confused because I ran this on the server:

[user@host ~]# rpm -q mysql mysql-server
mysql-5.0.77-4.el5_5.3
mysql-server-5.0.77-4.el5_5.3

Both the server and client should support the new authentication version, which was introduced all the way back in MySQL 4.1. So why wouldn't it connect?

It turns out that CentOS 5 disables the new password hashes by default in favour of remaining compatible with 3.x (and earlier) MySQL clients. All you have to do is edit /etc/my.cnf and comment the old_passwords=1 line. After restarting the server, you should notice that running SELECT PASSWORD('foobar'); in a MySQL prompt will return 41-character hashes, not the old-style 16 character hashes. Reset the user passwords to start using the new hashes and you'll be good to go.