Skip to content

Instantly share code, notes, and snippets.

View pfichtner's full-sized avatar

Peter Fichtner pfichtner

View GitHub Profile
@pfichtner
pfichtner / extract_gpx.py
Created July 26, 2025 11:52
Extract GPX data from gopro mp4
import sys
import os
import subprocess
from datetime import datetime, timezone
import gpxpy.gpx
from py_gpmf_parser.gopro_telemetry_extractor import GoProTelemetryExtractor
def extract_gpmd_stream(mp4_path, output_bin="gpmd_stream.bin"):
print("Extracting telemetry stream from MP4...")
cmd = [
@pfichtner
pfichtner / run-stub-service.sh
Last active April 10, 2025 08:33
Run a pact server providing the interactions from a pact file
docker run \
--rm \
--network=host \
-it \
-v $PWD/pacts/:/pacts \
pactfoundation/pact-cli:latest \
stub-service --port=8080 '/pacts/*'
# -p 8080:8080 instead of --network=host did not work
@pfichtner
pfichtner / gist:2e2611009e5dcd26a182f34f9055564d
Created January 1, 2024 23:25
Automatically unlock a remote luks drive
#!/bin/bash
# client: ssh-keygen -f $keyname -t rsa -b 4096 -o -a 100
# server: apt install dropbear-initramfs
# server: add generated public key of keypair to /etc/dropbear/initramfs/authorized_keys
# server: update-initramfs -u
REMOTE_USER="root"
REMOTE_HOST="192.168.x.xxx"
IDENTITY_FILE="~/.ssh/lukstest"
@pfichtner
pfichtner / PartitionBySeparator.java
Last active February 1, 2023 21:33
Partition a Stream of objects (e.g. Strings) into a Stream of Lists based on a separator in the Stream
import static java.util.function.Predicate.not;
import static java.util.stream.Collectors.toList;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.BinaryOperator;
import java.util.function.Predicate;
import java.util.function.Supplier;
package sonarsweep;
import static java.lang.Integer.MAX_VALUE;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.IntPredicate;
import java.util.stream.IntStream;
@pfichtner
pfichtner / esphome-ota-update.sh
Created August 8, 2021 22:11
Waits til device is online and then sends the new compiled firmware
#!/bin/sh
# waits til device is online and then sends the new compiled firmware
# uses https://esphome.io/components/deep_sleep.html#deep-sleep-prevent-action but should also work without it
if [ $# -eq 0 ]; then
echo "No arguments supplied"
exit 1
fi
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import static java.util.Arrays.asList;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.Date;
@pfichtner
pfichtner / restore-file-revisions-from-git.sh
Created December 2, 2018 10:32
Checks out each commit and copies $COPY_ONLY of each revision to /tmp
#!/bin/sh
dir=$1
COPY_ONLY=target/surefire-reports
count=1
#git log $dir | grep ^commit | cut -d' ' -f2 | while read TAG; do
cd $dir && git branch -a --sort=committerdate | grep -v ' -> ' | while read TAG; do
echo $count $TAG
count=`expr $count + 1` && \
@pfichtner
pfichtner / replay.sh
Created December 2, 2018 10:30
reruns all tests on each git commit and copy the results to tmp
#!/bin/sh
DIRECTORY=$1
count=1
cd $DIRECTORY && git log --date-order --reverse --grep="autocommit on change" | grep ^commit | cut -d' ' -f2 | while read TAG; do
git clean -fd && \
git reset --hard $TAG && \
rm -rf target/surefire-reports target/allure-results && \
mvn test ; \