Weird test behavior in my Django project test suite after an IntegrityError

Posted on 2024-12-01 in Programmation • Tagged with Python, Web, Django

Recently I encountered a very weird behavior in my Django project test suite. I created a view that caught an IntegrityError from the database (caused by duplicates in a unique index). When this error occurs, I want to respond with a 409 - CONFLICT status code and an error message.

TL …


Continue reading

Offline support almost without Javascript

Posted on 2024-02-27 in Programmation • Tagged with PWA, HTML, Javascript

Recently I wandered wether I could build a website with offline support without building a full SPA. The answer is yes it’s doable: you only need Javascript for the service worker. Just for the fun, I also tried it with navigation done with HTMX and without much surprise it …


Continue reading

Development containers

Posted on 2024-01-02 in Programmation • Tagged with Docker

I recently discovered the dev containers standard (or development containers for long) recently after trying to contribute to a project which had them enabled by default. It seems to be a new standard way to work with containers in development.

The goal is to provide a container you can use …


Continue reading

Django async

Posted on 2023-12-10 in Programmation • Tagged with Web, Django, Python

Now that Django is fully async (views, middleware and ORM), I though it was a good time to test how it behaves when run asynchronously. I’ll try to keep this article concise with only relevant data and resources. Code can be seen in a sample project so you can …


Continue reading

Ignore commits in git blame

Posted on 2023-12-02 in Trucs et astuces • Tagged with git

Commits that change formatting are a pain in git because they make using git blame much harder. It turns out, you can ask git to ignore these commits when running git blame with the --ignore-rev option and passing it a commit hash. You can even do things better and create …


Continue reading

Writing RSS reading app with various frontend frameworks

Posted on 2023-09-09 in Programmation • Tagged with Web, Javascript, Typescript, React, Angular, Svelte, Vue

During the summer, I decided to test a few frontend framework to see what’s going on in this space and form a better opinions over alternatives to React. I tested Svelte because after hearing from it I felt attracted to it, Vue because it is popular, React to have …


Continue reading

My opinion after testing some AI code assistant

Posted on 2023-08-21 in Programmation • Tagged with AI

With all the hype around AI and since I had time to spare, I decided to test some AI coding assistants to make my own opinion about them. I'll start by giving my opinion on each assistant I tried. I will be a bit fuzzy since I didn't intend to …


Continue reading

My opinion on enums in TypeScript

Posted on 2023-08-18 in Programmation • Tagged with TypeScript

Today I'd like to dig a bit on enums in TypeScript and their potential alternatives. For this, I'll be using the playground and TypeScript 5.1.6 (latest released version when I am writing this). I expect you to know what enums are and to be comfortable in TypeScript.

Let's …


Continue reading

Some cool type tips in TypeScript

Posted on 2023-08-17 in Trucs et astuces • Tagged with TypeScript

Here is an unsorted type tips I find useful in TypeScript. I may update it when I find new ones. Don't hesitate to share yours in the comments!

Another good start, is to read this page from the handbook which list various builtin utility types. If you are really motivated …


Continue reading

Use the same function as context manager and decorator

Posted on 2022-09-25 in Trucs et astuces • Tagged with Python

I recently learned that context managers created with @contextmanager can be used either as a context manager or a decorator:

from contextlib import contextmanager

@contextmanager
def test_context():
    print('Entering')
    yield
    print('Leaving')

with test_context():
    print('Inside')

@test_context()
def test_decorated():
    print('Decorated')

test_decorated()

We will yield:

Entering
Inside
Leaving

Entering
Decorated …

Continue reading