Open Source Christmas

This month, I've been participating in the 24pullrequests challenge. The idea is that you use open source projects all year for free. So, why not spend December giving back?

I've been able to submit a pull request to an open source project for each day this month up until Christmas Eve. That's 24 pull requests to 8 different open source projects, including:

Check it out!

Do Not Use Custom SSL Domains On Cloudfront

I've been using Amazon S3 and Cloudfront to deliver assets for several Rails apps for a while. It's a really great way to offload work from your application server, and it delivers your images, css, js, etc., really fast using caches around the world.

Basically, you send your assets out to S3, and set up Cloudfront to point at them. I've got this automated, and don't even think about it anymore. I will have to share that set up in a later post. But for now, on to the real issue.

Cloudfront supplies you with a subdomain -- -- and you can load all your files over https with it. It will even let you set up multiple subdomains pointing at your files so that your browser will download more items in parallel. So, I thought, wouldn't it be nice if I could set up subdomains of my own domain (,, point those at AWS, and deliver assets using Cloudfront that way. I figured there would be a nice way and affordable way to do this, as most AWS stuff is reasonably priced. So, I started the process of setting this up without even thinking about it.

"...we charge a fixed monthly fee of $600 for each custom SSL certificate you associate with your CloudFront distributions..."

- Amazon

And that was the end of that.

Edit - 1.13.2015

Robert pointed out in the comments that there is another option for using custom domains with SSL on Cloudfront using SNI. This is much more affordable, since there is no extra cost. You just pay normal Cloudfront rates for HTTPS requests. However, the caveat is that some older browsers don't support SNI.

In the case of the project I was working on, the team didn't think it was wise to drop support for those older browsers. So, we just stuck with the standard Cloudfront domains. SNI is a great option if you are targeting modern browsers.

First Friday Jams - Pool Lights

Lucas Hogg had a new album come out last month. It's really great, and it has been a staple in my "albums-to-work-to" since. Check it out, and if you like it, buy it.

Uploading Images To A Rails Api

Receiving an uploaded image at an API endpoint is a bit different than just processing form data. With form data, gems like Carrierwave or Paperclip abstract away the complexity of handling uploaded files. With an API, the client needs to be converting the image to Base64 data, and then uploading the data for the API to decode.

First, if you aren't already, you need to process your JSON so that it plays nicely with strong parameters. In this example I will assume you have a User model with a picture attribute.

def user_params
    # get raw json
    json = JSON.parse(request.raw_post)
    params =

    # process through strong params
    params = params.require(:user).permit(:picture_data)

    # call method to decode picture data
    params[:picture] = decode_picture_data(params[:picture_data])

Next, we need to decode the picture data. I use Carrierwave, and this is what I needed to do to make it happy. However, if you use something else it shouldn't be that different.

def decode_picture_data picture_data
    # decode the base64
    data =

    # assign some attributes for carrierwave processing
    data.class.class_eval { attr_accessor :original_filename, :content_type }
    data.original_filename = "upload.png"
    data.content_type = "image/png"

    # return decoded data

The important step there was converting decoding the Base64 data. The other steps were useful in talking to Carrierwave. Now you should be able to save your User record without any issue.


Alfred 2 Base CRM Workflow

Alfred 2 Base CRM Workflow

After posting my Basecamp Alfred workflow a couple weeks ago, someone contacted me about making one for Base CRM. I was not familiar with Base, but I was provided a trial account and did some research.

Today, I am open-sourcing version 1.0.0 of the workflow. It will pull in your leads, contacts, and deals from Base. All you need is an API key. I hope it helps those of you that use it. Let me know if you have any comments, and pull requests are always welcome on Github.

Alfred 2 Screenshot

After downloading, open the file to install, then:

  1. Right click on the “ba” Script Filter and click “Configure”.
  2. Fill in your Base CRM api key.
  3. Start being productive.