Skip to content

Instantly share code, notes, and snippets.

View Fuyukai's full-sized avatar
💭
-͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌

Lura Skye Fuyukai

💭
-͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌͌
View GitHub Profile

Keybase proof

I hereby claim:

  • I am fuyukai on github.
  • I am eyes (https://keybase.io/eyes) on keybase.
  • I have a public key ASAXv5uwgi22jETyqCViUhKDlHjoczct6kkxfXntVnYx4go

To claim this, I am signing this object:

"""
A custom connector, that wraps asyncpg in curio.
"""
from asyncqlio.backends.postgresql.asyncpg import AsyncpgConnector, AsyncpgResultSet, \
AsyncpgTransaction
from curio import asyncio_coroutine, AsyncioLoop
bridge_loop = AsyncioLoop(event_loop=asyncio.get_event_loop())
def patch(func):
%YAML 1.2
---
# The meta section.
# This gives some basic information about the modpack.
meta:
# The name of the modpack.
name: bobsangels
# The author of the modpack.
author: Fukkaudeku
@Fuyukai
Fuyukai / util.py
Created December 20, 2017 16:54
Scary metaprogramming
def subclass_builtin(original: type):
"""
Subclasses an immutable builtin, providing method wrappers that return the subclass instead
of the original.
"""
def get_wrapper(subclass, func):
@functools.wraps(func)
def __inner_wrapper(self, *args, **kwargs):
result = func(*args, **kwargs)
@Fuyukai
Fuyukai / splitter.py
Created December 19, 2017 17:17
Split quotes
def split_message_content(content: str, delim: str = " ") -> List[str]:
"""
Splits a message into individual parts by `delim`, returning a list of strings.
This method preserves quotes.
.. code-block:: python3
content = '!send "Fuyukai desu" "Hello, world!"'
split = split_message_content(content, delim=" ")
import sys
import asks
import curio
import traceback
from curious import Client
from curious.commands.manager import CommandsManager
from typing import Dict, Set
client = Client(token=sys.argv[1])
@Fuyukai
Fuyukai / bootstrap-py.sh
Created September 28, 2017 18:38
Bootstraps my Python install.
#!/usr/bin/env bash
# Step 1: Add ~/.local/bin to PATH if it's not there already.
if ! [[ ":$PATH:" == *":$HOME/.local/bin:"* ]]; then
export PATH=$HOME/.local/bin:$PATH
fi
# Step 2: Bootstrip pip into user directory using get-pip.py.
curl https://bootstrap.pypa.io/get-pip.py | python3 - --user
@Fuyukai
Fuyukai / classes.py
Created April 22, 2017 21:31
Bootleg classes
import functools
def gi(s, k):
try:
return s[k]
except KeyError:
raise AttributeError(k) from None
"""
A HTTP/2 interface to Kyoukai.
This uses https://python-hyper.org/projects/h2/en/stable/asyncio-example.html as a reference and a base. Massive thanks
to the authors of this page.
"""
import asyncio
import importlib
import ssl
import sys
"""
A uWSGI adapter for Kyoukai.
This allows you to run Kyoukai with uWSGI as the web server. It translates the WSGI protocol into Kyoukai itself.
"""
import asyncio
import greenlet
import functools