Skip to content

Instantly share code, notes, and snippets.

@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.

@rgov
rgov / Dockerfile
Created October 16, 2022 18:27
Example of building a custom Ubuntu kernel + metapackages
ARG RELEASE_CODENAME=bionic
ARG KERNEL_VERSION=4.15.0-176-generic
FROM ubuntu:${RELEASE_CODENAME} AS common_deps
# A pecularity of Docker is that we need to repeat args here
ARG RELEASE_CODENAME
# Add source repositories
@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
@rgov
rgov / gist:59a957d9d475a876bb86059c7b8baba3
Created October 5, 2022 16:24
Files in /System/Library on macOS Monterey 12.6 that link to LinkPresentation.framework
% find /System/Library -not -iname '*.*' -exec sh -c 'otool -L {} | sed -e s!^!{}\t!' \; 2>/dev/null | grep LinkPresentation | cut -d $'\t' -f 2-
/System/Library/Messages/iMessageBalloons/MSMessageExtensionBalloonPlugin.bundle/Contents/MacOS/MSMessageExtensionBalloonPlugin
/System/Library/Messages/iMessageBalloons/RichLinkProvider.bundle/Contents/MacOS/RichLinkProvider
(a few extraneous results are omitted from LinkPresentation.framework itself)