Skip to content

Instantly share code, notes, and snippets.

View gibson042's full-sized avatar

Richard Gibson gibson042

View GitHub Profile
@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 - <{Command,Ctrl}+[;BIK…]> commands to control Markdown inside textareas, {Command,Ctrl}+Alt+mousedown to toggle monospace.
@gibson042
gibson042 / github-fixer.user.js
Last active March 13, 2024 02:55
GitHub Fixer user script
// ==UserScript==
// @name GitHub Fixer
// @namespace https://github.com/gibson042
// @description Include pull request tabs in the sticky header and support CI check filtering by status.
// @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.1.2
// @date 2024-03-12
// @author Richard Gibson <@gmail.com>
@gibson042
gibson042 / esbench.sh
Last active October 12, 2023 17:37
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 September 8, 2023 21:52
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 November 9, 2023 18:01
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:

@gibson042
gibson042 / 2021.19.js
Last active December 23, 2021 22:42 — forked from gnarf/2021.19.js
Advent of Code 2021 - Day 19 Part 2 - Console Golfing
(await(await fetch("https://adventofcode.com/2021/day/19/input")).text(Q=[])).replace(r=/.*,.*|(\d+)/g,(d,s)=>(s?Q:q).push(s?q=[]:eval(`[${d}]`)))
T=[],[...'+3+6!-!+5-7-6!+!-8-5!+8+6+8+5!-8-6-!-7-7+-7!-!-1--7!+!+8+!-7!+8+-7-8-!-7!-8-2-!+!+3+6!+!-5-7-6!-!-!-7-7+-7!+!0--8'.replace(r,t=>'+!-!!!+!!!'.slice(t))][F="flatMap"]((s,i)=>((T[i/9|0]??=[])[i%9/3|0]??=[])[i%3]=s+1|0)
M=(t,m)=>t.map(o=>m?o[D]((s,p,i)=>s+m[i]*p,0):t[F](p=>m+1?N=(n=o.l[D]((s,o,i)=>s+A(o-p.l[i]),0))>N?n:N:p[D="reduce"]((s,p,i)=>s+A(o[i]-p)**2,0)))
for(A=Math.abs,S=JSON.stringify,R=Q[N=0],R.l=[0,0,0];Q.find(q=>(t=(H=q.l?0:M(R)[F]((e,x)=>M(q)[F]((d,B)=>d[D]((c,a)=>c+e.includes(a),0)>11?[[x,B]]:[]))).length>11&&T.find(t=>H.find(([r,u])=>(V[r=S(u=R[r][F]((p,i)=>p-M(t,q[u])[i]))]|=0,++V[r]>11?U=q.l=u:0),V={})))&&q[F](P=>S(P=M(t,P)[F]((p,i)=>U[i]+p))in R[F](S)||R.push(P))););M(Q,0)
N
@gibson042
gibson042 / highlight.awk
Last active March 10, 2022 15:28
highlight.awk - ANSI-format matching input (e.g. to supplement grep)
#!/usr/bin/awk -f
BEGIN {
USAGE="Usage: %s rule=<awk ERE pattern>/<ANSI SGR format>[.<extra format>]... [rule=...]...";
EXAMPLE="Example: </etc/resolv.conf %s rule='#.*'/dim rule='([0-9]+[.]){3}[0-9]+'/bold.red";
CMD=ENVIRON["_"];
if(!CMD) CMD="$0";
USAGE=sprintf(USAGE, CMD) "\n" sprintf(EXAMPLE, CMD);
}
function usage(msg, code) {
if(msg!="") print "[ERROR] " msg > "/dev/stderr";
@gibson042
gibson042 / route.sh
Created January 14, 2021 00:21
Use awk to implement `ip route`-like behavior
#!/bin/sh
awk '
BEGIN { OFS="\t"; HEX_LOWER="0123456789abcdef" }
FILENAME ~ /trie$/ { if($0 ~ "/32 host") ADDRS[ipv4_decimal_to_bits(prev)]=prev; prev=$2; next }
FNR==1 { print $1, $2, $3, $8, "Source"; next }
{
iface=$1; dest=hex_reverse_octets($2); gateway=hex_reverse_octets($3); mask=hex_reverse_octets($8);
source_guess=lookup_by_longest_prefix(ADDRS, apply_bitmask(hex_to_bits(dest), hex_to_bits(mask)));
print iface, ipv4_hex_to_decimal(dest), ipv4_hex_to_decimal(gateway), ipv4_hex_to_decimal(mask), source_guess;
}