Skip to content

Instantly share code, notes, and snippets.

@TheArcherST
TheArcherST / namedtuple_cls.py
Last active July 6, 2023 11:47
Python namedtuple, but a base class.
# https://gist.github.com/TheArcherST/fd9d924323de6e50cc7794d4a67fffd7
from typing import ClassVar, Type
from collections import namedtuple
from itertools import chain
class Namedtuple(
"""Event generation system
Assumes that we have some stream of data, and we want to synchronize
it with remote server with minimum network stress. Chosen solution is
to convert data stream to stream of data change events. This module
describes base units of convert system.
Specific features:
1. sources of the data are not eternal. when source expires, we must
accept the latest revision result.
@TheArcherST
TheArcherST / onecpy.py
Last active January 9, 2023 23:57
This script python in 1C-like format. Usage: `py onecpy.py source_code.py from to`. Currently supports languages en and ru. Example command: `py onecpy.py source.py en ru`. Converts code in `source.py` from en dialect to ru.
import dataclasses
import re
import sys
from enum import Enum
from dataclass_factory import Factory
from functools import partial
import typing
import yaml
import warnings
import os
from shutil import rmtree
class TDException(Exception):
pass
from typing import Any
from dataclasses import dataclass
class FunctionType:
const = 'const'
call = 'call'
@dataclass
from timeit import timeit
import plotly.express as px
import pandas as pd
EXPRESSIONS = [
"{v: k for k, v in data.items()}",
"dict(zip(data.values(), data.keys()))",
"new = {}\nfor k, v in data.items(): new[k] = v",
]
class Repr:
"""Repr method generator
Automatically parse object init-based definition.
To include extra fields, list them in `__repr_include__`.
>>> class User(Repr):
... __repr_include__ = ['uri']
...
... def __init__(self, uid: int, uname: str, referral: int = None):
from typing import Any, Dict, Union
from types import FunctionType
from inspect import getargs, getfullargspec
import functools
import warnings
class TypesCompilationWarning(Warning):
pass
@TheArcherST
TheArcherST / main.py
Last active December 14, 2021 20:33
Code to estimate your test results
"""
This program helps you to evaluate you test results
```input.md
1. .
2. ?
3.
4.