Requires the dont
library
This file contains hidden or 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
import click | |
from math import ceil | |
COLORS = { | |
0: (0, 0, 0), | |
1: (133, 153, 0), | |
2: (42, 161, 152), | |
3: (38, 139, 210), | |
4: (108, 113, 196), | |
5: (211, 54, 130), |
This file contains hidden or 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
import inspect | |
import ast | |
import hashlib | |
import sys | |
import textwrap | |
from contextlib import contextmanager | |
def indent(line): | |
return len(line) - len(line.lstrip(" ")) |
This file contains hidden or 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
import typing | |
import fishhook | |
class IntersectionMeta(type): | |
def __instancecheck__(self, other): | |
return all(isinstance(other, t) for t in self.types) | |
def __repr__(self): | |
if hasattr(self, "types"): | |
return " & ".join(t.__name__ for t in self.types) |
This file contains hidden or 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
import sys | |
from time import sleep | |
from contextlib import contextmanager | |
@contextmanager | |
def dots(): | |
def _dots(): | |
while True: | |
for i, char in enumerate("⠁⠃⠇⡇⣇⣧⣷⣿"): | |
if i: |
This file contains hidden or 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 importlib.util import spec_from_loader, module_from_spec | |
from importlib.machinery import SourceFileLoader | |
import pytest | |
class ModuleWithoutExtension(pytest.Module): | |
def _importtestmodule(self): | |
print(self.path, type(self.path)) | |
spec = spec_from_loader(self.path.name, SourceFileLoader(self.path.name, str(self.path))) |
This file contains hidden or 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
import sys | |
import threading | |
from time import sleep | |
from typing import Annotated, get_origin, get_args | |
from collections import namedtuple | |
timeout = namedtuple("timeout", "s") |
This file contains hidden or 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
class SubscriptableSneaky: | |
def __init__(self, ns, name): | |
self.ns = ns | |
self.args = [] | |
self.name = name | |
def __getitem__(self, items): | |
if not isinstance(items, tuple): | |
items = items, | |
self.args = [item.name for item in items] |
This file contains hidden or 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
class MatchMeta(type): | |
def __instancecheck__(cls, inst): | |
return cls.isinstance(inst) | |
def matching(fn): | |
class cls(metaclass=MatchMeta): | |
isinstance = fn | |
return cls |
This file contains hidden or 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/bash | |
if (( $# > 6 )); then | |
layout=tiled | |
else | |
layout=even-vertical | |
fi | |
hosts=( "$@" ) | |
tmux new-window | |
tmux send-keys "ssh ${hosts[0]}" | |
for i in $(seq 1 $((${#hosts[@]} - 1))) |
NewerOlder