Skip to content

Instantly share code, notes, and snippets.

View eliasjudin's full-sized avatar

Elias Judin eliasjudin

View GitHub Profile
from dataclasses import dataclass
from typing import Dict, Tuple, List, Optional
@dataclass(frozen=True)
class Arrow:
name: str
src: str
tgt: str
from dataclasses import dataclass, field
from typing import Callable, Iterable, List, Dict, Tuple, Optional, Set, Any
import itertools
import math
import json
############################
# GF(2) linear algebra
############################
from fractions import Fraction
from collections import deque, defaultdict
# Full implementation embedded from notebook; to keep file compact we import from the executed cell would be ideal,
# but for portability we replicate the functions here.
def decide_rep_type(V, A):
if len(set(V)) != len(V):
return {"errors":[{"code":"INPUT_INVALID","message":"vertex IDs must be unique"}]}
Vset = set(V)
from fractions import Fraction
from collections import defaultdict, deque
from itertools import combinations
def lex(labels): return sorted(labels)
class Rational(Fraction): __slots__ = ()
def run_procedure(adj):
removed_loops, removed_parallels = [], []
from collections import defaultdict, Counter, deque
from typing import Any, Dict, List, Tuple, Hashable, Optional, Set
# ----------------------------
# Core API
# ----------------------------
def classify_compact_surface_components(
V: List[Hashable],
E: List[Tuple[Hashable, Hashable]],
@eliasjudin
eliasjudin / olmocr_cli.py
Last active March 24, 2025 17:25
CLI for running olmocr on macOS using LM Studio with dolmaviewer output
#!/usr/bin/env python3
"""
CLI for running olmocr OCR on PDFs using LM Studio.
Based on:
https://jonathansoma.com/words/olmocr-on-macos-with-lm-studio.html
Requirements:
- openai
- olmocr
- pypdf