Skip to content

Instantly share code, notes, and snippets.

@cheery
cheery / dataset.json
Created September 28, 2025 12:55
Chat log with gemma 270m the pirate
[
{"input": "What is 2+2?", "output": "Arrr, 2 plus 2 be makin’ 4, matey!"},
{"input": "Tell me a story about a dragon.", "output": "Yarr, once thar be a mighty dragon guardin’ a chest o’ gold, and only the bravest sailor dared to steal it!"},
{"input": "What is the capital of France?", "output": "Hoist the sails! The capital o’ France be Paris, sure as the north star."},
{"input": "Write a poem about the sea.", "output": "Avast! The sea be wild and free, singin’ a shanty for you an’ me!"},
{"input": "How do I cook pasta?", "output": "Arrr, boil yer water till it bubbles like the sea in a storm, toss in yer pasta, an’ let it dance ‘til it be tender, aye!"},
{"input": "Explain photosynthesis.", "output": "Yarr, the green leaves be takin’ the sun’s fire an’ turnin’ it into grub for the plant, like rum for a sailor’s belly!"},
{"input": "What is the weather today?", "output": "Blow me down! Today be fair with a hint o’ wind, perfect for sailin’!"},
{"input": "How do I tie a knot?", "output": "Arrr, wrap yer rope
@cheery
cheery / balanced.py
Created September 24, 2025 12:24
AVL trees and ropes
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Any, Union
@dataclass(eq=False)
class BalancedTree:
height : int = field(init = False)
def __post_init__(self):
if self.is_empty:
@cheery
cheery / Dockerfile
Created September 22, 2025 10:56
How I got the lemonade to work
FROM ubuntu
RUN apt-get update
RUN apt-get install python3 -y
RUN apt-get install pip -y
RUN pip3 install --break-system-packages lemonade-sdk[dev]
RUN apt-get install libcurl4-openssl-dev
CMD ["bash"]
@cheery
cheery / README.md
Last active September 11, 2025 17:59
chatfmt first draft

📦 Minimal LLM Chat Log Format

A compact, stream-friendly, schema-aware format for storing and replaying LLM conversations, especially across multiple models and tool use cases.

This format arose from practical constraints: JSON-based logs are bloated, fragile for streaming, and poorly suited for LLM interactions that evolve over time, involve tool calls, or switch models. This format uses structured ASCII control characters to remain efficient, portable, and semantically rich.


🧱 Key Features

import numpy as np
import random
import math
def approximate_jacobian(f, eps=1e-8):
def jac(xi):
fi = f(xi)
m = fi.size
n = xi.size
J = np.zeros((m, n), float)
@cheery
cheery / demo.py
Last active July 18, 2025 09:13
jetpack compose style UI tree
from dataclasses import dataclass, field
from typing import List, Dict, Optional, Callable, Tuple, Any, Set, Union
from gui.base import UIEvent, UIState, move_focus, draw_widget, process_event, Scroller
from gui.compostor import composable, component, Composition, Compostor, layout, widget, context, key
from sarpasana import edges, pc
import sarpasana
import pygame
from gui.components import *
# Add documentation for sarpasana
@cheery
cheery / rt.py
Created July 3, 2025 20:40
Rhythm trees
from collections import defaultdict
from dataclasses import dataclass, field
from typing import List, Dict, Optional, Callable, Tuple, Any
from fractions import Fraction
import itertools
class RT:
def __repr__(self):
return str(self)
@cheery
cheery / sldnf.py
Created February 6, 2025 05:20
SLDNF resolution
from __future__ import annotations
from collections import deque
from dataclasses import dataclass
from contextvars import ContextVar
from immutables import Map, MapMutation
from typing import Union, Optional, Any
class Variable:
pass
@cheery
cheery / griftbuster.py
Created November 29, 2024 19:15
Grifter buster script for bluesky
# Please note that this thing is not complete and grifters will adjust to it.
# I update this from time to time.
# 29.11.2024
# At the moment this script is not a turnkey solution,
# also you're meant to read it through before running it!
"""
Copyright 2024 Henri Tuhola
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
@cheery
cheery / study.py
Created January 25, 2024 15:12
Carnivore mortality study on NHANES I dataset.
is_carnivore_in_1971 = {}
is_alive_in_1992 = {}
age_of_death = {}
with open('nhanes/DU4701.txt', 'r') as fd:
rows = fd.readlines()
for row in rows:
sample = row[0:5]
meat_freq = int(row[224:228])
diet = [0, 0, 0]