Skip to content

Instantly share code, notes, and snippets.

View 1ort's full-sized avatar
👩‍💻
Constantly learning

Daniil 1ort

👩‍💻
Constantly learning
View GitHub Profile
@1ort
1ort / .p10k.zsh
Last active June 19, 2024 09:20
zshrc
# Generated by Powerlevel10k configuration wizard on 2023-07-25 at 02:13 +05.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 28361.
# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 24h time,
# 2 lines, dotted, left frame, darkest-ornaments, sparse, few icons, fluent,
# transient_prompt, instant_prompt=quiet.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
# your own config based on it.
#
from dataclasses import dataclass
import pickle
import io
@dataclass(frozen=True)
class Foo:
x: int
@dataclass(frozen=True)
class Bar:
@1ort
1ort / markov.py
Created April 16, 2024 08:44
Simple name generation via markov's chains
import random
from collections import defaultdict
from itertools import islice
def batched(iterable, n):
"Batch data into tuples of length n. The last batch may be shorter."
# batched('ABCDEFG', 3) --> ABC DEF G
if n < 1:
raise ValueError('n must be at least one')
def anekdot(muzhik: Human) -> Humor:
shlyapa: Hat = muzhik.buy_shlyapa()
if shlyapa.is_kak_raz(muzhik.head):
return Humor.SMESHNO
return Humor.NESMESHNO
from collections.abc import MutableSequence
from typing import Optional
class SequenceView(MutableSequence):
def __repr__(self):
return f"SequenceView([{list(self)}])"
def __str__(self):
return str(list(self))
import itertools
from typing import Iterable
def apply_period(word: str, positions: Iterable[int]) -> str:
for index, position in enumerate(positions):
position += index
word = word[:position] + "." + word[position:]
return word
@1ort
1ort / starlette_server.py
Last active March 20, 2023 09:10
Starlette webhook server for aiogram3
import asyncio
from abc import ABC, abstractmethod
from typing import Any, Dict, Optional, Tuple
from starlette.applications import Starlette
from starlette.exceptions import HTTPException
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
from starlette.requests import Request
from starlette.responses import JSONResponse, Response
disp = {
"button_1": (
"Вы выбрали организацию транспортировки.",
[
guild.get_role(config.ROLE_ID_TheHeadInnkeeper),
guild.get_role(config.ROLE_ID_TheRoyalFamily),
guild.get_role(config.ROLE_ID_Courier),
guild.get_role(config.ROLE_ID_Porter),
guild.get_role(config.ROLE_ID_Security),
guild.get_role(config.ROLE_ID_Technician),
@1ort
1ort / anekdot.go
Last active February 5, 2023 00:11
func anekdot(muzhyk Human) humor {
shlyapa := muzhyk.buyShlyapa()
if shlyapa.Size == muzhyk.Head.Size {
return Smeshno
} else {
return NeSmeshno
}
}
@1ort
1ort / pipeline.go
Created January 25, 2023 01:36
go pipeline boilerplate using generics
package pipeline
import "errors"
/*
Usage:
myPipeline := NewPipeline(
NewMyEmitter()
)
.Plug(