Auto-automation

Today, I found myself ensnared in the classic trap of dedicating an entire day to automate a task that, in all honesty, could’ve been wrapped up in five measly minutes. It’s like my brain’s autopilot has a vendetta against inefficiency, even when it’s for the most trivial things.

Alright, picture this: I’ve got this stack of letters to hammer out, and they all follow this standardised template, right?

Usually, my go-to move is to recycle the last letter I penned and just swap out the necessary details. But today, oh today, I thought, “Hey, wouldn’t it be a riot to see how much of this rigamarole I could automate?”

Enter stage left: JSON-list housing all the vital details about the recipients.

Now, when it came to deciding which text-based formats to use for these docs, I had options aplenty:

  • LaTeX
  • HTML
  • Markdown…

LaTeX got the boot faster than you can say “MacTex installation,” leaving HTML as the reigning champ. Why, you ask? Well, because I wanted these babies formatted for print, and CSS had some nifty tricks up its sleeve with those “@media print” settings, giving me that sweet A4-paper vibe.

Then there was this whole debacle about Python libraries. ReportLab had its moment in the sun, but hold up, I wasn’t after PDFs straight outta the gate. Nope, what I really wanted was an HTML-file that I could jazz up manually before hitting that print button and saving it as a PDF.

Cue in the Java Spring application, strutting its stuff with Jackson for JSON parsing and Thymeleaf for HTML rendering.

Now, initially, I thought I’d be a smarty-pants and use LibreOffice for layout design. But boy, oh boy, did that plan backfire! Ended up with more HTML tags than I knew what to do with. So, I went back to basics, whipped up the simplest HTML-template known to mankind—a table with two columns for sender and recipient. Boom, problem solved.

Oh, and I couldn’t resist tossing in a signature image for that personal touch. And to keep the HTML-file self-contained, I went all-in with embedding that bad boy using a data-uri.

Now, I briefly entertained the idea of roping in ChatGPT or Copilot to ghostwrite these letters based on some inputs stored in the JSON-file. But then I remembered the fiasco with auto-translated strings and the GradientHatch plugin. Let’s just say, it’s probably best not to get too trigger-happy with generative software, especially when it requires a smidge of critical thinking.

But hey, maybe down the line, I’ll sketch out the blueprint for an app that combines web-scraping, document-formatting, and text-generation. Just thinking about it gives me goosebumps.