Skip to content

Instantly share code, notes, and snippets.

@wware
wware / iid.md
Last active April 24, 2025 20:23

Immutable Interface Design (IID): Definition and Key Features

Immutable Interface Design (IID) is a proposed architectural pattern for Python development. The primary goals of this protocol are threefold:

  1. Early and Specific Design Documentation: IID emphasizes defining comprehensive interface specifications before writing implementation code. This is achieved through the use of Python's abc module for interface classes, abstract methods with strict type annotations, detailed docstrings for all components, and frozen Pydantic models for immutable data structures[^0_2][^0_10]. This approach creates a clear blueprint, ensuring design details are captured early in the development process[^0_3][^0_6]. Static validation with tools like mypy further enforces type consistency from the outset.
  2. Robust Guardrails for LLM Code Generation: The detailed and validated structure provided by IID serves as effective guardrails when using Large Language Models (LLMs) for code generation[^0_7][^0_11]

Vibe Coding Meets Test-Driven Development

The Convergence of Approaches

Vibe coding - the practice of writing code that "feels right" and follows natural patterns - might seem at odds with Test-Driven Development (TDD)'s rigorous, test-first methodology. However, when combined thoughtfully, these approaches can create exceptionally robust and maintainable code.

A Concrete Example: WebAuthn Implementation

The WebAuthn implementation showcased in this repository demonstrates how these methodologies can work together effectively:

@wware
wware / 0README.md
Last active February 12, 2025 18:29

Prompt:

Alt text description

The inverters in the upper left are a square wave oscillator (around 100 kHz), used to sense capacitive connectivity between X wires and Y wires. The comparators are TLV3404. Inputs A,B,C,D,E,F and outputs G,H,I are connected to an Adafruit Grand Central M4 controller board. Inputs D,E,F select one of eight options in the 4051 analog multiplexer, just prior to the 3-bit flash ADC that generates G,H,I.

Show me Rust code that would run on the Grand Central board to perform a keyboard scan.

Response:

I'll help you create Rust code for scanning this capacitive keyboard matrix. From the schematic, we're dealing with:

docker-compose.yml
Dockerfile*
models/
ollama_data/
.pytest_cache/
__pycache__/
@wware
wware / mrsl.md
Last active February 3, 2025 01:42

Machine readable scientific literature

First a bit of background. Around 2010 I had the idea that computers could do science, not simply run lab equipment but iterate the scientific method on their own. I was thinking about how to make that happen, and within a month I stumbled across a brilliant piece of work done by Ross King, then at Aberystwyth University. He built a robot that could make observations, reason about hypotheses and the predictions implied by those hypotheses, and design and perform experiments.

How this stuff works

This is a Guile Scheme extension written in Rust instead of C. The longer-term goal is a Rust implementation of the Rete algorithm callable from Guile.

cargo build --release
sudo mkdir -p /usr/share/guile/site/3.0/

Graph RAG information (Neo4J, LlamaIndex, Groq API)

What follows is a conversation I had with Anthropic's https://claude.ai/ LLM, asking it questions about how Graph RAG works in as much detail as I could think of. When I think of graph databases, I normally think RDF, but the generally preferred graph DB for LLM apps seems to be Neo4J which uses a query language called Cypher rather than SPARQL, so there are some questions below about Neo4J and Cypher syntax. The thing I really wanted to know about was the sequence of queries and responses involved, and how the queries are constructed, and how the responses are interpreted.

Prompt:

During a typical graph rag query and response, what would a langsmith trace look like?

@wware
wware / local_logger.py
Created October 4, 2024 15:38
I once fooled with a flavor of local loggers (actually I called them "topical loggers") that I ended up not liking. Here the name is automatically derived from the source filename so there's less to keep track of. Maybe I'll like this approach better. Environment variables are used to decide who gets DEBUG-level logging, otherwise it's INFO-level.
# This first piece can go into some global utils.py file.
# python foo.py
# LOGGER_FOO_PY=DEBUG python foo.py
# python -m pytest foo.py
import logging
import os
import inspect
import pytest
from unittest.mock import patch
@wware
wware / RDF_Scholar_Readme.md
Last active November 13, 2023 21:22
This is a README for a GPT I'm working on

RDF Scholar

RDF Scholar is a specialized AI designed to assist in converting scientific text into Turtle/RDF format. This is particularly useful for enhancing the machine-readability of scientific literature. It leverages various ontologies, such as ModSci and PharmSci, and aligns with resources like the Semantic Web for Life Sciences to ensure that the RDF outputs are accurate and semantically rich. The goal is to facilitate the organization, sharing, and discovery of scientific knowledge through structured data. My functionalities

@wware
wware / literate_asserts.py
Last active July 29, 2023 04:27
A "literate" assert is one that tries to clarify better what's going on in some code that might be otherwise unclear.
"""
More detailed explanatory asserts can help to clarify code and provide
a narrative about what's going on, what is intended or expected, etc.
So a message might look like this.
Notify {name} that the errno is {errno}.
and object attributes are
foo.a = {foo.a}
foo.b = {foo.b}