cpanel broke mysqlhotcopy 1.22 but here is a fix!

mysql-logo.gif
Yesterday I logged into my server to back up my databases. I back up the mysql databases using a tool called “mysqlhotcoy”. It’s a handy perl application that copies the database files for easy restores, and it also works really quick when you run it.

I ran the mysqlhotcopy command as root, and was greeted with an error similar to this:
Invalid db.table name 'foo.foo`.`bar'

um, no…. this table exists

I have cpanel installed on my server, a lot of server do. cpanel does updates to many application, mysqlhotcopy is one of them. It looks like my version of mysqlhotcopy was updated to 1.22, and there is some major problems with mysqlhotcopy 1.22.

I did some googeling and I found some people talking about the problem. I even found a quick patch for the problem. The problem comes from a host adding the username and an underscore before a database name (example: “username_databasename.table“). mysqlhotcopy only looks for databasename.table

The following patch instructions will fix mysqlhotcopy 1.22

  • Open the perl script for editing. It is located at /usr/bin/mysqlhotcopy
  • find the following subroutine

    sub get_list_of_tables {
    my ( $db ) = @_;

    my $dbh = DBI->connect(“dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy”,
    $opt{user}, $opt{password},
    {
    RaiseError => 1,
    PrintError => 0,
    AutoCommit => 1,
    });

    my @dbh_tables = eval { $dbh->tables() };
    $dbh->disconnect();
    return @dbh_tables;
    }

  • look for this line (mine was link 821):

    my @dbh_tables = eval { $dbh->tables() };

  • immediately after that line add the following:

    map { s/^.*?\.//o } @dbh_tables

Here is my patched subroutine:

sub get_list_of_tables {
my ( $db ) = @_;

my $dbh = DBI->connect(“dbi:mysql:${db}${dsn};mysql_read_default_group=mysqlhotcopy”,
$opt{user}, $opt{password},
{
RaiseError => 1,
PrintError => 0,
AutoCommit => 1,
});

my @dbh_tables = eval { $dbh->tables() };
map { s/^.*?\.//o } @dbh_tables;
$dbh->disconnect();
return @dbh_tables;
}

After I applied the patch, everything was back to working order.

Some people have other approaches that would work also, like downgrading mysqlhotcopy all together.

Personally, I think adding one line of code wasn’t that big of a deal to fix the program

Who is listening to your iTunes?

sharing_itunes.gif

If you use iTunes while your computer is hooked to a network (work, dorms, and coffee shops are good examples), you can share your iTunes with other people. This feature has been around for a long time in iTunes. Something that isn’t included is the ability to see how many, and who is listening to your music.

I did a little bit of searching an found that iTunes uses port 3689 to share music on. Reaching back into my DOS days, I came up with this:

press the windows key + r
enter “cmd” and press enter
at the prompt type:
netstat | find “:3689”

you will get a listing of all the computers connected to your iTunes. A useless but interesting trick.

If you are running a mac, I’m sure you can do the same thing but with grep.

cfdump in php!

At work, I write ColdFusion, at home I write PHP. I bounce back and forth between worlds. Jack of all trades, master of none I guess.

One thing that I have always loved about ColdFusion is the cfdump tag. You feed it any variable, and it will spit out whats in it. Struct, String, Array, Query, Object, XML, it doesnt matter, it just works. I would go as far to say that its one of the best native debugging resources I have ever seen in a web development language.

In PHP, you can do a print_r() and look at the source, but that is no where as cool as cfdump. I have longed for a cfdump style resource to be available in PHP. Today I got my wish when I stumbled upon “dBug”. http://dbug.ospinto.com

dBug is a small PHP class that duplicates the cfdump tag from ColdFusion

look how simple it is to use:

include_once("dBug.php");
new dBug($myVariable);

The output looks like this:
phpdump.gif

dBug will handle anything you throw at it, just like cfdump does. This is going to help me so much in the future. If you develop in PHP, I think that this class is a must have in your tool kit.

dBug is free! get it today from http://dbug.ospinto.com

Making better mp3 files with iTunes

I am an mp3 snob, and I am not ashamed to say it.

I ripped my first mp3 file in 1994. I ripped them at 128 kbps, with no ID3 tag information. I did this with most of my cds

and any other cd I could get a hold of for years. Back then that was the way to go. Most people didnt have computers, forget

about portable mp3 players.

Flash forward to today. If someone hasnt heard the term "mp3" or "iPod" yet, they have been living under a rock, or in a time

warp. There isnt a person that I know who doesnt have some music on their computer in some format.

When it comes to music player, the iPod wins, hands down (at least until the zune comes out… hey, im hopeful for it).

iTunes is the defacto standard for loading up your ipod with music. Most people drop in a cd and import (rip) it without

thinking. All they know is that they now have the music on their computer and iPod, to most people its all just computer

voodoo magic.

Default settings on most things SUCK, including iTunes.
Lets look at the default settings of the itune cd import.
first off, iTunes doesnt defaulty rip cds into mp3 files. It uses an apple specific AAC format.

Why AAC files sucks:

  1. non Standard format, very few players and devices support it (mostly apple only)
  2. DRM : digital rights managements. In english, rules they say how you can and cant use that file
  3. Most of the time they are very lossy and sound horrible (high quality is 128kbps)

Why MP3 files rule:

  1. Standard format that almost any audio device can read, from computers to car stereos
  2. NO DRM : no one can tell you what to do with them once its in MP3 format, you are home free
  3. Capabable of producing very high quality sound

Terminology: BitRate
In a nutshell, the amount of data that is pushed out over an period of time. The more data being pushed, the more detail the

audio file can hold. The more detail, the better the sound.


Common Bitrates and their real life equivalents

32 kbps am radio
96 kbps fm radio
128 kbps very low cd quality
160 kbps low cd quality
192 kbps near cd quality
256 kbps high cd quality
320 kbps very high cd quality

looking at the list above, how would you want your cds transferred to your computer? Most software defaults to 128 kbps.

Personally I can tell you if a file is anything less then 192 kbps from listening to it. Im of the school of thought that if

I am go to take the tile to convert my cds into digital formats to listen to them, they should sound reasonably good. For me

reasonable is anything 192 kbps and higher.

With higher bit rates comes higher disk space usage though. In the space you can store 10 songs at 128 kbps, you might be

able to store 5 – 7 songs at 192 kpbs. personally I would rather 1000 songs that sounds awesome on my mp3 player then 1500

that just sound ok. A great combination of size and quality is VBR (variable bit rate) encoded MP3 files.

Basically when there is a part of a song, like a half second pause, you dont need that at super high quality, so if the blank

part of the song has a bit rate of 128 kbps, who cares, When there is a lot of detail to the music, the MP3 file is encoded

at a high rate, like 256 kbps. The net result is a song that changes rates hundreds if not thousands of times, ending up with

a song that sounds great and takes up a reasonable amount of space. Any person who is serious about their music should rip

High quality VBR MP3 files. end of story.

Below is how to make iTunes record High quality VBR MP3 files


  1. In iTunes, go to "edit->preferences" on the tool bar

  2. go to the advanced tab and select "importing", we want to change these settings, the default ones suck

  3. Select the MP3 encoder for importing, then pick the Custom setting

  4. You should get a pop up window what lets you adjust settings, select 192 knps as the bit rate, check use VBR, and set that to

    High

  5. I like to keep my mp3 files away from my other documents, so I changed where the library is. I also like to have iTunes

    organize the folders. iTunes will create a directories in the following manor. ArtistName/AlbumName/trackNumber trackname.mp3