Skip to content

Instantly share code, notes, and snippets.

View vacmar01's full-sized avatar

Marius Vach vacmar01

View GitHub Profile
@vacmar01
vacmar01 / sudoku_solver_seed.py
Created February 21, 2026 16:55
Original seed Sudoku solver used in GEPA optimization
import numpy as np
from collections import defaultdict
def get_cell_bounds(idx):
x, y = idx; return ((x//3)*3, (x//3)*3+3), ((y//3)*3, (y//3)*3+3)
def get_used_numbers(grid, idx):
x, y = idx; row, col = grid[x, :], grid[:, y]
(x1,x2), (y1,y2) = get_cell_bounds(idx); box = grid[x1:x2, y1:y2].flatten()
return np.unique(np.concatenate([row, col, box])[np.concatenate([row, col, box]) != 0])
@vacmar01
vacmar01 / sudoku_solver_optimized.py
Created February 21, 2026 16:52
Optimized Sudoku solver from GEPA blog post
# Fast Sudoku solver: bitmask constraints + MRV + forward-checking
# Drop-in replacement: solve(puzzle_str)->81-char string
# --- Precompute structures (indices 0..80) ---
ROWS = [list(range(r * 9, r * 9 + 9)) for r in range(9)]
COLS = [list(range(c, 81, 9)) for c in range(9)]
BOXS = []
for br in range(0, 9, 3):
for bc in range(0, 9, 3):
box = []
# /// script
# dependencies = [
# "dspy",
# "rich"
# ]
# ///
import dspy
import os
import inspect
➜ random_experiments uv run agent.py
Reading inline script metadata from `agent.py`
Enter your message or type 'exit' to quit.
👨‍💻User: what is the biggest file in the current folder?
Reasoning: To find the biggest file in the current folder, I first need to list the files
in the current directory. Once I have the list, I can inspect each file's size and
determine which one is the largest. The `list_files` function will give me the names of the
files, and then I can use `run_cmd` with a command like `ls -l` or `du -h` to get their
sizes.
Selected Function: list_files
from fasthtml.common import (
fast_app,
serve,
Main,
H1,
Article,
Div,
Form,
Textarea,
NotStr,
from fasthtml.common import *
from dataclasses import make_dataclass, fields
import datetime
from pathlib import Path
import yaml
def create_dataclass_from_schema(schema_dict, cls_name="DynamicClass"):
str2type = {
"str": str,
@vacmar01
vacmar01 / install_lemp_droplet.md
Created June 14, 2023 18:42
Install LEMP Stack on DigitalOcean Droplet.

How to Install Nginx, MySQL and PHP on an Ubuntu Droplet from DigitalOcean

This is meant to be as a reminder to myself and as a quick and dirty reference to others (heavily inspired by: https://www.techalyst.com/posts/laravel-hosting-with-digital-ocean-droplet-step-by-step-tutorial). It assumes you want to install a Laravel app afterwards, but it should be easily adaptable to other PHP apps.

I know that there are probably much more things you could config in your nginx (and maybe you should), but this works for now for me. I might update this with new things I learn.

1. Create DigitalOcean droplet

Choose the region that is nearest to you.

@vacmar01
vacmar01 / interpreter.py
Last active November 20, 2022 12:41
A quick and dirty re-implemented a small subset of the fastai Interpretation class for computer vision
class Interpreter:
def __init__(self, model, dl):
self.model = model
self.dl = dl
if hasattr(model, "loss"):
self.loss_func = self.model.loss
self.losses = torch.empty(0)
self.model.eval()
for batch in tqdm.tqdm(self.dl):
x, y = batch