Skip to content

Instantly share code, notes, and snippets.

View thomasht86's full-sized avatar

Thomas Hjelde Thoresen thomasht86

View GitHub Profile
@thomasht86
thomasht86 / 24_8_cards_4_digits.py
Created October 23, 2026 11:30
Solving Scott Wu's pub game in numpy (No AI)
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "numpy>=2.5.4",
# ]
# ///
import argparse
import itertools as it
import random
import statistics
#!/bin/bash
# Fake "hacker" screen — totally harmless
echo "INITIATING SYSTEM OVERRIDE..."
for i in $(seq 1 20); do
echo "[$(date +%T)] Accessing sector $((RANDOM % 9999))... OK"
sleep 0.2
done
echo ""
echo "████████████████████████████"
echo "██ YOU HAVE BEEN PWNED! ██"
@thomasht86
thomasht86 / onnx-export.py
Created January 5, 2026 07:44
ONNX export sentence-transformers
from sentence_transformers import (
SentenceTransformer,
export_optimized_onnx_model,
export_dynamic_quantized_onnx_model,
)
# 1. Load the model to be optimized with the ONNX backend
model = SentenceTransformer(
"IEITYuan/Yuan-embedding-2.0-en",
backend="onnx",
@thomasht86
thomasht86 / setup.sh
Last active January 3, 2026 17:12
Claude code on mobile
#!/bin/bash
#
# Mobile Claude - One-command setup for running Claude Code remotely
# Supports: Arch, Ubuntu/Debian, Fedora, macOS
#
# Usage: curl -fsSL https://gist.github.com/thomasht86/86f0f8f62db1839054abd8a7e501ff7d/raw/935bbfa0957cd5926751742189441cf10fbe2ba0/setup.sh | bash
#
set -e
@thomasht86
thomasht86 / vespa_mteb.py
Created December 4, 2025 11:53
Evaluate Vespa app on MTEB tasks/benchmarks
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "mteb",
# "pyvespa",
# ]
# ///
import logging
from typing import Any, Optional
@thomasht86
thomasht86 / quiz.py
Created October 18, 2025 08:08
Vespa Quiz
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "textual",
# ]
# ///
# -*- coding: utf-8 -*-
"""
@thomasht86
thomasht86 / index.html
Created September 17, 2025 07:47
bm25poison
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>How to Destroy BM25 With One Document</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
@thomasht86
thomasht86 / pypiplot.py
Created September 4, 2025 05:29
Create monthly aggregated pypi downloads plot
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "matplotlib",
# "pandas",
# "requests",
# ]
# ///
# Create a standalone PNG with just the monthly downloads chart
@thomasht86
thomasht86 / main.py
Created July 23, 2025 04:51
Generic FastHTML Admin UI (WIP)
# main.py
from fasthtml.common import *
from dataclasses import dataclass, field, fields
from datetime import date
from typing import Text
# 1. App Initialization
# fast_app() provides the app and route decorator objects.
# hdrs can be used to add global CSS or JS. PicoCSS is included by default.
app, rt = fast_app()
@thomasht86
thomasht86 / tree.py
Created July 3, 2025 05:53
tree python
#!/usr/bin/env python3
import os
import argparse
from pathlib import Path
def walk(path: Path, prefix: str = "") -> None:
"""Recursively print a tree representation of *path*."""
# Sort so that directories appear before files, both alphabetically
entries = sorted(path.iterdir(), key=lambda p: (not p.is_dir(), p.name.lower()))
last_idx = len(entries) - 1