I recently learned a nice way to manage your .env files in your Svelte projects. If you're using Rollup as your bundling tool, which is likely to be the case, you can use the node module dotenv to automatically inject the content of a .env file into your web page.

Read full post

A friend asked me today what is a simple way to copy files from a directory (in his case, extract some images from a node module) to the build directory, using Rollup.

My solution is to create a simple plugin like this:

Read full post

Last Friday evening I was following and discussing the 2020 US elections, while I got a really dumb idea: is there a logic behind Trump's use of ALL CAPS when tweeting? And if yes, can people guess correctly what is actually in ALL CAPS when given a lowercase version?

I felt that would be a funny, silly game, so I implemented it the next day.

You can play it right now at https://www.trumpscreaming.site.

Rules are very simple: you're given 6 tweets in a row, all in lowercase, and have to guess which words are supposed to be in ALL CAPS. You're score is then calculated based on your accuracy. That sounds easy, but in fact, some tweets are really hard to guess correctly!

A round looks like this:

game round screenshot

Words underscored in orange can be toggled between their lowercase and uppercase version. You then click on "Verify", which results in this:

game round score screenshot

The list of tweets is already quite big (360+ tweets with more than 2 ALL CAPS words), and new ones are added automatically once per day...

Read full post

When working on web projects it is often useful and recommended to enable SSL for your development environment. For example if your project works with cookies, it is likely that the server sets the Secure attribute, ensuring that they only sent to the server over HTTPS. But even without cookies it's a good idea to try to minimize differences between your development and production environments. Fortunately, using Docker that can be done done easily in just a few steps.

Generate locally trusted certificates

mkcert is a command line tool that makes it ridiculously simple to generate locally trusted certificates, for development.

  1. Install mkcert, as documented in the readme. In my case, running Windows, it's just a choco install mkcert
  2. Generate and install the CA (Certificate Authority): mkcert -install
  3. Create a new certificate for the project: mkcert elborai.me localhost
  4. And that's it, just rename the key and certificate to something that makes sense

Reverse proxy


Read full post

When I start to use a programming language I always have the following questions:

  • How do I build/run my program?
  • How do I run tests?
  • How do I install dependencies?
  • How do I integrate all of this in my text editor?

Some languages such as Go come with simple answers to these questions: go build ./..., go test ./..., go get <my module>, install the official Go extension for your editor. Done. But of course in the case of C++, things are ... different 🙃.

The C++ world is way more fragmented, there is a lot of choices of build and meta build tools, various test frameworks (each with its own test runner), lot of way to manage dependencies, etc. Because so much choices can be daunting for people who just want to start with the language, and because I know I will forget how things work, in this article I will document what I've done to get to a fully working environment that answers all my questions in a simple and coherent way. At the end of this guide we will be able to build and run tests in just one click (or command line if that's your thing).

Tools popularity can vary quite a lot from years to years, for example solutions to manage dependencies are still competing against each other and new ones are popping all the time, so I want to be clear that this document is my setup in 2020, hopefully it will stay evergreen in the future, but I wouldn't bet too much on it.

Read full post