Skip to content

Instantly share code, notes, and snippets.

View rgov's full-sized avatar
🤿

Ryan Govostes rgov

🤿
View GitHub Profile
#!/bin/bash -eu
# remount-circuitpy.sh -- remount a FAT disk, usually CIRCUITPY, so it works
#
# Works around bug where macOS 14.x causes file corruption on small FAT
# filesystems. The remount apparently causes older kernel FAT driver
# to be loaded. see https://github.com/adafruit/circuitpython/issues/8449
#
# Original author: Tod Kurt @todbot
DISKNAME=${1:-CIRCUITPY}
#!/bin/bash -eu
process_binary() {
local binary="$1"
echo "[*] Processing $binary..."
# Find all linked libraries from the Homebrew prefix
local libraries=(
$(otool -L "$binary" | grep '/usr/local/opt/' | awk '{print $1}')
)
@rgov
rgov / debruijn.py
Last active November 14, 2023 07:37
de Bruijn sequence generator
def deBruijn(n, k):
'''
An implementation of the FKM algorithm for generating the de Bruijn
sequence containing all k-ary strings of length n, as described in
"Combinatorial Generation" by Frank Ruskey.
'''
a = [ 0 ] * (n + 1)
def gen(t, p):
@rgov
rgov / dev.foxglove.Studio.yaml
Last active October 6, 2023 22:00
INCOMPLETE - Flatpak manifest for Foxglove Studio
# Based on https://github.com/flathub/com.nordpass.NordPass by @FakeShemp
# wget https://raw.githubusercontent.com/flathub/com.nordpass.NordPass/e93574f94b4387917fb8d5b0fb725660b2b01817/gcc10.diff
# wget https://raw.githubusercontent.com/flathub/com.nordpass.NordPass/e93574f94b4387917fb8d5b0fb725660b2b01817/xz_support.patch
# flatpak install flathub org.freedesktop.Platform//22.08 org.freedesktop.Sdk//22.08 org.electronjs.Electron2.BaseApp//22.08
# sudo flatpak-builder --install --force-clean build-dir dev.foxglove.Studio.yaml
# flatpak run dev.foxglove.Studio
app-id: dev.foxglove.Studio
base: org.electronjs.Electron2.BaseApp
@rgov
rgov / build
Last active June 24, 2023 23:31
Building a patched Ubuntu kernel
#!/bin/bash -eu
LINUX_META_PKG='linux-meta'
LINUX_PKG='linux-image-unsigned-"$KERNEL_ABI_VERSION"-generic'
# Enable apt source repositories
sed -i '/^deb /{n; s/^# deb-src/deb-src/;}' /etc/apt/sources.list
apt update
apt install -y dpkg-dev
#!/usr/bin/env python3
'''
I asked ChatGPT (GPT-4) to write some Z3 code that tries to generate a string
that roughly matches the letter frequency distribution of normal English text.
It got the implementation _very_ close on the first try. However, Z3 is not able
to make progress on the problem.
'''
from z3 import *
#!/usr/bin/env python3
'''
This file implements a wrapper API over the Triton Inference Server client API.
The wrapper API makes it easier to work with models that require pre- or post-
processing of their inptus and outputs, like image classification models:
model = Model(triton, 'feline_breed')
model.input = ImageInput(scaling=ScalingMode.INCEPTION)
model.output = ClassificationOutput(classes=1)
@rgov
rgov / jade-tcp-client.py
Created January 6, 2023 08:39
Example of commicating with the Sixclear JADE TCP Server plug-in
import json
import socket
import struct
def send_obj(s, obj):
# JSON-encoded object with a length prefix (32-bit, big endian, signed?)
encoded = json.dumps(obj).encode()
s.send(struct.pack('!l', len(encoded)) + encoded)
@rgov
rgov / debootstrap-docker.diff
Created December 18, 2022 00:07
Differences between a debootstrap'd chroot and a Docker container for Ubuntu Bionic
Only in debootstrap/bin: chvt
Only in debootstrap/bin: cpio
Only in debootstrap/bin: dumpkeys
Only in debootstrap/bin: fgconsole
Only in debootstrap/bin: ip
Only in debootstrap/bin: journalctl
Only in debootstrap/bin: kbd_mode
Only in debootstrap/bin: kmod
Only in debootstrap/bin: less
Only in debootstrap/bin: lessecho
@rgov
rgov / Dockerfile
Last active December 12, 2022 23:52
Example of using supervisord in a container
FROM debian:buster
# Install system dependencies
RUN apt update \
&& apt install -y \
supervisor \
&& rm -rf /var/lib/apt/lists/*
COPY supervisord.conf /etc/supervisor/supervisord.conf