Skip to content

Instantly share code, notes, and snippets.

View v--'s full-sized avatar

Ianis Vasilev v--

View GitHub Profile
@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 May 2, 2026 22:52
A script to rescale all pages of a PDF file that are larger than the given reference page.
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "click (>= 7.0)",
# "pypdf (>= 6.0)",
# ]
# ///
import pathlib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
@v--
v-- / pointer_arithmetic.d
Last active June 26, 2020 22:20
I saw a joke tweet some time ago about encoding natural numbers in levels of pointer indirection and doing arithmetic with them. This is different from what is usually called pointer arithmetic, however it is arithmetic and it involves pointers. I decided to implement addition and multiplication.
/+ dub.sdl:
name "pointer_arithmetic"
+/
import std.traits : isPointer, PointerTarget;
template IndirectionCounter(T)
{
static if (isPointer!T)
enum IndirectionCounter = 1 + IndirectionCounter!(PointerTarget!T);