Matt Hackmann

MattHackmann

The thoughts and goings-on of some programmer dad.

PHP ID3Lib 1.0 Release

Brand spanking new release of the PHP branch of ID3Lib!

[ Download ] [ Documentation ]

What's new:

  • Added support for ID3v1, older ID3v2
  • Genre now returned on all tag versions
  • Calculates song duration and average bit rate for constant (CBR) and variable (VBR) bit rate files
  • Single object instantiation can read more than one file
  • Much improved inline documentation (phpDoc style)
  • General code clean-up, bug fixes and improved compatibility

Example


include('id3lib.php');
$songs = array('song1.mp3', 'song2.mp3', 'song3.mp3');
$id3 = new ID3Lib();
for ($i = 0, $count = count($songs); i < $count; i++) {
    $id3->readFile;
    $min = floor($id3->length / 60);
    $sec = $id3->length - ($min * 60);
    $sec = strlen($sec) == 1 ? '0' . $sec : $sec;
    echo 'Title: ', $id3->title, '<br />';
    echo 'Artist: ', $id3->artist, '<br />';
    echo 'Album: ', $id3->album, '<br />';
    echo 'Track Number: ', $id3->track, '<br />';
    echo 'Disc: ', $id3->disc, '<br />';
    echo 'Year: ', $id3->year, '<br />';
    echo 'Genre: ', $id3->genre, '<br />';
    echo 'Length: ', $min, ':', $sec, '<br />';
    echo 'Avg. Bit Rate: ', $id3->bitrate, '<br />';
    $id3->savePicture($i.'_pic.jpg');
}

If you have any comments/issues, let me know!

The Revenge of Bottomembly

A few days ago I was out walking and reminiscing, as I am wont to do. While I was doing this, I recalled some of my first web related programming projects, most notably YPNgine. Considering it was my first major PHP outing, I pulled off quite a feat. Writing a message board is no small task. However, there was one part in particular that I was mulling over: the censor.

If you happen to be a former YPNer, you may recall seeing many references to "bottomembly". Carrying over the censor find/replace list that had been used on phpBB before it, all instances of the character sequence "ass" were summarily replaced with "bottom". Now I am being very choosy when I say "character sequence" and not "word" as the censor couldn't differentiate words.

This oversight was brought to my attention my young programmer self struggled to figure out a solution. Here's what I wound up doing:

// Copyright (c) 2003 Matt Hackmann
// Full copyright info in index.php

function censor_post ($body)
{

    $query = "SELECT * FROM bannedwords";
    $result = db_Query ($query);
    
    $body = " ".$body;
    
    $body = str_ireplace ("assembly", "ytrewq", $body);
    $body = str_ireplace ("assum", "asd;ljf", $body);
    $body = str_ireplace ("glass", "glss", $body);
    $body = str_ireplace ("hello", "hllo", $body);
    
    for ($i = 0; $i < db_num_Rows ($result); $i++) {
        $row = db_fetch_array ($result);
        $body = str_ireplace ($row["blocked_word"], "", $body);
    }
    
    if ($body == " ")
        $body = "Censored";
    
    $body = str_replace ("asd;ljf", "assum", $body);
    $body = str_replace ("ytrewq", "assembly", $body);
    $body = str_replace ("glss", "glass", $body);
    $body = str_ireplace ("hllo", "hello", $body);
    
    return $body;

}

As you can see, I started hard coding in a list of safe words, replacing those instances with a random (or not so random) string of characters, run the censor and then convert those strings back to the safe words. This was a list I kept expanding on as they were found during normal conversation on the forum. I giggle as I look at this list and think of what the censor was doing to those words: bottomume, glbottom and hecko.

It's just something that I, eight years later, have to look back on and chuckle about.

Could this be... progress?

Some moons ago, I had a little comic entitled Digital Double. It was terrible, but I found myself reading through it again one day not too long ago for whatever reason. One comic in particular intrigued me as I was attempting to take a stab at "anime style", an in joke to a couple of sudden character design changes I'd made. Here is the panel in question:

Now, one thing that intrigues me about this picture is that, at the time, I absolutely despised anime and all arts Japanese. That being said, I do not remember using much of anything as far as reference to even attempt to match the style. Just slap on some large, shiny eyes and a pleated skirt. DONE!

I thought it might be fun to revisit this frame and, given that I am actually attempting to draw in this style seriously, envision it as it should have been.

Continue Reading

Kate Reimagining

This is a re-imagining of a panel from a comic I drew back in the summer of '06. Proof that I have made some sort of artistic skills progress.

Little write-up with the original here

Profile Pics - The Story of One Man's Beard

I recently decided that it was time to update my profile picture across the various sites I frequent. This is something I do, on average, every 6-8 months or more (I didn't really bother to calculate the actual average). Looking through my past profile pics on Facebook, I noticed something interesting: they convey a visual history of my beard. My beard is certainly deserving of its own blog post, so I will regale its tale here for the masses!

April 2007 - A couple of straggling hairs, but otherwise nothing. My hand does not deserve to be stroking a smooth chin.

May 2007 - At this point, there's enough hairs that I could probably have cosplayed as Detective Gumshoe quite easily.

October 2007 - Okay, let's face it. 2007 was a crappy year for the beard.

October 2008 - While certainly not filled out, the beard was finally showing some promise of being EPIC. Interesting side note - I had to Photoshop that smirk onto my face

May 2009 - Two years later, the beard is finally respectable enough that it can be stroked in deep thought and look awesome.

October 2010 - After 24 years of beard growing, I think it's finally gotten to the "You don't want to fuck with me" status. The shades help.

Some other interesting things to notice in these pictures:

  • My face is almost always pointed away from the camera
  • I get fatter as time goes on