Monthly Archives: November 2014

Rake Task To Load Production Data

When I’m working on a Rails app that relies on live data, like a reporting app for example, I find myself constantly wanting to pull live data to my local dev database. So I made a rake task to do this:

namespace :db do
  namespace :heroku do
    desc "Load the PROD database from Heroku to the local dev database"
    task :load => :environment do
      if Rails.env == 'development'
        Bundler.with_clean_env do
          config = Rails.configuration.database_configuration[Rails.env]
          system <<-CMD
            heroku pgbackups:capture
            curl -o latest.dump `heroku pgbackups:url`
            pg_restore --verbose --clean --no-acl --no-owner -h localhost \
              -U #{config["username"]} -d #{config["database"]} latest.dump
            rm -rf latest.dump


Filed under programming, ruby

Polyglot Life – Benefits And Detriments

Perspective. Being a polyglot is good, and I think the natural evolution as you progress from beginner to seasoned developer. I’m not here to discuss the benefits of a multi-lingual cross-platform architecture. This is about me, and this is about you. This is about how we spend our time honing our craft on our time.

The Sapir-Whorf hypothesis says (about natural languages) that the languages we know limit what we think. Continuing that thought, I believe that the programming languages you know, the communities you participate in, the things you feel passionate about, all become the lens through which you see the world. Sort of like Kant’s subject-object problem, where he suggests that we experience the world as conveyed by our senses. You don’t experience (or evaluate) anything directly, but instead through rose-colored glasses (as I remember the lesson going).

As you participate more, and as you learn more, you expand your field of vision. You recognize patterns and see where different problems are better solved in different ways, and perhaps a language is a good match for some problems and not as good for others.

A single language (or pattern) isn’t the silver bullet for all programs.

Varied experience also allows you to think about problems at a higher level rather than getting lost in the weeds of implementation specifics or community dogma.

Another benefit to the polyglot life is that it’s just fun to explore and play around. We are naturally curious. The Pragmatic Programmer suggests that we make ourselves uncomfortable and learn a new language every year. A different language with different constructs.

As a reminder, I’m talking about personal growth and how we spend our off time honing our craft. Some of these new languages and patterns will make their way into production code or glue processes, but that’s not really what I’m driving at here. This is more along the lines of what Steve Klabnik has called “Irresponsible Ruby.” You’re playing with language to explore and push the boundaries.

I have noticed some downsides to the polyglot life, though.

I am a long-time Rubyist. I remember the bump to Rails 1.0. I remember Chunky Bacon and Rails is a Ghetto. I’ve forgotten more Rails API changes than I remember now. I haven’t spent as much time doing Ruby lately, and I miss it. I miss the community. I think the community sometimes takes itself a little too seriously, but I miss my “home” community.

Context switching can also be expensive. Even just between different tasks in a single project, but especially between different projects in different languages.

I also joked with someone recently that I’m not “good” at anything anymore. I once had a boss suggest (when I was just getting into web development) that I should narrow my focus. Remember all the things you have to get a handle on to do web development? HTML, CSS, JavaScript, some app server backend, some web server to run the app server, linux to run the web server that runs the app server, ….

He was trying to look out for me. He was concerned that I would be a Jack of all trades and master of none. I feel that way now as I bounce around different projects in different languages.

Maybe it’s like that for everyone, and maybe that’s just where I am personally in my own growth. Perhaps I am back in that “beginner” stage, but on a different field. I’ll take it, though.


Leave a Comment

Filed under programming