My opinions on HTMX

Posted on 2025-06-24 in Programmation • Tagged with Python, Django, Web, JavaScript

HTMX is a JavaScript library designed to add interactivity to your web pages. With it, you don’t build a single page application, you use standard templates (written in Django, Jinja) rendered in your backend, add attributes to your HTML elements and let HTMX add the appropriate interactivity. From what …


Continue reading

Simply how licenses are applied to your project with SPDX and reuse

Posted on 2025-06-22 in Programmation

SPDX (Software Package Data Exchange) is a project managed by the Linux foundation created to standardize how licenses are identified in a human and machine readable way. In a nutshell, instead of adding a big header to your files to identify the applicable license, you apply a copyright text and …


Continue reading

Using super to reuse method with inheritance in Python

Posted on 2025-06-09 in Trucs et astuces • Tagged with Python

If you use Python, you probably already know of super to call a method from the base class. You probably also know you can use a function as a method if it takes the instance as 1st parameter. What you cannot do, is call super().my_method() directly in such a …


Continue reading

Promise returned by async functions

Posted on 2025-05-24 in Programmation • Tagged with JavaScript, TypeScript

Recently at work, I encountered a problem with a function that should have returned a custom promise subclass. The goal of this subclass is to be able to call a cancel method to cancel some pending action done within the promise and then reject it. It looks like this:

class …

Continue reading

Using JavaScript and TypeScript in jupyter notebook

Posted on 2025-05-23 in Trucs et astuces • Tagged with Python, JavaScript, TypeScript

While wandering how to run some tests with JavaScript, I discorvered that deno, a JavaScript runtime like NodeJS, has support for jupyter notebooks thanks to this article. It works perfectly. Install deno (probably available in your distribution repositories), run deno jupyter --install and you are good to go!

To get …


Continue reading

Using Pydantic models within enums

Posted on 2025-04-26 in Programmation • Tagged with Python, Pydantic

In previous articles, I provided some tips on enums and explained how to use a custom class with Pydantic. Now, I’ll dig into all kinds of enum usages with Pydantic, including enums whose members are Pydantic models themselves! Let’s dive right in!

Just like before, you can access …


Continue reading

Reusing Pydantic validators and serializers

Posted on 2025-04-21 in Trucs et astuces • Tagged with Python, Pydantic

I’ll give some tips to reuse field and model validators and serializers. All my examples will use validators, but it works exactly the same for serializers.

Field validators

Assign the validator to a variable like so:

def _is_above_ten(value: int):
    if value > 10:
        return value

    raise ValueError(f"{value …

Continue reading

Using Pydantic with custom classes

Posted on 2025-04-19 in Programmation • Tagged with Python, Pydantic

Pydantic is an awesome data validation library for Python. It’s getting very popular these days because it’s fast, has lots of features and is pleasant to use. I’m using it at work and it personal projects. It’s one of the strong points of FastAPI, the new …


Continue reading

Converting jupyter notebooks

Posted on 2025-04-17 in Trucs et astuces • Tagged with Python

You can export a notebook directly from the interface under File > Save and Export Notebook As. You can also do it in CLI with:

jupyter nbconvert --execute --to <FORMAT> my_notebook.ipynb

The --execute will execute the notebook to make sure all output cells are up to date. Many export formats …


Continue reading

Sending all nginx logs to journald

Posted on 2025-04-13 in Trucs et astuces • Tagged with systemctl, Linux

As part of my work to uniformize my server setup around systemd, I decided to make nginx log everything with journald. By default, it logs accesses and errors in log files under /var/log/nginx. I already had one log file per vhost.

To do the change, I changed my …


Continue reading