Skip to content

Instantly share code, notes, and snippets.

View ooliver1's full-sized avatar
💀
I very much forgor

Oliver Wilkes ooliver1

💀
I very much forgor
View GitHub Profile
@ooliver1
ooliver1 / singleton.py
Created October 15, 2023 17:22
Here is your singleton implementation
Singleton = type("Singleton", (), {"instance": None, "__new__": lambda cls: (cls.instance if cls.instance else (self := super(Singleton, cls).__new__(cls), setattr(cls, "instance", self))[0])})
@ooliver1
ooliver1 / pydis-cj-2023-qualifier.py
Created August 16, 2023 17:15
My Python Discord codejam qualifier solution
# I haven't used numpy at all outside of tutorials years ago. They may have better perf
# instead of cropping but I don't really care to try that out. My funky part is the `map`
# which lazily gets each item (the thing which doesn't even need to be lazy, the cropping
# really should.
import functools
import operator
from PIL import Image
def valid_input(
@ooliver1
ooliver1 / theme.css
Last active August 16, 2023 20:12
Discord dark theme for https://next.elu.pages.dev/
:root {
--brand-260: hsl(235, 86.2%, 88.6%);
--brand-500-hsl: 235 85.6% 64.7%;
--primary-230: hsl(210, 9.1%, 87.1%);
--primary-560: hsl(225, 6.3%, 23.5%);
--primary-600: hsl(223, 6.7%, 20.6%);
--primary-630: hsl(220, 6.5%, 18.0%);
--primary-700: hsl(225, 6.3%, 12.5%);
--primary-730: hsl(225, 7.1%, 11%);
--primary-860-hsl: 240 7.7% 2.5%;
@ooliver1
ooliver1 / callable.py
Created March 4, 2023 15:50
Python callable typehints with defined initial arguments and undefined (...) arguments after.
from collections.abc import Callable
from typing import Any, Concatenate, ParamSpec, TypeVar
from typing_extensions import reveal_type
P = ParamSpec("P")
T = TypeVar("T")
Call = Callable[P, Any]
@ooliver1
ooliver1 / printer.cfg
Last active November 9, 2022 17:54
My config for the Ender 3 Pro (old) + BTT SKR E3 + E3D Hemera
# This file contains common pin mappings for the BIGTREETECH SKR mini
# E3 v1.2. To use this config, the firmware should be compiled for the
# STM32F103 with a "28KiB bootloader" and USB communication. Also,
# select "Enable extra low-level configuration options" and configure
# "GPIO pins to set at micro-controller startup" to "!PC13".
# The "make flash" command does not work on the SKR mini E3. Instead,
# after running "make", copy the generated "out/klipper.bin" file to a
# file named "firmware.bin" on an SD card and then restart the SKR
# mini E3 with that SD card.
(lambda a: lambda v: a(a, v))(lambda f, value: f(f, value * 2))(initial)
@ooliver1
ooliver1 / oneline.py
Last active December 3, 2023 19:12
my oneline madness I need to save forever: from adventofcode onelineofcode self-challenge in nextcord (https://discord.gg/nextcord :0)
print(int(((lambda a: lambda v: a(a, v))(lambda f, stuff: f(f, [[digits for digits in stuff[0] if digits[stuff[1]] == (max({v[stuff[1]] for v in stuff[0]}, key=[v[stuff[1]] for v in stuff[0]].count) if [v[stuff[1]] for v in stuff[0]].count("0") != [v[stuff[1]] for v in stuff[0]].count("1") else "1")], stuff[1] + 1]) if len([digits for digits in stuff[0]if digits[stuff[1]] == (max({v[stuff[1]] for v in stuff[0]}, key=[v[stuff[1]] for v in stuff[0]].count) if [v[stuff[1]] for v in stuff[0]].count("0") != [v[stuff[1]] for v in stuff[0]].count("1") else "1")]) != 0 and stuff[1] < 12 else stuff[0]))([list(open("input3.txt").readlines()), 0])[0], base=2) * int(((lambda a: lambda v: a(a, v))(lambda f, stuff: f(f, [[digits for digits in stuff[0] if digits[stuff[1]] == (min({v[stuff[1]] for v in stuff[0]}, key=[v[stuff[1]] for v in stuff[0]].count) if [v[stuff[1]] for v in stuff[0]].count("0") != [v[stuff[1]] for v in stuff[0]].count("1") else "0")], stuff[1] + 1]) if len([digits for digits in stuff[0] if digits[stuff