Skip to content

Instantly share code, notes, and snippets.

@MathiasSven
MathiasSven / LombardiSpirograph.py
Last active November 8, 2025 16:49
A Python 3 version of David Eppstein’s LombardiSpirograph.py graph drawing script. This version is based on the mirror from https://github.com/rbrito/lombardi-spirograph and has been converted using 2to3. The gist also includes a default.nix file for packaging.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2010 David Eppstein
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
@MathiasSven
MathiasSven / patch_imports.py
Created November 7, 2025 22:00
I learned afterwards that the problem I was tyringt o solve could be fixed by running `2to3`. But this may serve as an example for using `libcst` in the future.
from pathlib import Path
from typing import cast
import libcst as cst
import libcst.matchers as m
class ImportRewriter(cst.CSTTransformer):
def __init__(self, module_names: set[str]):
self.mod_match = m.Name(value=m.MatchIfTrue(module_names.__contains__))
@MathiasSven
MathiasSven / hydra_builds.py
Created June 27, 2025 15:19
A script to search for past hydra builds
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3Packages.requests python3Packages.beautifulsoup4 smenu
import argparse
from collections.abc import Sequence
from dataclasses import dataclass
from functools import partial
from subprocess import PIPE, CalledProcessError, run
from sys import exit
from typing import cast
@MathiasSven
MathiasSven / results.md
Created January 25, 2024 20:29
PrimVar vs IORef vs Parameters

PrimVar:

1:

real    0m39.444s
user    0m39.348s
sys     0m0.058s

2:

@MathiasSven
MathiasSven / flake.nix
Created December 4, 2023 08:09
Working liquidhaskell Flake (as of Dec 2023)
{
description = "LiquidHaskell";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable;
flake-utils.url = github:numtide/flake-utils;
liquidhaskell-src = {
url = github:ucsd-progsys/liquidhaskell;
flake = false;
{
description = "A very basic flake";
outputs = { self, nixpkgs }: {
a = 1;
};
}
@MathiasSven
MathiasSven / authorized_keys
Created October 15, 2023 19:36
yubikeys-ssh
[email protected] AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIFdCJVC5wYAM6YmK3TBjevMsEQa0xu1aK8iu5F7/fO8nAAAADXNzaDp5dWJpa2V5XzU= ssh:yubikey_5
[email protected] AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIN2ye/VS/VZQHGdTz7Yi/Wcfkr3ApbWVRH/xpIrDG7CJAAAADnNzaDp5dWJpa2V5XzVj ssh:yubikey_5c
### Keybase proof
I hereby claim:
* I am mathiassven on github.
* I am mathiassven (https://keybase.io/mathiassven) on keybase.
* I have a public key ASA52foPePg3jpHXheVAaCtLAoChovcMJQCw4eQZvjooPwo
To claim this, I am signing this object:
@MathiasSven
MathiasSven / type_covariance.py
Last active April 29, 2022 19:15 — forked from mypy-play/main.py
`type[T]` covariance issues
from __future__ import annotations
from contextlib import suppress
from typing import Any, ClassVar
from typing_extensions import reveal_type
class Foo: ...
class SubFoo(Foo):
def bar(self) -> int: return 5