Skip to content

Instantly share code, notes, and snippets.

View nilsso's full-sized avatar

Nils Olsson nilsso

View GitHub Profile
import typing
T = typing.TypeVar("T")
def not_none(v: T | None) -> T:
assert v is not None
return v
#!/usr/bin/env python
import functools
import argparse
import json
from pathlib import Path
import typing
import csv
#!/usr/bin/env python
"""Text file cleaning utility (primarily for secured roll preparation)."""
from pathlib import Path
import typing
def clean_file(
in_path: Path,
out_path: Path,
in_encoding: str,
We can't make this file beautiful and searchable because it's too large.
n,atomic,1,2,3,4,7,8,11,13,14
1131,true,0,0,1,0,0,0,0,1,1
951171,true,0,0,1,0,0,0,0,1,3
799934811,true,0,0,1,0,0,0,0,1,5
672745176051,true,0,0,1,0,0,0,0,1,7
6591,true,0,0,1,0,0,0,0,3,0
5543031,true,0,0,1,0,0,0,0,3,2
4661689071,true,0,0,1,0,0,0,0,3,4
3920480508711,true,0,0,1,0,0,0,0,3,6
3297124107825951,true,0,0,1,0,0,0,0,3,8
We can't make this file beautiful and searchable because it's too large.
n,atomic,1,2,3,4,7,8,11,13,14
1131,true,0,0,1,0,0,0,0,1,1
951171,true,0,0,1,0,0,0,0,1,3
799934811,true,0,0,1,0,0,0,0,1,5
672745176051,true,0,0,1,0,0,0,0,1,7
6591,true,0,0,1,0,0,0,0,3,0
5543031,true,0,0,1,0,0,0,0,3,2
4661689071,true,0,0,1,0,0,0,0,3,4
3920480508711,true,0,0,1,0,0,0,0,3,6
3297124107825951,true,0,0,1,0,0,0,0,3,8
n atomic 2 3 7 9
266 true 1 0 1 1
96026 true 1 0 1 3
34665386 true 1 0 1 5
12514204346 true 1 0 1 7
4517627768906 true 1 0 1 9
1630863624575066 true 1 0 1 11
686 true 1 0 3 0
247646 true 1 0 3 2
89400206 true 1 0 3 4
@nilsso
nilsso / ichain.rs
Created August 9, 2020 22:10
Rust helper to chain two or more iterators
macro_rules! ichain {
($a:expr, $b:expr) => {
$a.chain($b)
};
($a:expr, $b:expr, $($others:expr),+) => {
$a.chain(ichain!($b, $($others),+))
};
}
import numpy as np
import matplotlib as mpl
from matplotlib import pyplot as plt
import sympy
from sympy import lambdify, latex
from sympy.parsing.sympy_parser import parse_expr
import argparse
@nilsso
nilsso / rust_notes.md
Created June 3, 2019 00:06
My notes on Rust

Crates

Dependencies

Intellij IDEA with Intellij Rust sometimes can't pickup on re-exported libraries for auto-completion. To get around this, adding a dependency and renaming it can work. For example Amethyst re-exports specs to ecs, so adding a dependency ecs = { package = "specs", version = "0.14" } gets auto-completion working on ecs::.

Proposition. Prove $(a,b)=(a,b+a)$ for all $a,b\in\mathbb{Z}$

Proof. For some $x,y\in\mathbb{Z}$. $$ d_1=(a,b)=ax+by $$

Thus $d_1$ divides both $a$ and $b$.

\begin{align*} d_2=(a,b+a)&=ax+(b+a)y\