Skip to content

Instantly share code, notes, and snippets.

View vmagamedov's full-sized avatar
💥
War time

Volodymyr Magamedov vmagamedov

💥
War time
View GitHub Profile
@vmagamedov
vmagamedov / progress.tsx
Created February 28, 2023 18:31
nprogress alternative for showing page loading progress in SPA application
import { styled } from "@linaria/react";
import * as React from "react";
import { useLayoutEffect, useState } from "react";
import { useNavigation } from "react-router";
const Bar = styled.div<{ barPosition: number }>`
pointer-events: none;
opacity: ${(props) => (props.barPosition === 80 ? "1" : "0")};
position: fixed;
top: 0;
import asyncio
from contextvars import ContextVar
from opentelemetry import trace
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.trace import get_tracer, SpanKind
from opentelemetry.context import attach, detach
from opentelemetry.propagate import extract
@vmagamedov
vmagamedov / rich_text.py
Last active August 25, 2020 14:11
Allows easy rich text translation
import re
from functools import partial
from markupsafe import Markup, escape
_RE = re.compile(r'\[([\w\s]*)\|\s*([a-z0-9_]+)\s*\]')
def rich_text(text, **params):
import grpc
import grpc_testing
from google.protobuf import symbol_database
class _UnaryUnary:
def __init__(self, server, method_descriptor):
self._server = server
self._method_descriptor = method_descriptor
"""
This library can help you debug your asyncio application, to understand who
blocks event loop.
Install parameters:
- ``total_threshold`` (seconds, 0.1 by default) - we analyze callbacks which
took longer than this time to execute
- ``func_threshold`` (seconds, 0.01 by default) - we log functions which took
longer that this time to execute (total time)

Serverless и Boilerplate

Классика

Стек классического приложения:

  • Функции
  • Роутинг урлов
01e8e2aa-cd8c-c37e-4689-5db093f8847f
01e8e2aa-cd8c-c6bc-4689-5db093f88480
01e8e2aa-cd8c-c842-4689-5db093f88481
01e8e2aa-cd8c-c98c-4689-5db093f88482
01e8e2aa-cd8c-cb30-4689-5db093f88483
gen_uuid() -> 0.047747763
uuid.uuid1() -> 0.06972335500000001
uuid.uuid4() -> 0.10280339599999999
ObjectId() -> 0.05833711899999999
uuid0.generate() -> 0.12896245299999998
export PYTHON_VERSION="3.7.1"
export PYTHON_PIP_VERSION="18.1"
export SYSTEM_PACKAGES=""
export SYSTEM_DEV_PACKAGES=""
export PYTHON_PACKAGES="$1"
export PYTHON_GPG_KEY="0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D"
apt-get update
apt-get install -y --no-install-recommends ca-certificates netbase ${SYSTEM_PACKAGES}
@vmagamedov
vmagamedov / pylons_debugger.py
Created May 14, 2018 16:13
Werkzeug debugger for Pylons/Paste apps
import pylons
from webob import Request
from paste.registry import RegistryManager
from werkzeug.debug import DebuggedApplication
from werkzeug.serving import run_simple
def pylons_controller(environ, start_response):
1/0
from functools import wraps
import re
from hiku.graph import GraphTransformer, apply
from hiku.graph import Field, Link, Graph, Root, Node, Option
from hiku.types import Sequence, TypeRef
from hiku.query import Field as QueryField
from hiku.engine import Engine
from hiku.result import denormalize