runtime backup

This commit is contained in:
lachtan
2026-09-02 15:23:13 +02:00
parent 442ddc3c24
commit 812c30ed1a
17 changed files with 2238 additions and 315 deletions

40
scripts/hn_top.ts Normal file
View File

@@ -0,0 +1,40 @@
#!/usr/bin/env bun
/**
* Fetches top stories from Hacker News API and prints title + URL + score.
* Usage: bun run scripts/hn_top.ts [limit]
*/
const limit = Number(Bun.argv[2] ?? 10);
interface HNItem {
id: number;
title?: string;
url?: string;
score?: number;
by?: string;
type?: string;
}
const BASE = "https://hacker-news.firebaseio.com/v0";
async function fetchJSON<T>(url: string): Promise<T> {
const res = await fetch(url);
if (!res.ok) throw new Error(`HTTP ${res.status} for ${url}`);
return res.json() as Promise<T>;
}
const ids = await fetchJSON<number[]>(`${BASE}/topstories.json`);
const top = ids.slice(0, limit);
const items = await Promise.all(
top.map((id) => fetchJSON<HNItem>(`${BASE}/item/${id}.json`)),
);
for (const item of items) {
if (item.type !== "story" || !item.title) continue;
const score = item.score ?? 0;
const url = item.url ?? "(no url)";
console.log(`[${score}↑] ${item.title}`);
console.log(` ${url}`);
console.log();
}

View File

@@ -2,7 +2,8 @@
"""Parse the ollama library page text dump and list unique models."""
import re, json, sys
raw = open('scripts/ollama_library_full.txt').read()
with open('scripts/ollama_library_full.txt', encoding='utf-8') as f:
raw = f.read()
first_line = raw.split('\n')[0]
# Each line is prefixed "N| " repeated; find the first { and the last }
start = first_line.find('{')