Skip to content

Instantly share code, notes, and snippets.

View alanbchristie's full-sized avatar

Alan B. Christie alanbchristie

View GitHub Profile
@alanbchristie
alanbchristie / notes.txt
Created August 1, 2026 11:50
Updating noip-duc hostnames
# Using v3 (Rust rewrite)
noip-duc --version
# As ours if running as a service,
# edit /etc/default/noip-duc (the systemd unit reads its config from there)
# and change NOIP_HOSTNAMES, then:
sudo systemctl restart noip-duc
sudo systemctl status noip-duc
# One shortcut worth knowing: if you're using DDNS Keys,
@alanbchristie
alanbchristie / pf-example.txt
Created May 27, 2026 11:14
K8s port forward (to neo4j graph)
# Given a the command-line utility kubectl,
# a suitable KUBECONFIG file, and the graph password,
# we can port-forward the bolt interface of the deployed graph to our local machine.
#
# You will need: -
#
# - kubectl
# - A KUBECONFIG file
# - The graph password
#
@alanbchristie
alanbchristie / locate_ips.py
Created May 7, 2026 09:16
Python module to lookup location, organisation and ISP from an IP
"""Look up the geographic location of IP addresses found in a text file.
A self-contained Python module needing only the standard library.
The input is expected to contain pipe-separated lines where the IP address
is the last column, e.g.:
2779 | t | | | 1 | 217.61.227.209
Lines without a parseable IP in the last column are skipped (handles psql
header / separator rows naturally). Private, loopback, link-local and
@alanbchristie
alanbchristie / token-demo.py
Created June 6, 2024 13:49
Simplified API token-demo (Fragalysis)
#! /usr/bin/env python
#
# A simplified 'token-demo'.
# Driven by a number of envieonment variables,
# this code example illustrates the extraction of a token from the Stack keycloak server
# and then the invokation of a (non-CSRF) API endpoint using that toekn.
#
# Tested with Python 3.12.3 and requires 'requests' (and tested with 2.32.2).
# Last tested 6th June 2024 against the legacy Fragalysis Stack.
@alanbchristie
alanbchristie / notes.txt
Created March 19, 2024 23:39
LibreTranslate
Installed on a RPi 5 (libre-translate.local/192.168.0.6)
To create API keys enter the container: -
docker exec -it <container> bash
The use 'ltmanage' to list the keys: -
./venv/bin/ltmanage keys
@alanbchristie
alanbchristie / borg_code.py
Last active February 11, 2024 12:16
Code generator for key code locks from BorgLocks
#!/usr/bin/env python3
"""Simple class to generate keypad codes for Borg door locks.
Run this code to generate random 4 and 5 digit codes.
Each random code is generated once with, and once without using the X and Z buttons.
See https://borglocks.co.uk
"""
import random
@alanbchristie
alanbchristie / git_query.py
Last active January 23, 2024 12:04
Querying a repository with GitPython
#!/usr/bin/env python3
# Here we assume you've installed the GitPython package
# and you're running this code from a repository clone.
from typing import Optional
from git import Repo
from git.refs.tag import TagReference
repo: Repo = Repo()
@alanbchristie
alanbchristie / kc-users.sh
Last active July 14, 2023 15:22
Getting keycloak users with httpie and jq
# Get username and emails from a Keycloak realm
# assuming you've installed httpie and jq
#
# - https://httpie.io
# - https://jqlang.github.io/jq/
# Armed with a keycloak URL
# And realm and realm manager password
URL=example.com
REALM=blob
{
"folders": [
{
"path": "squonk2-python-cl-tools"
},
{
"path": "squonk2-admin"
},
{
"path": "squonk2-deck"
{
"folders": [
{
"path": "Diamond/fragalysis-backend"
},
{
"path": "Diamond/dls-fragalysis-stack-kubernetes"
},
{
"path": "Diamond/fragalysis-stack"