Skip to content

Instantly share code, notes, and snippets.

View mnogom's full-sized avatar
🔴
Tomato

Konstantin Freidlin mnogom

🔴
Tomato
View GitHub Profile
@mnogom
mnogom / config.py
Created September 11, 2024 08:33
Config class from env
from pathlib import Path
import os
from dotenv import load_dotenv
class BaseConfig:
def __init__(self, config_file: Path = Path("cxsdn-env")):
load_dotenv(config_file)
@mnogom
mnogom / Centos7-fix-mirrors.md
Last active March 31, 2025 11:23
Centos 7 fix yum mirrors

Shooting trouble on Centos 7 (in 2024)

https://vault.centos.org/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14]
curl#35 - "Peer reports incompatible or unsupported protocol version."

Part I

on Centos 7:

sed -i -e "s|mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/*
from __future__ import annotations
from dataclasses import dataclass
from typing import Generic, TypeVar
_HEAD_VALUE = "HEAD"
class CantGoBackError(Exception):
pass
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"