Skip to content

Instantly share code, notes, and snippets.

@jigpu
jigpu / dump_bos_descriptors.py
Last active March 6, 2024 18:54
Scan the USB bus and print out the BOS descriptors for each device, if they exist.
#!/usr/bin/python3
# dump_bos_descriptors.py
#
# Scan the USB bus and print out the BOS descriptors for each device, if
# they exist. Alternatively, decode and print out the BOS descriptor that
# is passed in via stdin.
#
# Usage: `./dump_bos_descriptors.py [< binary]`
#
@jigpu
jigpu / c4000-ssid.sh
Created January 2, 2024 18:36
Set the SSID / password on C4000BG DSL modems
#!/bin/bash
# Set the SSID / password on C4000BG DSL modems
#
# WARNING: This script does no sanity checking! It does not check
# that the SSID is available, or that it is even well-formed (i.e.
# 32 octets or less in length). Be careful!
set -e
@jigpu
jigpu / usbmon-annotate.awk
Created November 7, 2023 19:59
AWK script to make some usbmon events a bit more readable
# AWK script to annotate output from usbmon
#
# Usage: `awk -f usbmon-annotate.awk < usbmon.log`
#
# Output: If possible, each line of usbmon output will have a human-
# readable description of what it is printed out immediately before
# the usbmon line itself.
#
# For example, the following INPUT:
#
@jigpu
jigpu / compare-commit-upstream.sh
Created August 30, 2023 17:56
Compare a commit in the current (input-wacom) repository with its upstream source.
#!/bin/bash
# compare-commit-upstream.sh
#
# Given a commit ID in the current repository, find the corresponding
# upstream commit and print out the difference, if any. If no upstream
# commit can be found, print a message and exit with code 0.
#
# Usage: ./compare-commit-upstream.sh <local-git-commit-id>
#!/bin/bash
# Perform a distributed kernel build using icecream and a specific compiler
# version.
#
# For example, you might set SUFFIX=-12 to build with the "gcc-12" compiler.
SUFFIX=
export PATH=/usr/lib/icecream/bin:$PATH
@jigpu
jigpu / gpx-to-flightbook-csv.sh
Last active March 19, 2023 17:41
GPX to CSV converter for MyFlightBook
#!/bin/bash
if [[ $# -ne 2 ]]; then
echo "GPX to CSV converter for MyFlightBook"
echo
echo "Converts a GPX file (e.g. from a handheld GPS unit) into a CSV file that"
echo "can be imported into MyFlightBook. Performs basic data filtering, event"
echo "detection, etc."
echo
echo "Usage: $0 <start> <stop>"
@jigpu
jigpu / license-merge.py
Created January 12, 2023 18:39
Extract and merge the copyright headers from a list of files
#!/usr/bin/env python
import sys
import re
"""
Extract and merge the copyright headers from a list of files.
Foreach file:
1. Find a copyright header
@jigpu
jigpu / manifest-calculator.py
Last active December 19, 2022 18:32
Calculate Manifest lines for Chrome OS fwupd package
#!/usr/bin/env python
"""
manifest-calculator.py
Calculate the string which must be added to the Chrome OS Manifest file
as part of the firmware submission process.
Usage:
$ ./manifest-calculator.py <lvfs-cabfile>
@jigpu
jigpu / event-bin-to-text.py
Last active January 30, 2023 20:15
Convert binary Linux kernel input events (e.g. from /dev/input/eventN) into a human-readable list of events.
#!/usr/bin/env python
# Convert binary Linux kernel input events (e.g. from /dev/input/eventN)
# into a human-readable list of events. Takes input from stdin.
#
# Only supports a limited number of event types/codes, but can be extended
# without much effort.
#
# Usage: `sudo cat /dev/input/event<N> | ./event-bin-to-text.py`
#
@jigpu
jigpu / capture-multi.sh
Created April 8, 2022 23:36
Simultaneously capture HID and libinput events from multiple devices
#!/bin/bash
# Usage: capture-multi.sh
# Simultaneously capture HID and libinput events from multiple devices
#
# This script must be run as root in order to read all events.
set -e
trap cleanup INT QUIT TERM