Skip to content

Instantly share code, notes, and snippets.

Avatar

Arti Zirk artizirk

View GitHub Profile
@artizirk
artizirk / xinput.py
Last active Nov 17, 2020
Pure Python implementation for reading Xbox controller inputs without extra libs
View xinput.py
#!/usr/bin/env python3
""" XInput Game Controller APIs
Pure Python implementation for reading Xbox controller inputs without extra libs
Copyright (C) 2020 by Arti Zirk <arti.zirk@gmail.com>
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted.
@artizirk
artizirk / vga.dts
Created Jun 11, 2020
Cubietruck Allwinner A20 VGA output on mainline Armbian
View vga.dts
/dts-v1/;
/plugin/;
/* Based on https://github.com/wens/linux/commits/sun4i-drm-tve-vga-wip */
/* Tested with Cubetruck */
/* save it somewhere and run sudo armbian-add-overlay vga.dts */
/ {
compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";
@artizirk
artizirk / nanopi-r2s-power-button.dts
Last active May 11, 2020
Custom Armbian user device tree overlays for NanoPi devices
View nanopi-r2s-power-button.dts
/dts-v1/;
/plugin/;
/ {
compatible = "friendlyelec,nanopi-r2", "rockchip,rk3328";
fragment@0 {
target-path = "/gpio-keys/button@0";
__overlay__ {
linux,code = <116>;
@artizirk
artizirk / make_nspawn_iface_mac.py
Last active Apr 23, 2020
Generate systemd nspawn interface MAC aadresses based on the host id and container name https://wiki.wut.ee/sysadmin/systemd-nspawn_containers
View make_nspawn_iface_mac.py
#!/usr/bin/env python3
"""
This script implements systemd-nspawn MAC aadress generation algorithm
"""
import sys
import struct
from subprocess import run
import siphashc # https://pypi.org/project/siphashc/
@artizirk
artizirk / dhclient_ipv6_prefix_delegation.md
Last active Apr 23, 2020
ISC dhclient IPv6 prefix delegation hook script https://wiki.wut.ee/en/sysadmin
View dhclient_ipv6_prefix_delegation.md
@artizirk
artizirk / readme.md
Last active Feb 4, 2020
Atlassian Bitbucket Server (Stash) OAuth1 example with Python
View readme.md

Based on this https://developer.atlassian.com/server/jira/platform/oauth/

generate private key

openssl genrsa -out jira_privatekey.pem 1024

generate public key

openssl req -newkey rsa:1024 -x509 -key jira_privatekey.pem -out jira_publickey.cer -days 365
openssl pkcs8 -topk8 -nocrypt -in jira_privatekey.pem -out jira_privatekey.pcks8
@artizirk
artizirk / debug.md
Last active Nov 7, 2020
Debug WireGuard Linux kernel module
View debug.md
@artizirk
artizirk / wg-ip.py
Last active Jun 28, 2020
Generate WireGuard IP Addresses from public key, compatible with wg-ip bash script
View wg-ip.py
#!/usr/bin/env python3
# need at least python3.6+ for blake2
from base64 import b64decode
from hashlib import sha256, blake2s
from ipaddress import ip_address, ip_network
# https://github.com/chmduquesne/wg-ip
def gen_ip(pubkey, subnet=ip_network('fe80::/64')):
"""Generate wg-ip compatible addresses from WireGuard public key.
View postgresql_zfs.md

PostgreSQL optimize

ZFS Config

atime = off  # Recoding access time on file open is stupid
relatime = on  # writing access time on file write is fine because we are writing anyway.
compression = lz4  # Its faster to compress/decompress on the CPU than it is to wait for the data from HDD/SSD  
recordsize = 128K  # postgres native 8k will give give horrible compression ratio, default 128k is fine
primarycache = metadata  # maybe?
@artizirk
artizirk / create_container.sh
Last active Nov 3, 2020
Create a debian container on a zfs pool for usage with systemd-nspawn and machinectl https://wiki.wut.ee/en/sysadmin/systemd-nspawn_containers
View create_container.sh
#!/bin/bash
set -euo pipefail
BASE="/var/lib/machines"
ZDATA="rpool/machines"
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
You can’t perform that action at this time.