Skip to content

Instantly share code, notes, and snippets.

View Strangemother's full-sized avatar

Jay Strangemother

View GitHub Profile
/*
<div class="checkbox-wrapper">
<!-- <input type="checkbox" name="apply-background" checked=checked> -->
<input type="checkbox" class="switch" name="apply-background" checked="checked">
</div>
*/
.checkbox-wrapper .switch {
appearance: none;
background-color: #080808;
border-radius: 3em;
@Strangemother
Strangemother / example.py
Created September 9, 2025 11:30
cache tiktoken blobs
"""An example of caching tiktoken data, so I can count tokens offline.
"""
import tiktoken
import hashlib
from pathlib import Path
import shutil
import os
# from tiktoken_ext

Form Post Issue

The does not correctly post when pressing "Add to basket" on any product form page.

When hit, the form does perform a POST, with the expected data, however the cart is not updated and the page refeshes to the origin page.

A given speculative reason may have been due to the apache server hosting the wordpress, incorrectly receiving form POSTs - and mangling the body data before usage.

@Strangemother
Strangemother / dynamic_enums.py
Created December 3, 2023 20:31
Dynamic Python Enums; Create an `enum.Enum` with members defined in a `dict`
"""I saw on StackOverflow _It isn't possible_ - then I asked GPT, and it parroted the stack overflow answer.
In this example we wish to create a ready-to-use Enum extended class.
class Cooked(Enum):
POP = 'pop'
FOO = 'foo'
This, with the ability to append new enums members.
Understandably this cannot be done _after_ the Enum is defined,
@Strangemother
Strangemother / pypi push.bash
Last active November 18, 2022 00:43
When pushing to test pypi on windows, I hit a surreal bug where the `.pypirc` could not be located, but all filepaths were correct.
# my C:\Users\username\.pypirc *absolutely exists* and has the correct entry from here:
# https://packaging.python.org/en/latest/guides/using-testpypi/#setting-up-testpypi-in-pypirc
(env-django-4-0) >cat C:\Users\username\.pypirc
[distutils]
index-servers=pypi
[testpypi]
repository = https://test.pypi.org/legacy/
username=__token__
password=pypi-bigstring
@Strangemother
Strangemother / index.html
Created February 24, 2022 01:20
Perlin Disruption
<canvas id="canvas"></canvas>
@Strangemother
Strangemother / link.txt
Created January 25, 2022 15:04
share link
@Strangemother
Strangemother / dynamic_module.py
Created January 3, 2021 09:02
A module level getter/setter
"""A module level getter/setter
>>> import vmod
>>> vmod.Woof
Getting Woof...
<class 'vmod.Woof'>
>>> vmod.Woof
Getting Woof...
<class 'vmod.Woof'>
"""Create complex functional or class-based decorators without effort.
+ Capture the class of a method: `owner_class`
+ Accept arguments at create, decorate or execution
+ functional based drop-in replacement for `functools.wraps`
+ Alternative work with a class-based setup
+ no dependecies
+
A class-based decorator provides methods to override the given function.