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

React hook to load fonts

Posted on 2022-06-11 in Trucs et astuces • Tagged with JavaScript, React

If you need to load a specific font in a component, you can use this hook. It will return true when the fonts are loaded. It relies on the document.fonts API to load the fonts. If the fonts are already loaded, the promise will be fulfilled immediately and the …


Continue reading

Exploring a weird HTTP issues

Posted on 2022-05-04 in Programmation • Tagged with Python, Django, nginx, GCP, devops

Today I'd like to explain how I tried to solve a weird HTTP issues that I found at work. I hope you will find the method and the trials I used the useful/interesting if/when you will encounter something similar.

The issue was this: I needed to dynamically generate …


Continue reading

Create test environments in Kubernetes

Posted on 2022-02-20 in Programmation • Tagged with Devops, Kubernetes

Context and possible solutions

If you are working …


Continue reading

How to avoid CSRF token issues with Django when running on different sub-domains

Posted on 2022-02-13 in Trucs et astuces • Tagged with Python, Django

If you deploy multiple Django websites on your infrastructure on various subdomains, you may get issues about invalid CSRF tokens. This is happening either because:

  • You erase the cookie by using the same domain. For instance, if you have your prod API at api.jujens.eu and pre-production one at …

Continue reading

Yarn workspaces and mono repos

Posted on 2022-02-06 in Programmation • Tagged with Devops, JavaScript

I currently work in a small startup with two other developers. We have three projects: an API written in Python with the Django web framework, a big React app and a website written with NextJS. All these project are in the same git repository. This allows us to easily share …


Continue reading

Shutdown Kubernetes

Posted on 2022-01-30 in Programmation • Tagged with Devops, Kubernetes

It can be a good idea to shutdown part of your infrastructure when you don't need it. It will help you reduce costs and your environmental impact. It is however, not always easy to actually do it.

In this article, I'll talk here about how to shutdown a Kubernetes based …


Continue reading

Testing the re-frame Clojure frontend framework

Posted on 2022-01-16 in Programmation • Tagged with JavaScript, Clojure

I wanted to test re-frame a Clojure framework for building user interfaces. It is built on top of Reagent a Clojure library to interface with React in ClojureScript. The main goal of this framework is to help you manage the state of your application. To do that, you need to …


Continue reading