Skip to content

Instantly share code, notes, and snippets.

View benji-york's full-sized avatar

Benji York benji-york

View GitHub Profile
from typing import Callable, TypeVar, ParamSpec, Iterable, Any
import functools
P = ParamSpec('P')
Q = TypeVar('Q')
R = TypeVar('R')
def postprocess(post_func: Callable[[Q], R]) -> Callable[[Callable[P, Q]], Callable[P, R]]:
"""A decorator that filters a function's return value through a callable.
@benji-york
benji-york / psql-srv.py
Created June 21, 2022 13:24 — forked from eatonphil/psql-srv.py
postgres "server" wire protocol example (ported python3)
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---