Skip to content

Instantly share code, notes, and snippets.

@v--
v-- / merge_lockfile.py
Created February 21, 2026 18:11
A naive scripts that iterates through version specifiers of the form "package (>=version)" and updates the version based on the lockfile.
import pathlib
import re
import tomllib
import click
def sync_dependencies(raw_pyproject: str, dep_list: list[str], lockfile: dict) -> str:
for dep_string in dep_list:
match = re.match(r'(?P<name>[^(@\s]+)\s*\(>=?(?P<version>[^)]+)\)', dep_string)
@v--
v-- / bad_factorial.ipynb
Last active December 2, 2024 15:39
Unraveling of a bad factorial implementation
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@v--
v-- / scalepdf.py
Last active September 26, 2024 20:59
A script to rescale all pages of a PDF file that are larger than the given reference page. Running it (i.e. `python -m scalepdf`) requires two packages, which can be obtained via `pip install click pypdf`.
import pathlib
import click
from pypdf import PdfReader, PdfWriter
class ScalePdfError(click.ClickException):
pass
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# This is a GNU Make file specifically designed for building PDF books from a directory of images.
# It can process multiple images concurrently with `make --jobs=8`.
#
# Every book is different and has different processing requirements,
# and it often makes sense copying this file and adapting it for an individual book.
# Adapting usually involves modifying in non-trivial ways the targets for the individual pages.
#
# The script builds a PDF file with a table of contents and an OCR layer.
# I used to build DjVu files instead because of their better image compression, but I learned that
# it's better to provide a PDF myself than to let people use bad converters.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@v--
v-- / party_mode.md
Last active December 2, 2024 15:42
Achieve full runtime nondeterminism by randomly selecting which function to run
@v--
v-- / distributions.ipynb
Last active January 30, 2022 20:37
Distributions meme
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.