Use a Custom Domain and SSL Certificate With Amazon Cloudfront

Running your own CDN has become incredibly cheap and easy these days thanks to Amazon’s Web Services (AWS). I’ve been using an Amazon Cloudfront CDN distribution to host assets for several websites for a couple of years now. They’re super easy to set up and they cost pennies a month for the average site. The only problem was that, until recently, if you wanted your CDN to serve assets over HTTPS then you either had to pay thousands a month for Amazon to give you a dedicated IP address or you were forced to use the default Cloudfront domain which was long, ugly, and looked something like https://dsy12448xkv.cloudfront.net/. No one wants that. But now there’s a cheaper option! Amazon allows you to upload your own SSL certificate to use with your custom Cloudfront domain for no extra cost. The process was a bit confusing the first time I set it up so I’m documenting it here for anyone who needs a reference.

Read on

What Is It Really Like to Run a Company?

Starting a company is the cool thing to do these days it seems. If you watch TV for any length of time you’ll inevitably see that VistaPrint commercial that glorifies new businesses and makes it seem as though its everyone’s dream to start one. Then there are the GoDaddy commercials that, if you didn’t know any better, would have you believe that having a business means you get a website and then customers charge in to shove money down your throat. Its also cool to not start a business. No, businesses are lame. What’s cool is starting a “startup” which to me has become a synonym for “an unrealistic business idea that involves a website and the word ‘viral’ that can only be profitable through investment and/or a buyout”. I have to roll my eyes any time I hear someone say they started or work for a startup. Everyone wants to start a startup or a business and have these dreams of what its like. I’m here to crush your dreams and tell you its nothing like what you imagine.

Read on

Nginx Mysteriously Fails to Start

Here’s a weird error for you. You have Nginx running, you change the configuration, run sudo nginx -t and it tells you everything is fine. You try to restart the server and it fails. What’s going on? Here’s how to fix it.

Read on

∞ First Five Minutes on a New Server

A lot of times we don’t have the luxury of being able to hire a full time server admin or ops person. That’s alright though! It isn’t hard. As a developer, if you’re comfortable on the command line you can competently manage a server of your own. The two places I always look first when setting up a new server are the Linode quickstart docs and this article. The rest you’ll learn on the job. This is just a link post but if I had to give someone one piece of advice about managing servers it would be this: focus 90% of your energy on security, triple check your iptables, and, if you’re managing servers for a company, hire someone who specializes in it ASAP.

Friends Don’t Let Friends Auto-generate Docs

Imagine you’re working with a new framework or library for your next project. You discovered the perfect tool. The README is perfect – not too much detail, not too little either. You’ve breezed through the installation and setup process, committed to using this new package, and suddenly you encounter a problem the README doesn’t cover. No problem, you’ll just head over to the official docs. What you find there makes you want to murder the original author. It’s auto-generated documentation. Friends don’t let friends generate docs.

Read on

We Don’t Use CoffeeScript Ever

CoffeeScript is a very popular alternate syntax for JavaScript with very little benefit compared to plain JS. There are few reasons to use it and a great many reasons why it’s pointless. This is a totally off-the-cuff, opinion based piece on why CoffeeScript is totally useless and stupid. If you don’t like rants, then read this and tell me why I suck or don’t read it and tell me why I suck anyway.

Read on

Simple API Authentication With Authorization Headers in Sinatra

Rails has a really helpful (but not well documented) token authentication mechanism you can use for authenticating your API users. But Rails is overkill for many APIs and so I usually turn to Sinatra. Sinatra doesn’t have much selection when it comes to API authentication. At least not the secure methods I’m interested in. So for my company’s new insurance quoting and licensing API I rolled my own. Here’s how to implement secure token authentication in a Sinatra app.

Read on

Initializing a Class in Node

Ever used a Node.js module that was instantiated like so: something = new Something(). We’re used to it with built in types like Date() but how are the developers of Node modules doing this and why would you want to?

Read on

Making Raw HTTP Requests in Node

If you’ve used Node for any amount of time you’ve probably worked with the http module. In most cases people use it to create their own server applications or for interacting with remote APIs. Using it to make API calls is pretty straightforward but if you’re using a newer version of Node (0.10+) then you may be tripped up when you get 400 Bad Request responses from the endpoint you’re communicating with. Here are the two trickiest issues I’ve come across. Hopefully this will help someone else who is scratching their head when they get these mysterious 400 responses back after making what would seem to be a perfectly valid HTTP request.

Read on

Turn a String Into a Hash With String.to_hash in Ruby

When used wisely, metaprogramming in Ruby can be one of the language’s most useful features. During the development of my latest project I had a need to take the results of a very complex MySQL query and turn a string into a hash. Here’s how.

Read on