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
class Env(jinja2.sandbox.SandboxedEnvironment):
def is_safe_attribute(self, obj, attr, value):
if isinstance(obj, basestring) and attr == 'format':
return False
return super(Env, self).is_safe_attribute(obj, attr, value)

Setup

$ git clone https://gist.github.com/256bcfd64e47b27507d7.git
$ cd 256bcfd64e47b27507d7
$ virtualenv env && source env/bin/activate
$ pip install https://github.com/vmagamedov/kinko/archive/master.zip
$ npm install --save-dev browser-sync gulp gulp-stylus
$ gulp
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
@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
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}
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

Serverless и Boilerplate

Классика

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

  • Функции
  • Роутинг урлов
"""
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)
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
@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):