published on Sunday July 28, 2019 22:07:58
Today, I'm going to write about what did I learn from creating a side project called bear_todo_counter.
If I have to put what is it in one sentence, I would say it is
A simple Python script to put a TODO progress in Bear note's title.
I appreciate that Bear has a visual indicator of TODO notes. But having a TODO progress that can tell me the number of completed tasks can be helpful.
Screenshot below depicts both the visual and numeric TODO progress indicator.
- Visual: Bear displays a progress bar for TODO note in Notes list.
- Numeric: bear_todo_counter gives a [completed/all tasks] progress at the end of note's title.
I had been using org-mode in Emacs for some time. In org-mode, you can easily see the progress of your TODO (percentage or number of completed items in TODO heading). Emacs and org-mode are great, but when it's time to write note on mobile I could not find a good application for it.
Now, I use Bear for my note taking -- journals, reading list, travel plan, TIL logs, TODO list, etc. It works great for my workflow. However, one functionality that is still lacking in Bear is TODO progress counter or a numeric indicator of completed tasks in a TODO note like org-mode.
I have created a file called
bear_todo_counter.py in my Desktop to solve this problem. Combining
the script with BetterTouchTool, I got some kind of automation workflow that allow me to get the
TODO progress just like in org-mode. Later, I thought it would be a good exercise to make this
a proper side project.
Setting up a new project 😊
At work, I usually work on various projects someone created in the past. Setting up a new project from scratch or using some kind of bootstrapping tools can be challenging and also a good exercise.
This part was easy for open source projects. I learned how to setup Travis CI and coveralls from reading .travis.yml file from black repo.
Managing Python environment
I have a bad experience with Pipenv, so I just use conda for this task. Learned a couple things in the process, e.g., how to rename a conda environment
conda create -n bear_to_counter python=3.7 # had a typo here
conda create -n bear_todo_counter --clone bear_to_counter
conda env --remove bear_to_counter
Writing Python tests using pytest
While Python's built-in unittest is great, I prefer the simplicity of pytest. One
problem I've faced when I was writing tests for this project was I need my test input to looks
similar to actual Bear notes. I've learned that putting
\ after the opening triple-quotes string
can remove the initial newline (documented here and here 😉) .
I am pretty happy with this project. It solved my own problem and I also learned a lot from it. Some people on Reddit find it useful, but it is not the native feature and Bear currently does not have any plugin system. Because of that, I guess I am the only user of bear_todo_counter for now 😁.