My MacBook’s birthday

I was looking at some old notes this morning, and I realized that I bought my current MacBook on December 2, 2007. So, tomorrow will be the MacBook’s fifth birthday!

I had been planning to replace it at the end of this year, but, as I’ve been thinking about it, I may put that off for a while more. It’s still working fine, and I don’t really have anything I need to do that I can’t do on this one.

I’m running OS X 10.7.5 right now, and I know that this machine isn’t supposed to be upgradeable to 10.8 (Mountain Lion). That’s really the only reason I’d feel the need to get a new machine.

Selenium

OK, one more post for tonight. (This is another one I suspected that I may have previously written up, but apparently not.)

I’ve known about Selenium for awhile now, mostly because one of our clients has a “testing guy” and he uses it. I’ve always wanted to be able to do some automated testing of web site projects, but it always seemed like the tools for doing so were too limited or complex. I’ll admit I put off downloading & learning Selenium, largely because I thought it would be a hassle and eat up a lot of time before I could really do anything useful with it. When I finally gave it a chance, though, I was surprised how easy it was to use.

I initially started with WebDriver, which is basically a couple of DLLs that let you “drive” Firefox (or another browser), sending keystrokes and click events, and looking for certain responses. You can get started with WebDriver quickly by grabbing it via NuGet. My first project with WebDriver was a simple console program that launches Firefox, then goes to several of the store locator web sites that use our Bullseye API, does a search at each one, and checks to see if it gets results. Nothing big, but just a useful program that I can run any time I roll out code changes to the API. Previously, I’d been checking this stuff by hand after each rollout.

Today, I took another step, and downloaded Selenium IDE. This is a Firefox plugin that lets you record a series of actions as you do them, then save them to a script. There are plugins allowing you save the script in several languages, including C#. So, I can record some steps, export some C# code, then fix it up to do some reasonable testing. My main purpose today was to record the steps involved in a fairly complex workflow on one of our client sites. It’s a multi-step process (around 20 steps, I think). Just in and of itself, the script is useful to have, as I often need to step through it to establish a new test account, so now I can just “play” it instead of clicking through the whole process myself. But, I would also like to use it to automate some testing of this process. Now that I have a base script, I can go in and replace the values I entered today with variables, so I can abstract things out in such a way that I can run the code repeatedly, testing multiple scenarios. And since I can do this all in C#, I can also then check the database, and see if the values I entered were interpreted and stored in the database correctly.

This may all seem pretty routine to some people, but I have to admit that I’ve never really had a chance to do this kind of testing before. It’s kind of cool!

I think my next project is going to have to be trying WebDriver with browsers other than Firefox.  I’d like to be able to test the same workflow in IE, Firefox, and Chrome, at least. (And if I get really ambitious, maybe I’ll see about iOS browser automation…)

xdebug

I thought I’d written up an entry on Xdebug for PHP a while ago,  but apparently not. (Or, if I did, it’s not coming up when I search for “xdebug” for some reason.) Anyway, Xdebug is a debugging tool for PHP. It’s definitely worth enabling, if you’re doing anything with PHP that’s in any way non-trivial.

It’s a bit hard to figure out the best way to get started with it under Windows. It turns out to be pretty easy, though, given a few pointers. First,  go to the wizard page, and paste in the contents of a phpinfo() call, run on the machine you’re installing to. This will then tell you exactly which file to download, where to put it, and what to add to your php.ini. Much easier than trying to figure that stuff out yourself!

A few other pointers:
– Depending on how you download & copy the DLL over, you may need to unblock it. (Blocked files really annoy me, by the way. I don’t know whose idea that “feature” was, but it was not a *good* idea. See here for some ways to unblock multiple files easily.)
– Xdebug can add color to your var_dump() calls. Add “set html_errors = On” to your php.ini to enable this. I’ve found it to be very helpful when looking at a complex object. (Of course, there’s always krumo for that too.)
– To get debugging working under Komodo IDE, take a look at this document. One thing that was confusing to me was that debugging locally is still considered “remote debugging”.

Also, on a related note, I’m not sure I ever mentioned that, after looking at a few options, I settled on Komodo as my PHP IDE of choice. It’s reasonably fast and easy to use, and the debugger works pretty well. There are a few things about it that I’m not too fond of, but overall, it’s really good.

Drupal Rules

I haven’t blogged in a bit, and I have a few random items I want to write up. I’m doing a lot of work with Drupal, and I’m still learning some little tricks here and there.

When I’m writing custom code, I often use Drupal’s cache. That’s pretty easy to do, with cache_set and cache_get. I recently found myself in a situation, though, where I wanted to clear a certain item from cache any time a user created or edited a node of a certain type.

It turns out to be really easy to do that with the Rules module. Just set up a rule that is triggered on insert or update of a certain node type, and make the action a simple line of PHP code:

cache_clear_all(‘your_cache_key’, ‘cache’);

Easy!

another failed Windows 8 upgrade attempt

I took another shot at upgrading my desktop PC to Windows 8 today. I first uninstalled some software that I thought might be causing problems, then ran the upgrade using the “just personal files” option. I figured this would wipe out the Windows and Program Files folders, and leave me with a clean Windows 8 install. The plan would then be to re-install all the software I would need, under Windows 8. Good plan, but once again, the install failed and rolled me back to Windows 7.

I’m really not sure what’s going wrong. I have a few ideas, based on stuff I’ve found in the Windows 8 install forums, but I’m not sure what’s likely to work and what’s not. Since the install/restore process takes about two hours, I think I’m going to have to wait a bit before trying the upgrade again.

Windows 8 upgrade failed

So my ill-considered attempt to upgrade my desktop machine to Windows 8 failed. The computer seemed to blue-screen after the install finished (showing the silly new Win 8 error screen), then rebooted to a screen telling me that the upgrade failed, and that it was restoring my previous Windows version. Surprisingly enough, that worked well, and I’m right back where I started.

I had originally only intended to run the upgrade advisor, and not actually do the upgrade. But, when I ran setup.exe from the DVD, it went straight into the upgrade, without giving me any indication of software incompatibilities or anything like that. I was going to cancel the install, but I decided to give it a shot anyway. I guess that wasn’t really a good idea.

So, with the computer back to Windows 7, I started poking around on the DVD to figure out how to run the upgrade advisor. I didn’t actually find it on the DVD, but I managed to download it from Microsoft and run it from there. There are actually a number of things on the computer that won’t work in Win 8, and that need to be either removed or upgraded. I’m not sure which of those might have been serious enough to have screwed up the install though, or if the problem might be with something else entirely.

Well, I’m going to try to take care or removing and upgrading stuff, then maybe take another shot at the upgrade next weekend.

Sandy follow-up and more

I got cable service back yesterday, so I’m pretty much back to normal, at least as far as utilities are concerned. My goals for today were modest — I just wanted to get my laundry done, pay some bills, run a couple of errands, and then relax and watch some TV.

At work, over the last couple of days, we’ve been working on a web site to allow people to search for open gas stations in the area. Getting gas has been a huge problem here in NJ since the storm. The web site is live at http://findgas.org/ now. Unfortunately, it’s been popular enough that we had to make some adjustments, lest the site take down our main web server. Not really what I wanted to be doing today, but not a big deal either. In hindsight, we should probably have put the thing up on AWS, on a self-contained EC2 instance. Live and learn, right?

Meanwhile, I decided to take a shot at upgrading my main desktop computer (here at home) to Windows 8. I was originally going to go through and uninstall some old software first, but in the end, I decided to just start the upgrade and hope for the best. I didn’t even do a backup first, which is something I may regret later. Either way, it’s running right now. Previous experience from my laptop upgrade would lead me to believe that it’ll take an hour or two to finish.

Sandy

Just a quick post to say that my section of Main St in Somerville got power back at around 9pm last night. I’d lost power on Monday night, at around 9pm, so that was three days with no power. I know a lot of places got hit much worse that Somerset County. It was weird living without electricity for three days though.

My iPhone and iPad kept me connected. Both Verizon (iPhone) and AT&T (iPad) 3G stayed up most of the time. (AT&T disappeared for several hours at one point, but I never had a problem with the Verizon service.)

My cable service isn’t back up yet, so no high-speed internet at home just yet. Hopefully soon!

Hello from Windows 8

Well, I went ahead and installed the $40 download version of the Windows 8 upgrade on my ThinkPad. I did an in-place upgrade, and hoped for the best. It turned out pretty well. I had to remove several Lenovo utilities, but almost everything else seems to be working. Visual Studio 2010 is working fine. (I haven’t tried much, other than a “hello world” program, but that worked OK.) My “WIMP” stack is fine — MySQL is running, and PHP under IIS is still working fine. I checked phpMyAdmin and my test Drupal site, and they both look OK.

Most of the utility programs I use seem to be fine. That includes DropBox, Evernote, KeePass, IrfanView, VLC, and Notepad++. I still need to re-install iTunes, so I’m not sure about that, but I think it will work. And of course Firefox is working fine — I’m using it right now to write this blog post.

The install process was pretty smooth. It took about an hour from the point where I started the purchase, to the point where all the files were downloaded, the pre-install stuff was done, and the actual install started. Then, the install itself took about an hour to complete.

My experience on the ThinkPad has been good enough that I think I can probably do an in-place upgrade of my desktop too, so I’ll probably do that when the box upgrade arrives.

I’ve got a bunch of other stuff to mess around with, so I’ll probably write at least one more blog post on this. But, so far, so good!

my first Drupal module

Here’s my second blog post for today. (Still sitting around at home, watching storm coverage.)

I recently read an article on CNET about how companies are increasingly looking at sites like GitHub when they’re looking at potential hires, to see actual code, rather than just going on what people say about themselves on, say, LinkedIn. I think the article exaggerates a bit, and maybe overgeneralizes. There are plenty of great programmers working in environments where they’re not likely to be posting any code on GitHub. I have been thinking lately, though, that it would be good if I had some open-source code out there for people to look at. My boss recently wanted me to write a Drupal module that would allow people to embed our store locator in a Drupal site. I recently finished writing the initial version of that module, and posted it as a sandbox project at drupal.org. You can find it here.

Because Drupal itself is open-source, and because PHP is interpreted, you really have to expose your code if you’re writing a Drupal module. So, as a beneficial side-effect, I now have some code out there that I could point someone to, if I needed to show a code sample to anyone. Mind you, I’m not actively looking for a new job, but it’s good to have something out there.

Given the kind of work that I normally do, it’s not that common that I work on any code that (a) I can post openly, (b) isn’t part of a “group effort” that multiple people have worked on, (c) is (somewhat) self-contained, and (d) is non-trivial. I think a lot of developers are likely in this category. It’s a good idea to keep an eye out for opportunities to work on occasional projects that fit these criteria, and can be posted publicly to GitHub or similar sites.

I’d like to do a couple of blog posts later highlighting some of the stuff I learned while writing this module. While Drupal is reasonably well-documented (for an open source project), there are a fair number of “dark corners” that are hard to get a handle on, and which I could possibly write some useful posts on.