Skip to content

Instantly share code, notes, and snippets.

View runekaagaard's full-sized avatar

Rune Kaagaard runekaagaard

  • Copenhagen, Denmark
View GitHub Profile
@runekaagaard
runekaagaard / minimal_mcp_server.py
Created May 20, 2025 19:56
Minimal vanilla mcp server in python
import sys, json, inspect
from typing import get_type_hints
## MCP Server "Framework" ##
TOOLS, TOOL_DEFINITIONS = {}, []
def tool(f):
TOOLS[f.__name__] = f
TOOL_DEFINITIONS.append(tool_definition(f))
@runekaagaard
runekaagaard / txt
Created February 3, 2025 23:00
The number 999999
999999
@runekaagaard
runekaagaard / sql
Last active December 27, 2024 11:51
SELECT id, casestatus_id FROM counseling_case LIMIT 1;
@runekaagaard
runekaagaard / mysql-5.7-install.sh
Last active November 8, 2024 15:04
Unattended install of mysql 5.7.42 (latest ubuntu deb packages) on Ubuntu 22.04. Change ROOT_PASSWORD. Choose gdal support.
#!/bin/bash
set -e
# Pre-configure root password
export DEBIAN_FRONTEND=noninteractive
ROOT_PASSWORD="your_password_here"
debconf-set-selections <<< "mysql-community-server mysql-community-server/root-pass password $ROOT_PASSWORD"
debconf-set-selections <<< "mysql-community-server mysql-community-server/re-root-pass password $ROOT_PASSWORD"
mkdir -p /tmp/mysql-install
@runekaagaard
runekaagaard / minecraft-start
Last active September 1, 2024 14:18
Linux script to start java minecraft with a custom username directly without running the launcher
#!/usr/bin/env bash
# Function to display help message
show_help() {
cat << EOF
Usage: minecraft-start [options] <username>
Launch Minecraft with the specified username.
Arguments:
@runekaagaard
runekaagaard / tails.py
Last active April 8, 2022 05:53
Runs and outputs multiple bash commands in one terminal. Each command gets a color. "pip install termcolor" is needed.
import fcntl, os, re, sys, signal
from subprocess import Popen, PIPE
from termcolor import colored
from itertools import cycle
RE = re.compile(r'(?:\x1B[@-_]|[\x80-\x9F])[0-?]*[ -/]*[@-~]')
CLEARLN = "\033[2K\r"
def escape_ansi(s):
return RE.sub('', s)
@runekaagaard
runekaagaard / python_pipes.py
Last active February 26, 2022 13:18
pipe operator in python.
from functools import wraps
class Ror:
def __init__(self, func, args, kwargs):
self.func = func
self.args = args
self.kwargs = kwargs
def __ror__(self, arg):
return self.func(arg, *self.args, **self.kwargs)
@runekaagaard
runekaagaard / last-daemon.sh
Last active April 26, 2021 14:17
Run multiple dev servers in parallel with a single command. Each line has a colored prefix. CTRL+C closes all. Requires GNU parallel.
#!/bin/bash
# COLOR CODES
# Red 31 41
# Green 32 42
# Yellow 33 43
# Blue 34 44
# Magenta 35 45
# Cyan 36 46
# White 37 47
state = {
"users":
User.mutable.all() > {
"tags": Tag.mutable.up().all(),
},
"movie":
Movie.mutable.get(pk=91) > {
"actors": Actor.mutable.up().all(),
"style": Style.mutable.up().get(),
}
@runekaagaard
runekaagaard / change_monitor.py
Created November 2, 2019 12:53
POC Python Change Monitor of generic nested data
from collections import namedtuple
ATTR_LOOKUP = 1
ITEM_LOOKUP = 2
Change = namedtuple("Change", "path to")
class Lookup(namedtuple("Lookup", "key lookup_type")):
def __str__(self):
if self.lookup_type == ATTR_LOOKUP: