RSSAmplifier

Blog

Articles — mutelight.org

mutelight.orgRSS feed ↗20 posts

Latest posts

Discriminating Input

While designing our V3 platform API , we made the decision to make the formatting in our requests and responses as symmetric as possible. Although common for an API to return JSON, it’s not quite as common to take it as input, but is our recommended usage for all incoming PATCH / POST / PUT requests. Largely reasons largely for developer convenience, we decided to allow fall back to…

Testing Sinatra With Rack-test

A common problem when starting out with Sinatra and trying to exercise what you’ve built with rack-test is that by default, Sinatra will swallow your errors and spit them out as a big HTML page in the response body. Trying to debug your tests by inspecting an HTML backtrace from last_response.body is a harrowing experience (take it from someone who’s tried). The solution is to tell…

The Asset Pipeline in Sinatra

The spectacular asset pipeline that shipped with Rails 3.1 is an easy feature to get used to once you’ve started using it, and when writing light Sinatra apps it’s one feature that I miss enough to pull in. Initially, I’d boot up a Sprockets module directly in my application’s rackup file (that’s config.ru ) and map it to a particular URL path. This approach works…

Have Unicorn Log to $stdout

A strange quirk of Unicorn is that by default it will write all its logging output to $stderr . Even a relatively harmless operation like a restart will result in noise written to your system error log: executing ["/home/core/.bundle/gems/ruby/1.8/bin/unicorn_rails", "-c", "config/normalized_unicorn.rb"] (in /home/core) forked child re-executing... I, [2012-10-17T09:00:35.029145 #12322] INFO -- :…

1 SSL Endpoint, N Apps

A few months ago, SSL was rolled out as an included feature for every app on the Heroku platform by enabling secure connection to each app’s heroku/herokuapp.com domain, so even if developers prefer to use a custom domain, they’ll at least have an SSL option for the components of their app where a secure connection is critical. The platform’s answer for developers requiring SSL…

Max Connections for a Postgres Service

Once in a while, it’s useful to know how many connections your Postgres service can support. For example, at Heroku we use this information to help alert us when any of our production-critical databases are approaching their connection limit. Inspecting a Postgres configuration file will reveal a setting that specifies the maximum number of connections that its associated service will allow:…

Prettifying JSON for Curl Development

In the same vein as my post from a few weeks ago on developing an API with Curl and Netrc , here’s a handy trick for sending pre-prettified JSON output back to clients, but only those that are identifying as Curl. The reasoning being that prettified JSON isn’t useful most of the time, but it’s a nice touch while using developing or testing against an API with Curl. Bundle…

HTTP Basic Authentication with Backbone

I recently ran across a situation where I needed to call down to an HTTP basic authenticated API in a Backbone app. Short of doing some hacking of the source, Backbone doesn’t provide an easy way to accomplish this, so here’s one simple option for your perusal. Backbone relies on the inclusion of jQuery or Zepto in your project to provide the underlying infrastructure for making AJAX…

Caps Lock + Tmux

Nothing. But beyond that, without rebinding, the location and function of caps lock on a modern keyboard is more than inconvenient – it’s actively destructive. Enabling caps lock during a Vim session in normal code causes all hell to break loose, and what’s going on isn’t obvious unless you’ve seen the symptoms before. I was pleasantly surprised to find that in OSX…

The Heroku CLI's API Workflow

Ever wondered how the Heroku command line client accomplishes its work? We don’t talk about it much, but the Heroku CLI isn’t a black box, it’s a fairly thin consumer of our own RESTful API, and that means everything you do in your day to day workflow on Heroku is available to work with in a programmatic fashion. The CLI even uses our own implementation of the API library called…

406, 415, and API Formatting

While working on getting our API restructured, I had to lookup how we want to respond to a client who has requested a format that we don’t support. Is it a 406 ? A 415 ? Here are some plain English explanations: 406 Not acceptable – In the context of format, when the server can’t (or won’t) respond in the format that the client has requested. This requested format could…

A Simple @todo Pattern

Modern task tracking apps are both mindblowing in their sophistication, and somewhat ostentatious in their flashiness and sheer volume. We have apps like Remember the Milk that offer multiplatform support with cloud synchronization, and apps like Clear that provide such a beautiful interface and compelling experience that they beg to be used. The earliest apps on both the iPhone and iPad platforms…

Building an API with Netrc

If you track the progress of the Heroku client , you may have noticed that in the last few months we’ve switched the way that your credentials are stored over from a custom format in ~/.heroku to an older and more normalized storage standard, .netrc . This isn’t an isolated event either, you may have noticed that GitHub has recently changed the recommended clone method on new…

Your Ruby App Should Have a `bin/console`

Those of us who have worked or are working on Rails are somewhat spoiled by the ability to boot script/rails console and immediately start running commands from inside our projects. What may not be very well known is that this console isn’t a piece of Rails black magic, and makes a nice pattern that extends well to any other type of non-Rails Ruby project. Here’s the basic pattern:…

A Cross-version Debug Pattern for Ruby

As circumstances would have it, I work with a few projects that need to be compatible with both Ruby 1.8 and 1.9. I also like to use a debugger, and getting one to work seemlessly under both versions isn’t exactly intuitive, so I wanted to share a nice pattern that I’ve been using recently in my personal projects. The traditional debugger ruby-debug has been known to be 1.9…

Authbind with a Simple Test

Having recently deployed an ELB in front of the production instances running the core Ruby application in our ecosystem, we started experimenting with the idea of removing Nginx from the box’s HTTP stack. Why? Having been devised by people smarter than myself, I couldn’t understand this idea initially, so let me explain a little further. We use Unicorn because of its nice restarting…

Upgrade to Heroku Postgres Dev

Our Heroku Postgres Dev plans recently went into public beta. They’re very exciting work, providing the full power of a true Postgres database for development applications, and for free! Some key features of the new dev plan is that databases under it are 9.1 (up from 8.3 which is what the shared databases ran under), support hstore, and can be managed remotely using heroku pg:psql or any…

The Hitchhiker's Guide to the Galaxy

Wikipedia can improve the way that you travel by putting a vast store of knowledge at your fingertips. Offline versions allow it to be carried across international lines without incurring massive data charges. Many of us have fond memories of reading of Arthur Dent and Ford Prefect traveling the galaxy accompanied by their towels and depressed robot. Readers will remember the friendly book…

Learn to Speak Vim

I don’t often post a blog article containing nothing but a link to content elsewhere, but I’ll be doing it today because Yan Pritzker’s Learn to Speak Vim – Verbs, Nouns, and Modifiers! is just that important. Frustrated beginners will claim that Vim invovles nothing but rote memorization–and they’re right, but only on the most basic level. Vim’s far more…

Subtleties of the X Clipboard

A few months back, I started running the lean Archlinux build that I’ve been using through to today. I elected not to use a display manager, instead preferring booting Awesome (an aptly named tiling window manager) via the startx script. After getting used to Awesome’s key bindings, and throwing Luakit, Urxvt and Tmux into the mix, I got about as close to an optimized Linux build as I…