Skip to content

Instantly share code, notes, and snippets.

View mhelsley's full-sized avatar

Matt Helsley mhelsley

View GitHub Profile

RFC: Enable Grouping of Code Blocks in CommonMark

Abstract

It may be useful to group multiple code blocks while interspersing non-code sections (e.g. step-by-step explanations) between them.

Background and Motivation

Some tools process code blocks to test them and ensure they

@mhelsley
mhelsley / highlighting.md
Created June 9, 2022 03:30
Preserve CLI color output

Many commands determine whether to color their output using escape sequences by checking if their output file descriptor is a terminal.

This doesn't work very well when piping that output into a pager like more or less.

(Ideally UNIX folks would have created a way to determine if executables in a pipeline preserve color escape sequences and if the output fd at the very end of a pipeline was a tty or not. But they didn't.)

So many commands have an explicit command line option that can be used to specify that the color output should turned on, off, or be switched based on the immedita-output-fd type.

This is a collection of the common ones on a typical Linux (especially the GNU-centric distros) system.

@mhelsley
mhelsley / remove-snap-crap.sh
Created December 14, 2020 00:12
Remove snap droppings -- snaps leave stale revisions which incur startup cost by littering your system with systemd mount units and possibly more.
snap list --all | grep disabled | awk '{print $1 " " $3}' | while read SNAP REV ; do sudo snap remove $SNAP --revision $REV; done
@mhelsley
mhelsley / fdswap.sh
Last active September 24, 2020 22:28
Swap file descriptors in running processes
#!/bin/bash
#
# fdswap
# Based on https://www.redpill-linpro.com/sysadvent/2015/12/04/changing-a-process-file-descriptor-with-gdb.html
# Alternatives https://github.com/bewakes/fdswap
# Updated by
# anonymous friend of mhelsley
# mhelsley
# defanging, error handling, GDB verbosity/UI quirks, reduced appearance of magic numbers
#

Keybase proof

I hereby claim:

  • I am mhelsley on github.
  • I am mhelsley (https://keybase.io/mhelsley) on keybase.
  • I have a public key whose fingerprint is B31D 6147 08C6 3AD2 2848 F50D 102C 49AD 7831 F4C9

To claim this, I am signing this object: