Skip to content

Instantly share code, notes, and snippets.

@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.
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);