The Lazy Programmer

Mon, Sep 7, 2020 2-minute read

Looking back, scripting was one of most important things I failed to learn while completing my CS degree. I picked up a few basic bash commands here and there but was far from proficient. Some of the tricks and tools I now use might only save me a few minutes here and there, but those minutes quickly add up to hours over time. Sometimes its a matter of saving a few key strokes while creating a pull request:

$ cat `which done.sh`
git checkout -b pc/$1
git add .
git commit -m $2
git push -u origin head
mkpr $2

But wait, what is mkpr?

$ cat `which mkpr`
hub pull-request -m"$1" | xargs open

hub documentation can be found here

Another trick I’ve picked up is aliasing those somewhat random commands so I don’t have to go back and look up the documentation to find the right arguments:

alias resetauthor='git ci --amend --reset-author -C HEAD'

However, my favorite scripts are the scripts I no longer run myself. They’ve now graduated from my local machine into nightly cronjobs that run as part of our ETL pipeline.

I remember hearing a while back about what makes a lazy programmer the ideal employee: they’ll automate everything. Any time a repeated task is encountered, a script is written. Even the hacky and undocumented v0.1 scripts hold value as they become the building blocks for more robust automation down the line. Once it’s pickied up some logging here, a little error reporting there, you now have something thats running without fingers on a keyboard. This is where the true time savings really start to take effect. And, for once, being lazy pays off.