Monthly Archives: August 2013

HTTP Status Codes

I recently wanted a quick way of looking up HTTP status codes while working with a REST service. I thought it would be great to type this on a command line:

~ $ http 301

and receive a response:

301: Moved Permanently

   The requested resource has been assigned a new permanent URI and any
   future references to this resource SHOULD use one of the returned
   URIs.  Clients with link editing capabilities ought to automatically
   re-link references to the Request-URI to one or more of the new
   references returned by the server, where possible. This response is
   cacheable unless indicated otherwise.

...

So I builtĀ httpcode.info.

To get the handy shortcut in your terminal, you should add the following to your .bash_profile (or application file for your preferred shell):

function http(){
    curl http://httpcode.info/$1;
}

The app sniffs User-Agent headers to determine if plain text should be returned. Otherwise, a rough HTML page is returned for browsers.

The data is built from the RFC with a really primitive scraper. All of the code is written in php, since I wanted to run the site on the cheapest hosting I had available at the time.

If there’s interest in improving the app, I’ll post the code to GitHub. Ping me on ADN or Twitter if you’d like to contribute.

Update: check out the source on GitHub.

Ambition

While attending my niece’s birthday party yesterday, I overheard my grandfather and brother-in-law’s grandfather chat as they watched my toddling nephew run around. These two men have seen economic booms and depressions. They’ve been in war. They’ve labored physically, raised families, and built legacies for themselves.

Here’s the brief exchange:

In-law: “I wish I had half the ambition of that little boy.”

Grandpa: “I bet at one time you probably did.”

“You think so?”

“You wouldn’t have made it this long if you didn’t.”