In recent years I’ve come to deeply appreciate the phrase “don’t make me think.” I will forget how to perform a setup step approximately 7 seconds after I do it, let alone 3 years after I’ve done it (and I know I’m not alone!).
Thus starting to work on an existing project will often give me anxiety—not because I’m worried about learning a new domain or existing system, but because getting the dang thing running can sometimes be the hardest part!
Of course, the best way to mitigate this pain is to codify setup tasks. Why rely on my memory when the computer can do something for me? In other words, don’t make me think. Below are two examples of where I scripted away my annoyances at setting up some projects.
Setting up YouTube Playlists
I worked on a Rails project that integrated with YouTube playlists. Our system created playlists, added, and removed videos from them via the YouTube API. Each system that interacted with YouTube—be it a production instance or local test instance—requires several API tokens in order to interact with YouTube. The tokens are read from the
config/system_config.yml file at runtime.
After setting this up once locally, I knew I’d never want to do it by hand again. Who wants to create this file, go to YouTube, create a bunch of playlists with specific names, dig out the tokens, and then paste them back into the file? It’s boring, repetitive, and error prone. Thus I created a Rake task to generate
config/system_config.yml on new machines.
I’m not going to paste the implementation here, as I am not here to discuss writing Rake tasks or the YouTube API. The point is that I used a script to replace my memory and opportunity for human error.
Another Rails project I fired up required three generated tokens to be in the
config/secrets.yml file. Thankfully the README documented how to generate the secrets—run
rake secret, copy the output, and paste into the YAML file. But who wants to do that three times every time you setup the local repository?
In this case, I created another Rake task named
- Checks for the presence of an existing
config/secrets.ymland aborts if it’s already there.
- Generates three secrets using the same library
rake secretdoes. The secrets go into a Ruby hash.
- The hash is serialized to
Script Away Your Annoyances
Now I don’t need to think about setup again in either project. As long as I can copy and paste a setup command from a README, I’ve saved my brain cycles for more valuable problems. I hope that this post has inspired you to script away your setup annoyances, whatever they may be!
Other posts in this series:
- Script Away your Annoyances – Patching a Gem
- Script Away Your Annoyances – Testing a Data Import Process
- Script Away your Annoyances: Employing Automator in a Pinch
- Script Away your Annoyances: Creating Word Groupings from Anki’s Database
The post Script Away Your Annoyances – Removing Manual Project Setup Tasks appeared first on Atomic Spin.