Skip to content

Instantly share code, notes, and snippets.

View AlyceOsbourne's full-sized avatar

MissArticulatePython AlyceOsbourne

View GitHub Profile
from datetime import datetime
from textual.widgets import Static
from textual.containers import Vertical
from textual.timer import Timer
class TuiOsHome(Vertical):
DEFAULT_CSS = """
TuiOsHome {
height: 100%;
print("You has been haxxored!")
@AlyceOsbourne
AlyceOsbourne / vectordb.py
Created March 20, 2026 02:15
VectorDB implementation in Python, very simple, uses SQLite
"""
Vector database module: SQLite-backed store with OpenAI-compatible embeddings.
Provides:
- VectorDB, SQLite-backed store with embeddings from an OpenAI-compatible embedding API
- source_files table, Tracks each file path and mtime so unchanged files skip re-embedding entirely
- embedding_to_blob / blob_to_embedding, Pack/unpack float32 vectors to/from SQLite BLOBs
- cosine_similarity, Computes similarity between two vectors
- SearchResult, NamedTuple for search hits (id, text, score, source)
- SearchResults, Iterable container with ``.threshold(min_score)`` and ``.with_file_contents()``
@AlyceOsbourne
AlyceOsbourne / agent.py
Created November 17, 2025 16:45
A simple agent builder
"""
A simplified AI agent with tool calling and automatic schema generation.
"""
import openai
import inspect
import json
from typing import Annotated, get_origin, get_args, Any, Callable
from dataclasses import dataclass, field
use std::collections::{HashMap, BTreeSet};
use std::fs::File;
use std::io::{Read, Write};
use std::path::PathBuf;
use std::sync::{RwLock, Arc};
use std::collections::HashMap as StdHashMap;
use serde::{Deserialize, Serialize};
use thiserror::Error;
#[derive(Error, Debug)]
#![feature(likely_unlikely)]
use crate::entity_type::Entity;
mod static_data {
/*
This represents a global blackboard of data.
All state that can be represented is stored here.
Entities are pointers into this data.
@AlyceOsbourne
AlyceOsbourne / parse.rs
Last active May 15, 2025 16:02
Example parser
use std::io::Read;
use std::marker::PhantomData;
pub use token::{Token, tokenize};
pub use ast::{Expr, BinOp, EvalError};
pub use parser::{ParseError, parse_tokens};
struct Runic<State = Ready>(PhantomData<State>);
struct Ready;
struct Tokenized;
@AlyceOsbourne
AlyceOsbourne / server.gd
Last active April 1, 2025 02:32
Godot Web Server
class_name HTTPServer
extends Node
var server := TCPServer.new()
var port := 8080
var clients := []
var router := Router.new()
func add_route(method: String, path: String, handler: Callable):
router.add_route(method, path, handler)
@AlyceOsbourne
AlyceOsbourne / RingBuffer.gd
Created October 2, 2024 15:07
A Ringbuffer for Godot, with thread safety
class_name RingBuffer
extends RefCounted
var buffer: Array
var size: int
var head: int = 0
var tail: int = 0
var mutex: Mutex = Mutex.new()
var buffer_not_empty: Semaphore = Semaphore.new()
@tool
class_name Grumble
class DecodeResult:
var string: String
var idx: int
func _init(input_string: String):
string = input_string
idx = 0