Skip to content

Instantly share code, notes, and snippets.

View aconz2's full-sized avatar

Andrew Consroe aconz2

View GitHub Profile
@aconz2
aconz2 / inspecttar.py
Created October 25, 2024 20:10
little script to print out tar file info and also for oci image manifest per layer
#!/usr/bin/env python
import tarfile
import json
from pathlib import Path
import argparse
types = {}
for k in 'REGTYPE AREGTYPE LNKTYPE SYMTYPE DIRTYPE FIFOTYPE CONTTYPE CHRTYPE BLKTYPE GNUTYPE_SPARSE'.split():
types[getattr(tarfile, k)] = k
/*
* Do the thing in https://github.com/containers/bubblewrap/issues/592#issuecomment-2243087731
* unshare --mount
* mount --rbind / /abc --mkdir
* cd /abc
* mount --move . /
* chroot .
*/
#define _GNU_SOURCE
git clone https://github.com/bytecodealliance/wasmtime/
cd wasmtime
git checkout 87817f38a128caa76eaa6a3c3c8ceac81a329a3e
RUST_MIN_STACK=1048576 cargo build # segfaults
coredumpctl -1 dump > core
or
SYSTEMD_DEBUGGER=lldb coredumpctl -1 debug
RUST_MIN_STACK=1048576 strace --stack-traces -f --trace='open,openat' cargo build
@aconz2
aconz2 / qemu-fedora-cloud.sh
Last active July 9, 2024 21:27
qemu fedora cloud explicit kernel and initrd learnings
# download fedora cloud qcow2 image
wget https://download.fedoraproject.org/pub/fedora/linux/releases/40/Cloud/x86_64/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2
# set root password to hello
virt-customize -a Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2 --root-password password:hello
# this extracts the kernel binary and initramfs from the qcow2 image
# this lets you pass custom kernel parameters, qemu requires passing -kernel in order to use -append
# https://www.kernel.org/doc/html/latest/admin-guide/kernel-parameters.html
virt-get-kernel -a Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2
@aconz2
aconz2 / Containerfile
Last active June 28, 2024 20:18
run singularity from a container just to test it out
# TODO idk what a good base package is
FROM ubuntu:24.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && \
apt-get install -y wget \
cryptsetup \
libfuse-dev \
squashfs-tools \
uidmap \
@aconz2
aconz2 / lldbtest.py
Created August 8, 2021 17:20
Example using the lldb Python bindings to create breakpoints, run a program, and step through programatically
import lldb
import os
import sys
symbol_types = {}
for x in dir(lldb):
if x.startswith('eSymbolType'):
symbol_types[getattr(lldb, x)] = x[len('eSymbolType'):]
dbg = lldb.SBDebugger.Create()
@aconz2
aconz2 / inkscapeautosmoothnodes.py
Last active November 25, 2022 07:40
Implements the auto-smooth node type from Inkscape in Python with svgpathtools. Keywords: fitting cubic bezier curve spline points smooth
import svgpathtools as svg
from typing import List, Tuple
def points(path: svg.Path):
for seg in path:
yield seg.start
yield path.end
def normalized(x: complex) -> complex:
return x / abs(x)
@aconz2
aconz2 / cookie-cutter-cutter.scad
Created February 21, 2021 04:55
Easy way to make cookie cutters from an SVG or DXF using openscad for 3d printing
@aconz2
aconz2 / serve-serial.sh
Created February 12, 2021 22:55
proxy serial port from laptop to virtual machine running on a server
# on server that has virtual machine, IP is 192.168.1.207
# in virt-manager, add a serial port, it will show up as /dev/pts/something
sudo socat -d -d file:/dev/pts/1 TCP-LISTEN:9090
# on laptop that is plugged into device, -x will log communication as hex
sudo socat -x -d -d /dev/ttyUSB0,b9600,raw TCP:192.168.1.207:9090
# then remote into virtual machine and use the serial port!
@aconz2
aconz2 / blenderlivereload.py
Last active April 20, 2020 00:08
Blender plugin to rerun a Python script on change. Still buggy properly shutting down
from threading import Event, Thread
import bpy
from inotify_simple import INotify, flags
import traceback
# this is still buggy on properly cleaning things up on exit
def run(exit: Event, changed: Event, filename):
inotify = INotify()
inotify.add_watch(filename, flags.MODIFY)