Skip to content

Instantly share code, notes, and snippets.

View AstraLuma's full-sized avatar
🐍
snek snek snek snek

Jamie Bliss AstraLuma

🐍
snek snek snek snek
View GitHub Profile
@AstraLuma
AstraLuma / tocxml.py
Created June 15, 2025 21:25
build TOC files next to sphinx xml
import docutils
from docutils.io import StringOutput
import sphinx.builders.xml
class TOCXMLBuilder(sphinx.builders.xml.XMLBuilder):
name = "tocxml"
def write_doc(self, docname: str, doctree: docutils.nodes.document):
print(f"write_doc {docname=} {doctree=}")
@AstraLuma
AstraLuma / index.html
Created June 5, 2025 20:47
Service worker synthesizing a response
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width" />
<title>Service worker demo</title>
</head>
import collections.abc
import sys
class FooneList(collections.abc.MutableSequence):
def __init__(self, *keys: str):
self._store = sys._getframe(1).f_locals
self._keys = keys
def __getitem__(self, index):
return self._store[self._keys[index]]
@AstraLuma
AstraLuma / crowsnest.conf
Last active January 20, 2025 01:26
Ender 3 Configs
#### crowsnest.conf
#### This is a typical default config.
#### Also used as default in mainsail / MainsailOS
#### See:
#### https://github.com/mainsail-crew/crowsnest/blob/master/README.md
#### for details to configure to your needs.
#####################################################################
#### #####
#!/usr/bin/env python3
"""
Uses GitHub's contributions APIs to summarize your activity on GitHub.
Leaves a stats.json with the stats of each block of time.
Must have the GitHub CLI installed and authenticated.
"""
import datetime
import json
@AstraLuma
AstraLuma / example.kdl
Created April 18, 2024 01:52
KDL for Misbehave
Import MoveForward="my_actions.MoveForward" Rotate="my_actions.Rotate"
Tree "foo" {
Sequence {
IncreaseValue "behavior_tree_runs"
MoveForward 10
Rotate 90
}
}
@AstraLuma
AstraLuma / channels.py
Last active April 9, 2025 23:45
Python Server-Sent Events/EventSource Implementations
# For Django Channels
import json
from channels.exceptions import StopConsumer
from channels.generic.http import AsyncHttpConsumer
from django.utils.http import parse_header_parameters
from django.utils.http import parse_header_parameters
@AstraLuma
AstraLuma / pixels.html
Created June 27, 2023 15:52
Pixels dice quick vanilla page
<!doctype html>
<html>
<head><title>Pixels Quickie</title></head>
<body>
<script type=module>
import {
requestPixel
} from "https://unpkg.com/@systemic-games/pixels-web-connect?module";
@AstraLuma
AstraLuma / main.py
Created March 29, 2023 20:06
Paramiko server based on socketserver
#!/usr/bin/env python3
import base64
import logging
import paramiko
from paramiko.agent import AgentServerProxy
from paramiko.sftp import SFTP_NO_SUCH_FILE
from paramikosocket import SocketServerInterface, run_server
@AstraLuma
AstraLuma / flac-encode.py
Created February 16, 2023 05:58
StreamBeats OBS web page
#!/usr/bin/env python3
"""
This looks in its directory for files. It looks in the format
`playlist/artist/album/1. title.ext`, allowing components to be omitted.
Requires ffmpeg.
"""
import os
from pathlib import Path
import re