Skip to content

Instantly share code, notes, and snippets.

View FFY00's full-sized avatar
🌈
struggling to live

Filipe Laíns FFY00

🌈
struggling to live
View GitHub Profile
import collections.abc
match []:
case collections.abc.Iterable():
print('iterable!')
case _:
print('default :/')
import typing
@typing.runtime_checkable
class SomeProtocol(typing.Protocol):
def foo(self): ...
class Hello:
def foo(self):
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
#!/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
import typing
from typing import Generic, List, Optional, Set
T = typing.TypeVar('T')
class Grouper(Generic[T]):
def __init__(self) -> None:
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:
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)
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):
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
import importlib
import types
from typing import Any, Callable
class _staticproperty():
def __init__(self, fget=None, fset=None, fdel=None, doc=None):
self.fget = fget
self.fset = fset