Skip to content

Instantly share code, notes, and snippets.

View i-am-unknown-81514525's full-sized avatar

i-am-unknown-81514525

  • United Kingdom
  • 13:30 (UTC)
View GitHub Profile
import builtins
import io
import sys
import types
from ctypes import py_object
#from forbiddenfruit import curse
from typing import Never, Type, Optional, Any, Callable
class __MISSING_BASE(type):...
@i-am-unknown-81514525
i-am-unknown-81514525 / comp.py
Created May 31, 2025 21:43
d.py related: compare local slash command against discord server record
# !!! Any check checks for they are not the same
from typing import Mapping
class __X(type):...
class MISSING(__X, metaclass=__X):
def __new__(cls, *args, **kwargs):
return cls
def __init__(self, *args, **kwargs):...
MISSING.__class__ = MISSING
@i-am-unknown-81514525
i-am-unknown-81514525 / mutex_class.py
Last active May 30, 2025 15:26
Python Class Mutex via MRO
from typing import Callable
from random import choices
from itertools import permutations
registry: dict[type, tuple[type, Callable, Callable]] = {} # old: (new, ori_init, ori_init_subclass)
rev_registry: dict[type, type] = {}
__lock: bool = False
__inner: bool = False
def get_latest_from_reg(cls: type):
while cls in registry:
@i-am-unknown-81514525
i-am-unknown-81514525 / base.py
Created May 28, 2025 00:48
d.py DynamicItem Base Class implementation
from typing import Callable, Coroutine, Type, TypeVar, Self, overload, Any, Optional, Generic, ParamSpec
K = TypeVar("K", bound=Item)
R = TypeVar("R", bound="BaseOnboardingDynamicItem")
P = ParamSpec("P")
class BaseOnboardingDynamicItem(DynamicItem[K], Generic[K], template=r"onboarding::(\d+)::(\d+)::[a-zA-Z\d_]*::(\d+)"):
ACTIONS: dict[Type["BaseOnboardingDynamicItem"], str] = {}
generate_appearance: Callable[[P], ...]
{
"latest-preset": {
"theme": "seti",
"backgroundColor": "#ADB7C1",
"windowTheme": "none",
"windowControls": true,
"fontFamily": "Hack",
"fontSize": "11px",
"lineNumbers": true,
"firstLineNumber": 1,
@i-am-unknown-81514525
i-am-unknown-81514525 / ProgramD10.cs
Last active December 10, 2024 20:38
AOC csharp one-line
using System;
using System.Linq;
using System.IO;
namespace D10
{
internal class Program
{
static int P1(string[] d, int r = -1, int c = -1, Tuple<int, int>[] prev = null) => prev == null
? Enumerable.Range(0, d.Length)
.Where(nr => d[nr] != "")
@i-am-unknown-81514525
i-am-unknown-81514525 / signals.py
Created November 2, 2024 13:59
A single file which allow data communication through asyncio Future
"""
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
@i-am-unknown-81514525
i-am-unknown-81514525 / bellman-ford.py
Last active July 4, 2024 01:10
Bellman Ford method without require terminating after n-1 sweep and fix negative cycle loop
from __future__ import annotations
import decimal
from typing import Union, Optional, Mapping
class Node:
def __init__(self, name: str, connection: Optional[Mapping[Union[str, Node], Union[float, int, decimal.Decimal]]]):
self.name = name
self.connection: dict[str, Union[float, int, decimal.Decimal]] = \
@i-am-unknown-81514525
i-am-unknown-81514525 / esoter_compile.py
Last active February 28, 2024 16:18
Esoteric Code Generator (Convert python code to a one-linear with only symbol and 5 a-z character)
import math
import traceback
from typing import Callable
COMPILING = 'hi.py'
OUT = 'out-hi.py'
# Normal style
repr_1 = '-~(()<())'
num_repr = {
@i-am-unknown-81514525
i-am-unknown-81514525 / esoter.py
Last active February 25, 2024 22:30
Esoteric Number Generator
import math
import traceback
from typing import Callable
# Normal style
repr_1 = '-~(()<())'
num_repr = {
0: f'({repr_1}>>{repr_1})',
1: f'{repr_1}',
2: f'({repr_1}<<{repr_1})',