This gist has been migrated to a new repository, https://github.com/thegamecracks/joblin!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import annotations | |
from concurrent.futures import Future, InvalidStateError, ThreadPoolExecutor | |
from contextlib import suppress | |
from typing import Any, Callable, TypeVar | |
T = TypeVar("T") | |
R_co = TypeVar("R_co", covariant=True) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from tkinter import Event, Tk | |
from tkinter.ttk import Frame, Label | |
if sys.platform == "win32": | |
from ctypes import windll | |
windll.shcore.SetProcessDpiAwareness(2) | |
LOREM_IPSUM = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce malesuada ipsum enim, feugiat venenatis sapien tempus et. Morbi auctor egestas metus vel faucibus. Nullam in nunc nisi. Maecenas eget sagittis ante. Sed ut turpis turpis. Morbi suscipit massa ac efficitur iaculis. Suspendisse risus nisi, tempor non pulvinar sed, vehicula a sapien. Pellentesque iaculis ligula sed sapien faucibus, eget mollis magna volutpat. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Morbi porttitor luctus tellus, nec tincidunt lacus. Nunc dui eros, laoreet sed pretium id, porttitor eget nunc." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires Python>=3.11 | |
import asyncio | |
import contextlib | |
import threading | |
import unittest | |
class Event(threading.Event): # TODO: any better name? | |
"""A thread-safe event compatible with asyncio.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Dependencies: | |
Pillow>=10.3.0 | |
usage: composite.py [-h] [-s SCALE] [-o OFFSET] image | |
Create a composite of the given image and display it. | |
The window can be clicked to toggle it as an overlay. | |
You can also right click it to save the image. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Converts resistor parameters into their corrresponding color bands.""" | |
import argparse | |
from decimal import Decimal | |
# list of colors ordered by their corresponding digit (0-9) | |
DIGIT_BANDS = [ | |
"black", | |
"brown", | |
"red", |
This gist has been migrated to a repository: https://github.com/thegamecracks/iconify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires Python 3.11-3.12 | |
import asyncio, contextlib, contextvars | |
from asyncio.tasks import _PyTask | |
x = contextvars.ContextVar("x", default=1) | |
def create_pure_python_task(loop, coro, context=None): | |
return _PyTask(coro, loop=loop, context=context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import concurrent.futures | |
import threading | |
from tkinter import Event, Tk | |
from tkinter.ttk import Button | |
from typing import Self | |
class EventThread(threading.Thread): | |
"""Runs an asyncio event loop in a separate thread. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from tkinter import Event, Tk | |
from tkinter.ttk import Button, Frame, Widget | |
from typing import Literal | |
FlexboxMode = Literal["horizontal", "vertical"] | |
class Flexbox(Frame): | |
def __init__( |
NewerOlder