Subversion vs. CVS Review

Like many, many of coders before me I have used CVS to maintain my code. I’m not as disciplined as others, but I am comfortable using CVS and I think it’s fairly essential for a company to version their code (CVS and Subversion aren’t the only kids on the block in that aspect).

As part of setting up a development environment at Enotes.com after our migration I needed to finally bring the code into a versioning system of some sort. It was at this point that I thought I should look into Subversion. I was more than capable of setting up CVS, but CVS had some serious flaws that really annoyed me. Here are the reasons I went with Subversion instead.

  1. Subversion allows you to delete files and folders from the repository with svn delete. CVS lets you delete files, but isn’t very kind in handling the removal of folders. SVN, on the other hand, recursively deletes folders and you don’t have to physically remove the file before removing it from the repository like you do in CVS (rm -f file.php && cvs remove file.php)
  2. Subversion utilizes Apache 2.0 as a way to access repositories. I liked the idea of being able to use an application I was used to configuring as the access point for my repositories. How do you authenticate? HTTP AUTH. How do you connect via SSL? Buy an SSL certificate. Pretty simple and you can browse the repository from a web browser with mod_dav_svn by default.
  3. Hooks in CVS where always confusing to me. I’m not sure why, but I never got around to setting them up. In Subversion there is a directory named hooks in each repository that lets you create shell scripts that are fired at different points in the checkout/commit process.

The final note is that Subversion emulates a lot of CVS commands. For most of what you have to do replacing cvs with svn will work just fine. Overall, I like Subversion. I don’t think it’s exceptionally better than CVS, just easier to work with.

Keeping it real

I was reading a story about the final staff announcer at NBC when I read this amazingly funny quote. The guy has been working for NBC for 62 years!

When he started, WRGB-TV didn’t have a regular schedule.

“The TV station went on the air whenever we pleased,” he said. “Somebody would get on the phone and call the 200 or 300 people who had sets and tell them to turn on their TVs.”

They CALLED you when they were going on the air. How classic is that? I’ll someday have a conversation with some young person telling them how I had to turn the antenna to the appropriate N/S/E/W coordinates depending on which channel I wanted to watch and which direction that station was relative to my position.

Congress is Busy!

Man, am I so happy that my senators and congressman are working hard at eradicating the evil perils of our society! They’ve been working nights! Weekends! Why? Well, evidently it’s been legal for years for spouses and guardians to remove loved ones from life support and now people are ACTUALLY DOING IT! Holy Crap!!111111

This happens every day to poeple all over the world. So why is this case different? Well, my mother always told me the squeaky wheel gets the oil and that is what this appears to be a case of. The parents want their daughter to “live” (if you call a persistent vegitative state living), while her husband and legal guardian says she wouldn’t want to live that way. Guess who gets to choose? The husband. Pesky laws are getting in the way again!

In other news, Congress has been very busy working to eradicate steroid use from MLB. If this isn’t the biggest waste of my tax dollars I don’t know what is. I’m actually amazed they found the time to tear themselves away from the procedings to try and save Terry Schiavo.

Both of these news stories are PERFECT examples of political grand standing. If you have been buying into any of this shame on you. I, on the other hand, am going to call my representatives and tell them to start using their time more wisely or they’re losing my vote.

Optimizing Apache

Before I get into the specifics of why I’m a complete dumbass, I want to say that I’m not always this dumb. Sometimes you research a problem, settle on a few things to test and implement them only to find out the real problem is how stupid you are. The following entry describes how I “optimized” our web server at work.

Like all problems it started with a trip to Google and lots of reading. The following are great introductions to tuning Apache.

  1. Performance-tuning Apache is a brief HOWTO on simple steps you can take to get load under control.
  2. A short Google Answer thread on KeepAlive and KeepAliveTimeout that gives some insight into those directives.

After making appropriate changes to my httpd.conf and reloading Apache I saw a slight dip in load from about 10 to 7. Still, I thought, it was way too high for the hardware we were running on. A few more tweaks and I got the load down to 6. After some more discussion with a friend I decided to sanity check myself and see if both processors were being used by Linux.

A quick check of /proc/cpuinfo resulted in a big slap on the forehead – I had not installed the SMP enabled kernel. I had an entire CPU sitting idle. I quickly installed my SMP kernel and rebooted to find the load dropped to a mere 1.5.

For the non-geeks out there I’ll translate: Joe is a moron.

Running Apache/MySQL/PHP on Debian AMD64

I’ve been pulling my hair out for the last few weeks working on migrating enotes.com over to a new server setup. The new setup runs on dual Opteron AMD64’s. AMD64’s are relatively new 64-bit processors that offer lots of processing power for very little money.

There are a few things you should pay attention to when running Apache, MySQL and PHP under these 64-bit processors.

  1. Bugs in MySQL (8555 and 3483) cause INSERT statements to hange indefinitely. A temporary work around is to add skip-concurrent-insert to your my.cnf.
  2. A bug in Apache’s regex.c engine causes problems with mod_rewrite on AMD64 (31858). You can either upgrade to Apache 2.0 or use the patch supplied in the bug to fix Apache 1.3.33. I continued to have problems running our code in 64-bit mode so I chose to run Apache in an i386 chroot using debootstrap (thanks to Jeremy)
  3. A bug in PHP’s strtotime() function (30215) causes the function to return huge numbers instead of -1 on error. This boned Smarty’s date_format on my sites.

Those were the serious problems I had getting things up and running. Other than that things appear to be running smoothly. The following is the work around I submitted to the Smarty mailing list concerning PHP’s strtotime() bug.

Why not put a check into the smarty_make_timestamp() function? It’s predictable in that it returns huge timestamps (3441718022400 is an example). The check could (and should) be removed once PHP fixes what appears to be a fairly simple bug.

So, until then, what do you do? Well, I’ve put together a simple fix. In plugins/shared.make_timestamp.php around line 51 there is something like this:


    $time = strtotime($string);
    if (is_numeric($time) && $time != -1) {
        return $time;
    }

Change that to:


    static $endOfTime;
    if (!isset($endOfTime)) {
        // End of 32-bit UNIX time - 1
        // 19 Jan 2038 at 03:14 and 7
        $endOfTime = mktime(3,14,6,1,19,2038);
    }

    $time = strtotime($string);
    if (is_numeric($time) && $time != -1 && $time < $endOfTime) {
        return $time;
    }

This fixed my problem since the function fails in a predictable format on my Opteron box. Of course, it will break if this code is still running after Jan of 2038.

Works on Apache 2.0.53/PHP 4.3.10 under Debian GNU/Linux (2.6.8-10).

Beer fights cancer! I knew it!

In what will most definitely go down as a ground breaking study, researchers have found beer fights carcinogens found in charred meat.

After a few days of administering the beer diets, the scientists laced some of the animals’ food with either of two heterocyclic amines (HCAs)—the carcinogens from cooked meat….Beer diminished by some 40 to 75 percent the number of HCA adducts (abnormal DNA structure) that formed, depending on the type of tissue (studied after dissecting the mouse) and quantity of beer ingredients ingested, the researchers report in the Feb. 9 Journal of Agricultural and Food Chemistry. Good news for beer drinkers: Both light-colored lager and a darker stout proved protective.

I always knew there was a reason my brain was telling me to buy a nice cold beer with that hamburger I just ordered. Of course, too much beer causes liver cancer and brain damage. Just more proof that just about anything is OK as long as you don’t take too much of it.

American Idol Finalists

I’m going to pick out my finalists for American Idol. You guys aren’t going to like it, but I think Mikalah Gordon is going to make it into the finals. Her nasty ass implants (pick a part and she’s most likely had it stitched) and equally craptastic voice will keep her out of the top 6 for sure. So who else makes it?

Anwar Robinson and Bo Brice are my top picks from the guys. Anwar is, to put it simply, amazing. Hopefully, he isn’t another La Toya London (who, in my not-so-humble opinion, should have won Season 3. What the hell were you thinking, America?!?!). As for the girls, well, they suck. Nadia Turner and, possibly, Carrie Underwood are the only girls who can compete with the guys. For fun you can throw in Jessica Sierra.

So who gets voted off this week? Well, I’m not sure, but I TiVo’d it so we will see tomorrow. However, is it too much to ask Janay Castine be voted off (and possibly put out of her misery)?

Checking large sites for PHP parse errors

I now work for a large site. It’s not a place I haven’t been before, but I’m definitely getting back into the swing of running a large (we’ll do over 10 million requests during our busy months). We’re in the middle of migrating our websites in house onto larger servers that we’ll manage ourselves. It’s a daunting task because our company runs lots of smaller sites we’ve either picked up or somewhat abandoned along the way. These sites were written in older versions of PHP (probably PHP3) by the owner of the company as he was learning PHP. As a result I’m having to go back and fix include paths, etc. as we migrate to the new server, but how exactly do you automate the task of checking a site with hundreds to tens of thousands of pages for parse errors?

A friend of mine, Ian, who I do a lot of “bouncing off of” had a great idea. Basically, you turn on log_errors in your php.ini file, tail -f /path/to/error.log | grep PHP and then run a garden variety link checker against your site. As the link checker crawls your site it should trigger parse errors that will show up in your error file.

There you have it. A simple and easy way to check a large site for parse errors. Turn your error_reporting to simply be E_ALL to find notices and other problems in your code.

Lauren gets a new job

<?php

  include('Wife.php');
  include('Husband.php');

  $currentJob = Wife::getCurrentJob();
  $newJob = Wife::getNewJob();
  if ($newJob->getWage() > $currentJob->getWage()) {
      /**
      * Lauren got a new job so Joe gets lots of fun new gadgets
      */
      Husband::getNewGadgets();
  }

?>

Maxent 42 inch plasma EDTV Review

This weekend we stopped by Target to get a few things. This Target has a Best Buy right below it and I figured with time to waste I could spend a few minutes drooling over the many flat panel TV’s they have sitting around. We were not disappointed. While looking around we saw a Maxent 42 inch plasma EDTV for $1,700. I thought for sure it was some sort of typo. Either that or this crazy EDTV was some sort of marketing trick to make people buy the thing. Come to find out EDTV is a stepping stone to HDTV. It supports a higher resolution than standard TV signals and also supports progressive scan DVD’s.

We ended up getting a great deal on the TV and I’m now watching Matrix Revolutions in all of its glory. I’ve finally figured out all of this HDTV crap and I can now recommend to all four of my readers what my take on all of this stuff is.

  1. If you are going to buy a flat panel display make sure you buy a plasma and not an LCD display. The plasma displays are, oddly enough, cheaper and have better picture quality than LCD displays.
  2. Unless you live in a magical universe where everything is already being broadcast in HDTV there isn’t any reason to buy HDTV. For the most part your shiney HDTV will be running in EDTV mode anyways so you might as well save a buttload of cash and buy an EDTV display.
  3. Make sure you get the service plan. I know, I know, they always sound like a line of crap, but LCD/plasma displays suffer from something called “dead pixels” and the service plan states if you get three dead pixels you get a new TV. This is definitely worth the money.

What I found most amazing was that the clerk at Best Buy was willing to haggle over the pricing. If we had bought the display, paid taxes and bought the service plan all at retail we would have spent about $2,250 on our TV. In reality, we only paid $1,900. To say your DVD’s have never looked this good would be a huge understatement. I’m super impressed thus far. Now I just need to get a HDTV compliant TiVo box.