August 2009 Archives

mark-kolich-mobi-url-pattern.pngAbout a month ago, I posted a quick update that dealt with an improved REST style URL pattern interpreter for my mobile blog, mark.kolich.mobi.  At the time, the enhancement was to convert the style of my mobile blog URL's from this:

http://mark.kolich.mobi/m.php?a=1

to this:

http://mark.kolich.mobi/m.php/1

This improvement was fairly easy to implement as I described here.  However, I realized today that I wasn't totally satisfied with this enhancement, given that the ".php" in the URL was still visible.  After a little investigation, I discovered that I could use Apache's mod_rewrite to make my mobile URL's look a little cleaner, like so:

http://mark.kolich.mobi/m/1

This URL style is much simpler and cleaner: I dropped the annoying query string, and I also got rid of the .php extension.  Implementing this was actually quite easy using mod_rewrite.  I simply used mod_rewrite to internally re-write any requests starting with "m" to the PHP script that serves up individual articles/posts on my mobile blog.  In my Apache httpd.conf file, I added the following:

RewriteEngine On

RewriteRule ^/m /m.php [L]
RewriteRule ^/twitter /tw.php [L]

Any request starting with "m" will be sent to m.php.  Any request starting with "twitter" will be sent to "tw.php".  Check out my mobile blog to see this re-writing method in action.  The PHP code that parses the REQUEST_URI to determine what article to serve up can be found here.

Simple enough.  Enjoy.
I recently wrestled with Log4j's RollingFileAppender, which lets you automatically rotate your application's log files once they reach a certain size.  Automatically rotating log files are important for distributed applications so your logs don't fill up a user's PC, or waste server disk space unnecessarily.  After putting all of the Log4j pieces together, I finally got things working as desired and thought it might be nice to share my success with the world.

Here's the complete source to the example.
san_gorgonio_mountain.jpgLast weekend a buddy of mine and I hiked Mount San Gorgonio.  Sitting at roughly 11,503 feet, Gorgonio is Southern California's tallest mountain nestled in the heart of the San Bernardino National Forest.  It was a fantastic experience, and probably the 2nd hardest physical challenge of my life (second only to my single-day domination of Mount Whitney in September of 2006).  The most popular trail to the top of Old Greyback is the Vivian Creek Trail, which was supposedly closed last weekend due to excessive bear activity.  As a result, we took the Fish Creek Trail to the summit.  To the top and back, Fish Creek is roughly 20-miles round trip starting at an elevation of approximately 8,180 feet.  Fish Creek is a little longer than Vivian Creek, but less steep which probably saved our legs a little in the long run.

Here are some of my notes and pictures from the trail ...
I received a few great blog comments in response to my post on Updating my Mobile Blog Portal to Support Multiple URL Patterns (m.php?a=1 vs m.php/1).  The general question in each of these comments was, "so what is your preferred, or favorite, way of validating form inputs in PHP?"  Good question.

When I don't have access to PHP 5.2 or later, I'm unable to take advantage of PHP's filter_input_array() validation mechanism.  That's OK though, because there's nothing like validating form inputs the hard-way.  When validating form inputs manually, without the use the of any specialized helper functions, I think it's hard to do much better than a nice combination of isset, preg_replace, preg_match, and empty.

My First Tic-Tac-Toe Game

| No TrackBacks
tic-tac-toe2.pngEvery once in a while I'll dig into my code archive and stumble across a total gem.  This morning I rediscovered a very primitive tic-tac-toe game I wrote in 2001.  In fact, I explicitly remember writing this game one Saturday afternoon and thinking to myself how amazing and awesome it was.  I've since moved on to bigger and better things, but I always enjoy a trip down memory lane.  I wrote this game in Borland C++ on an old 200MHz Pentium II HP Vectra with about 128 MB of RAM.  I still have the binary executable and tried to fire it up on Windows Vista.  Surprisingly, it still works!

If you dare play the best damn tic-tac-toe game you've ever seen, you can download it here.  Or, for the true software engineers out there, try downloading the source.

As a good buddy of mine always says, "rock on."
I just realized this evening that the "Send Mark a Direct Message" form on each page of my blog has been broken for quite some time.  An oversight on my part caused my code to reject messages from several readers.  Anyways, it's been fixed and I'd like to extend my sincere apologies to the many blog readers who tried to contact me without success.

What the heck happened anyways?

Well, several weeks ago I decided to increase the max size of acceptable messages from 200 characters to 400.  I tweaked my JavaScript to accept longer messages, but I somehow forgot to update the PHP that processes all incoming blog comments.  As a result, my PHP code was only processing messages less than 200 characters, and blindly rejecting everything else (even though my blog itself says the max message length is 400 characters).  I'm sure this was confusing and irritating to many folks.

define("MAX_MESSAGE_LENGTH", 400);

It's amazing how forgetting to change one character in a piece of code can really throw a huge monkey wrench into an otherwise smoothly working piece of software.
new-network-solutions-firefox-whois.pngMy domain registrar, Network Solutions just launched a new networksolutions.com.  The site is fantastic; they did a great job on the re-design!  I especially enjoy the look-and-feel of the new Account Manager.  Anyways, I took this opportunity to update my Network Solutions WHOIS Firefox and IE Search Plugin/Provider.  I've updated the Firefox and IE search plugin to include their new default favicon.

If you're on Firefox or IE, you can install the new search plugin by clicking here.  If you want to read more about how to make your own Firefox or Internet Explorer browser search plugin, check out this post.

Enjoy.
Luckily, the answer to this one is an emphatic NO.  I was recently working on some code that dealt with MySQL table locking.  My app WRITE LOCK'ed a table while processing an UPDATE, INSERT, or DELETE because of an interesting multi-user concurrency problem.  BTW, if you are unfamiliar with a WRITE LOCK, this means all other MySQL connections will block until your transaction has finished.  In other words, all other transactions will not be able to access the locked table until your transaction sends an UNLOCK TABLES.  Or, as I described in this post, until your PHP script dies unexpectedly and the transaction is implicitly closed.

Twitter (@markkolich)

Translate

About this Archive

This page is an archive of entries from August 2009 listed from newest to oldest.

July 2009 is the previous archive.

September 2009 is the next archive.

Find recent content on the main index or look in the archives to find all content.