Skip to content

Instantly share code, notes, and snippets.

View olithissen's full-sized avatar
🏠
Working from home

Oli Thissen olithissen

🏠
Working from home
View GitHub Profile
@olithissen
olithissen / AssertCollector.java
Last active November 12, 2024 08:41
A small Java util class to don't have JUnit 5 fail on each assert. Handy if you have multiple asserts in one test and don't want to fix each failure one by one ...
package net.tonick.demo
import org.junit.jupiter.api.function.Executable;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.fail;
/**
@olithissen
olithissen / get_all_statuses.sh
Created November 23, 2023 18:44
A bash script to retrieve all account statuses using the Mastodon API
#!/bin/bash
instance="your.instance.org"
access_token="your_access-token"
account_id="your-account-id"
api_endpoint="https://${instance}/api/v1/accounts/${account_id}/statuses"
min_id="1"
while true; do
response=$(curl -s -X GET -H "Authorization: Bearer ${access_token}" "${api_endpoint}?min_id=${min_id}&limit=40")
@olithissen
olithissen / vector.sql
Created May 30, 2023 09:14
PL/pgSQL vector and matrix functions
CREATE OR REPLACE FUNCTION get_vector_from_angles(azimuth double precision, altitude double precision) RETURNS double precision[] AS
$$
DECLARE
vector double precision[];
BEGIN
vector := ARRAY [ sin(azimuth) * cos(altitude),cos(azimuth) * cos(altitude), sin(altitude) ];
RETURN vector;
END;
$$ LANGUAGE plpgsql IMMUTABLE;

openpgp4fpr:1746113F877E72AC51E75B970E41827D76D10766