Skip to content

Instantly share code, notes, and snippets.

View rikmeijer's full-sized avatar

Rik Meijer rikmeijer

View GitHub Profile
@rikmeijer
rikmeijer / nostr-proof
Last active November 18, 2024 07:29
nostr-proof
Verifying that I control the following Nostr public key: npub1efz8l77esdtpw6l359sjvakm7azvyv6mkuxphjdk3vfzkgxkatrqlpf9s4
@rikmeijer
rikmeijer / checksum-trigger.php
Created June 13, 2025 11:24
Trigger checksum generator in Nextcloud, remotely
<?php
/**
* This script uses "sabre/dav" Client to make webdav requests to a Nextcloud instance.
* The "nextcloud-checksum-update" option is a, somewhat, hidden feature in the Sabre Connector (Checksum Update Plugin)
* https://github.com/nextcloud/server/blob/master/apps/dav/lib/Connector/Sabre/ChecksumUpdatePlugin.php
*
* The basic flow is:
* - PROPFIND on /remote.php/dav/Photos (explicitly asking for '{http://owncloud.org/ns}checksums' property)
* - use the proper hash from the response
#!/bash/sh
for dir in ./*/
do
dir=${dir%*/}
album="${dir##*/}"
docker run -it -d --name "upload_${album//[^0-9a-zA-Z]/_}" -v "$(pwd)":/import:ro -e IMMICH_INSTANCE_URL=https://<IMMICH_DOMAIN>/api -e IMMICH_API_KEY=API_KEY_HERE ghcr.io/immich-app/immich-cli:latest upload --album --concurrency 5 --recursive ${album}
done
@rikmeijer
rikmeijer / gist:395a3c079a7be7ba0a3d043846072300
Created August 14, 2025 13:26
generate-nextcloud-release
#!/bin/sh
# Based on instruction at https://nextcloudappstore.readthedocs.io/en/latest/developer.html
# Call ./generate-nextcloud-release <APP_ID>
# Assuming app is in folder <APP_ID>
# and assuming signing key is in ~/.nextcloud/certificates/<APP_ID>.key
tar --exclude=".git*" -czf $1.tar.gz noxtr
openssl dgst -sha512 -sign ~/.nextcloud/certificates/$1.key $1.tar.gz | openssl base64
@rikmeijer
rikmeijer / gist:ad692f1e4ef02616e6e9e89be860f91d
Created February 24, 2026 17:11
fix originalDatetime based on filename for immich assets (searching for signal- in this example)
<?php
$uri = "https://immich.example.org/api";
$api_key = "<API_KEY_HERE>";
$request = function(string $method, string $endpoint, mixed $body = null, array $headers = []) use ($uri, $api_key) {
$curl = curl_init($uri . $endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
@rikmeijer
rikmeijer / import.php
Created June 16, 2026 08:38
Simple script to import nostrdeck backups into relays.
<?php
// composer require nostriphant/client
require __DIR__ . '/vendor/autoload.php';
$nostrdeck_backup_file = 'nostr-backup-XXX.json';
$target_relays = ['wss://1.2.3.4'];
$events = \nostriphant\NIP01\Nostr::decode(file_get_contents($nostrdesk_backup_file));
$nostr = \nostriphant\Client\Client::connectToUrl(...$target_relays);
$nostr(fn(callable $send_event, callable $subscribe) => nostriphant\Functional\Iterator::walk($events, fn($event, $index) => $send_event(new \nostriphant\NIP01\Event(...$event), fn($accepted, $reason) => var_dump($index, $accepted, $reason))));
@rikmeijer
rikmeijer / fix.php
Created July 7, 2026 11:10
immich-data-fixer
<?php
// simple script to fix some data issues on my Immich installation
$uri = "https://immich.example.org";
$api_key = "ApIk3Y";
$request = function(string $method, string $endpoint, mixed $body = null, array $headers = []) use ($uri, $api_key) {
$curl = curl_init($uri . $endpoint);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);