Skip to content

Instantly share code, notes, and snippets.

View ArthurDelannoyazerty's full-sized avatar

Arthur Delannoy ArthurDelannoyazerty

View GitHub Profile
@ArthurDelannoyazerty
ArthurDelannoyazerty / display_available_geometries.py
Created June 3, 2025 12:46
Display geojson/geometris on a earth map and save it as png/jpg
import geoplot
import contextily as cx
import geopandas as gpd
import matplotlib.pyplot as plt
from pathlib import Path
from shapely.geometry import shape
def display_available_geometries(list_geometries:list[dict], output_filepath:Path):
@ArthurDelannoyazerty
ArthurDelannoyazerty / dataloader_benchmark.py
Created May 23, 2025 09:46
Pyotrchdataloader benchmark
import time
import torch
from torch.utils.data import Dataset, DataLoader
from tqdm import tqdm
import pandas as pd
import matplotlib.pyplot as plt
from fourm.data.dummy_dataset import DummyDataset
def check_dataloader_speed(dataset:Dataset,
@ArthurDelannoyazerty
ArthurDelannoyazerty / linux_folder_size.md
Last active May 19, 2025 09:51
See the size of files & folders at your current location
du -sh ./* | sort -h
  • -s Gives only the total of each element
  • -h Human readable values
  • ./* all element in your current location (you can change that part for a specific location
  • sort -h Sort the element by size (bottom = largest)
docker run --rm -v "$PWD:/pwd" busybox rm -rf /pwd/<element>
  1. Create a small linux docker (busybox)
  2. Make the current terminal location a volume binded to /pwd in the container
  3. Remove an element from that location (/pwd/<element>)
  4. Erase the launched container (--rm)
@ArthurDelannoyazerty
ArthurDelannoyazerty / pg_dump_pg_restore.md
Created March 26, 2025 11:14
postgres use of pg_dump and pg_restore

General info

  • pg_dump : Database to file
  • pg_restore : file to Database
  • Better if pg_restore --version > pg_dump --version

pg_dump

pg_dump -f /pg_dump.dump -Fc --dbname DB_NAME -U USERNAME

  • -Fc : Format=custom
@ArthurDelannoyazerty
ArthurDelannoyazerty / json_utils.py
Created March 20, 2025 13:55
Extract a json/dict from a string in Python
import logging
logger = logging.getLogger(__name__)
def extract_json_from_string(text:str) -> dict:
"""Convert a text containing a JSON or python dict into a python dict.
:param str text:
:raises ValueError: If the string does not contains a valid json
:return dict:
@ArthurDelannoyazerty
ArthurDelannoyazerty / .bashrc
Last active April 15, 2025 14:52
My .bashrc
alias lps="lps -dF"
alias ls="ls --color"
alias ll="ls -alFhv --group-directories-first"
alias df="df -h"
umask 0002
# UV ------------------------------------------------
. "$HOME/.cargo/env"
@ArthurDelannoyazerty
ArthurDelannoyazerty / nginx_flask_socketio_gunicorn.md
Created March 17, 2025 16:11
Simple Flask socketIO + nginx + gunicorn
@ArthurDelannoyazerty
ArthurDelannoyazerty / Git_auth.md
Last active March 17, 2025 15:45
Notes on git authentification

Clone a repository

git clone <url>

Git config

git config --global user.name "Name"
git config --global user.email [email protected]
@ArthurDelannoyazerty
ArthurDelannoyazerty / current_time.py
Created March 13, 2025 10:41
Python script that get the UTC time from a NTP server. Usefull when the machine clock is wrong.
import time
import ntplib
import logging
logger = logging.getLogger(__name__)
def get_current_utc_time() -> float:
logger.debug('Requesting current UTC time')
response = ntplib.NTPClient().request('pool.ntp.org')
logger.debug(f'UTC time : {response.tx_time} | {time.strftime('%Y-%m-%dT%H-%M-%S',time.gmtime(response.tx_time))}')