Pradeep's Stream

tohray

The source of the software that is behind this blog can be found on my github.com/btbytes/tohray. The Readme file has the details on how to install it, and the technologies behind it.

You can leave your questions and feedback to me on X - x.com/btbytes or on the github issues page of the project.

Things I learnt about Nim while writing Tohray

  • Karax's vdom is super sweet for building HTML interfaces. I like it lot more than using any kind of templates now. the mismatch between code and markup(HTML) is jarring after this.

  • I learnt how to write a .nimble for a working project. Nimble had always left me frustrated.

  • I leant about the distros package and specifically the foreignDep method. With this essentially, I was able to replace apt-get install blah with (see below), which captures the package dependency with the code and not in a script or a Dockerfile

import distros
if detectOs(Ubuntu):
  foreignDep "libpcre3-dev"
  foreignDep "libsqlite3-dev"
  foreignDep "build-essential"
  foreignDep "wget"
  • Once or twice, I thought using a class to share variables would have been nicer. I have to study that more.

  • Learnt about using SQLite's Full Text Search, mostly through the help from Anthropic Claude. The FTS felt finicky with it's inability to handle special characters. But, it's a start towards understanding a powerful DB feature - FTS.

  • Got a lot more comfortable with using multi-stage Docker builds

  • Tried my hand at statically building tohray binary. It was coming out to be 20MB ALL INCLUSIVE, which is a great small size for a full fledged web app. However, I could not figure out how to statically link libpcre.

  • The hunt for static building took me to hello_musl, a mere .nims config, but it showed the power of nim scripting. I think the way forward for static linking pcre is to improve the above script.

About

Welcome to the stream. Here you can find me small snippets of things I'm thinking about or woking on, or things I find interesting.

This application is written using Nim, with the help of Karax and Prologue web frameworks. The styling is provided by Terminal.css

You can find me on github, my homepage or on twitter/X.

Calendar , Export