The httpd.conf exploder!

Posted on November 30, 2006

I thought that it’d be easy to break up a httpd.conf file up into multiple files per VirtualHost using a single line of perl. Turns out, I was most mistaken. Here is the one loooong line of perl to perform the explosion.

perl -ne ' if (/<Virtualhost (\*:80|[0-9.:]+)>/ .. /< \/VirtualHost>/) { $data.=$_ }; if (/ServerName/) { chomp; $sn=$_; $sn=~s/\s*ServerName\s*([^\s]+)\s*/$1/; } if (/<\/VirtualHost>/) { open(outfile, “>>$sn.conf”); print outfile $data; close outfile; $data=”" } ‘ < httpd.conf

The Waking Dream

Posted on November 29, 2006

I’ve grown to dislike how we communicate with each other. Every conversation involves one person rationalizing his or her own importance over another. Adults that have graduated from college really identify with the experience. They’ll say, “So-and-so is smart, but he doesn’t have a degree!” In their world, degrees preclude true enlightenment. Developers that use one platform will deify their own system over all the others. You’ll read things like, “Java is for stupid programmers and using it will evaporate your soul!”

Recently, Joel Spolsky blogged about a developer who started his own business and failed miserably. After that, he proceeded to blast Agile Development. Why did Joel do that? Because he’s frightened of people starting competitive businesses with tools that he doesn’t use. Joel raises perfectly valid points about Rails and Agile development. Unfortunately, his criticisms were the same exact ones that Wordperfect had against using C++ in the early 1990s. They believed that the new level of abstraction was unnecessary and that everyone should continue to develop applications in assembly. Wordperfect was 100% correct because compiled applications are slower than ones written in custom assembly. As a result, it is now the fastest word processor that nobody uses.

This communication is very common on the Internet. People tend polarize theirself to one belief by endlessly reading articles that reaffirm it. Some dude sipping on a latte at Starbucks is currently writing a blog post about how his Mac is better than a PC. He vehemently believes this idea and will defend it to the core of his existence because he identifies with owning Apple products. This is what happens when people believe propaganda. This man does not understand that the commercials he watched were rhetoric delivered to increase Apple’s influence. He bought the hype because his fragile grip on reality doesn’t disregard all commercial messages as irrelevant.

Wars on the Internet are similar to the real ones. One group of people think that the way they are is way more kickass than the any other way. What? You don’t like how I am? Well, I’ll prove that I’m better than you by using violence! The entire world will then see how powerful I am by way of my own actions. Everyone is doing it. It is easy and fun!

The waking dream is to realize that everyone is telling a story. Actively avoid defining our own existence in terms of others’ thoughts. Invent your own consumer products and propaganda. Better yet, create your own philosophy and vehemently proselytize it. Philosophies are more exciting than consumer products anyway. After you’ve successfully converted everyone over to your superior philosophy, construct another. That old one was holding you back anyway.

Blanket generalizations are the last refuge of the irrelevant. Michaelangelo never scuttled around exclaiming, “If you buy a Craftsman hammer, you can chisel out a David statue ten times faster than those unenlightened Luddites using Stanley hammers!” His life was a single-minded, frenetic burst of action devoted to his own art. This is the right way to be. Then again, maybe I’m rationalizing that the way Michaelangelo lived was superior than how we are living today.

Xaggly vs Hpricot vs REXML

Posted on November 28, 2006

Feeling the heat from the usual crowd, I cobbled together a XML-parser Ruby extension in C with a flagon of magic Flex and Bison elixir. This weekend, in a frenetic burst of Tryptophan-obliterating productivity, I had coded to the point where most reasonable XPath queries were working. So, I promoted my prematurely optimized, non-conformant bits to a named program called Xaggly. Tonight, I tested my parser using a ginormous XML file pilfered from the old-timey GPS watch’s serial interface. I am pleased with the pixels fired into the aether and will henceforth scuttle about with a jaunty step. Mr bray and _why: step away from the gogglebox and take heed.

A Special Birthday Poem From John Northeast

Posted on November 22, 2006

Today, Mr. John Northeast sent me the best birthday poem that I have ever received. It is even better than bumper’s effort from last year, “Twenty-nine Prime Fishotots”. While bumper’s effort was appreciated, John’s opus easily usurps it due to his poem’s unique pentameter and rhyme. Hats off to you, Mr. Northeast as you are Samuel T. Coleridge’s worthy heir. I have Paypal’d five pounds Sterling to the barman at The Boot and instructed him to dole out a frosty mug of Tom Wood’s Jolly Ploughman on my behalf.

Today is Tony’s Birthday
Hip Hip Hip Hooray
He’s reached a special milestone
To celebrate today
You see, he’s just reached 30
And recently got wed
Let’s hope the celebrations
Don’t go to his head
Have a great day, Tony
Enjoy it while you can
‘Cause the next big celebration
Is when you’re 40 man

Happy Birthday
John

Generating MP3 Durations with PHP and DBDO

Posted on November 16, 2006

I had to update a MySQL database full of mp3 names with the inherent track, album, and genre metadata. So, I grabbed the Zend mp3 library and sorted it out like the clappers using the DataObjects ORM.

    $m = new DataObjects_Tracks;
    $m->addWhere("filename RLIKE '[.period.]mp3′");
    $m->find();
    while($m->fetch()) {
        $mp3 = new MP3($m->filename);
        $mp3->get_id3();
        $mp3->get_info();
        $m->duration = $mp3->info["length"];
        $m->album = $mp3->info["album"];
        $m->title = $mp3->info["title"];
        $m->update();
    }

If ORMs were automobiles, DB_DataObject would be somewhere between a 1976 Pinto and an Edsel, but it gets the job done OK. The most annoying thing about it is that you have to run php DB/DataObject/createTables.php every time you alter the database. Unfortunately, the more I use DBDO the more I miss the ActiveRecord sauce. Once you’ve driven a Porsche, you don’t want to go back to the old Rustang.

Exploiting the Triangle

Posted on November 02, 2006

Well, last night was pretty much the best nuclear taco night ever. I won’t attribute any of these, but here are some of the highlights.

“If it wasn’t for the plow, Britney Spears wouldn’t even exist!”
“The town crier was mass media in the 1700s!”
“Britney Spears and Shakespeare are the same thing.”
“There are no self-made men.”
“British MPs gave me a T-Shirt that said ‘Fort Niagra 1814′ when I was in Belize, and I didn’t know why it was so funny.”
“One time I’d like to come here and have Cow do most of the talking”
“My daddy dropped me on my head as an infant. That’s why I couldn’t take the FE.”
“I DIDN’T EVEN STUDY FOR THE FE AND I GOT A 95%!”
“It’s not exploitation, it’s a symbiotic relationship!”
“You need to learn to exploit the triangle. It has always existed.”
“You have to have deceit in your heart before you can sense it in others.”
“GET OUT OF MY HOUSE!”