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 / 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 July 4, 2022 11:37
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
@speters
speters / Ais SOTDMA Transceiver B600 pinout.md
Last active December 8, 2021 16:03
Ais SOTDMA Transceiver B600 pinout

Ais SOTDMA Transceiver B600 pinout

In einer Abbildung im Manual kann man auf der Buchse ein "LTW" lesen, also AmphenolLTW als Hersteller. Das Kabel könnte dann ABU-12BFFM-LL7A__ sein.

Mit den Platinenbildern der FCC Anmeldung kann man nachvollziehen, an welche Pins die NMEA-Datenleitungspaare gehen. Ausserdem kann man die Leitungen der "silent" Pins in Richtung eines ICs sehen, der ein Optokoppler sein könnte, was zur Funktion passen würde.

Die Litzenfarben des Amphenol-Pigtails entsprechen denen aus dem Handbuch des AIS Senders.

@speters
speters / fbhostfilter.py
Last active September 8, 2021 18:13
FritzBox HostFilter script to enable/disbale WAN access of lan devices
#!/usr/bin/env python3
import tr064
import argparse
import configparser
from os import path
from socket import gethostbyname_ex
from time import sleep
args = {}