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 / 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 / reboot-recovery.c
Last active November 30, 2022 02:04
Tool to reboot an NVIDIA Jetson device into recovery mode
/*
Tool to reboot an NVIDIA Jetson device into recovery mode. Run as root.
Based on https://forums.developer.nvidia.com/t/remote-reboot-into-recovery-mode/36032/4
*/
#include <linux/reboot.h>
#include <sys/syscall.h>
#include <unistd.h>
int main() {
@rgov
rgov / README.md
Created November 6, 2022 13:08
Script for building the Linaro compiler toolchain

I wanted to compile software for NVIDIA Jetson release r32.7 using the recommended Linaro gcc 7.3.1 2018.05 aarch64 toolchain. However there is no binary release for native compilation on aarch64 hosts, so I needed to build my own copy of the toolchain. This script does so.

Note that from Jetson release r34, the toolchain has changed to the Bootlin gcc toolchain. This script does not compile this toolchain.

Thanks to Vivin Uthappa for his blog post that introduced the process of building the Linaro toolchain.