Skip to content

Instantly share code, notes, and snippets.

View alanbchristie's full-sized avatar

Alan B. Christie alanbchristie

View GitHub Profile
@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
@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 / 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 / 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 / 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.