The code is pretty rough and probably won’t work for anybody else’s setup, but it has some ideas I thought worth discussing in more detail:
I store my journal entries as text files, one per day. Every day, I start a new journal entry with the snippet ;dj
, which expands to
date: 2021-06-03
tags: #daily-journal
Prompts: family, friends, home, work, craft, entertainment, embodiment, exercise, diet, skills
## What did I do?
## How am I feeling?
## What do I want to change?
I use the date
/tags
header in all my text files. The tag allows me to filter for journal entries in Obsidian, my note-taking app, and my script can easily extract the date.
The prompts and headings give me ideas for what I want to write about. I change them on a regular basis, and part of what I want to track is whether my choice of prompt affects my journalling. I feel like some prompts get better results than others.
I wrote my script because I have a radically different prompt for June, and I want to see if it has any effect.
A darker shade means that I wrote more in that entry. This is based on the metric “file size” rather than “words written”, because I wanted something fast and approximate, rather than slow and accurate.
The Python standard library includes HTMLCalendar, a class for generating HTML calendars. My script uses a modified version which adds a day-YYYY-MM-DD
id to every cell, so I can select individual days in CSS to add the shading.
Calendars are quite fiddly, so it’s nice to have one available with minimal work on my part.
I wanted each year to have a different colour (because pretty), but I also wanted the colours to be consistent between different runs of the script. I choose the colour for a year like so:
import colorsys
import random
rand = random.Random(year)
hue = rand.random()
r, g, b = colorsys.hsv_to_rgb(hue, 1, 1)
By seeding the random
module, I get consistent output. I then choose a value between 0 and 1, which I use as the hue in the hue-saturation-value (HSV) colour space.
This code is pretty slapdash, but I’m not going to go back and tidy it up. It works, and that’s good enough for now. Tempting as it would be to keep fiddling, it would just distract me from the greater goal: actually writing my journal.