Skip to content

Instantly share code, notes, and snippets.

View avyfain's full-sized avatar

Avy Faingezicht avyfain

View GitHub Profile
@dbreunig
dbreunig / jekyll_glossary_generator.py
Last active January 5, 2025 02:47
A script to generate a glossary of key terms from your Jekyll posts. We're using DSPy to handle LLM interactions; it helps with boilerplate prompt context and parsing responses into Pydantic objects. To run this, put this script in a folder named 'scripts' (or whatever) in your Jekyll site directory. Then plug in your Anthropic API key (or point…
from pathlib import Path
import re
import dspy
from typing import TypedDict, List
import yaml
# Set up DSPy and the LM
lm = dspy.LM('anthropic/claude-3-5-haiku-latest', api_key='YOUR_API_KEY')
dspy.configure(lm=lm)
#!/usr/bin/env python3
"""Generate 1-dimensional automata based on various rules"""
def ngrams(iterable, n=1):
"""Generate ngrams from an iterable"""
return zip(*(iterable[i:] for i in range(n)))
def states(state, rule, left_pad='0', right_pad='0'):
"""Generate a stream of states from an initial state and a rule"""
next_state = ''.join(rule[''.join(window)] for window in ngrams(state, 3))
@coolaj86
coolaj86 / github-pages-https-lets-encrypt.md
Last active November 16, 2021 22:36
Github Pages: Let's Encrypt!