Skip to content

Instantly share code, notes, and snippets.

View serjflint's full-sized avatar

Sergei Iakhnitskii serjflint

  • Russia, Orenburg
View GitHub Profile
@serjflint
serjflint / scratch.py
Created October 29, 2023 23:33
bench json
import json
import orjson
import pickle
import time
import contextlib
DATA = []
@contextlib.contextmanager
@serjflint
serjflint / script.sh
Created October 29, 2023 18:22
datamodel-code-generator params
python3.11 -m datamodel_code_generator --input=path/to/openapi.json \
--input-file-type=openapi --output-model-type=pydantic_v2.BaseModel \
--output=path/to/genearated.py \
--use-annotated --strict-nullable --use-standard-collections \
--use-generic-container-types --use-union-operator \
--use-schema-description --use-field-description \
--reuse-model --use-operation-id-as-name \
--target-python-version=3.11 --validation --openapi-scopes paths schemas parameters \
--enum-field-as-literal all
@serjflint
serjflint / log.txt
Created June 20, 2023 22:04
Error when cross-compiling ruff from Ubuntu to Mac
Fresh unicode-ident v1.0.9
Fresh autocfg v1.1.0
Fresh once_cell v1.17.2
Fresh cfg-if v1.0.0
Dirty bitflags v1.3.2: the config settings changed
Compiling bitflags v1.3.2
Fresh rand_core v0.6.4
Dirty static_assertions v1.1.0: the config settings changed
Compiling static_assertions v1.1.0
Running `rustc --crate-name bitflags --edition=2018 /home/serjflint/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitflags-1.3.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --diagnostic-width=203 --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto --cfg 'feature="default"' -C metadata=4dc675ba8ac0d3b0 -C extra-filename=-4dc675ba8ac0d3b0 --out-dir /home/serjflint/workspace/ruff/target/x86_64-apple-darwin/release/deps --target x86_64-apple-darwin -C linker=/home/serjflint/.cache/cargo-zigbuild/0.16.11/zigcc-x86_64-apple-darwin.sh -L dependency=/home/serjflint/workspace/ruff/target/x86_64-apple-da
@serjflint
serjflint / cases.txt
Created October 9, 2022 11:39
Useful commands for testing 04.3.HW1/vm/
simple
constant
globals
for_loop
inplace_operators
inplace_division
slice_a_b
slice_b
slice_a
slice
@serjflint
serjflint / day_18.py
Created December 18, 2021 09:21
Day 18 Try 2
import copy
import functools
import typing as tp
Value = tp.Union[int, tp.List]
Pair = tp.List[Value]
def loader(lines: tp.Iterable[str]):
@serjflint
serjflint / day_18.py
Created December 18, 2021 09:20
Day 18 Try 1
import copy
import functools
import typing as tp
Value = tp.Union[int, tp.List]
Pair = tp.List[Value]
def loader(lines: tp.Iterable[str]):
@serjflint
serjflint / build.bat
Created August 11, 2020 07:01
Trio multi-thread file update idling
pyinstaller --onefile --noconfirm --hiddenimport=win32timezone ^
--hiddenimport=pkg_resources.py2_warn --hiddenimport=win32serviceutil ^
--noupx --uac-admin --name=AG_Loader cli.py
@serjflint
serjflint / pyproject.toml
Created August 1, 2020 06:37
Pyproject.toml
[tool.poetry]
name = "zkd"
version = "0.1.0"
description = ""
authors = ["Sergei Iakhnitskii <serjflint@gmail.com>"]
[tool.poetry.dependencies]
python = "^3.6"
cython = "^0.29.21"
geohash-hilbert = "^1.4.0"
@serjflint
serjflint / trio_lru_cache.py
Created July 31, 2020 18:00
This gist is 100% port of Python built-in function functools.lru_cache for trio
import threading
import weakref
from collections import namedtuple
from functools import update_wrapper
import trio
# Idea of using weakref, trio.Lock and thread-local storage is given by Nathaniel J. Smith <njs@pobox.com>