This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# reads a big-endian signed 16-bit .sio file and emits raw pcm samples | |
# usage: ./sio2pcm.py < J1312340.hla.south.sio > J1312340.hla.south.pcm | |
import sys | |
import struct | |
import numpy as np | |
idfield, number_of_records, record_length_bytes_per_channel, C, bytes_per_sample, f0, total_samples_per_channel, endianness_indicator = struct.unpack('>IIIIIIII', sys.stdin.buffer.read(32)) | |
if 32677 != endianness_indicator: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import xml.etree.ElementTree as ET | |
import sys | |
import datetime | |
for trkseg in ET.parse(sys.stdin).find('{http://www.topografix.com/GPX/1/1}trk'): | |
for trkpt in trkseg: | |
lon = float(trkpt.attrib['lon']) | |
lat = float(trkpt.attrib['lat']) | |
timetext = trkpt.find('{http://www.topografix.com/GPX/1/1}time').text |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
for repo in $(find . -mindepth 2 -type d -name '.git' | sed -e 's/\/.git//'); do | |
(cd $repo && | |
git diff --exit-code HEAD && | |
git log --decorate --oneline | head -n1 | grep origin | |
) 1>/dev/null || printf '"%s" has uncommitted or unpushed changes\n' $(basename $repo) >&2 | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import os | |
def plot_image_vs_time(data, timestamps, x0, dx, xlabel, title=None): | |
import datetime | |
try: | |
import numpy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# campbell, 2022-2023 | |
# Given a mesh of already-mutually-known peers, initially not fully connected with non-stale | |
# handshakes, this script will propagate knowledge of current endpoints to peers which need | |
# them, such that in the steady state, the network is fully-connected and will self-heal if | |
# an endpoint moves around. | |
# This conservative implementation requires that a peer already be known to wireguard in | |
# order to have its endpoint updated. No provision is made for having peers forward traffic |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
find . -type f \( -name '*.c' -o -name '*.h' -o -name '*.py' \) \ | |
-not -name 'main*' \ | |
-not -name '__init__.py' \ | |
-not -name 'version.h' \ | |
-not -name 'ViewController.h' \ | |
-not -name 'AppDelegate.h' \ | |
-not -name 'test.c' \ | |
-not -name 'config.h' -exec cksum {} + | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* demo of a three thread generator-style pipeline where the middle thread is a child process, with | |
which communication happens via its stdin and stdout */ | |
#include <stdlib.h> | |
#include <string.h> | |
#include <errno.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/wait.h> | |
#include <pthread.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* blink the LED on the pi zero 2W using /dev/gpiomem, and best-effort realtime timing */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <time.h> | |
#include <unistd.h> | |
#include <fcntl.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use Fcntl qw(:DEFAULT :flock); | |
if (!@ARGV) { die "Usage: $0 fd | { lockfile prog args }\n"; } | |
# get a filehandle to either the supplied filename or fd, depending on whether it is an integer | |
open(my $fh, $ARGV[0] =~ /^\d+$/ ? ">&=" : ">", $ARGV[0]) or die "cannot open: $!\n"; | |
# flock the filehandle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# TODO: this leaks the session key to arguments visible to ps while decrypting | |
set -euo pipefail | |
# if an argument was provided, use it as the path to the rsa private key, otherwise assume openssh | |
keypath=${1:-"$HOME/.ssh/id_rsa"} | |
# deal with converting openssh special file format to something openssl understands | |
TMPFILE=$(mktemp) | |
cp -p "$keypath" $TMPFILE |
NewerOlder