Skip to content

Instantly share code, notes, and snippets.

View GuillaumeDesforges's full-sized avatar
🥁
Building a SalesTech product

Guillaume Desforges GuillaumeDesforges

🥁
Building a SalesTech product
  • Tweag
  • Paris
View GitHub Profile
# Power 4
# two players
# one grid: 7 columns, 6 rows
# turn by turn
# each turn: put a coin at the top of a column,
# it falls and reaches the lowest available row in the column
# display ~
from dataclasses import dataclass
@GuillaumeDesforges
GuillaumeDesforges / obj.txt
Last active April 16, 2024 02:29
Writing an ELF file manually
# This file `obj.txt` is a hexdump with comments to manually build an ELF file.
# Lines starting with '#' are comments.
# The rest is read as per `xxd -r -p` (see `man xxd`)
# You can build the binary executable `obj.elf` using the command:
# ```bash
# <obj.txt grep -v '^#' | xxd -r -p >obj.elf
# ```
# You can then use chmod to make `obj.elf` executable.
# ==================
@GuillaumeDesforges
GuillaumeDesforges / instructions.md
Last active January 26, 2024 16:03
Local development setup for python-nix

First, let's prepare Nix.

Get Nix source code and the C API branch:

git clone https://github.com/NixOS/nix.git
cd nix
git remote add tweag https://github.com/tweag/nix.git
git checkout nix-c-bindings
@GuillaumeDesforges
GuillaumeDesforges / kitty_wslg.md
Last active January 18, 2023 19:57
Instructions to get a kitty shortcut on Windows via WSL and WSLg for NixOS-WSL

Get a kitty shortcut on Windows via WSL and WSLg for NixOS-WSL

Pre-requisite

  • have WSLg installed
  • use NixOS-WSL
  • have bash as part of your system packages (just check /run/current-system/sw/bin/bash exists)

First, add kitty to your home-manager profile.

# usage:
# NIXPKGS_FLAKE_REF="github:nixos/nixpkgs/master" nix eval --json --file "./nixpkgs-graph.nix"
let
nixpkgsFlakeRef = builtins.getEnv "NIXPKGS_FLAKE_REF";
pkgs = import (builtins.getFlake nixpkgsFlakeRef) { };
in
with pkgs.lib;
curl -s 'https://graphics.afpforum.com/data/presidential-fr-2022-live-constantes/communes_codes.json' | jq -c '.[]' \
| while read commune_dict
do
code=$(echo "$commune_dict" | jq -r '.c')
nom=$(echo "$commune_dict" | jq -r '.n')
curl -sq "https://graphics.afpforum.com/data/presidential-fr-2022-live-results/resultats1/communes/IR1_$code.json" \
| jq --arg code "$code" -c '.lesResultats | map({key: .individuNom, value: .resPourCent}) | from_entries | . + {code: $code}' \
>> "resultats.json"
done
@GuillaumeDesforges
GuillaumeDesforges / nixos_python_patch_venv_bins.md
Last active February 11, 2024 00:54
How to: make Python dependencies installed via pip work on NixOS

EDIT: check out fix-python instead, make Python run "as usual" on NixOS!

How to: make Python dependencies installed via pip work on NixOS

The issue

  • You are using NixOS
  • You start working on a Python project
  • You manage the dependencies in a classic Python virtual environment using pip or poetry
for dir in ~/.vscode-server*/bin/*
do
node=$dir/node
echo Fixing $node
rm -v $node
ln -vs $(which node) $node
rm -vf $dir/vscode-remote-lock*
done
GCCLIB=$(dirname $(gcc -print-file-name=libstdc++.so.6))

Cours git - ENPC IMI 2021 - TP

Introduction

La pratique se fait en binôme, avec 2 ordinateurs par binôme (1 ordinateur par personne).

L'objectif est de montrer comment git permet de travailler collaborativement, et comment gérer les conflits lors de l'intégration des changements distants.

Dans ce TP nous abordons les notions suivantes:

@GuillaumeDesforges
GuillaumeDesforges / .vscode_launch.json
Last active February 4, 2021 06:05
Simplest use of TypeScript for node development with VS Code
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Run server (dev)",
"type": "node-terminal",
"request": "launch",