Skip to content

Instantly share code, notes, and snippets.

View vskrachkov's full-sized avatar

Viacheslav Krachkov vskrachkov

View GitHub Profile
@tomchristie
tomchristie / proxy.py
Created January 15, 2020 13:06
An ASGI proxy service.
import httpx
from starlette.requests import Request
from starlette.responses import StreamingResponse
class Proxy:
def __init__(self, hostname):
self.hostname = hostname
self.client = httpx.AsyncClient()
@vskrachkov
vskrachkov / pipe.py
Created January 13, 2020 22:01
python, pipe, chain, monad, functor
from typing import Callable, Union
class Pipe:
def __init__(self, callable_: Callable):
self.callable_ = callable_
def __rshift__(self, then: Union[Callable, "Pipe"]) -> "Pipe":
if not isinstance(then, Pipe):
then = Pipe(then)
@dabeaz
dabeaz / aproducer.py
Created October 17, 2019 17:46
"Build Your Own Async" Workshop - PyCon India - October 14, 2019 - https://www.youtube.com/watch?v=Y4Gt3Xjd7G8
# aproducer.py
#
# Async Producer-consumer problem.
# Challenge: How to implement the same functionality, but no threads.
import time
from collections import deque
import heapq
class Scheduler:
@bobbytables
bobbytables / build.sh
Created February 18, 2017 15:49
Protocol Buffer build script for multiple folders
#!/usr/bin/env bash
# This script is meant to build and compile every protocolbuffer for each
# service declared in this repository (as defined by sub-directories).
# It compiles using docker containers based on Namely's protoc image
# seen here: https://github.com/namely/docker-protoc
set -e
REPOPATH=${REPOPATH-/opt/protolangs}
CURRENT_BRANCH=${CIRCLE_BRANCH-"branch-not-available"}