Every week, I send out an automation tutorial that will save you time and make you more productive. I also write about being a solopreneur, and building helpful things with Ruby. Join 2853 others who value their time.
Hi Reader, how's your day so far? Can you believe it's already March?!
As I mentioned last week, this latest guide is about asking for help and debugging. I hope you find it useful. I ended up keeping it more general. I'm planning on creating a more specific guide about troubleshooting common Jekyll problems, probably in the form of a video. Stay tuned!
Before we get into this week's guide, I wanted to let you know that my scripts now work on the latest M1 Macs with the Apple Silicon chip! I just got my M1 MacBook Air this weekend, and set it up using my dotfiles and laptop script.
bundler --version
. If you installed my "laptop" script, the easiest way to keep everything up to date is to run the laptop
command in your Terminal.And now on to the guide:
Getting stuck while coding is a fact of life. Whether you're experienced or a beginner, if you can't figure it out on your own, asking for help is the best way to get unstuck. How you ask for help, though, makes a big difference.
You want to stick to the facts by answering these questions:
The more details, the better. Include these pieces of evidence if applicable:
For Ruby projects, this extra information can be helpful:
gem env
Gemfile
and Gemfile.lock
Remember that when you ask for help, you are asking for someone's time, so giving them as much information as possible will make it easier for them to help you. Having said that, try to keep it focused on one problem at a time.
Here are examples of different ways people might describe a problem when asking for help:
bundle exec jekyll serve
locally, everything looked fine. I'm not sure what else to try."Another advantage of taking the time to write down the answers to those 5 questions at the top is that it can sometimes lead you to find the solution on your own. This is known as rubber duck debugging.
When you haven't yet mastered the basics, debugging can be hard, and the list of things to try can be specific to what you're working on. However, there are some general techniques you can add to your toolkit. Below are three of them. More to come in future guides.
Git makes it easy to save your work in small increments, which is why you'll hear the adage "commit early, commit often". When you make small changes at a time, it makes it easier to pinpoint what went wrong.
If you update 10 gems at the same time in your Ruby project, and then it stops working, it might take a while to figure out which gem broke it. But if you update one gem at a time, and check that everything still works after each gem, you will know right away.
You might not know why, but you'll know what, and you can provide that information when asking for help.
All the major browsers come with developer tools for debugging and testing.1 On a Mac, you can open and close the developer tools with the same keyboard shortcut on all browsers: option-command-i
. Take a look at the Console
and Network
tabs and look for any errors, usually shown in red. If you're not sure what the errors mean, look them up and see if that gives you any clues. If not, make a note of them or take a screenshot when asking for help.
As humans, we are influenced by a wide range of cognitive biases. One of them that can affect how we test and debug is the confirmation bias. It describes how we tend to look for information that confirms our beliefs. If you have a theory for what is causing a coding problem, you might limit your research to things related to that theory, while dismissing anything that doesn't fit the theory.
I came across a perfect real-world example by chance. While taking a break from writing this guide, I noticed a new email from Julia Evans. You might know her from her programming zines. It was her blog post about debugging an issue with server-sent events.
She describes how she "went on a whole digression trying to understand how sleep in Ruby works", and that she "was really 100% committed to debugging both of those bugs from first principles." When a colleague pointed Julia to some Stack Overflow threads, she "was skeptical of the solutions those threads were suggesting."
In the end, she was able to get everything working, and those Stack Overflow threads did hold the clues. The key here is that someone else helped her shift her mindset and become less influenced by confirmation bias. Even if we know about cognitive biases, it's hard to avoid them on our own.
As Daniel Kahneman says, the most effective check against biases is from the outside because others can perceive our errors more readily than we can.
What if you're coding alone?
You can write down or print out a reminder and keep it visible while you code. Stay tuned for a cheatsheet that summarizes this guide.
What are your favorite debugging tips and ways to ask for help? Tweet me @monfresh, or reply to this email.
If you found this guide helpful, please share it with any beginners you might know.
In Safari, you have to turn on the tools by checking "Show Develop menu in menu bar" in the Advanced tab of Safari's preferences. ↩
Every week, I send out an automation tutorial that will save you time and make you more productive. I also write about being a solopreneur, and building helpful things with Ruby. Join 2853 others who value their time.
Hi Reader 👋🏼 Happy Sunday! I hope you and your loved ones are doing well. Earlier this week, I found a great use case for the 1Password CLI that hadn't occurred to me before. I'm gonna use it a lot more often whenever I can! If this email doesn't look right, or if you prefer reading on my site, you can click the title link below. Automate GitHub API Calls With Ruby, Keyboard Maestro, and 1Password CLI One of the perks of the “Ultimate” version of Ruby on Mac is access to the private GitHub...
Hi Reader! This week's automation guide is about a free but powerful Mac app called Bunch. I had heard of it years ago but never took the time to explore it in detail. Until now, and it has proven very useful so far. I'm not sure how the code samples will look like in your email, so you might prefer to read this on my site by clicking the title below. Automate Context Switching With Bunch You sit down to work on a feature, and wake up your Mac. Oh hey, Slack is open. You decide to check it...
Hi Reader! This week's automation guide is about a little-known app called PopClip. PopClip was originally released in 2011, but I didn’t hear about it until four years ago, and I’m sure there are still a lot of people who don’t know about it. It’s one of the many useful apps you can discover and quickly install with the “Ultimate” version of Ruby on Mac. You can pick and choose from hundreds of Mac apps, fonts, and dev tools in the included Brewfile, and Ruby on Mac will install them all at...