Quote of the day

I was reading TrueHoop today regarding the Don Imus situation and read something that, with a little modification, makes a great quote.

Did you ever think we’d have a world without people acting like idiots? Ask any grade school teacher. There are always one or two.

The great thing about free speech is that it encourages those people to identify themselves …

My revised version of the above is as follows.

The great thing about free speech is that it encourages idiots to identify themselves.

Don't say I didn't say I told you so

I’ve had, shall we say, heated debates with a few of my friends about the stability of Ruby on Rails. After hearing about the way Ruby on Rails handles database interactions I was fairly convinced that it would make serious scaling a huge pain in the butt. Today, by way of an interview of a Twitter developer, comes the answer I’ve been expecting:

Running on Rails has forced us to deal with scaling issues – issues that any growing site eventually contends with – far sooner than I think we would on another framework.

All the convenience methods and syntactical sugar that makes Rails such a pleasure for coders ends up being absolutely punishing, performance-wise. Once you hit a certain threshold of traffic, either you need to strip out all the costly neat stuff that Rails does for you (RJS, ActiveRecord, ActiveSupport, etc.) or move the slow parts of your application out of Rails, or both.

It’s also worth mentioning that there shouldn’t be doubt in anybody’s mind at this point that Ruby itself is slow.

I knew ActiveRecord was a pile of crap from the minute I read in their documentation that it was “only” 50% slower than going straight to bare metal. Combine that with the fact that you can’t connect to more than one database server, force indexes or do other various MySQL-specific DB foo and you’ve got a recipe for disaster once you hit a certain amount of traffic.

Writing phpt files for PEAR and profit

I’ve been programming PHP now for, oh, almost a decade and I’ve been a contributor to PEAR for about four years now. It took me this long to finally get to the point that I think writing unit tests, in some form, is a good idea. I jumped on the OOP bandwagon about 6 years ago and drank the MVC koolaid about 4 years ago. As of a few weeks ago, I’ve jumped on the phpt bandwagon. I’m not going to cover the basics, because they’re well covered in a few different places around the web, but I am going to cover some of the nuances I’ve learned in the last few weeks.First off, you can run phpt files using the PEAR command line utility. I’ve been creating a tests directory and putting all of my phpt files in there. I normally name them 000-class-method.phpt and then increment the sequence number at the front for each test by 5 so I can do a decent job of predicting how tests run. Once you have a few tests you can run your tests in two different manners from the command line:

  1. pear run-tests
  2. pear run-tests 000-class-method.phpt

When you run your tests you’ll get results of which tests passed, which failed, if any of them were skipped and the reason why they were skipped, and files for debugging. If 000-class-method.phpt fails, there are a few files that will be of interest to you:

  • 000-class-method.php is the actual PHP file ran, which is found in the --FILE-- portion of your phpt file.
  • 000-class-method.outis what was actually output by the PHP file ran from the --FILE-- portion of your phpt file.
  • 000-class-method.exp is what the test expected the output of 000-class-method.php to be, which is found in the --EXPECT-- portion of your phpt file.

You pretty much have everything you need to debug why a test failed. I normally diff the exp and out files and then debug the test (or my code, which is usually the case) using the php file.

Another great thing about phpt files is that you can use a cgi PHP binary to debug actual GET requests (phpt supports spoofing $_GET, $_POST and $_COOKIE using the cgi binary). This lets you create tests like the following:

--TEST--
Test a GET request
--GET--
foo=bar&baz=foo
--FILE--
<?php
echo $_GET['bar'] . "\n";
echo $_GET['baz'] . "\n";

?>
--EXPECT--
bar
foo

This test should pass without incident. The only catch is that you need to specify your cgi binary path using the --cgi argument when you run the tests (e.g. pear run-tests --cgi=/path/to/php-cgi).

Overall, I’m pretty happy with my newfound testing experiences. My only complaint is that phpt files don’t support spoofing of $_SESSION natively. A small complaint to be sure.

My first Digg code goes live

So if you’re interested in seeing what I’ve been doing for Digg lately, you can now go to the site, log in and send invites to your friends. You’ve actually always been able to do this, but now you’re able to keep track of how many friends you’ve invited, those friend invites will be announced to the world on the homepage and you’ll automagically be added to the invitee’s friends list.

Once you’ve invited a friend, the friend needs to register and digg at least three stories before they count as a referral. At that point a little note is posted to the frontpage announcing your invite and your friend referral count in your user profile goes up. I, of course, invite all of you to join.

I’ve also been working on other magical doings, but I can’t talk about those quite yet. I hope to talk more about that work after it goes live as well.

Bill of Non-Rights

A family member of mine sent me one of those ultra-patriotic/conservative mail forwards that was, essentially, a “Bill of Non-Rights” that included a bunch of “get off your lazy ass and get a job” language and two things, in particular, I find laughable.

This is an English speaking country. We don’t care where you are from, English is our language. Learn it or go back to wherever you came from!

I submit that this country, from the very beginning, was multi-lingual and multi-national. I know for a fact that my ancestors didn’t speak English when they arrived, rather they spoke German and French. America is not, nor has it ever been an English-only speaking country. In fact, about 28 million Americans over the age of 5 speak Spanish at home. There’s nothing wrong with being bilingual. In fact, that’s pretty cool if you ask me.

You do not have the right to change our country’s history or heritage. This country was founded on the belief in one true God. And yet, you are given the freedom to believe in any religion, any faith, or no faith at all; with no fear of persecution. The phrase IN GOD WE TRUST is part of our heritage and history, and if you are uncomfortable with it, TOUGH!

Where to start? How about with the fact that “In God We Trust” wasn’t added to coins in America until the Civil War. Also, there’s that pesky fact that “One nation … under God” wasn’t added to the Pledge of Allegiance until 1954.

Now, please, let’s stop with the preposterous assertions that we’ve always been an English-only Christian nation. The truth is we’ve always been a multilingual multicolored nation and it’s only getting moreso. California, for instance, became the first state in the union in 2000 to be a minority-majority population (meaning there’s more of “them” than “us” if that’s how you think).

Maybe a better solution is to follow the Bill of Rights as they are, which guarantee the right to speak any language you want and practice any religion you want. And, guess what, it’s actually been like that from the beginning.

Term 'Civil War' is inadequate term for Iraq

A new Pentagon report said some elements of the war in Iraq fit the definition of civil war, but the term “does not adequately capture the complexity of the conflict.

What I read from this is that the situation in Iraq is much worse than a simple civil war. In fact, with the meddling ways of Iran and Syria it probably is much worse than a simple civil war. Throw in a little religion and a thousand years of bikering and you’ve got yourself something that the term ‘civil war’ “does not adequately capture the complexity of …”.

The problem, of course, it’s that it’s our complex conflict. We’re the ones that messed everything up and we’ve got to at least try to fix the mess, which is why I don’t support an immediate troop pullout. What I do support:

  1. Actively engage Syria and Iraq on all fronts.
  2. Add strict deadlines to a phased reduction of forces so the Iraqis are forced to step up and start policing their own state.
  3. If all else fails, bribe Turkey into letting us create three states out of Iraq. If you didn’t already know, Turkey is vehemently against an independent Kurdistan.

God, please kill my daughters

The state of Texas is up in arms about the fact that the governor had the nerve to require that the HPV vaccine be given to all 6th grade girls. The nerve! A vaccine that prevents cancer?! Given to my daughters?! Blasphemy!

Their reasoning? It promotes promiscuity. Please. How about you do what every other self-respecting parent does when faced with an uncomfortable situation with their children: lie. Tell them it’s a vaccine that prevents cancer and leave it at that. How about having a responsible conversation about safe sex instead of pretending that your daughter is different and won’t have premarital sex.

I’ll let you in on a little secret; 9 out of 10 Americans practice premarital sex. That study includes women from the 1940’s as well so you older folks can’t get all holy on us younger people.

My vote is every girl is vaccinated and we cross our fingers that cervical cancer and HPV is abolished in the same manner that polio was for our parents.

FBI snooping did not follow "rules"

To absolutely nobody’s surprise the Justice Department’s inspector found the FBI to be guilty of “serious misuse” of the power’s granted to it via the PATRIOT Act to secretly request a person’s financial, banking and phone records. What I find laughable is that the audit says that there were no indications that any of the activity “constituted criminal misconduct.”

I find this laughable because these rules are actually laws governing how the FBI can use these powers. They’re not guidelines; they’re law. Normally, when a person or entity doesn’t work within the letter of the law they’re guilty of criminal misconduct in some form or another. How this isn’t the case here I’ll never know.

On a slightly higher note it is refreshing to see a head of a public agency take fully responsibility for the misconduct of their agency. Mueller, the head honcho of the FBI, plainly stated, “”I am to be held accountable.”

I’m looking at you Bush. I’m also eyeing you Cheney.

My First Week at Digg

The new sign at the Digg office

So I made it down to San Francisco in one piece. After spending a week in a hotel I’m now up in Concord, CA staying with Jeremy.

Tomorrow I start my second week at Digg. I can’t really talk about what’s going on or what I’m doing, but I’m surrounded by lots of geeky people and back in the thick of Silicon Valley, which is always interesting. As expected, things are exciting and there’s ton of potential everywhere.

One thing that will take some getting used to at Digg is that there are people who handle servers and such, which is new to me. At all my other jobs I was the PHP Developer/MySQL Administrator/Systems Administrator. At Digg I just say “Hey, Time, I need a DB.” or “Hey, Ron, can you upgrade GD?”

I don’t think I’ll be blogging about work very much as we have people who do that as well, but suffice it to say I’m excited about the job, city and possibilities.

Farewell Seattle

I’m a huge fan of Seattle and, with great dismay, I announce I’m leaving this fair city for San Francisco tomorrow morning. The LandRover is packed and the trip has been planned.

The route will take us through Oregon to Eureka, CA on our leg. We’ll be taking our sweet time down HWY 1 along the California coast all the way to San Francisco from there. It should be a great trip along one of the most fabled roads in the country.

I’m not especially happy to be leaving the Pacific Northwest, but what do you do when the big leagues call you up? I’ll miss the mountains, living downtown in a place I renovated myself, my friends and the city I’ve grown to love so dearly.

Thanks for everything Seattle!