Skip to content

Instantly share code, notes, and snippets.

View raylee's full-sized avatar

Ray Lee raylee

View GitHub Profile
@raylee
raylee / .gitconfig
Last active February 17, 2024 20:00
.gitconfig aliases to give an overview of all branches in a repository.
[alias]
# branches: List recent branches sorted by date
# ${COLUMNS} is the standard environment variable to use to get the terminal's width. Unfortunately
# git sanitizes that away. git 2.31 will have a way to keep that variable. For now, extract it from
# the environment via stty. The below adds 20 to that value to account for the overhead of ANSI
# color sequences.
branches = !git for-each-ref refs/heads \
--color=always \
--sort=-committerdate \
--format='%(HEAD)%(color:bold blue)%(refname:short)|%(color:green)%(committerdate:relative)|%(color:blue)%(authorname)|%(color:reset)%(subject)' \
@raylee
raylee / Reed-Solomon-encoder.md
Last active September 27, 2022 04:07
gf256 implements arithmetic over the Galois Field GF(256) and Reed-Solomon encoding. A mechanical transliteration of rsc.io/qr/gf256. ECCs about 115MiB/s/thread on a low-end virt or laptop.
local wezterm = require 'wezterm'
--~~ customizing themes for translucency
local nordCoal = wezterm.get_builtin_color_schemes()['nord']
nordCoal.background = '#000000'
wezterm.on('toggle-opacity', function(window, pane)
local overrides = window:get_config_overrides() or {}
local opacity = overrides.window_background_opacity or 1
@raylee
raylee / queue.h
Last active August 23, 2022 05:58
// Ray Lee 2022 August 22 ~ license CC0
#ifndef circular_queue_h
#define circular_queue_h
#include <stdint.h>
#include <stddef.h>
/* There are two ways a circular queue can deal with a request to enqueue
// Package letterbag provides operations on bags of letters.
package letterbag
import "errors"
// This implementation trades off perfect accuracy for speed and space. For a
// more straightforward version substitute `type Bag [26]int` and adjust
// accordingly.
//
// Below the 'a' to 'z' alphabet is represented by 26 prime numbers. Words are
@raylee
raylee / how.sh
Last active January 6, 2021 14:34
notes on exporting a wordpress site
#!/bin/bash
# Create a list of pages from the website, one url per line, in a file named "pages". Easiest
# way for small sites is to get them from the admin interface, open each page in a tab then
# copy all tab URLs to the clipboard via chrome extension:
# https://chrome.google.com/webstore/detail/copy-all-urls/djdmadneanknadilpjiknlnanaolmbfk?hl=en
# Have ripgrep and wget handy. The heavy lifting is done by an html to markdown lib, wrapped here:
# https://github.com/suntong/html2md#usage
for page in $(cat pages); do
@raylee
raylee / zipguess.go
Last active October 23, 2020 19:51
guesses passwords for zip files
package main
// zipguess.go
// reads a tsv file, one set of possibilities per line
// one possibile segment is chosen from each line in order
// and concatenated together into a guess
import (
"flag"
@raylee
raylee / xterm-kitty
Created October 8, 2020 17:56
terminfo dump of xterm-kitty. Recompile it via tic -x -o /usr/share/terminfo
# Reconstructed via infocmp from file: /home/ray/.terminfo/x/xterm-kitty
xterm-kitty|KovIdTTY,
am, ccc, hs, km, mc5i, mir, msgr, npc, xenl,
colors#256, cols#80, it#8, lines#24, pairs#32767,
acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
bel=^G, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
clear=\E[H\E[2J, cnorm=\E[?12l\E[?25h, cr=^M,
csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
cud=\E[%p1%dB, cud1=^J, cuf=\E[%p1%dC, cuf1=\E[C,
cup=\E[%i%p1%d;%p2%dH, cuu=\E[%p1%dA, cuu1=\E[A,
@raylee
raylee / mdpdf.go
Created October 5, 2020 05:34
Convert markdown to pdf using goldmark and wkhtmltopdf.
package main
import (
"bytes"
"flag"
"io/ioutil"
"log"
"path"
"github.com/yuin/goldmark"
@raylee
raylee / interact.go
Last active January 6, 2021 14:34
wrapper for https://github.com/google/goexpect which gives it a simpler interface, plus a multiWriteCloser implementation for logging.
// Interact wraps google/goexpect with a simpler interface
package main
import (
"io"
"log"
"regexp"
"time"