Skip to content

Instantly share code, notes, and snippets.

View raylee's full-sized avatar

Ray Lee raylee

View GitHub Profile
@raylee
raylee / virt
Created March 12, 2020 02:05
A note on using virsh and virt-install to set up and manage a VM, tested once. Because reading a script is faster than googling random pages.
#!/bin/bash
MAC=52:54:00:__:__:__
VIRTNAME=______
VM_STORAGE_DIR=/srv/virts
BRIDGE=br0
INSTALLER=http://archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/
OS_VARIANT=ubuntu18.04 # from `osinfo-query os`
cmd=$(basename $0)
@raylee
raylee / install.sh
Created May 7, 2020 15:15 — forked from dzindra/install.sh
Raspberry PI read only filesystem with writable overlay
#!/bin/bash
cp overlay /etc/initramfs-tools/scripts/
echo "overlay" >> /etc/initramfs-tools/modules
mkdir /overlay /overlay/temp /overlay/base
update-initramfs -c -k `uname -r`
echo "initramfs initrd.img-`uname -r`" >> /boot/config.txt
echo "boot=overlay `cat /boot/cmdline.txt`" > /boot/cmdline.txt
@raylee
raylee / actout.py
Created June 30, 2020 18:00
Convert a text file with R G B values [0-255] separated by whitespace, one triplet per line, to Photoshop's ACT format.
#!/usr/bin/env python3
import os, struct, sys
if len(sys.argv) < 3:
sys.exit(
"Convert a text file with up to 256 RGB values to Photoshop's ACT format\n\n"
" Usage: " +sys.argv[0] + " <infile> <outfile>\n"
" <infile> is a text file with R G B values [0-255] separated by\n"
" whitespace, one triplet per line\n"
" <outfile> will be written in Photoshop's .ACT color format\n"
@raylee
raylee / act-out.go
Last active July 1, 2020 03:15
Convert a text file with R G B values [0-255] separated by whitespace or commas, one triplet per line, to Photoshop's ACT format.
package main
import (
"fmt"
"io/ioutil"
"os"
"strconv"
"strings"
)
@raylee
raylee / braille.go
Last active July 3, 2021 21:03
Translate a dot pattern to the correct Unicode braille codepoint
package main
import "fmt"
type BrailleDots [4][2]bool
func (b BrailleDots) String() string {
var braille uint32 = 0x2800
set := [4][2]uint32{
{0x01, 0x08},
@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"
@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 / 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 / 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 / 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