Thursday, June 21, 2012

dependency injection minimal (dim) gem v1.2 released

I just released v1.2 of the dependency injection minimal gem (dim). Originally this project was just a gemification of Jim Weirich's example code, but v1.2 marks my first meaningful feature addition.

dim aims to provide a simple, Ruby-esque way to handle dependency injection. I find myself using it in all of my projects as a way to consolidate into one file all of the configuration that my apps need.

I noticed a common pattern, though. I had started to use dim to encapsulate ENV variables, so that my code would not need to know the source of a configuration variable (usually an API key or a URI for accessing a third-party service); in the test environment, the source might be a hard-coded literal string, but in production it might come from an actual ENV variable.

So I added a register_envmethod to complement the register method that Jim originally added. Below is an example of how I'm using it.

# attempts to read ENV["API_PASSWORD"], otherwise makes sure that the parent container has
# a service named api_password registered
The above code will fail if you don't have ENV["API_PASSWORD"] defined, or if ServerContainer doesn't have a parent container with :api_password set. Typically I'm using a YAML file to populate ServerContainer's parent with sensitive values that I want to have in my development environment (and then I make sure to ignore that file in source control).

See the docs or the source code for more details.

Wednesday, June 20, 2012

Personal creative process talk with some important books

I recently had a chance to speak at a new event in Baltimore called Midmorning Social where I was asked to speak about how I work and where I find inspiration. It ended up being one of the most personal and introspective things I've ever done. The video is embedded below, or you can watch here.

I thought a lot about all of the books that had influenced me on my current path or that just resonated with me and shaped me. I mentioned a bunch of these in the talk but left out others due to time. Since I was asked over Twitter to provide links to the books, I ended up making the following reading list. Hope you find it interesting as I really enjoyed compiling it!
  • The 4 Hour Work Week / The 4 Hour Body: very trendy amongst the Internet set, I know, but full of provocative and inspiring ideas about how to design the way you live instead of just following a pre-defined path
  • Organizing from the Inside Out: very useful technique for getting organized and staying that way
  • The Primal Blueprint: helped me plan how I exercise for maximum benefit with minimal, regular investment of energy/time
  • Why We Get Fat and What To Do About It or the more intense version Good Calories, Bad Calories: helped me figure out a healthier way to eat and lose weight; also a great example of debunking widely-accepted conventional wisdom. Good to contrast with another favorite book about eating, Omnivore's Dilemma.
  • The Cybernetic Brain: still grappling with what this book means, but my favorite part is the dissection of the ontology of unknowability as applied to the brain
  • The Song of the Dodo: the first really good nonfiction book I can remember reading, really turned me into a nonfiction fan
  • Collapse: I think about what happened to the European settlements on Greenland, and how that applies to the fate of our society, almost every day
  • Wizard and Glass: probably the best novel I've ever read, an incredible coming-of-age story. There's a powerful battle scene in the end that I recall so vividly it's like I lived it.
  • Godel, Escher, Bach and I Am a Strange Loop: awesome meditations on the nature of conciousness; the first book is also just an awesome work of art, stretching the notion of what a book can be or do far beyond anything else I've read
  • Imperial Hubris: Extremely prophetic book written in the early years of the "war on terror"; greatly influences how I think about the conflicts we're embroiled in and explains why "war on terror" belongs in quotes
  • Code: The Hidden Language of Computer Hardware and Software: being a self-taught programmer, this book really helped me understand lower levels of computational abstraction that I don't usually spend much time thinking about
  • Getting Things Done: also very trendy, but definitely changed the way I work and made me much more productive
  • Daemon: great near-future novel exploring the implications of current technology developments
  • The Warrior Elite: about Navy SEAL class 228; I washed out of class 230 and this book helped me decide to move on and not try to go back
  • Man's Search for Meaning: helped me clarify the truly important sources of happiness in life (the "pillars" that I mention in the talk
  • Hackers & Painters helped me decide to leave the Navy and become a programmer
  • The Lean Startup: really great manual for how to build things with less wasted effort in the 21st century. I reference this book in business conversations many times.
  • Rapid Development and Software Estimation: introduced me to the notion that in software you want your schedule to be very predictable, not necessarily super fast
  • Code Complete: introduced me to the notions of software quality and how to achieve it
  • Full Catastrophe Living: I ran out of time to discuss meditation, but this book helped me learn how and why to meditate, and helped me cultivate a mindfulness practice
Here's the video of the talk, about 20 minutes long:

Thursday, June 7, 2012

Ruby Study Hall In Session at the Baltimore Hackathon

My project for this weekend's Baltimore Hackathon is a new screencasting series called Ruby Study Hall.  I've been working informally with a small group of people who are new to programming or new to the Ruby language, and RSH is an experiment to see if I can scale myself to help a wider group of people in public. It's been really fun explaining how to get things done in Ruby by giving the students small projects to work on and providing feedback.

The home-made Ruby Study Hall logo
Ruby Study Hall will be in session on Saturday from 2 to 4 pm at the Hackathon. Due to space restrictions you must register for the hackathon to attend (which you should do anyway, it's gonna be awesome). The registration fee includes lunch at 1 pm, so why not make an afternoon of it? If you can't attend, I'll be screencasting the whole thing for posterity and posting the video to Youtube and Vimeo.


This is not a class per se. I will not be showing you how to code Ruby from scratch. The first 60 to 90 minutes is meant to be a study session for beginners, functioning like a reverse classroom. I'll be  answering beginner-level questions about Ruby based on the homework assignments people have been doing.  

The last 30-60 minutes will be aimed at intermediate and advanced-level coders. I've invited Nick Gauthier to sit-in and critique some work I've done with his Domino gem. Beginners will still like this part because it'll be a glimpse of how the smaller exercises will lead you to building something in the real world.


To get the most of out Ruby Study Hall you should:
  • Work on some Ruby code using the tutorials listed below
  • Get stuck on something
  • Post where you're stuck somewhere online where I can easily read it (preferably at
  • Think of questions about programming or Ruby concepts you don't yet understand
  • Email your questions and/or the link to your code to me at
  • Attend the live event on Saturday at 2 pm or watch the video later
Here's some homework to get you started, in no particular order:

So far I am seeing that it's really hard, but definitely possible to learn programming even if you've never done it before. Every programmer I know is largely self-taught, and to quote Viola Spolin, "We learn through experience and experiencing, and no one teaches anyone anything..."