tconsole 1.0 is out!
I’ve been using a little project I spiked out called tconsole for a couple of months now, so I figured I should mark the gem as 1.0 and get on with things. tconsole is a command line tool that helps me and other Rails developers test more efficiently by not requiring us to reload our environment every time we run a test. tconsole has some helpful features like allowing us to easily test single test files, or even specific tests.
Interested in tconsole? Check it out on GitHub!
Figuring Out Where a File Was Required
I’ve been working on test performance a lot lately. Tonight I ran into a strange issue and needed to figure out where a file was being required from. That can be pretty tricky in a Rails app, since often files are being autoloaded.
I used this code up at the top of the file in question to figure out where it was loaded from:
puts caller.join("\n")
When the file was loaded by the Rails autoload code I got a nice looking stack trace of where execution was at that point in time, and all I had to do was look back to the first place where my code was referenced to figure out what was happening.
Be Sure to Include A Rating for Gravatar
When we launched Treehouse, we decided to use Gravatar for user avatars on profile pages. Here’s my profile page, for example. When we rolled it out I copied the Gravatar code on their site and ported it to Ruby. It was a pretty simple task.
Unfortunately, I heard reports from a few users after launch that their profiles weren’t showing up correctly, and were instead showing the fallback image. I tested their images on some other sites, and things showed up great. I was stumped.
After more trial and error I figured out that the problem was ratings. Gravatar has a rating system for avatars, so that you don’t show an avatar that’s a bit racier than would be acceptable for your audience. By default, they set the rating to G, so no images that are rated above a G rating will be returned. Our users that were having the issue all had a PG rating on their avatars. I’m not sure why they were rated PG because they were just pictures of the peoples’ faces, but that’s what was happening.
Adding that rating parameter fixed things, though. Here’s the code we use for grabbing Gravatar image urls:
require 'digest/md5'
class Gravatar
def self.url(email, default, size = 200)
email = email.downcase
hash = Digest::MD5.hexdigest(email)
"http://www.gravatar.com/avatar/#{hash}?s=#{size}&d=#{default}&r=pg"
end
end
How I GTD with Email
I read David Allen’s Getting Things Done quite a while back when I was younger, worked at an insurance company, had VP in my title and thought that was awesome, and felt like more than anything else I just needed to get things done. Now, six or so years later, my mind summarizes the book something like this:
- Keep a list on paper. Add things to it as you realize you need to do them.
- Double check that list every day. If you can knock something out in a couple of minutes, go ahead and knock it out.
- Work back through the list again, from highest priority to lowest.
Over the past month, since getting an iPhone 4S, Siri has pretty much rocked my world and I’ve been using the Reminders app a ton since I can easily record things I need to do by just saying them. iCloud syncs Reminders to my Mac as well, so I use Reminders a good bit there too (although I’d love to pay for a Reminders app that’s more like the iPhone one, but for Mac). In general I use the rules above to handle what I’m up to and what I need to do, but track it in Reminders instead of on paper.
I’ve always had a problem with email, though. I get a decent amount of email, and have been getting about twice what I used to consider a lot since Treehouse launched. I’ve typically considered my email inbox a sort of To Do list and worked through things, archiving them when I’m done with them, but with super high email volumes that hasn’t been nearly as possible. I realized recently that it’s taking me a week or more at times to get back to some messages, and I hate the idea of being that slow to respond because more than anything I try to make people the most important thing about what I do. That called for a new process.
For the past week or so I’ve been doing is processing emails with my normal GTD method. Here’s how it works:
- Read a new email.
- If I can handle the email in a couple of minutes, I knock it out.
- If I can’t handle the email in a couple of minutes, I let the person on the other side know it’ll be a bit before I can do whatever it is I need to do to handle the email, and then log the email in my Reminders list in iCal and put the email in a folder called Later.
- Whenever I finish handling that email, I search for it in my Later folder, respond to the person if needed, and then archive the email.
Whenever I add an email based reminder to my list I make sure I include some text that’ll make it easy to search for the email and remove it from the Later folder.
This probably isn’t that unique of a workflow, but it has worked well for me over the past week. I personally feel a lot better about a crowded list of short To Do items than a crowded email inbox with paragraphs and paragraphs of information to deal with. I’ve been able to keep my inbox pretty clear and it has helped me make sure I’m responding to everyone who emails to me in a pretty timely manner.
Cellular Automata Method for Generating Random Cave-Like Levels
I’ve always been super interested in cellular automata and thought it was interesting to see such a practical use case for them.
Teen Texting
Gruber linked to an article by Nielsen about Teen Texting. He quotes the article:
The number of messages exchanged monthly (SMS and MMS) hit 3,417 per teen in Q3 2011, averaging seven messages per waking hour.
At first that data point was pretty astounding to me. The average teen sends 3,417 text messages per month? 7 per waking hour? I can’t imagine texting anything near that frequency.
But then I realized something. In the late 90’s when I was a teenager I probably sent 3,417 or more messages per month to my friends, I just did it with a different medium - instant messaging. When you think about it in that context the number of text messages sent makes a lot of sense. In many ways it’s even easier to text more than IMing since you always have your phone with you.
Looking at the data in that light, it makes a lot of sense that Apple’s text messaging interface on the iPhone looks so much like iChat.
Ditching Rdio
I’ve been an Rdio member for a while now, but something kept nagging me. I love music. I have a job that lets me listen to it pretty much all day, and I definitely take advantage of that, but the whole time I used Rdio it felt like it was causing me to keep music at arms length.
I think Rdio’s social features and recommendation features are amazing because they told me what music I could be checking out and offered me all sorts of great new options. There’s one major negative to that, though. With Rdio it’s way easier to taste test tons of music but never really settle onto something and listen to it over and over again like you did when you were in high school and you bought a new album and knew that one album would be the only new album you would get to listen to that month. I’ve realized for a while that I miss paying that kind of attention to music, so I decided to ditch Rdio.
Instead I’m using iTunes again, and purchasing music through iTunes and Amazon MP3. I realized during the changeover that there were a few albums from my Rdio days that I couldn’t live without, like Torches by Foster the People, Gimme Some by Peter Bjorn and John, and Tron: Legacy Reconfigured. So my time with Rdio didn’t completely keep me from loving some albums, but I’m still sticking with my opinion that I’m better off without it.
If you’re wondering, this month’s albums are Songs for Christmas by Sufjan Stevens (Adair really wanted us to get this one, but I’m really loving it), Revolver by the Beatles (how did I not own this album already?), and Manners by Passion Pit. I’m listening to them like crazy and loving every moment of it.
Sharing Reminders with iCloud
I didn’t realize this was possible, but you can share reminders with other people in iCloud. It’s pretty easy to do:
- Log into iCloud
- Go to your calendar.
- Click on the share link for the reminder list you want to share.
- Enter the email address of the person you’d like to share the reminders list with.

Once you do that, the person you’re sharing the list with will get an email telling them you’ve shared the list with them. They’ll need to click a link in that email to add the list to their iCloud account.
My wife Adair and I are trying out using shared lists in iCloud for our grocery list. I tossed several things on there today and she’s at the store checking them off now. It’s pretty great!
Test Performance Tip from José Valim
I came across this post by José Valim and while two out of the three test speedup recommendations didn’t apply to me, this one did:
Add the following to your spec/test helper:
Rails.logger.level = 4
I thought it was worthwhile to give it a try. On the entire Treehouse test suite, our test execution time went from 2 minutes 28 seconds to 2 minutes 1 second. That’s around an 18% decrease!
My testing methods were definitely far less than scientific, but the performance jump was enough to encourage me to commit that extra line of code.
Emoji Cheat Sheet for Campfire and GitHub
Because, you know, getting your emoji on in Campfire and in GitHub comments is pretty important.


