Skip to content

Instantly share code, notes, and snippets.

View Rooba's full-sized avatar
😸

Ra Rooba

😸
  • mushroomgame
View GitHub Profile
@Rooba
Rooba / class_wrapper.py
Created September 18, 2022 15:54
wrapper which works for normal views and class based views
from typing import Callable
from sanic.blueprints import Blueprint
from sanic.request import Request
from sanic import Sanic, text
from sanic.response import HTTPResponse
from sanic.views import HTTPMethodView
from sanic_ext.extensions.templating import render
def template(
@Rooba
Rooba / extendable.py
Created August 18, 2022 00:54
extending python enums
from enum import IntFlag, EnumMeta
class BaseExt(IntFlag):
__extending__ = None
@classmethod
def append(cls, members: list[tuple[str, int]]):
_members = BaseExt(cls.__name__, members)
for member in _members:
@Rooba
Rooba / wrap_hell.py
Last active November 25, 2021 23:04
from queue import Queue
from threading import Thread
def threaded_task(fn):
fn.queue = Queue()
def worker():
while True:
self, num = fn.queue.get()