Skip to content

Instantly share code, notes, and snippets.

View Dan-Q's full-sized avatar
🚣

Dan Q Dan-Q

🚣
View GitHub Profile
@Dan-Q
Dan-Q / wireguard-server-for-debian-13.sh
Created February 18, 2026 14:20
Launch script, originally intended to be used as a Linode StackScript but suitable for any Debian 13 box, for setting up a WireGuard VPN server.
#!/bin/bash
# With thanks to: https://www.server-world.info/en/note?os=Debian_13&p=wireguard
#
# How to use:
# 1. Spin up a tiny virtual machine (the cheapest one with a public IP address will usually do!) with your choice
# of cloud provider (Linode, Google Cloud, AWS, Azure, whoever...) and region.
# 2. Run this script (you can modify it to your liking if e.g. you want to support multiple simultaneous clients.
# 3. Download the /root/wireguard.conf file it creates and load it into your WireGuard client.
# 4. Use e.g. icanhazip.com or ipleak.net to check and see where in the world you now appear to be!
#
@Dan-Q
Dan-Q / 3r.org.uk-shift-volunteer-counts.user.js
Created February 8, 2026 20:21
[Userscript] Three Rings: add 'count' alongside volunteers on shifts
// ==UserScript==
// @name Three Rings: add 'count' alongside volunteers on shifts
// @namespace Violentmonkey Scripts
// @match *://*.3r.org.uk/rota
// @match *://*.3r.org.uk/rota/*
// @grant GM_addStyle
// @version 1.0
// @author Dan Q
// @description Switch the list of volunteers on a shift into a numbered list so they're easy to enumerate.
// ==/UserScript==
@Dan-Q
Dan-Q / rss-feed-suffixes.php
Created January 1, 2026 18:04
Code referenced by a ClassicPress/WordPress theme's functions.php to add RSS 'suffix messages', as used by DanQ.me.
<?php
/**
* Returns the DEFAULT "thanks" message for a post. This is determined (functionally-)randomly,
* using the ID of the post as the random seed.
*/
function q23_rss_thanks_default( $post ) {
$rss_thanks_messages = [
"πŸ’– RSS is fantastic, and so are you for using it. πŸŽ†",
"πŸ‘ Congratulations on being an RSS user. πŸŽ‰",
@Dan-Q
Dan-Q / blog.html
Created November 28, 2025 09:41
Frameset with Self-Correcting Anchor Link Tracking, based on Melon Link, for kro
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Blog</title>
</head>
<body>
<h1>Blog</h1>
@Dan-Q
Dan-Q / gb-scotland-ireland-voronoi-boundary.py
Created November 10, 2025 17:30
Hacky Python script to plot across England the Voronoi boundary between Scotland and Ireland, showing which English point is closer to which of its neighbours, as a GPX file.
#!/usr/bin/env python3
"""
Generate a GPX line dividing parts of England that are closer to Scotland
than to Ireland, using real polygon boundaries from Natural Earth.
"""
import os
import tempfile
import requests
from zipfile import ZipFile
@Dan-Q
Dan-Q / SCROLOOP.BAS
Last active October 15, 2025 09:12
QBasic program demonstrating a scroll effect in a loop. Details/explanation: πŸ”— https://danq.me/2025/10/15/the-scroll-art-museum/
CLS
I% = 0 ' Screen position
J% = 1 ' Direction of flow ( -1 <= => +1 )
Action:
FOR A% = 0 TO I%
PRINT " "; ' Print lots of spaces to position
NEXT A%
I% = I% + J%
IF I% = 70 OR I% = 0 THEN
@Dan-Q
Dan-Q / openai-gpt4o-photo-geolocation-prompt.md
Created April 17, 2025 12:42
Prompt for GPT4o to guess GPS coordinates from data in a photographic image.

Identify the location from photographs and provide an analysis.

When given one or more photographs, your task is to analyze the visual elements within each photo to determine the most likely location where it was taken. You should consider details such as architectural styles, natural landmarks, linguistic elements in signage, and any other distinguishable geographic or cultural features. Once you've identified a possible location, provide a rationale for your guess, explaining the reasoning behind your conclusion. Additionally, supply a set of GPS coordinates in decimal format that corresponds to the guessed location.

Steps

  1. Analyze Details: Examine the photograph(s) for identifiable landmarks, languages, architectural styles, natural scenery, vehicles, clothing, signage, and any other clues that may indicate the region or city.

  2. Reasoning: Develop a reasoning process based on these observed details to narrow down the potential locations.

@Dan-Q
Dan-Q / 7-red-lines-claude-3.7-sonnet.html
Created February 27, 2025 10:40
I asked Claude 3.7 Sonnet "Write a JavaScript program that uses a `<canvas>` element to draw seven red lines, all of them strictly perpendicular; some with green ink and some with transparent. Can you do that?". It responded "I see you're referencing the famous "Expert Talks - Draw 7 Red Lines" comedy sketch! This is a deliberately impossible ta…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Seven Red Perpendicular Lines</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
@Dan-Q
Dan-Q / generate-continuum.php
Created February 10, 2025 17:07
Script to run via WP-CLI to generate "continuum" images (and associated HTML imagemaps) of the featured images associated with the posts in a WordPress blog. More details: https://danq.me/2025/02/10/continuum/
<?php
# Run using WP-CLI, e.g. with `wp eval-file /path/to/generate-continuum.php`
$V_WIDTH = 640;
$H_HEIGHT = 1160;
$OUTPUT_DIR = '/home/dan/tmp';
$OUTPUT_TMP_DIR = "$OUTPUT_DIR/thumbnails-banner-parts";
$parts = [];
$posts_with_thumbnails = new WP_Query(
[
@Dan-Q
Dan-Q / bbc-news-with-sports.rb
Created February 3, 2025 20:41
"BBC News... without the crap" RSS feed generators 2025 | https://danq.me/2025/02/03/bbc-news-rss-improved/ β€Ž
#!/usr/bin/env ruby
require 'bundler/inline'
# Dependencies:
# * open-uri - load remote URL content easily
# * nokogiri - parse/filter XML
gemfile do
source 'https://rubygems.org'
gem 'nokogiri'
end