This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from asyncio import run | |
from os import environ | |
from atproto import AsyncClient, client_utils, models | |
def chunked(text, *, size): | |
buf = [] | |
for ln in text.splitlines(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Coroutines</title> | |
</head> | |
<body> | |
<div id="root"></div> | |
<script src="index.jsx" async type="module"></script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from random import Random | |
from itertools import combinations, chain | |
from collections import defaultdict, Counter | |
from statistics import mean | |
letters = {1: 'aeilnorstu', 2: 'dg', 3: 'bcmp', 4: 'fhvwy', 5: 'k', 8: 'jx', 10: 'qz'} | |
tiles = {v: k for k, vs in letters.items() for v in vs} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
identity="${1:?Must supply identity file for `age` or '-' for first run}" | |
target="${@[2,-1]}" | |
setup() { | |
mkdir -p ~/public | |
if [[ -e /tmp/.identity ]]; then | |
unzip -d ~/public -o /tmp/.vault >/dev/null 2>&1 | |
age -d -i /tmp/.identity ~/public/.private 2>/dev/null | tar -C ~ -I zstd -xf - >/dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
script() { | |
typeset -A expected=( | |
a 0 | |
b 1 | |
c 5 | |
"d d" 10 | |
) | |
mkdir -p "${(@k)expected}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from numpy.random import default_rng | |
from pandas import Series, date_range, MultiIndex, Index, to_timedelta | |
from string import ascii_lowercase | |
rng = default_rng(0) | |
s = Series( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass, field, replace | |
from collections import namedtuple, defaultdict | |
from itertools import count | |
from collections.abc import Generator | |
from contextlib import contextmanager | |
from time import perf_counter | |
from networkx import DiGraph | |
@dataclass(frozen=True) | |
class timer: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from dataclasses import dataclass | |
@dataclass | |
class Ctx: | |
mode : bool = True | |
def __post_init__(self): | |
if (mode := self.mode): | |
cls = type(self) | |
self.__class__ = type( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from functools import wraps | |
from itertools import islice, tee, zip_longest, chain, product | |
from collections import deque | |
from pandas import DataFrame | |
nwise = lambda g, *, n=2: zip(*(islice(g, i, None) for i, g in enumerate(tee(g, n)))) | |
nwise_longest = lambda g, *, n=2, fv=object(): zip_longest(*(islice(g, i, None) for i, g in enumerate(tee(g, n))), fillvalue=fv) | |
first = lambda g, *, n=1: zip(chain(repeat(True, n), repeat(False)), g) | |
last = lambda g, *, m=1, s=object(): ((y[-1] is s, x) for x, *y in nwise_longest(g, n=m+1, fv=s)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
code="$(<<-EOF | |
#!/usr/bin/env python3 | |
from logging import getLogger, INFO, basicConfig | |
from sys import version_info | |
def g(): | |
raise StopIteration() |
NewerOlder