Skip to content

Instantly share code, notes, and snippets.

View raylee's full-sized avatar

Ray Lee raylee

View GitHub Profile
@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"
@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 / 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 / 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 / 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 / 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 / make-openbsd-virt
Last active May 25, 2020 02:57
example of creating an openbsd 6.6 virtual machine with virt-install / kvm
#!/bin/bash
OWNER=libvirt-qemu:libvirtd
RELEASE=https://cloudflare.cdn.openbsd.org/pub/OpenBSD/6.6/amd64
function sudo {
command sudo -p "Please enter password for %u@%h to fiddle with virtual machines: " ls /dev/null >/dev/null
command sudo "$@"
}
@raylee
raylee / macapp.go
Created February 20, 2020 18:38 — forked from mholt/macapp.go
Distribute your Go program (or any single binary) as a native macOS application
// Package main is a sample macOS-app-bundling program to demonstrate how to
// automate the process described in this tutorial:
//
// https://medium.com/@mattholt/packaging-a-go-application-for-macos-f7084b00f6b5
//
// Bundling the .app is the first thing it does, and creating the DMG is the
// second. Making the DMG is optional, and is only done if you provide
// the template DMG file, which you have to create beforehand.
//
// Example use:
@raylee
raylee / appify
Created January 26, 2020 23:35 — forked from mathiasbynens/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh