revjim.net

December, 2002:

California here I come…

Having been born in California, and a resident of that state for 13 years I can tell you this: if California secedes from these United States of America, I’m moving back right before it does.

MT to LJ

I’ve written a PHP script that posts an entry to a LiveJournal account using the TrackBack API for input and XML-RPC to speak to LiveJournal. It was intended for use with MovableType, however, it can be used with any TrackBack enabled software. It currently supports most of the LiveJournal functionality, including posting to communities and turning off comments. In fact, if you’re reading this post on LiveJournal right now, it is because of this script.

Even though the script isn’t that complicated, is there enough interest in it to warrant me packaging it up and writing a small tutorial? As it stands now, all of the functionality of the script is activated by modifying the TrackBack URL that is used within MovableType, which isn’t a big deal for me, but makes it pretty clumsy for most novices.

Is there significant interest in seeing this script hosted remotely with a more attractive wrapper placed around it’s features? I’m thinking that it would work like this: someone would login, enter all the LiveJournal related information, and then it would give them a nice, clean, memorable URL to use for TrackBack.

Comments, questions, and display of interest appreciated.

everyone’s an expert

I love PHP. I really do. I swear. I just really get tired of seeing so many “articles” and “tutorials” and “code examples” that are complete and utter shit written by people who claim to be “experts”. Maybe I’m being a bit harsh. Let me give you an example.

Take an article written by Joe O’Donnell entitled “Using ForceType for Nicer Page URLs“. It’s a great idea. It’s something I wish every PHP application author would do. Nothing, to me, is uglier than a URL with a bunch of question marks, ampersands, and equal signs. This article informs all of its readers of the virtues of ForceType and the benefits of nice clean URLs. That’s great.

However, the second the author gets into the real PHP portion of the article, things turn sour.

This REQUEST_URI variable is the key to implementing the ForceType directive in combination with a PHP script.

Those of you who aren’t PHP programmers probably don’t see anything wrong with such a simple, direct statement. And that’s exactly my point. The novice, and perhaps even slightly advanced, PHP programmer might not realize there is anything wrong with that statement either. But there is.

The author then shows some code to use this “REQUEST_URI” variable in PHP:

$nav = $_SERVER["REQUEST_URI"];
$script = $_SERVER["SCRIPT_NAME"];
$nav = ereg_replace("^$script", "", $nav); 

Here’s the problem: The author of this article is performing two variable assignments and an expensive regular expression operation to end up with a string of text that is provided by PHP already. Instead of using REQUEST_URI one should merely use PATH_INFO. PATH_INFO is already equal to the information this author performed three separate operations to obtain. Of course, it doesn’t surprise me to see this author using double quotes, when the “less expensive by a factor of two” single-quote would do just fine. I could continue picking apart his article, but it wouldn’t do any good.

I don’t mean to come off rude. My code isn’t perfect. Far from it. But when I publish a tutorial, offer code samples, or submit an idea for mass consumption by PHP programmers new and seasoned alike, I at least make sure I’m writing about something I understand. And, even then, I send what I’ve written to a fellow programmer or two (or three) to look over and make sure there aren’t any glaring mistakes.

If any of you are looking for the proper code to use in this author’s example, you merely need to replace this chunk of his code:

$nav = $_SERVER["REQUEST_URI"];
$script = $_SERVER["SCRIPT_NAME"];
$nav = ereg_replace("^$script", "", $nav);

$vars = explode("/", $nav);
$team = "";
$player = ""; 

switch(sizeof($vars))
{
case 2:
$team = $vars[1];
break;
case 3:
$team = $vars[1];
$player = $vars[2];
break;
}

With this:

list($empty,$team,$player) = explode('/',$_SERVER['PATH_INFO']);

Sigh. Maybe I should start a “Stupid PHP code” site offering the best and worst moments of stupid PHP code from around the net.

Maverick -> Ambivalence

For you Java folks, Maverick looks like an interesting project. It’s another web application framework pushing the MVC (Model 2) pattern similar to Struts. [via Matt Croydon]

More interesting than that — to me anyway — was a link I found on the Maverick site to “PHP Maverick” or Ambivalence. I haven’t dug very deep into this yet, however, at first glance, my impressions of it are better than they were with Phrame (which is modeled after Struts) for several reasons.

First of all, it uses an XML based mappings file instead of a native PHP file. Editing such a complex structure using native PHP code just looks ugly. Secondly, instead of using $_REQUEST variables (via GET or POST) to determine which “action” it should take, it uses $_SERVER['PATH_INFO'] — a much cleaner approach in my opinion.

I’ve been working on a mini-tutorial for using Phrame. However, if this framework appears to operate cleaner, I’ll rewrite it to use Ambivalence instead. The best part about that is, either way, I’m using the MVC pattern, so almost all of my code merely plugs into an entirely new framework. Can I get three cheers for MVC?

machine-readable copyright licenses

Creative Commons has launched it’s first product today: Machine-Readable Copyright Licenses. They support many different licenses and have a easy to use interface for deciding which license is right for you. [via BurningBird and Matt Croydon]

broken truck

My truck broke. I’m not quite sure why just yet. I was driving home from Justin’s house, suddenly my “check engine” light came on. Then I noticed my coolant temperature was high. I pulled over. The entire engine compartment is wet and the engine smells of baked anti-freeze, but none of the hoses seem to be busted. All of the connection point, however, are covered in a substance that resembles dried chewing gum. It looks like hardened coolant, but it doesn’t seem possible that all of that happened in one night.

Justin came and got me and brought me home (thank you, Justin). My Dad will help me figure out what’s wrong with it — and hopefully fix it — tomorrow. So, for now, the truck’s sitting where I left it: in the parking lot of the “Delux Inn” just south of Sandy Lake on the South Bound access road of 35E. If anyone reading this is interested in a 1999 4WD Toyota Tacoma, you’d do me a huge service by stealing it. Just don’t tell me it was you.

The best part is this: I got the extended warranty on it, which means I’m covered for 5 years and 75,000 miles. And I’ve only had the truck for 3 years last month. But… I have 80,000 miles on it. So this one’s coming out of my pocket.

Merry Christmas, Jim. You get some car parts and manual labor. Don’t you just love Christmas?

Sigh… my Saturn never had any problems.

morning photo shoot

I’m planning on getting up early tomorrow morning (7ish) and going out to take some photographs. I’ll leave around 8:30am and should be home by noon-ish.

If you’re interested in coming along, leave a comment, send an email, send a text message or call me sometime before then.

plastic jesus and other Christmas gifts

Thanks to Matthew Baldwin of The Morning News, those of us who have diligently waited until the last minute to buy Christmas gifts this holiday season now have a list of last minute gift ideas to choose from.

This year, give the gift of grease with a $5 Denny’s Gift Certificate! It’s the perfect way to say, ‘Even though over 300 days have passed since the last holiday season, I am no longer even pretending that I pay any attention whatsoever to your personality or hobbies or interests, so rather than spend even the slight amount of effort it would take for me to guess what small token of my affection you might appreciate, I’m just going to get you a proscribed portion of food, something that you are biologically required to want.’ Happy Holidays!

I can’t think of a better gift for Justin than the book entitled, “How to Good-Bye Depression: If you Constrict Anus 100 Times Everyday. Malarkey? or Effective Way?“. My Jessica would just love this Freud action figure. And personally, I’d really like Jesus Bobblehead on my dashboard.

For some reason I have a song stuck in my head now.

I don’t care if it rains or freezes
‘Long as I got my Plastic Jesus
Riding on the dashboard of my car.

Through my trials and tribulations
And my travels through the nations
With my Plastic Jesus I’ll go far.

When I’m in a traffic jam
He don’t care if I say “damn”
I can let all my curses roll

Plastic Jesus doesn’t hear
‘Cause he has a plastic ear
The man who invented plastic saved my soul.

‘possibly dismembered’ body found

According to police a ‘possibly dismembered’ body has been found in a field at O’Connor and Buffalo, about a mile from my apartment.

I’ve always said that that area would be good for dumping a body. I never thought it would actually happen. The area is speckled with the headquarters of big businesses. However, due to a lack of devlopment in the area, much of it is paned with 4 and 6 lane roads, and yet nothing but fields on either side.

I’ve been driving around in these fields as a shortcut between my apartment and the grocery store for some time now. One day, while on my way to lunch, I noticed a van parked in one of the fields along the tree line. Now I can’t be 100%, as the trees are pretty far from the road, but my best guess was that it was a nude woman and a photographer.

can I get some privacy please?

This website is causing me a bit of a dilemma. Because I work in a technology field, I do my best to stay on top of the latest technological advancements, new software, and profound programming concepts. Additionally, I share those things that I find interesting with anyone who would care to know about such things by posting them here. In the past, and occasionally now, I play an active role in the development and support communities for various web technologies and open standards. However, the time and effort that I put into this site goes unseen with my current and, hopefully, any future employer. Why is that? Because not all of the content here is suited for my employer or someone who might consider offering me employment in the future.

I’ve done my best to keep my real name off of this site. You don’t see a copy of my resume here. You don’t see a list of my accomplishments. You don’t see any connection to the real, in the flesh, me. Well… you might, if you dig deep enough, but, I do my best to make sure that it isn’t incredibly easy.

Sure, if my employer knew that this site existed, and thought that I might be the author of it, he could simply do a whois on the domain name to find that the address is the same that is stored in our human resources database. And maybe someday I’ll get rid of that piece of information as well. I’m not worried so much about my current or any future employer deliberately checking to see if this particular site is owned by me. Instead, I do my best to make sure it won’t come to the point where he/she would even consider that this site might be maintained by yours truly.

This secrecy, however, is part of the problem. Mark Pilgrim has written, among many other things, Dive Into Python a free online book (which I have yet to read) teaching the ins and outs of the Python programming language. Let’s say, for a minute, that I had written “Dive into PHP” (which I haven’t, so don’t get your hopes up). It would be great to be able to state on my resume that I had done so. I would be wonderful to share with you, my faithful readers, that I have done so. However, regardless of how well I keep the name “revjim” off of the fictitious “Dive into PHP” site, connecting revjim.net in anyway to that site would be getting dangerously close to that line that I don’t want to cross. It would just make it too easy to connect the REAL me to this site.

So. I’ve decided I have to stop hiding. I’m just not quite sure how to do it.

I have another website where I write truly personal, non-technical “journal” entries about my life. I don’t update it that often mostly because I don’t have any readers. Well, okay… I have three. Three whole readers. The reason I have no readers, is because I’ve never advertised it’s existence. Sure, I ping weblogs.com and blo.gs just like any other weblog would. But that’s it.

So what do I do? I have readers that come for the technical content. I have readers that come for the photography. I have readers that come for the personal content. Where do I draw the line between what should be here and what should be somewhere else? Additionally, how do I let my current readers know that there are currently two versions of this site, without linking the professional site to the personal one? Also, which site should keep the name “revjim”? If I let the professional site keep the name (and the domain) I have to run through all my archives and delete content and then still worry about cached copies in various search engines. And if I let the “personal” site keep this name then I have to establish a new identity and anything that I’ve done here cannot be referenced or “claimed” at the new site.

Or maybe I’m just worrying too much. Maybe I’ve done a decent job at keeping the content here away from being “too” personal. Or maybe having a nice mixture of personal and technical is the reason I have any readers in the first place.

What do you think?