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
diameter_small = 3.3; | |
diameter_big = 4.2; | |
distance = 15.5; | |
border = 2; | |
thickness = 0.8; | |
$fn = 80; | |
difference() { | |
hull() { |
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 collections.abc | |
match []: | |
case collections.abc.Iterable(): | |
print('iterable!') | |
case _: | |
print('default :/') |
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 | |
@typing.runtime_checkable | |
class SomeProtocol(typing.Protocol): | |
def foo(self): ... | |
class Hello: | |
def foo(self): |
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
def expand(value): | |
args = [] | |
escape = False | |
end_section = None | |
section = '' | |
for c in value: | |
# previous character was \, just append this one | |
if escape: | |
section += c | |
escape = False |
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
#!/usr/bin/env python | |
import pathlib | |
import subprocess | |
import time | |
# paired with fan speed (0-255) and temp (degrees C) | |
f_low_speed = 40 | |
f_low_temp = 35 |
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 | |
from typing import Generic, List, Optional, Set | |
T = typing.TypeVar('T') | |
class Grouper(Generic[T]): | |
def __init__(self) -> None: |
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 Memory(): | |
@dataclasses.dataclass | |
class Pool(): | |
offset: int | |
size: int | |
def __contains__(self, other: Any) -> bool: | |
return isinstance(other, int) and self.offset <= other <= (self.offset + self.size) | |
def __init__(self, default_align: int = 0) -> None: |
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
def escape_error_handler(func): | |
def new_func(*args, **kwargs): | |
try: | |
return func(*args, **kwargs) | |
except: | |
import traceback | |
print() | |
traceback.print_exc() | |
import os | |
os._exit(1) |
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 | |
def get_caller(level=1): | |
return inspect.stack()[level+1][3] | |
def log_call(func): | |
parameter_names = [ | |
parameter.name for parameter in inspect.signature(func).parameters.values() | |
] | |
def small_repr(value): |
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 cached_property(object): # type: ignore | |
def __init__(self, func): | |
self._func = func | |
def __get__(self, instance, owner): | |
attr = self._func(instance) | |
setattr(instance, self._func.__name__, attr) | |
return attr |