Skip to content

Instantly share code, notes, and snippets.

View blep's full-sized avatar

Baptiste Lepilleur blep

View GitHub Profile
@blep
blep / atomic_save.py
Created September 25, 2025 17:50
Python: Atomic file save/load utilities with backup, compression, and msgspec.Struct integration.
"""
Atomic file save/load utilities with backup, compression, and msgspec.Struct integration.
Features:
- Atomic save: ensures either the old or new file is present after a crash.
- Automatic backup rotation: configurable number of backups (.bakN).
- Zstandard compression for efficient storage and automatic checksum integrity verification.
- msgspec integration: serialize/deserialize Python dataclasses with msgpack.
- Automatic recovery from most recent valid backup on load.
@blep
blep / imgui_impl_sdl.cpp
Created March 23, 2020 12:06
DearImGi : change to automatically adapt to keyboard layout with SDL (handling both qwerty/azerty)
// The ideas:
// - Initialize varying key to SDL_SCANCODE_UNKNOWN
// - On KeyPress, retrieve the actual ASCII code corresponding to the letter, and map related input
static void ImGui_ImplSDL2_SetScancodeFromLetter(ImGuiIO& io, int scanCode, int ascii)
{
switch (ascii)
{
case 'a': case 'A':
io.KeyMap[ImGuiKey_A] = scanCode;