Skip to content

Instantly share code, notes, and snippets.

View lmmx's full-sized avatar
🍜
focusing on pho

Louis Maddox lmmx

🍜
focusing on pho
View GitHub Profile
@lmmx
lmmx / chat-1-user.md
Last active July 24, 2024 09:21
Asking Claude 3.5 Sonnet about code execution simulation via static analysis

What form of static analysis can be used on dependencies to simulate the code execution? For example a Pydantic model class defined at runtime is 'built' (its core schema is collected from model fields from the class type information) and when an instance is subsequently instantiated at runtime, it invokes the validators on the schema.

How would all of this be traced in static analysis? Do not leave any details vague

@lmmx
lmmx / run.py
Last active July 16, 2024 15:49
Breaking a pipeline step out into 'tasks', and making trivial use of a TypeAdapter on a singleton list to use IO linting at runtime (in line with the progressive nature of a pipeline step)
from pathlib import Path
from pydantic import BaseModel, FilePath, NewPath, OnErrorOmit, TypeAdapter
class AvailableTask(BaseModel):
src: list[FilePath]
dst: list[NewPath]
@lmmx
lmmx / run.py
Created July 16, 2024 10:47
Example of running an idempotent pipeline using Pydantic validation for control flow (using `OnErrorOmit`)
from pydantic import BaseModel, FilePath, NewPath, OnErrorOmit
class Step(BaseModel):
source: FilePath
dest: NewPath
class Pipeline(BaseModel):
steps: list[OnErrorOmit[Step]]
@lmmx
lmmx / constituencies.json
Last active July 5, 2024 09:30
Constituency results
This file has been truncated, but you can view the full file.
[{"party_code":"LAB","candidate":"Alex Baker","vote_number":19764,"vote_share":40.71,"is_previous_mp":false,"constituency_id":"E14001063","name":"Aldershot","region":"SE","country":"England","result_2019":"CON","majority_2019_percent":34.7,"status":"result","time_reported":1720148731000,"time_declared":1720148703000,"result_2024":"LAB","majority_2024_number":5683,"majority_2024_percent":11.71,"turnout_2024_number":48544,"turnout_2024_percent":61.79},{"party_code":"CON","candidate":"Leo Docherty","vote_number":14081,"vote_share":29.01,"is_previous_mp":true,"constituency_id":"E14001063","name":"Aldershot","region":"SE","country":"England","result_2019":"CON","majority_2019_percent":34.7,"status":"result","time_reported":1720148731000,"time_declared":1720148703000,"result_2024":"LAB","majority_2024_number":5683,"majority_2024_percent":11.71,"turnout_2024_number":48544,"turnout_2024_percent":61.79},{"party_code":"REF","candidate":"Trevor Lloyd-Jones","vote_number":8210,"vote_share":16.91,"is_previous_mp":false,"c
@lmmx
lmmx / message_1.md
Last active June 30, 2024 09:30
FastUI GitHub auth explained by Claude (with Artifacts)

explain this code, it's in a new framework called FastUI from the maker of Pydantic. I'm particularly interested in how the GitHub auth works


Certainly! I'd be happy to explain this code and focus on the GitHub authentication process. This code is indeed using FastUI, a new framework for building web user interfaces that works in conjunction with FastAPI and Pydantic.

@lmmx
lmmx / prompt.md
Last active June 29, 2024 15:24
Blameless post-mortem explanation Claude prompt (to debug Project Artifacts naming decision logic and amend custom instructions to correct it)

Thanks Claude. I'm curious about how best to work with you, specifically when it comes to how you are making Artifacts for me. Can you explain your thought process behind all the Artifacts you created in the previous step, including their names and the decisions to create/update their content, based on my request.

Then:

Now I don't want you to take this as a criticism, you did what I told you in the instructions I gave you, and you were very diligent at that. However there was a mistake and I want to fix our communication around how to work together, so I want to do this in a 'blameless post-mortem' style with you, because this is our joint responsibility and I want to be clear you did not mess up any more than I did by not being clear enough about my expectations.

So the specific error you made is in combining the SVG files together.

I don't know if perhaps I biased you towards updating Artifacts more than you otherwise would have if I hadn't instructed you in how to update and create Artifacts.
@lmmx
lmmx / custom-instruction.md
Last active July 1, 2024 17:40
Custom instruction to make Claude Artifacts use persistent file identifiers and names

Custom instruction to make Claude Artifacts use persistent and distinct file identifiers in Projects

  • The title attribute of the <AntArtifact> XML tag becomes the file_name attribute when 'Add to Project' is clicked.
  • Since Claude defaults to a human-readable title (e.g. "Modified Web Page With New Features"), this will tend to change the filename in the Project
  • It's easier to keep a single file copy in your Project docs ("Project Knowledge") when the file names are persistent in this way
Click to show earlier versions

0.0.1

@lmmx
lmmx / App.jsx
Last active June 28, 2024 20:11
HTMX React app (combo) demo: random joke generator
import React, { useEffect, useRef } from 'react';
import htmx from 'htmx.org';
function HTMXComponent() {
const divRef = useRef(null);
useEffect(() => {
// Initialize HTMX on the component
htmx.process(divRef.current);
@lmmx
lmmx / Cargo.toml
Created June 18, 2024 17:52
Simple `.npy` file format reading (to benchmark against `np.load`)
[package]
name = "hello_npy"
version = "0.1.0"
edition = "2021"
[dependencies]
npyz = "0.8.3"