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 contextlib | |
from contextlib import AbstractContextManager, ExitStack | |
from functools import wraps | |
from inspect import getfullargspec | |
from typing import Any, Callable, Dict, get_type_hints, Type | |
class Depends: # todo mypy | |
def __init__(self, dependency: Any = None): | |
self.dependency = dependency |
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
# Author: David Beazley (https://www.dabeaz.com) | |
# Twitter: @dabeaz | |
from functools import reduce | |
run = lambda s: reduce(lambda *_:..., iter(lambda s=[s]: | |
(_:=s.pop()(),s.append(_))[0], None)) | |
const = lambda v,c : lambda: c(v) | |
add = lambda x,y,c : lambda: c(x+y) | |
mul = lambda x,y,c : lambda: c(x*y) |
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 typing import Any | |
from dataclasses import dataclass | |
class FunctionType: | |
const = 'const' | |
call = 'call' | |
@dataclass |
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 timeit import timeit | |
import plotly.express as px | |
import pandas as pd | |
EXPRESSIONS = [ | |
"{v: k for k, v in data.items()}", | |
"dict(zip(data.values(), data.keys()))", | |
"new = {}\nfor k, v in data.items(): new[k] = v", | |
] |
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 typing import Any, Dict, Union | |
from types import FunctionType | |
from inspect import getargs, getfullargspec | |
import functools | |
import warnings | |
class TypesCompilationWarning(Warning): | |
pass |
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
" Простая конфигурация Vim для пользователей с русско-английской клавиатурой | |
" Как правило, русскоязычных (duh) | |
" Минималистичная, минимум плагинов, но с развёрнутым описанием каждой функции, настройки и команды | |
" Работает для Vim 8.*, скомпилированного по максимуму. | |
" Чистый конфиг, без использования менеджеров плагинов. | |
" Цветовые схемы вручную копировал в папку ~/.vim/ | |
" Также, ручками добавил | |
" lightline и NERDTree в ~/.vim/pack/plugins/start, |
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 _EmbellishedBase: | |
_constructor_name: str | |
def embellished(name, definition): | |
class EmbellishedMeta(type): | |
def __repr__(self): | |
return f"embellished({self._constructor_name!r}, {definition!r})" | |
class Embellished(_EmbellishedBase, metaclass=EmbellishedMeta): |
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
" plugins | |
let need_to_install_plugins = 0 | |
if empty(glob('~/.vim/autoload/plug.vim')) | |
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs | |
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
let need_to_install_plugins = 1 | |
endif | |
call plug#begin() | |
Plug 'tpope/vim-sensible' |
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 E(BaseException): | |
def __new__(cls, *args, **kwargs): | |
return cls | |
def a(): yield | |
a().throw(E) |
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 asyncio | |
from functools import wraps | |
def dec(fn): | |
@wraps(fn) | |
async def wrapper(*args, **kwargs): | |
print(fn, args, kwargs) # <function foo at 0x10952d598> () {} | |
await asyncio.sleep(5) |
NewerOlder