Scott Watermasysk

Still Learning to Code

Quick and Dirty Rails View AB Testing

Not bad, a blog post less than one week after retiring from technical blogging….

There are many ways to do A/B testing and I generally prefer the likes of services like VisualWebOptimizer.

However, there are times when you want to test a much bigger change (or just need something simpler). In those cases, we use this helper on KickoffLabs to enable A/B testing across multiple views.

Then it is just a matter of calling the choose__test helper method.

We then send any relevant data to KissMetrics so that we can analyze it with everything else.

While it is quite simple, it worked really well for us.

Even More Efficient With Heroku

I came across this blog post a couple of weeks ago, Getting efficient when working with Heroku.

The tips are definitely good and can save you some time. However, I think you can save yourself even more time and effort if you use your Git remote name instead of your Heroku application name.

Using Remotes

Most of the Heroku cli documentation uses -a or –app to specify the specific application. However, instead of using the app name, you can use -r or –remote to specify the name of a remote.

Knowing this and sticking to some specific naming conventions, you can add the following functions to back or zsh (preferred) profiles:

<p>[View the code](</p>

Naming Remotes

You can name your remotes when you create your Heroku app with the –remote parameters. You can also rename a remote at any time with the following:

git remote rename [previoususuallyheroku] production

Using the Code

Now, to run a rake command it is as simple as:

hp run rake db:migrate
hp run console

And as a side benefit, deploying now looks like this:

git push production
git push staging


One downside to this approach is you need to execute them from within your app directory. This isn’t an issue for me personally, but you will probably need to stick with the app suggestions in the in link above if you want to be able to execute commands from anywhere on your computer.

Protocol-Relative Css With Ie on S3 and CloudFront

Protocol relative resource allow you to avoid writing code which checks for http:// or https:// (or simply defaulting to one or the other). The benefit, besides less code and complexity, is your visitors will have the resources optimally served to them (fast and not secure or slower and secure).

This has been around forever (in terms of the web) and every browser handles it perfectly for JavaScript, CSS, images, etc…..well, not quite everyone. As usual, someone invited Internet Explorer to the party and they had to go screw things up.

As was mentioned in Paul Irish’s article above, IE7 and IE8 download the file twice. Annoying, but if you are going to use IE 7 or 8 that’s what you get.

Unfortunately, I cam across another baffling issue.

We host most of our external resources on S3 and CloudFront. A link to a CSS file looked like this:

<link href="//" type="text/css" media="all" />

Now I would have expected IE7 and IE8 to download the file twice. Again, annoying, but what can you do?

Unfortunately, instead of just requesting the file at both http:// and https:// it appends current domain name to the file.

So instead of requesting http(s):// it instead requests

Anyway, not much you can do to fix it except for denying IE7/IE8 or appending https:// for CSS requests.

Hopefully this post saves someone else out there many hours of head shaking and fist pumping.

UPDATE: Just to clarify, everything appears to work perfectly fine on non-ssl requests. It is via SSL where everything goes in the toilet.

Heroku, Assets, and S3

We are just about done on V2 of KickoffLabs. One of my side goals has been to finally move our web assets (images, css, and javascript) to S3 (and CloudFront).

My first attempt was based on this article, Make your website super fast with Asset Pipeline, Sprites & Cloudfront.

In a nutshell, we used a pass through approach with CloudFront (Amazon’s CDN). Assets would be requested on our CloudFront domain. If they did not exist, they would be passed back through to us. Once they were found, they would be cached on the CDN.

Because the asset pipeline will generate hashed file names, this appeared to be a very effective way to offload our assets.

This worked pretty well at first, but we started to notice some assets where missing. This may (or may not) be related to switching between SSL and non-SSL. But in the end, we decided the risk was not outweighing the reward.

Recently, Ben Scheirman wrote an article, Serving Assets From S3 on Heroku. This sounded like the perfect solution, until Ben confirmed in the comments that he had to push assets separately after a deploy.

This creates a small windows where assets may not be available. Probably not that big of a deal (especially on deploys without new assets), but it was enough for me to temporarily shelve the idea again.

However, a recent comment on the post mentioned the asset_sync gem will now override the default assets:precompile rake task and will deploy your asset changes when you deploy.

I have tested this a couple of times this morning on our V2 staging app and it appears to be working perfectly.

The only big issue we are still seeing is in serving fonts. We use a custom icon font heavily in KickoffLabs. Both FireFox and IE are not fans of fonts being served by different domains without setting Access-Control headers. Unfortunately, although it has often been requested, Amazon will not allow this header to be set on S3.

The fix (I use that term loosely) is to move our font out of the asset pipeline and server it directly ourselves. This isn’t ideal, but at least that limits us to a single asset per request.

One more bonus tip, if you are serving fonts, check out the rack-access-control-headers gem. This will set the proper headers on any fonts you server directly via Rack.

UPDATE: Amazon recently announced Cross-Origin Resource Sharing (CORS) support. Enabling CORS on your bucket is a breeze and once completed you can easily server font files to both IE and FireFox. Even better, these options carry through perfectly well to CloudFront.

Stop Doing Work You Hate

One of my biggest personal failures is my inability to convince those around me to stop sticking with jobs/careers/industries/etc they hate.

If it doesn’t feel right, don’t settle on the first or second career field you dabble in. Keep searching. Eventually you will find work you love to do. If you catch yourself working hard and loving every minute of it, don’t stop. You’re on to something big. Because hard work isn’t hard when you concentrate on your passions.

It doesn’t matter what you have already invested. You will never get that back. Look forward and find something you love to do (and yes, it is possible for everyone).

Reviewing Osfoora for Mac

Osfoora is a new’ish Twitter client for the Mac.

Overall, it is a very polished app that works extremely well. It has all the features you would expect in a great Mac Twitter client:

  1. Multiple account support
  2. Lots of keyboard short cuts
  3. Growl notifications (if you are into that)
  4. Instapaper integration (it’s about the links)
  5. Good inline image previews

However, there are some things which drive me nuts and I hope get fixed/updated/implemented:

  1. No easy way to scroll to the top. I really don’t need to read or scroll through all tweets. The lack of support for Command+ArrowUp catches me off guard all the time.
  2. No keyboard short cut for reporting spam and/or blocking someone. Direct missile support would be nice as well.
  3. You can mute users (nice) but muting keywords would be better. I am really hoping to avoid seeing even a single SXSW tweet. Help!
  4. No drag drop on images. Similar to scrolling I try this daily because it is just supposed to work in every Mac app.
  5. If you are going to support Url shorteners, skipping is a big oversight.

Despite the list above, I still highly recommend it. $5 is a small price to pay for something as nicely put together as Osfoora.

And of course, don’t forget you can find me way too often on Twitter at @scottw.

No-Reply Must Die!

Bart Simpson writing on chalkboard


Why miss the opportunity to engage with your (would be) customer? Why make them jump through even a single hoop to contact you?

I wrote about this a while ago on the KickoffLabs blog as well: Email Is Never Just a Notification.

Announcing: Unwind Gem

Unwind has a single goal. Take a url and figure out what it actually points to.

It is able to walk various redirect status codes, handles relative and absolute locations, and a couple of other gotchas.

Once completed you have the destination url and a list of the hops along the way.

require 'unwind'

follower = Unwind::RedirectFollower.resolve('')
assert_equal '', follower.final_url

Hat Tip: This gem started with code from John Nunemaker’s Following Redirects with Net/HTTP which provided the basic code to get this done.