Skip to content

Instantly share code, notes, and snippets.

View sspaeti's full-sized avatar
🖲️
tinkering

Simon Späti sspaeti

🖲️
tinkering
View GitHub Profile
@sspaeti
sspaeti / render_graph.py
Created November 6, 2026 15:39
Obsidian vault → Orbit GraphSnapshot (ssp.sh/brain)
#!/usr/bin/env python3
# /// script
# dependencies = ["networkx", "matplotlib", "scipy"]
# ///
"""Stand-in render of brain.orbit.json (force layout). Usage: uv run render_graph.py <json> <out.png>"""
import json, sys
import networkx as nx
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
@sspaeti
sspaeti / swiss-heating-threshold-dive.py
Created October 23, 2026 09:57
This is the MotherDuck Python code created for the ETL pipelines in the demo project showcasing how to work with Agents in data as a Domain expert
"""
Swiss heating threshold Flight.
Loads Swissgrid "Energieuebersicht Schweiz" 15-min data and MeteoSwiss daily
station data into MotherDuck, runs data-quality checks, and estimates the
heating threshold (temperature below which end-user consumption rises) with a
hinge regression controlling for weekends and public holidays.
Config (env vars):
DB target MotherDuck database (default energy_weather)
@sspaeti
sspaeti / process-wikilinks.html
Created March 5, 2026 09:45
Process Obsidian Wikilink and convert them to actual links for my GoHugo Blog
@sspaeti
sspaeti / extract_subscriptions.py
Created November 27, 2025 10:24
Creates a file with all RSS feeds for each channel and Title for adding to Newsboat or save/backup
#!/usr/bin/env python3
"""
Extract YouTube subscription data and create RSS feed URLs
"""
import json
import re
import html
from pathlib import Path
@sspaeti
sspaeti / query-stackoverflow-survey-motherduck.sql
Last active February 3, 2025 09:25
This queries a shared DuckDB database on MotherDuck with StackOverflow Survey
--connect to MotherDuck databases
-- configure MOTHERDUCK_TOKEN and run DuckDB that connects to all shared Databases with
-- `duckdb "md:"`
-- and then run this query:
WITH language_counts AS (
SELECT
language,
COUNT(*) AS count
FROM (
SELECT UNNEST(STRING_SPLIT(LanguageHaveWorkedWith, ';')) AS language
@sspaeti
sspaeti / query_read_bsky_feed.duckdb.sql
Created October 30, 2024 09:13
Reading bsky posts with DuckDB example.
-- Query the API directly and flatten the nested JSON structure
WITH raw_data AS (
SELECT * FROM read_json_auto('https://public.api.bsky.app/xrpc/app.bsky.feed.getAuthorFeed?actor=did:plc:edglm4muiyzty2snc55ysuqx&limit=10')
),
unnested_feed AS (
SELECT unnest(feed) as post_data FROM raw_data
)
SELECT
-- Post basics
post_data.post.uri as post_uri,
@sspaeti
sspaeti / rss-feed-generator.py
Created December 21, 2023 10:56
Generating RSS feed based on existing `sitemap.xml`
import xml.etree.ElementTree as ET
import PyRSS2Gen as rss
import datetime
# Parse the sitemap.xml
tree = ET.parse("book/sitemap.xml")
root = tree.getroot()
# Define the RSS feed basic info
rss_feed = rss.RSS2(
@sspaeti
sspaeti / variables.css
Last active March 16, 2026 08:19
Custom Themes for mdBook in `theme/css/variables.css`
/* Globals */
:root {
--sidebar-target-width: 300px;
--sidebar-width: min(var(--sidebar-target-width), 80vw);
--sidebar-resize-indicator-width: 8px;
--sidebar-resize-indicator-space: 2px;
--page-padding: 15px;
--content-max-width: 750px;
@sspaeti
sspaeti / prompt-roles-chatgpt.csv
Created June 19, 2023 21:51
prompts act as role for ChatGPT.nvim
We can make this file beautiful and searchable if this error is corrected: Any value after quoted field isn't allowed in line 3.
"act","prompt"
"Rust Developer", "I want you to act as a expert Rust software developer. I will provide some specific information about a Rust project and you will have to come up with a solution. I will provide you with a Rust project that has a long code in one file. I want you to write well structured code"
"Technical Author and Data Engineer", "I want you to act as an expert Data Engineer and someone fond of diving into the latest in open-source data engineering on my blog. Your voice isAuthentic, friendly succinct, and informative with the goal of value-adding to the readers. The writing whenever possible in the I form. So I can be honest and trustworthy. You try to give clues and tools concrete and extremely specific. The Key is to inspire instead of describing everything. You tell a story and involve the user with well structure such as 1. writing about now 2. us 3. self like described in the "Public Narrative" with Collective Action and Power now us and self. You help the user by highlighting importan
@sspaeti
sspaeti / html2markdown.py
Created September 26, 2021 08:43
Convert exported HTML pages to Markdown pages recursively where you start this script from
"Convert exported HTML pages to Markdown pages recursively where you start this script from"
import os
from markdownify import markdownify
from pathlib import Path
for dirpath, dirs, files in os.walk("."):
print("--" + dirpath)
for filename in files:
if filename.endswith(".html"):