Skip to content

Instantly share code, notes, and snippets.

@parity3
parity3 / InotifyWrapper.py
Created December 30, 2019 16:59
use of trio wait_readable and inotify_simple
import functools
import logging
import os
import struct
from typing import Dict, cast, Optional, List
import cytoolz
from trio.hazmat import wait_readable
import inotify_simple
import trio
@parity3
parity3 / pub_sub.py
Last active December 31, 2019 01:39
publish-subscribe with sequential async delivery
from contextlib import asynccontextmanager
import trio
class broadcaster:
def __init__(self):
super().__init__()
self.subscribers = {}
async def __aenter__(self):
@parity3
parity3 / quart-trio-triopg.py
Created January 19, 2020 22:37
running quart-trio inside trio_asyncio.run
import logging
import sys
import trio, trio_asyncio, asyncio
from hypercorn.trio.run import worker_serve
from hypercorn import Config
import contextlib
import math
from types import TracebackType
from quart import current_app, json
import functools
import logging
import os
import struct
from typing import Dict, cast, Optional, List
import cytoolz
from trio.hazmat import wait_readable
import inotify_simple
import trio
@parity3
parity3 / unpriv.sh
Created December 1, 2023 04:41
Create and switch to a user matching the owner of the first bind mount
#!/usr/bin/env bash
set -o pipefail
set -e
set -x
function _get_userid_from_mounts() {
type -fp awk >/dev/null || return 1
local mountpath
local folder_uid
while read -r mountpath ; do