Skip to content

Instantly share code, notes, and snippets.

View Bobronium's full-sized avatar
🤘
All units, rock‘n’roll!

Arseny Boykov Bobronium

🤘
All units, rock‘n’roll!
View GitHub Profile
@Bobronium
Bobronium / main.py
Created February 17, 2018 15:54
Currency Bot
print("Initializing variables")
import requests
from settings import token
import time
tlgrm_url = "https://api.telegram.org/bot{}/".format(token)
cryptonator_url = "https://api.cryptonator.com/api/ticker/"
greeting = 'Привет, я умею показывать текущий курс криптовалют. Отзываюсь на команды /btc и /eth'
offset = 0
from dataclasses import dataclass
from enum import Enum
from timeit import timeit
from typing import NamedTuple
from pydantic import BaseModel
from pydantic.dataclasses import dataclass as pydantic_dataclass
class Model(BaseModel):
import unittest
def find_longest_unique_substring(string: str) -> int:
"""
Returns length of the longest substring of unique characters
"""
max_length = 0
current_substr_chars = set()
start_index = leading_index = 0
ATTR_ACCESS:
Testing with 1000000 repeats:
>>> Qrator.FOO # 0.04096488799999998 seconds
<Qrator.FOO: FOO>
>>> BuiltinPatched.FOO # 0.038564896999999654 seconds
<BuiltinPatched.FOO: 'FOO'>
ATTR_ACCESS:
Testing with 10000 repeats, result is average of 10 tests:

    >>> NewEnum.foo  # 0.6069349023270748 ms
    <NewEnum.foo: 1>

    >>> OldEnum.foo  # 4.5089948174334005 ms
    <OldEnum.foo: 1>
@Bobronium
Bobronium / make_crud.py
Last active September 21, 2024 10:35
FastAPI CRUD fabric to reduce amount of boilerplate code
import inspect
from functools import partial
from typing import Type, Literal, Callable, Dict, TypeVar, List
from fastapi import APIRouter, Depends
# import your database base model here
# from db_model import BaseDBModel
# this part is a bit outdated since you can now use SQLModel
@Bobronium
Bobronium / better_minecraft_experience.md
Last active February 10, 2021 16:32
Better Minecraft Experience (Java Edition)

Better Minecraft Experience (Java Edition)

This is a list of various mods I use that make Minecraft experience ~1000 times better

Huge thanks to LambdAurora for his Recommended OptiFine alternatives on Fabric gist.

Installation

  1. Download and install Fabric
  2. Download any mods from list below and put them in .minecraft/mods folder

All mods in this list are compatible with each other, unless it stated otherwise

@Bobronium
Bobronium / FastTelethon.py
Created February 6, 2022 18:20 — forked from painor/FastTelethon.py
This will increase the download/upload speed when using telethon
# copied from https://github.com/tulir/mautrix-telegram/blob/master/mautrix_telegram/util/parallel_file_transfer.py
# Copyright (C) 2021 Tulir Asokan
import asyncio
import hashlib
import inspect
import logging
import math
import os
from collections import defaultdict
from typing import Optional, List, AsyncGenerator, Union, Awaitable, DefaultDict, Tuple, BinaryIO
@Bobronium
Bobronium / video_fragment_to_tg_with_subs.sh
Last active May 29, 2022 21:45
Cut out fragment of a video with burned subtitles for Telegram
input_file=in.mp4
output_file="${input_file%%.*}"-fragment."${input_file##*.}"
subs_file= # can be srt file or mkv container with subtitles
start_from=
stop_at=
duration=
# delete lines below that contain empty optional variables from above before use
# if duration is specified, '-to' or 'stop_at' is ignored
ffmpeg \
@Bobronium
Bobronium / typeid.py
Created March 5, 2024 13:51
Python TypeID implementation
from collections.abc import Sequence
from functools import cached_property
from typing import Any
from typing import ClassVar
from typing import LiteralString
from uuid import UUID
from uuid_utils import uuid7
ALPHABET = "0123456789abcdefghjkmnpqrstvwxyz"