Skip to content

Instantly share code, notes, and snippets.

View theomart's full-sized avatar
🎆
eating

Théo Martin theomart

🎆
eating
  • Unifai
  • Paris
  • 19:28 (UTC +01:00)
View GitHub Profile
@theomart
theomart / Dockerfile
Created May 2, 2024 10:55 — forked from usr-ein/Dockerfile
Optimal multistaged Dockerfile for poetry
# syntax=docker/dockerfile:1
# Keep this syntax directive! It's used to enable Docker BuildKit
# Based on https://github.com/python-poetry/poetry/discussions/1879?sort=top#discussioncomment-216865
# but I try to keep it updated (see history)
################################
# PYTHON-BASE
# Sets up all our shared environment variables
################################
@theomart
theomart / Dockerfile
Created May 2, 2024 10:55 — forked from usr-ein/Dockerfile
Optimal multistaged Dockerfile for poetry
# syntax=docker/dockerfile:1
# Keep this syntax directive! It's used to enable Docker BuildKit
# Based on https://github.com/python-poetry/poetry/discussions/1879?sort=top#discussioncomment-216865
# but I try to keep it updated (see history)
################################
# PYTHON-BASE
# Sets up all our shared environment variables
################################
@theomart
theomart / template_str.py
Last active September 8, 2023 10:35
Template string for pydantic
from typing import Annotated
import pydantic
def template_str(required_fields: List[str]):
def template_validator(value):
missing_vars = []
for var in required_fields:
if "{" + var + "}" not in value:
missing_vars.append(var)
@theomart
theomart / draw.py
Created July 12, 2023 18:15
Success of an AI company
import matplotlib.pyplot as plt
import networkx as nx
# Create the Directed Graph
G = nx.DiGraph()
# Add nodes
nodes = [
"Funding",
"Talent",
@theomart
theomart / extract_info_pap.js
Created December 24, 2022 16:15
Gather information while browsing pap.fr using Greasemonkey/Tampermonkey
// ==UserScript==
// @name Display price meter squared
// @namespace https://www.pap.fr
// @include https://www.pap.fr/annonce*
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_addValueChangeListener
// ==/UserScript==
@theomart
theomart / README.md
Last active September 26, 2024 11:42
A script that looks for free slots for a specific doctolib search before a given date

This script scrapes the doctolib search link you passed every minute to find a free slot before the date of your choice.

Get Started

@theomart
theomart / encrypted_json_file_dict.py
Created February 14, 2022 22:06
A wrapper that behaves more or less like a dict but is directly linked to an encrypted json file.
import functools
from cryptography.fernet import Fernet
import json
class EncryptedFileDict():
# The dict which actually contains the data
_data: dict
def __init__(self, crypto_key: str, plain_filepath: str = None, encrypted_filepath: str = None):
"""A dictionnary looking class that automatically syncs modifications with an encrypted json file.
@theomart
theomart / remote_jupyter_bind.sh
Created October 18, 2021 14:00
Starts a jupyter notebook server on a remote host over SSH and creates an SSH tunnel between the client and the remote host before opening the notebook in the browser.
function cjupyter {
port=8899 # The port you want to use on both machines, client and remote
token=localjupyernotebook
jupyterpath=/home/mtheo/.local/bin/jupyter # The path to the jupyter command
kill $(lsof -t -i:$port) # Freeing the port on the client if anything is running on it
ssh -f -N -L $port:127.0.0.1:$port $1 # Creating port forwarding
# Stopping any instance of jupyter server running on the port we want to use
# Launching a server with a predefined token
ssh -f $1 "$jupyterpath notebook stop $port; $jupyterpath notebook --no-browser --port $port --NotebookApp.token=$token"
# Opening the jupyter notebook on the client's browser
@theomart
theomart / reupload_vinted_items.py
Last active April 3, 2025 09:02
Reupload items on vinted.fr to appear at the top of the listings
from playwright.async_api import async_playwright
import time
import re
import json
import urllib
import requests
from bs4 import BeautifulSoup
import logging
logger = logging.getLogger()