Clearing Quicksilver’s clipboard to free up RAM
I’ve been using Quicksilver for so long it’s second-nature, and I hate being on a computer without it. One thing I use regularly is the clipboard history. The downside to this is that occasionally I copy something big into your clipboard, like a chunk of formatted text in Word or a range of cells in […]
Log userInfo, not localizedDescription, for CoreData errors
Most of the Core Data code samples out there log [error localizedDescription] on errors. However, that will return a message that isn’t particularly useful, like: The operation couldn’t be completed. (Cocoa error 1570.) Instead, if you log [error userInfo], you’ll get a much more actionable message, like: { NSLocalizedDescription = “The operation couldnU2019t be completed. […]
Multi-line strings in ObjC localization files
I manage my email templates in localization files for ease of formatting. When first creating them, I found lots of documentation on creating single-line strings, but nothing on multiline strings. I could create a single-line string like this: “my-email-template”=”Dear %@,\n\nMessage here.\n\nSalutation,\n\nSender”; However, that will quickly get unruly with a real email template. It turns out […]
Verifying JSON in Rails functional tests
If your rails controllers return JSON, you can call ActiveSupport::JSON.decode on the response body to get a hash you can validate in your functional tests. Since that doesn’t quite roll off the tongue, I’ve added this method to my test-helper.rb: class ActionController::TestCase def json ActiveSupport::JSON.decode @response.body end end Now I can evaluate the JSON like […]
Setting request headers in Rails functional tests
I have some Ruby on Rails controllers that depend on checking a custom HTTP header value, which I wanted to test. In integration tests, you can pass a hash of headers when you call your request method: post(:create, {:something => {:name => “foo”}}, {“CUSTOM_HEADER” => “bar”}) But in functional tests, you set custom headers on […]
