Skip to content

Instantly share code, notes, and snippets.

View wyfo's full-sized avatar

Joseph Perez wyfo

View GitHub Profile
@wyfo
wyfo / asyncio-select.py
Last active October 22, 2024 16:12
Python asyncio select implementation
import asyncio
import collections.abc
import inspect
import random
import typing
@typing.overload
def select[T](
awaitables: collections.abc.Sequence[collections.abc.Awaitable[T]],
@wyfo
wyfo / atomic_waker.rs
Last active July 10, 2023 05:11
`AtomicWaker` optimized implementation
#![no_std]
use core::{
cell::UnsafeCell,
mem::MaybeUninit,
sync::atomic::{AtomicU8, Ordering},
task::Waker,
};
const EMPTY: u8 = 0b000;
@wyfo
wyfo / one_of.py
Last active October 14, 2022 20:10
GraphQL @OneOf directive implementation in Python using graphql-core
"""
This example shows an implementation of the @oneOf directive proposed here:
https://github.com/graphql/graphql-spec/pull/825.
It requires Python 3.9 and graphql-core 3.1.3 (https://github.com/graphql-python/graphql-core).
Although the directive support can be implemented out of the box when used in a field
definition, its use in input object type definition requires a specific graphql-core
feature custom output types of input object types
(https://graphql-core-3.readthedocs.io/en/latest/diffs.html#custom-output-types-of-input-object-types).