Weeknotes WK42: Elixir & i18n, Jocasta, Pi-hole

A quite productive week - both private and business. Learned a lot about i18n in Elixir and setup a GitHub Project for Jocasta. (Re)started a new product at work.

Elixir and i18n

Coming from the Django web framework, I expect a complete web framework to supply decent support for i18n based on gettext and automatic language detection capabilities.

While the i18n capabilities of Phoenix are en-par with Django, it is unable to detect the language for a request automatically. You have to use an external dependency like set_locale or write a Plug. I took the later approach for Jocasta because set_locale didn’t satisfy me and writing a Plug for an Elixir project is super easy and fun anyway. Maybe this can be a small first project to release on hex.pm.

Another thing I didn’t get in the first place when I read about i18n for an Elixir project — the relationship between mix gettext.extract and mix gettext.merge. Maybe I was too biased by the workflow of my Django projects. I expected mix gettext.extract to generate and merge the language files for the supported languages in the project. But the extraction part „only“ fills a template file in the priv folder. This template is then picked up by the merge step and applied to the individual language files. It took me almost an evening to understand this.

Elixir @ Discord

The most inspiring article this week was the Elixir case study Real time communication at scale with Elixir at Discord.

None of the chat infrastructure engineers had experience with Elixir before joining the company. They all learned it on the job. Team members Matt Nowack and Daisy Zhou report initially struggling to understand how all of their services communicate. Matt adds: “In the beginning, it was hard to accept all of the guarantees that Erlang VM provides. I’d worry about data races and concurrency issues that were impossible to happen”. Eventually, they took these guarantees to heart and found themselves more productive and more capable of relying on the platform and its tools. Matt continues: “The introspection tools the Erlang VM provides is the best in class. We can look at any VM process in the cluster and see its message queue. We can use the remote shell to connect to any node and debug a live system. All of this has helped us countless times.”

Jocasta

Made some small progress on the project. I put it on GitHub this weekend and put it under the Apache-2.0 license.

Added authentication using Phx.Gen.Auth as I mentioned in my last weeknote. The simplicity is great and it is easy to tweak. I learned a lot by reading the code it generates. Still feel a bit uneasy how to handle updates to the code generation process.

I configured the GitHub actions workflow for CI/CD, which is as usual pretty easy and straightforward. In case you are curious how to do it have a look at my main.yml. I learned most of it from the article CI/CD with Phoenix, GitHub Actions, and Gigalixir.

Pi-hole

We have a pi-hole running again in our home network. This time I installed it on a PI 4 and not as Docker container on our slow starting QNAP NAS. The acceptance is much better, because in case of a restart it is available immediately. On the QNAP it took almost 10 minutes until „the network“ was available again.

A nerd joke on COVID-19

Tools

  • about:blank is a handy tool to block sites on devices. It is available for iOS, iPadOS and macOS. It helped me a lot in my transition to ignore Amazon completely. I didn’t want to block Amazon on our pi-hole, because my wife still uses Amazon. So I needed a solution on my devices that also syncs the settings between them.
  • Elixir Regex is a handy web application to built and test regular expressions for use with Elixir.