Clone me with the URL at right! Make changes!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Explanation: | |
# * `-v CHUNK_SIZE=128 -v CHUNK_OFFSET=0 -v CHUNK_COUNT=32` configures the process: | |
# * 128 octets per chunk | |
# * don't skip any leading chunks | |
# * stop after outputting data for 32 chunks (i.e., 128×32=4 KiB of data) | |
# * `LC_ALL=C` makes sure that numbers above 127 don't get transformed into multi-octet sequences. | |
# * `--re-interval` and `RS=".{" CHUNK_SIZE "}"` expresses fixed-length records of CHUNK_SIZE octets. | |
# * `OCTETS` is a string of all possible octets 0x00 through 0xFF in numerical order. | |
# * `NR>CHUNK_OFFSET` only matches after the first CHUNK_OFFSET records. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
description = """ | |
Replaces JSON Schema/OpenAPI "allOf" arrays with an expansion of their contents. | |
An "allOf" array containing a reference to its parent schema is not replaced, | |
although the self-reference is removed. | |
"description" and "summary" are not copied from a $ref target unless it is | |
a duplicate of the previous $ref target. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Editor Tweaks | |
// @namespace https://github.com/gibson042 | |
// @description <{Command,Ctrl}+[;BIK…]> commands to control Markdown inside textareas, {Command,Ctrl}+Alt+mousedown to toggle monospace. | |
// @source https://gist.github.com/gibson042/13f4bf8ee4c0905c0abcb0f4edbcf55f | |
// @updateURL https://gist.github.com/gibson042/13f4bf8ee4c0905c0abcb0f4edbcf55f/raw/editor-tweaks.user.js | |
// @downloadURL https://gist.github.com/gibson042/13f4bf8ee4c0905c0abcb0f4edbcf55f/raw/editor-tweaks.user.js | |
// @version 0.6.1 | |
// @date 2024-11-25 | |
// @author Richard Gibson <@gmail.com> |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Focus Search | |
// @namespace https://github.com/gibson042 | |
// @description Responds to <{Command,Ctrl}+/> by attempting to find and focus a page's search box. | |
// @source https://gist.github.com/gibson042/c9b3406bc54f55726ec4 | |
// @updateURL https://gist.github.com/gibson042/c9b3406bc54f55726ec4/raw/focus_search.user.js | |
// @downloadURL https://gist.github.com/gibson042/c9b3406bc54f55726ec4/raw/focus_search.user.js | |
// @version 0.4.0 | |
// @date 2023-09-08 | |
// @author Richard Gibson <@gmail.com> |
jQuery.xhr
will be an asynchronous HTTP request API returning standards-compliant thenables. We have identified two possible approaches:
- Autosend: control by
options
parameter; advanced functionality viabeforeSend
(similar tojQuery.ajax
) - Chainable: control by
options
and/or chainable setters; advanced functionality viasend: false
and a chainablesend
method
This gist compares the approaches by imagining their use for current jQuery.ajax
examples. To better highlight differences, chaining methods will be used instead of options
more heavily than is likely in actual practice (assuming that options
is available in the "Chainable" solution).