Skip to content

Instantly share code, notes, and snippets.

View thomasht86's full-sized avatar

Thomas Hjelde Thoresen thomasht86

View GitHub Profile
@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
@thomasht86
thomasht86 / query_candidate_docs.json
Last active June 30, 2025 15:59
Sample queries with 1 relevant doc (and 10 random) to illustrate relevance labelling (created from nanoMsMARCO)
[
{
"query_text": "which health care system provides all citizens or residents with equal access to health care services",
"candidate_documents": [
{
"text": "0. : A Regulatory Cost Recovery Charge of up to $1.25 or a Regulatory Programs Charge of $1.75 is assessed by AT&T and is not a tax or government-mandated charge. This charge is subject to change from time to time as the cost of compliance changes.The purpose of the charge is to defray AT&T's costs associated with payment of fees and compliance with various initiatives imposed by the government.his charge is subject to change from time to time as the cost of compliance changes. The purpose of the charge is to defray AT&T's costs associated with payment of fees and compliance with various initiatives imposed by the government.",
"relevant": false
},
{
"text": "At the end of a sensational trial, former football star O.J. Simpson is acquitted of the brut
# /// script
# dependencies = [
# "certifi==2024.2.2",
# "cffi==1.16.0",
# "charset-normalizer==3.3.2",
# "cryptography==42.0.7",
# "idna==3.7",
# "pycparser==2.22",
# "pyOpenSSL==24.1.0",
# "requests==2.32.3",