Archive for July, 2010

23
Jul

Lazy Testing your URLs

So I have a Rails app that’s broad but not very deep: there are a lot of different types of URLs and thousands of pages, generated dynamically or built through a CMS. No one page is that complicated, but there’s a fair amount of shared code and thus some tentacles throughout. Yes, I should have written behavior-level and unit-level tests from the beginning, but I didn’t, don’t judge me.

Anyway, after I broke the site yet again, I realized what I really wanted was a post-release test suite – I wanted to test a whole bunch of pages in production and make sure they’re still rendering.

Stealing from the Net::HTTP canonical examples, then, I wrote a standalone script:

require ‘net/http’

URIs = ['http://example.com/', 'http://example.com/page/2']

puts “Running URL Test Suite…”
URIs.each do |uri|
  url = URI.parse(uri)
  req = Net::HTTP::Get.new(url.path)
  res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }
  unless res.code == ’200′
    puts “ERROR: #{uri} #{res.code}”
  end
end
puts “Test Suite Complete!”

Then, since I deploy directly with git, I added a call to this script in my post-receive hook. As long as I watch the deployment (which I do anyway), I’ll see if there’s a problem and fix it immediately. (I can handle a few minutes of downtime or just roll back.)

There are obvious improvements to this (like not storing the URLs in the file), and this doesn’t handle redirect, workflow, or authentication scenarios, but it’s a perfectly acceptable 99% case for a content site.

Note that if you are doing Rails development and you’ve built a custom 404 page, you’ll want to make sure that you’re actually returning a 404 status code, or this won’t catch errors: you can test your status codes, and if you aren’t, you can add code in your application controller to do the right thing.

15
Jul

The reason to upgrade to iOS 4.0.1

There’s a great reason for iPhone users to upgrade to the new iOS 4.0.1, and it’s not the changes to the signal strength indicators: it’s the reversion of the behavior of the wake/sleep button.

There are two principal complaints users are making about the iPhone 4: the loss of signal when you bridge the antenna with your salt-water hands, and the oversensitivity of the proximity sensor (aka the “I keep hanging up on you with my cheek” problem). I’ve found the antenna issue to match the conventional wisdom, and have had far fewer dropped calls on the iPhone 4 than on any previous model. The proximity sensor, though, has been a real problem, as I’ve been hanging up, accidentally muting calls, and starting FaceTime calls – no matter how much I think I’m holding the handset away from my cheek at a weird angle.

Of course, I used to press buttons accidentally on previous versions, especially when I would put the phone in my pocket and wear my handset. In every version of the iPhone and iOS before 4, this was easy to avoid: pressing the wake/sleep button during a call would lock the phone. So I’d press the button as I put the phone in my pocket.

In iOS 4.0, that behavior changed: pressing the wake/sleep button during a call would hang up the call. So for the first week, I’d try to avoid the accidental hangup problem by pressing the wake/sleep button, and so then I’d hang up on them anyway. This was a clear change in behavior that I haven’t seen documented anywhere. (I don’t know if it behaved the same way on the 3G or 3GS.)

In iOS 4.0.1, the behavior is reverted – pressing wake/sleep locks the phone again. So now, if you make “always lock when you start the call” part of your muscle memory, you won’t hang up on people quite as often. And if that isn’t what you want from your phone, what is?

UPDATE: It turns out that I was entirely wrong – Elan Lee had a larger array of phones to test than I did, and he determined that the behavior didn’t actually change – it’s just that the wake/sleep button only locks the phone when your headset is in. Since I’d never had the cheek problem before, I wasn’t locking the phone when I held it to my ear – that hangs up in earlier models as well.

I did hear from a few other folks thanking me for telling them about the locking-with-headset trick, though, so my doofusness wasn’t entirely useless.




Twitter Updates

  • Tips for SEA travelers this am: get dropped at arrivals, look for security line hacks - today I was a family needing assistance at far left. 11 hrs ago
  • On way to SEA, heading to Vegas, so starting with the @alaskaair wifi roulette. Daddy needs a new pair of IP's! 12 hrs ago
  • @mcgarty we were wondering the same thing. Let us know how your research turns out. 20 hrs ago
  • More updates...