Skip to content

Instantly share code, notes, and snippets.

@w495
w495 / non-trivial-reverse.c
Created January 16, 2019 18:34
Non-trivial reverse with offset and limit
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef unsigned char byte_t;
static const byte_t offset = 1;
static const byte_t limit = 4;
@w495
w495 / base_function.py
Created March 5, 2020 18:48
Пример использования приватных методов модуля в классе
# coding: utf-8
import logging
__logger = logging.getLogger(__name__)
def global_function():
__logger.error('global_function')
@w495
w495 / base_function.py
Last active March 5, 2020 19:17
Простой пример добавление атрибута через метакласс
# coding: utf-8
import logging
class AddLoggerMeta(type):
def __new__(mcs, class_name, bases, attr_dict):
attr_dict[f'_{class_name}__logger'] = logging.getLogger(class_name)
return super().__new__(mcs, class_name, bases, attr_dict)
@w495
w495 / manjaro-dolphin-shortcut.shortcuts
Last active November 15, 2020 02:54
Manjaro KDE shortcuts for Dolphin that is compatible with Konsole shortcuts. The problem was described here: https://unix.stackexchange.com/questions/605671/key-sequence-ambiguous-in-konsole
[Shortcuts]
activate_last_tab=Alt+0
activate_next_tab=Ctrl+PgDown; Ctrl+]; Ctrl+Tab
activate_prev_tab=Ctrl+PgUp; Ctrl+[; Ctrl+Shift+Tab
activate_tab_0=Alt+1
activate_tab_1=Alt+2
activate_tab_2=Alt+3
activate_tab_3=Alt+4
activate_tab_4=Alt+5
activate_tab_5=Alt+6
@w495
w495 / complex_validation_for_pydantic_1.py
Last active July 25, 2024 12:52
Validation example with connected fields
import logging
from typing import TypeVar, Literal
from pydantic import BaseModel, root_validator
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
class TestMarkup(BaseModel):