Skip to content

Instantly share code, notes, and snippets.

@dmwyatt
dmwyatt / rongta-rp820-notes.md
Last active November 2, 2026 03:22
Rongta RP820 network receipt printer: working notes (python-escpos, code pages, network setup)

Rongta RP820 network receipt printer: working notes

Notes from getting a Rongta RP820 (80mm thermal, Ethernet) working from Python over the network. Everything is marked by how well it is known, because good documentation for this model is hard to find.

  • Tested: seen working on this printer.
  • Documented: from Rongta or another published source, not tested here.
  • Unknown: not settled yet.

Quick start

@dmwyatt
dmwyatt / nomic-xrt-compare.sh
Last active August 29, 2026 19:44
Cross-runtime check: llama.cpp/Metal nomic vectors vs grans ONNX vectors
#!/usr/bin/env bash
# Cross-runtime check: do llama.cpp/Metal nomic vectors agree with the ONNX
# vectors grans stored on Windows? Input: xrt-sample.jsonl (one JSON object per
# line with "text", "vector", optional "tokens"/"id").
# Usage: bash nomic-xrt-compare.sh xrt-sample.jsonl
set -euo pipefail
SAMPLE="${1:?path to xrt-sample.jsonl}"
MODEL_DIR="${MODEL_DIR:-$HOME/.cache/nomic-gguf}"
WORK="$(mktemp -d)"
SEP='<#sep#>'
@dmwyatt
dmwyatt / nomic-metal-bench.sh
Last active August 29, 2026 18:59
nomic-embed-text-v1.5 Metal vs CPU throughput on Apple Silicon (llama-bench)
#!/usr/bin/env bash
# Metal vs CPU throughput for nomic-embed-text-v1.5 on Apple Silicon via llama.cpp.
# Usage: bash nomic-metal-bench.sh
set -euo pipefail
MODEL_DIR="${MODEL_DIR:-$HOME/.cache/nomic-gguf}"
MODEL="$MODEL_DIR/nomic-embed-text-v1.5.f16.gguf"
URL="https://huggingface.co/nomic-ai/nomic-embed-text-v1.5-GGUF/resolve/main/nomic-embed-text-v1.5.f16.gguf"
if ! command -v llama-bench >/dev/null; then
@dmwyatt
dmwyatt / cursor-unofficial-api.md
Created April 5, 2026 21:20
Unofficial Cursor dashboard usage API documentation (reverse-engineered endpoints, auth, pagination)

Cursor Dashboard Unofficial API

These are undocumented endpoints used by the Cursor dashboard at https://cursor.com/dashboard/usage. They are not part of any public API and may change or break without notice.

Authentication

All endpoints use cookie-based session authentication. Requests without valid session cookies receive a 401 {"error": "not_authenticated"} response.

@dmwyatt
dmwyatt / django.py
Created August 31, 2024 17:31
blue/green django
# models.py
from django.db import models
class User(models.Model):
# Old field (blue version)
name = models.CharField(max_length=100)
# New fields (green version)
first_name = models.CharField(max_length=50, null=True, blank=True)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dmwyatt
dmwyatt / encrypted_field.py
Last active June 8, 2024 16:43
An experimental Django EncryptedField for encryption-at-rest
"""
Encrypted field for Django for encrypting data at rest.
Inspired by: https://scottarc.blog/2024/06/02/encryption-at-rest-whose-threat-model-is-it-anyway/
"""
import base64
import os
from django.db import models
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
@dmwyatt
dmwyatt / checks.py
Last active September 6, 2024 21:31
Check that Django models inherit from a common base model and that they explictly define db_table
import ast
import inspect
from pathlib import Path
from django.apps import apps
from django.conf import settings
from django.core.checks import Error, register, Tags
from .models import UniversalBaseModel
@register(Tags.models)
@dmwyatt
dmwyatt / filetype_types.py
Last active February 21, 2024 21:18
A Union of all file types in `filetype` package
frofrom typing import Union
from filetype.types import application, archive, audio, document, font, image, video
ImageFileType = Union[
image.Dwg,
image.Xcf,
image.Jpeg,
image.Jpx,
image.Apng,
{
"manifest_version": 3,
"name": "Superpower ChatGPT",
"version": "5.1.2",
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzG6ZR+j3lpHF0XrDLIXdrk25idObfq+RK7WM+pIaQmDO2nM5Y+SZJJbFwyxjWX+3V6XOgS5v9Lpnqg46OJ/W9Q5i23Usx1MXgaJBTlEFz0XG+PYK6BElhc9itS7m6oCLknin97a533tusXmm8zW7kaDGy8vycMDY6Ffbqa3sn0PqZ8bXUlAjgO91dQcB8EtlT906hwhZjtfEYvp2hdxYkRFxfuaR1WMLkxttVXv506RXJowxq0LO3aqj83QeJoXkQF1wbzCxYO1VpVGEmYIQxIKw/csusZNZs8gwJrIWtOzhMgDNOFzXNeZl0ASgoj2M9UsZp+Dunn57VT8tQyaE6QIDAQAB",
"description": "ChatGPT with superpowers! Sync/search history locally, create folders, export all chats, pin messages, access thousands of prompts",
"icons": {
"16": "images/icon-16.png",
"32": "images/icon-32.png",
"48": "images/icon-48.png",