Ruby articles

Brought to you by Honeybadger—simple application monitoring that helps developers move fast and fix things.

A beginner's guide to exceptions in Ruby

The other day I was searching for an introduction to Ruby exceptions written for beginners - people who know basic Ruby syntax but aren't really sure what an exception is or why it's useful. I couldn't find one, so I decided to have a go at it myself. I hope you find it useful.

Why is URI.join so counterintuitive?

I recently found myself using URI.join to construct certain some redirect URLs. But I quickly ran into a problem. URI.join wasn't behaving like I expected. In this post we trace the unexpected behavior through the source of URI.join and back to the original RFC.

Writing command-line apps in Ruby

In order to write a first-class command-line app, you have to understand a lot of details like arguments, environment variables, STDIN/STDOUT, and more. This post is my humble attempt to cover most of these details and bring together everything you need to know in one place.

How HTTP headers get passed from nginx to your Ruby app

Whether you use rails, Sinatra, or Lotus, you don't really have to think about how cookies and other headers pass from nginx or apache, to the application server and into your app. We're going to examine this journey in a little more depth. Because it turns out that the story of headers contains a lot of interesting information about the history of the web.

Working with fractions and rationals in Ruby

Most people are able to think about fractions a lot more easily than they can think about arbitrary decimal numbers -- when was the last time you measured out 0.65739 cups of flour? This post will discuss how to use ruby to work with fractions, and how you can convert gnarly floating point numbers, to nice fractional approximations.

Level up your command-line-fu with Ruby

To really master the command line you have to master dozens - if not hundreds - of small utility programs. Fortunately, it's possible to replace a lot of these single-purpose tools with a general-purpose programming language like Ruby. This post will show you how you can use your Ruby skills to level up your command-line game.