Skip to content

Instantly share code, notes, and snippets.

View speters's full-sized avatar

Sönke J. Peters speters

View GitHub Profile
@speters
speters / warpmail.py
Created October 12, 2025 17:16
Download last month's charging log from WARP3 as PDF via http API and send it via email.
#!/usr/bin/env python3
#
# warpmail.py
#
# Downloads last month's charging log from WARP3 as PDF via http API and sends it via email.
#
# Crontab example:
# 0 5 1 * * /home/me/warpmail.py >/dev/null 2>&1
#
# Configuration is done in /etc/smtpclient.ini or ~/.smtpclient.ini as follows:
@speters
speters / experiment_synced_primarykey__uuid.sql
Created November 18, 2024 13:31
Experiment syncing FIDs (feature ids) in a GeoPackage (gpkg) for unique fids across all layers
/* primary key autoincrement syncing across tables */
/* fids table: holds all primary keys of synced tables */
DROP TABLE IF EXISTS fids;
CREATE TABLE fids (
fid INTEGER PRIMARY KEY AUTOINCREMENT,
rel TEXT NOT NULL
);
/* fids table trigger: updates the autoincrement sequence number of synced tables */
@speters
speters / shotwell_photodb_viewbytag.sql
Created May 15, 2024 13:02
Shotwell photo.db sqlite view by tag name
-- Shotwell photo.db SQLITE VIEW to query by tag_name
--
-- Usage after creating the view:
-- SELECT * from v_tagged_photos WHERE tag_name LIKE '%slo%';
--
-- (the view is as hellish as the db layout of Shotwell)
--
-- thx @ https://gist.github.com/ChiChou/97a53caa2c0b49c1991e?permalink_comment_id=4721301#gistcomment-4721301
-- thx @ https://stackoverflow.com/questions/46483859/split-values-in-parts-with-sqlite
@speters
speters / README.md
Last active January 27, 2024 16:07
UserScripts

UserScripts

@speters
speters / README.md
Last active January 5, 2024 13:41
codeanywhere PlatformIO install

PlatformIO install on CodeAnywhere

For the Xenial distribution, there are some fixes needed, as PlatformIOs urllib3 depends on newer SSL libs.

So just get an older urllib3 implementation via PIP and copy over to PlatformIO.

Container

set up a Python container first

Block sinks in sea water

You:

a block with length 0.35m, width 0.25m, height 0.35m weighs 12kg. How deep does it sink in sea water?

ChatGPT:

To determine how deep the block sinks in sea water, we need to consider the buoyant force acting on the block and compare it to the weight of the block.

The buoyant force is equal to the weight of the water displaced by the block. In this case, the block is submerged in sea water, which has a density of approximately 1,025 kg/m³.

@speters
speters / db_to_gpx.py
Created June 8, 2023 12:15 — forked from endolith/db_to_gpx.py
Maprika sqlite database to GPX track converter
"""
Written by GPT3 from this English prompt (with one tweak to the prompt, to get
the timestamp parameter to not error out, and PEP8 fixes):
----
1. Open a sqlite database with a name like `2022-07-17 17.48.19.db` or
`2021-04-11 08.44.16.db`
2. Inside is a table called `locations`, with headers [LOCTYPE INTEGER,
TIMESTAMP BIGINT, LATITUDE REAL, LONGITUDE REAL,ALTITUDE REAL, ACCURACY
@speters
speters / ftoktest.c
Created January 26, 2023 12:02
ftok implementation test
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/stat.h>
void touch(char *file_name) {
FILE *fp;
if ((fp = fopen(file_name, "w")) == NULL) {
@speters
speters / candump2ydcanview.sh
Created July 8, 2022 19:21
A simple candump to yacht devices canview converter using netcat and some sed
candump -t A can0 | sed -e 's/ (.* \(.*\)\.\(...\).*) *can. *\([0-9A-F]*\) *\[.*\] */\1.\2 R \3 /g' -e 's/[\r\n]*$/\r/' | nc -l -p 1457 2>&1 | sed -u -n -e 's/^\([^ ]*\) /\1#/g;s/ //g;s/\r//g;/^$/!p;' | while IFS="" read CMD ; do cansend can0 $CMD ; done
@speters
speters / NASAClipper_I2C_to_NMEA.ino
Last active June 29, 2025 19:24
Decode the NASA Clipper Data into a NMEA compatible serial string; https://wiki.openseamap.org/wiki/De:NASA_Clipper_Range
/*
NASAClipper_I2C_to_NMEA v0.5.2
Decode the NASA Clipper Data into a NMEA compatible serial string
written by Peter Holtermann
with additions from Victor Klein