Skip to content

Instantly share code, notes, and snippets.

View gibson042's full-sized avatar

Richard Gibson gibson042

View GitHub Profile
@gibson042
gibson042 / graph-path-extremes.ts
Created April 28, 2026 17:51
beyond Dijkstra's algorithm
/**
* Calculate shortest and longest paths from specific nodes in a directed graph
* to all other nodes.
* Consider loading in the TypeScript Playground:
* https://www.typescriptlang.org/play/
*/
// #region utils
/**
* @typedef {<O extends Record<string, unknown>>(
@gibson042
gibson042 / git-diff-to-ecmarkup.cjs
Last active July 5, 2025 21:08
A script for translating `git --word-diff=plain` output into ecmarkup-compatible <ins>/<del> tags
#!/usr/bin/env node
/**
* Usage:
* git diff --numstat | sed 's/.*\t//' | while read f; do
* t="$(mktemp -p "$(pwd)" "$f.XXXXXX")"
* git diff -U99999 --minimal --word-diff=plain -- "$f" | sed '1,/^@@/d' | $0 > "$t"
* chmod --reference="$f" "$t"
* mv -f "$t" "$f"
* done
<link rel="stylesheet" href="https://fred-wang.github.io/MathFonts/STIX/mathfonts.css">
<style>
mtd[columnalign=left] { text-align: left; }
mtext { display: inline; white-space: pre-wrap; }
</style>
<h1>Value first</h1>
Let <var>final</var> be <math>
<mrow>
<mo>{</mo>
@gibson042
gibson042 / user-scripts.md
Created September 8, 2023 22:17
User scripts

A collection of user scripts with no other home, for use with Greasemonkey, Tampermonkey, and similar browser extensions.

General Use

Suitable on all sites.

  • Anchors Up - Navigates to in-page anchors upon {Command,Ctrl}+click or (with Shift) scrolls to arbitrary elements.
  • Editor Tweaks - &lt;{Command,Ctrl}+[;BIK…]> commands to control Markdown inside textareas, {Command,Ctrl}+Alt+mousedown to toggle monospace.
@gibson042
gibson042 / github-fixer.user.js
Last active December 16, 2025 22:39
GitHub Fixer user script
// ==UserScript==
// @name GitHub Fixer
// @namespace https://github.com/gibson042
// @description Make pull request tabs sticky, expand all toggles on <{Alt,Option}+Shift+E>.
// @source https://gist.github.com/gibson042/d8ab425d133400959bc5bb875898a97b
// @updateURL https://gist.github.com/gibson042/d8ab425d133400959bc5bb875898a97b/raw/github-fixer.user.js
// @downloadURL https://gist.github.com/gibson042/d8ab425d133400959bc5bb875898a97b/raw/github-fixer.user.js
// @version 0.8.0
// @date 2025-12-16
// @author Richard Gibson <@gmail.com>
@gibson042
gibson042 / esbench.sh
Last active September 5, 2024 12:19
ad hoc multi-engine JavaScript benchmarking
#!/bin/sh
# TODO start versioning
usage () { awk -v CMD="$0" '{ gsub(/\$0/, CMD); print }' <<'END_USAGE'
Usage: $0 [OPTION]... [--] SETUP VARIATIONS
Measures the performance of code variations in multiple ECMAScript implementations.
Options:
--number COUNT, -n COUNT
The count of timed iterations of each variation (defaults to 1000).
@gibson042
gibson042 / confluence-fixer.user.js
Last active March 5, 2025 06:17
Confluence Fixer user script
// ==UserScript==
// @name Confluence Fixer
// @namespace https://github.com/gibson042
// @description Fixes Confluence annoyances (inline comment jumps and page reloads, stacked notifications, hidden anchors and excerpts, etc.).
// @source https://gist.github.com/gibson042/6e42cb4341f6a308af5e8515cceb3d5a
// @updateURL https://gist.github.com/gibson042/6e42cb4341f6a308af5e8515cceb3d5a/raw/confluence-fixer.user.js
// @downloadURL https://gist.github.com/gibson042/6e42cb4341f6a308af5e8515cceb3d5a/raw/confluence-fixer.user.js
// @version 0.6.0
// @date 2023-09-08
// @author Richard Gibson <@gmail.com>
@gibson042
gibson042 / anchors-up.user.js
Last active March 20, 2025 16:26
Anchors Up user script
// ==UserScript==
// @name Anchors Up
// @namespace https://github.com/gibson042
// @description Navigates to in-page anchors upon {Command,Ctrl}+click or (with Shift) scrolls to arbitrary elements.
// @source https://gist.github.com/gibson042/73dfb17bfa7d35a9fb2e4c396365c321
// @updateURL https://gist.github.com/gibson042/73dfb17bfa7d35a9fb2e4c396365c321/raw/anchors-up.user.js
// @downloadURL https://gist.github.com/gibson042/73dfb17bfa7d35a9fb2e4c396365c321/raw/anchors-up.user.js
// @version 0.5.0
// @date 2023-09-08
// @author Richard Gibson <@gmail.com>
@gibson042
gibson042 / emoji-spy.user.js
Last active October 15, 2023 18:20
Emoji Spy user script
// ==UserScript==
// @name Emoji Spy
// @namespace https://github.com/gibson042
// @description Add tooltips describing emoji sequence and symbol code points.
// @source https://gist.github.com/gibson042/5495b65eed0d8e371c155c0dd91262b1
// @updateURL https://gist.github.com/gibson042/5495b65eed0d8e371c155c0dd91262b1/raw/emoji-spy.user.js
// @downloadURL https://gist.github.com/gibson042/5495b65eed0d8e371c155c0dd91262b1/raw/emoji-spy.user.js
// @version 0.3.0
// @date 2023-10-15
// @author Richard Gibson <@gmail.com>

Keybase proof

I hereby claim:

  • I am gibson042 on github.
  • I am gibson042 (https://keybase.io/gibson042) on keybase.
  • I have a public key ASCRNcg7OOoL54GcUj1bi8I32hMOhyM4J5at14t33fj_6go

To claim this, I am signing this object: