Skip to content

Instantly share code, notes, and snippets.

View svandragt's full-sized avatar
💪
+11 −272,086

Sander van Dragt svandragt

💪
+11 −272,086
View GitHub Profile
@svandragt
svandragt / functions.php
Last active December 9, 2025 09:09
Enqueue a theme style and opt into WP's small-CSS inlining.
<?php
/**
* Enqueue a theme style and opt into WP's small-CSS inlining.
*
* If the file is small enough (per core’s internal threshold), WP will inline it.
* Otherwise it remains a normal <link>.
*
* @param string $handle Unique style handle.
* @param string $relative_path Path relative to the theme root (e.g. 'assets/css/theme.css').
@svandragt
svandragt / archive.sh
Last active December 7, 2025 09:42
archive.sh — Heuristic Zstandard tar archiver
#!/usr/bin/env bash
# archive.sh — Heuristic Zstandard tar archiver with optional PAR2 redundancy
# - Decides compression strategy based on directory size
# - Appends trailing slash if needed
# - Produces a uniquely named .tar.zst archive
# - Optionally adds PAR2 recovery files for large datasets
#
# Usage: ./archive.sh <directory>
#
# Env overrides:
@svandragt
svandragt / check_busy.md
Last active November 26, 2025 09:35
Google Calendar - Busy or free

Google Calendar Busy Check

A small Python script that reports your current availability from Google Calendar, using uv inline dependencies.

It outputs:

  • Busy until HH:MM — you are currently in a meeting that counts as busy.
  • Free until HH:MM — you are not busy, and the next busy meeting starts at that time.
  • Free — no busy meetings ahead in the look-ahead window.
@svandragt
svandragt / generate-datasource.sh
Created November 18, 2025 12:03
Generate a JetBrains .idea/dataSources.xml file from the output of Altis local server
#!/bin/bash
# Capture the output of the command
OUTPUT=$(composer server db info)
# Extracting the necessary values using grep and awk
DB_NAME=$(echo "$OUTPUT" | grep "Database:" | awk '{print $2}')
DB_USER=$(echo "$OUTPUT" | grep "User:" | awk '{print $2}')
DB_PASSWORD=$(echo "$OUTPUT" | grep "Password:" | awk '{print $2}')
DB_HOST=$(echo "$OUTPUT" | grep "Host:" | awk '{print $2}')
@svandragt
svandragt / tabtime.html
Created August 25, 2025 09:21
TabTime
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Time</title>
<style>
body {
font-family: sans-serif;
display: flex;
justify-content: center;
<?php
const REST_NAMESPACE = 'test/v1';
add_action( 'rest_api_init', function () {
register_rest_route( REST_NAMESPACE, '/test', [
'methods' => 'GET',
'callback' => 'handle_rest_test',
'permission_callback' => '__return_true',
] );
@svandragt
svandragt / userChrome.css
Created May 22, 2025 14:12
Firefox userChrome optimised for the compact connaisseur
/* Make it easier to find active tab */
.tab-background {
&:is([selected], [multiselected]) {
border-top: 1px solid #444 !important;
}
}
/* Thinner pins, even in compact */
.tab-content {
padding: 0 4px !important;
@svandragt
svandragt / github-viewer.py
Last active May 6, 2025 16:03
Open pull request viewer
#!/usr/bin/env python
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pyperclip",
# "requests",
# ]
# ///
import os
import json
@svandragt
svandragt / open-links.py
Last active June 2, 2025 15:31
Open text links in browser tabs
@svandragt
svandragt / jira-ticket.py
Created April 23, 2025 12:56
JIRA Ticket Checker Script
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "pyperclip",
# "requests",
# ]
# ///
import os
import requests
import subprocess