Skip to content

Instantly share code, notes, and snippets.

View mnogom's full-sized avatar
🔴
Tomato

Konstantin Freidlin mnogom

🔴
Tomato
View GitHub Profile
class Parent
...
@classmethod
def __init_subclass__(cls, **kwargs):
dir_subclass = set(field for field in dir(cls) if not field.startswith(f"_{cls.__name__}__"))
dir_base = set(field for field in dir(cls.__base__))
extra_dir = dir_subclass.difference(dir_base)
if extra_dir:
raise CellCantHasExtraFieldException(
from abc import abstractmethod
from typing import Protocol, Callable, Any, runtime_checkable
@runtime_checkable
class LoggerProtocol(Protocol):
@abstractmethod
def echo(self, msg: str) -> None:
...
@mnogom
mnogom / UploadFileComponent.vue
Last active July 26, 2022 10:20
Vue component to upload text file (styled with bootstrap). Press button to choose file or drag&drop it. With refactoring can be used for multiple file.
// Child (UploadFileComponent.vue)
// TODO: finish setActive and setInactive methods
<template>
<div
id="upload-zone"
class="col-1 mt-2 py-5 border w-100 bg-light rounded"
@dragover.prevent
@dragenter="setActive"
@dragleave="setInactive"