Skip to content

Instantly share code, notes, and snippets.

@JeroenPeterBos
JeroenPeterBos / asyncio_utils.py
Last active April 5, 2024 08:23
Run synchronous code inside asynchronous context without blocking the event loop
import asyncio
from asyncio import AbstractEventLoop
from concurrent.futures import Executor
import functools
from typing import Any, Callable, Coroutine, TypeVar
R = TypeVar("R")
@JeroenPeterBos
JeroenPeterBos / Makefile
Last active September 24, 2023 13:25
Makefile - Auto Documentation Magic
.PHONY: help
.DEFAULT_GOAL := help
COMMAND_TEXT_WIDTH=17
help: ## Show this help message
@printf "\n\033[1;31mProject Maintenance Commands\033[0m\n\n"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m %-${COMMAND_TEXT_WIDTH}s \033[0m %s\n", $$1, $$2}'
@printf "\n"