Skip to content

Instantly share code, notes, and snippets.

View Elektordi's full-sized avatar

Guillaume "Elektordi" Genty Elektordi

View GitHub Profile
@Elektordi
Elektordi / sqlite.py
Last active January 3, 2025 16:05
Ansible callback plugin to store results in SQLite
DOCUMENTATION = '''
name: sqlite
callback_type: store
author: Guillaume "Elektordi" Genty <[email protected]>
requirements:
- enable in configuration
- install sqlite3
short_description: Store playbook results in sqlite
version_added: "1.0" # for collections, use the collection version, not the Ansible version
description:
@Elektordi
Elektordi / !!! WX02 keyboard codes
Last active November 27, 2024 01:18
Bluetooth WX02 keyboard on linux
https://www.aliexpress.com/item/1005007861441274.html
(with connector on right, like on manual)
Short video mode
UP press: BTN_TOUCH/BTN_TOOL_PEN/ABS_Y
UP hold: KEY_VOLUMEDOWN
UP double: BTN_TOUCH/BTN_TOOL_PEN/ABS_X
MID press: BTN_TOUCH/BTN_TOOL_PEN/ABS_Y/ABS_Y
MID hold: KEY_POWER
@Elektordi
Elektordi / try_renew_kube.sh
Created June 10, 2024 12:33
Renew kube certificates if expiring
#!/bin/bash
kubeadm certs check-expiration | grep -B999 "CERTIFICATE AUTHORITY" | grep -E "no +$" | grep -E "( [0-9]d |invalid)"
if [[ $? == 0 ]]; then
echo "Certificates to renew!"
kubeadm certs renew all
crictl ps --label io.kubernetes.pod.namespace=kube-system -q | xargs crictl stop
echo "OK"
else
GET http://localhost:5500/api/internal/rundown/?rundownId=default.rundown.json
POST http://localhost:5500/api/internal/playGroup/?rundownId=default.rundown.json&groupId=aa1LYW7C
POST http://localhost:5500/api/internal/stopGroup/?rundownId=default.rundown.json&groupId=aa1LYW7C
POST http://localhost:5500/api/internal/playPart/?rundownId=default.rundown.json&groupId=aa1LYW7C&partId=sPtWQfd9
To find args: https://github.com/SuperFlyTV/SuperConductor/blob/3b49349a3492615d801d49c65136eff8126c3b5a/apps/app/src/ipc/IPCAPI.ts#L99
@Elektordi
Elektordi / LICENSE
Created February 10, 2024 17:47
Licence MIT traduite en Français
Licence MIT traduite en Français (uniquement la version anglaise fait foi)
Tous droits réservés, 2024 par Guillaume Genty
L'autorisation est accordée gratuitement à toute personne obtenant une copie
de ce logiciel et des fichiers de documentation associés (le « Logiciel »),
de manipuler le Logiciel sans restriction, y compris les droits d'utiliser,
copier, modifier, fusionner, publier, distribuer, sous-licencier et/ou vendre
de copies du Logiciel, et pour permettre aux personnes à qui le Logiciel est
@Elektordi
Elektordi / pg_stat_activity_log
Last active December 4, 2023 11:20
Postgres activity log
# Put this file in /etc/cron.d/
# Setup:
# sudo -u postgres psql -c "create table activity_log as select now(), * from pg_stat_activity limit 0; create index activity_log_idx on activity_log (now);"
* * * * * postgres psql -q -c "insert into activity_log select now(), * from pg_stat_activity;"
0 0 * * * postgres psql -q -c "delete from activity_log where now < now() - interval '7 days';"
@Elektordi
Elektordi / kube2env.sh
Created October 27, 2023 14:59
Import kube secret into env
source <(kubectl get -n xxxnamespacexxx secret xxxnamexxx -o json | jq -r '.data | to_entries[] | ["export " + .key + "=\"" + (.value | @base64d) + "\""] | join("\n")' | xargs -d '\n')
@Elektordi
Elektordi / proxmox_import_debian_cloud.sh
Last active October 3, 2023 10:37
Import Debian Cloudimage in Proxmox
#!/bin/bash
url=https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
nextid=$(( `qm list | cut -c 1-10 | tr -d ' ' | sort -gr | head -n 1` + 1 ))
if (( $nextid < 9000 )); then
nextid=9000
fi
file=`basename $url`
@Elektordi
Elektordi / slides_remote_passthrough.py
Created September 27, 2023 22:56
Slides remote passthrough
#!/usr/bin/env python3
import evdev
import xdo
dev = None
for d in [evdev.InputDevice(path) for path in evdev.list_devices()]:
# print(device.path, device.name, device.phys)
if d.name == "NORWII Norwii Wireless Presenter Keyboard":
dev = d
@Elektordi
Elektordi / matviews_refresh.sql
Last active August 29, 2023 17:05
Refresh all materialized views in a schema (Postgres)
CREATE OR REPLACE FUNCTION remote.refresh()
RETURNS bool
LANGUAGE plpgsql
AS $$
DECLARE
r record;
BEGIN
for r in SELECT matviewname FROM pg_catalog.pg_matviews where schemaname = 'remote'
loop
raise notice 'Refreshing %...', r.matviewname;