Programming is a wonderful mix of art and science; source code is both a poem and a math problem. It should be as simple and elegant as it is functional and fast. This blog is about that (along with whatever else I feel like writing about).

Friday, November 16, 2007

Becoming a Consultant

Last week I decided to look for work. From what I can tell, the best way to do that is to throw your resume up on and wait for the calls to roll in (well, the best way is probably to know someone who'll get you a job more easily, but I don't). I didn't have to wait long until I had a couple of promising contacts with what I assumed were both recruiting firms. I set up face to face interviews with both of them.

As it turned out, the first firm was in fact a recruiting firm who had a permanent position in mind for me. Everything seemed to go well, and when I left the meeting I felt good (which was significantly different from how I felt when I went in ... I was quite nervous). They were going to send my information along to their client, and I'd have an interview on Monday. While waiting for my next interview a couple hours later, I decided to have lunch at Potbelly Sandwich Works, who make delicious sandwiches for a low low price. (I guess it's not as low as Jimmy John's ... but Potbelly actually cooks their sandwiches.) I got my usual, the "Italian on Wheat." I love restaurants where you can order something that sounds almost non-sensical, and they know exactly what you mean. While eating my sandwich, I took the opportunity to get nervous again. After all, the second interview was in the Sears Tower, which is designed to be intimidating ... and is successful. It has as much security as an airport, and is much, much taller.

I stood outside the massive tower, unable to see the top, for about an hour and a half. This did not help the state of my nerves. Finally, I decided to call my contact at the recruiting firm to get this show on the road. He came downstairs and we held our meeting in the Starbucks in the lobby. I declined the offer for coffee, since I don't drink the stuff, but he insisted "Come on, make me feel good," and I was obligated to order a small bottle of orange juice. It was delicious. You've got to love expense accounts.

Early into our meeting, I learned that this company was not really a recruiting firm, but was instead a consulting firm. It was SPR, and he spent a considerable amount of time convincing me about the greatness of the company. And you know those cases where someone tries really hard to make you think they're great, but the whole time you're sitting there thinking "That doesn't sound so great," and waiting for them to let you leave? Well ... this wasn't one of those times. He didn't have to try very hard at all, because he had a lot of "we're great and it's pretty self-evident" material. He went on to describe the client I'd be working for, and it sounded like a great situation and a great person to work for.

I left that meeting excited about working with SPR, and again nervous since I had to pass a technical screening followed by a face to face interview with the client if the technical screening went well. I had to wait a few days (it was a weekend) for the phone screening, and as it turned out I didn't need to be so nervous (as had been the case every time). I had the interview the next day, and so the next morning I hopped on the bus and rode downtown. I didn't know exactly where to get off, so I sat there the whole time with my iPhone out, matching the streets on Google Maps with the stops on the way. That worked fine, because I managed to get off on the correct street.

This interview was mostly over lunch, and was with the guy I'd be working for as well as another developer I'd be working with. It turned out that they were both vegetarians, and I ordered a meat ravioli (in other words, something that you know exactly what it is when you hear the words, which I don't like as much). At first I thought "What if they think I'm one of those heartless meat-eaters?" Then I immediately thought "If the fact that I'm not a vegetarian is any kind of an issue, would I really want this job?" Neither of them had a second thought about it. That was excellent. So was the rest of the lunch interview. After lunch, the boss went back to work and the developer gave me a tour of the office, and after a little while I went home feeling pretty good about my chances.

When I talked to my dad, he tried to manage my expectations and keep my feet on the ground (though they already were). "Don't get too excited, you don't have the job yet." Yeah. I know. Don't remind me. After that phone call, I was on the edge of my seat, staring anxiously at the phone. It took about two hours, but it rang and the voice on the other end said "I have good news and good news." Well, needless to say, that was good news! He told me the deal, and when I hung up the phone I was a consultant.

The whole way through the process I was nervous, and I shouldn't have been. The key is just to be yourself, and everything will go well. Now I have to wait two weeks before I can start (professional courtesy to the current employer), and then I get to get down to the part I'm good at, which is actually doing the work. It's all very exciting. And since I'll be paid by the hour, the number of 12 hour days will probably decrease just a bit (down from "every day except Sundays").

After I start, I'll know how I like it. I'll post my thoughts here, naturally. Until then, have fun.

Thursday, November 15, 2007

Apache Rewrite Rules

Everybody likes websites that have good, clean URLs. On a minor little project I'm working on on the site, I wanted to give that a try. So instead of seeing a URL like /index.php?username=user1&view=feeds, you'd see /user1/feeds. It's kind of cool ... and remarkably easy!

One assumption this particular projects makes is that index.php is the only page that'll be viewed. It checks the query string parameters and changes its behavior depending on that. I don't personally like this method, but it makes it easier to handle the rewriting rules.

Here's the .htaccess file you're going to want to put into your webroot directory:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?username=$1
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z]+)/?$ index.php?username=$1&view=$2
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z]+)/([a-zA-Z]+)/?$ index.php?username=$1&view=$2&action=$3
RewriteRule ^([a-zA-Z0-9]+)/([a-zA-Z]+)/([a-zA-Z]+)/([0-9]+)/?$ index.php?username=$1&view=$2&action=$3&id=$4

So that seems simple enough. The first option on each line is the regular expression that you want to match. Each match within a set of parentheses corresponds to the $1, $2, etc, flags in the second option. The ^ at the beginning and the $ at the end are regex symbols signifying the beginning and end of the string, respectively. the /? right before the $ on each line makes it so the rule will match the URL whether there's a trailing slash or not. (For example, /user1 and /user1/ will work in exactly the same way.)

Thanks ... and enjoy!