Skip to content

Instantly share code, notes, and snippets.

View kylemanna's full-sized avatar

Kyle Manna kylemanna

View GitHub Profile
@kylemanna
kylemanna / README-python-service-on-systemd-activated-socket.md
Last active January 20, 2025 10:48 — forked from drmalex07/README-python-service-on-systemd-activated-socket.md
An example network service with systemd-activated socket in Python. #systemd #python #socket #socket-activation

README

The example below creates a TCP server listening on a stream (i.e. SOCK_STREAM) socket. A similar approach can be followed to create a UDP server on a datagram (i.e. SOCK_DGRAM) socket. See man systemd.socket for details.

An example server

Create an simple echo server at ~/tmp/foo/serve.py.

@kylemanna
kylemanna / set_pwm.py
Created December 16, 2024 05:17
Shelly Plus RGBW Arduino BLE Server
import asyncio
import argparse
import sys
from bleak import BleakClient
# Updated characteristic UUID
characteristic_uuid = "1ED5100D-F00D-FA11-0F1C-1ED5100D1F10"
def parse_args():
parser = argparse.ArgumentParser(description="Read and optionally write PWM values to an ESP32 BLE device.")
@kylemanna
kylemanna / parse-ext-csd.py
Last active October 9, 2024 15:46
Parse eMMC Extended CSD and print useful things.
#!/usr/bin/env python
"""
Author: Kyle Manna <kyle@kylemanna.com>
Blog: https://blog.kylemanna.com
cat /d/mmc0/mmc0:0001/ext_csd
0000000000000001030100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000087a0000000000000000061502030700100608010101080800100000728000000808080808080000000000010200070002000500000000000001000200000000000000000000000000000100050000000000030001ca00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
@kylemanna
kylemanna / build-friendlywrt.md
Last active September 12, 2024 15:33
FriendlyElec NanoPi R5S Linux PTP Support

Build Notes

Environment

Use systemd-nspawn on Arch Linux with debootstrap:

sudo debootstrap --include=systemd-container --components=main,universe jammy ubuntu22.04-rk3568 http://archive.ubuntu.com/ubuntu/
@kylemanna
kylemanna / 7z+tar.md
Last active September 5, 2024 10:15
Archive with tar + 7z + max compression

Overview

7-zip doesn't preserve the Linux/Unix owner/group of files and possibly other details. Use tar instead because it's designed to preserve these things, then just 7zip the tar archive.

Create the archive

tar cf - --exclude=\*.o -v directory | 7z a -si -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on directory.tar.7z
@kylemanna
kylemanna / onfailure.sh
Created September 11, 2014 08:44
Example failure handler for systemd that emails me
#!/bin/bash
#
# Author: Kyle Manna <kyle@kylemanna.com>
#
# Simple systemd script used to be called via something like:
#
# Example Unit section of a service file:
#
# [Unit]
# ...
@kylemanna
kylemanna / podman-compose.yaml
Last active March 17, 2024 22:02
Podman Compose File that runs Windows in KVM + QEMU
# Podman Compose File that runs Windows in KVM + QEMU
#
# Upstream: https://github.com/dockur/windows
#
# Note: Can't run this rootless as the netardvark proxy doesn't create a host
# network interface for communication with the container which is what's
# expected for the iptables NAT port forwarding rule to work for port 3389.
# Instead it arrives appearing to be from the same interface and skips the nat
# redirect and fails.
#
@kylemanna
kylemanna / android-ca-cert-hash.sh
Last active March 7, 2024 20:41
Generate hash file name for Root CAs on Android. Handy for things like mitmproxy.
CERT=$1
NAME=$(openssl x509 -in $HOME/.mitmproxy/mitmproxy-ca-cert.cer -subject_hash_old -noout)
cp ${CERT} ${OUT}/system/etc/security/cacerts/${NAME}.0
@kylemanna
kylemanna / gist:1367672
Created November 15, 2011 17:20
Relocate ELF binary file for use with JTAG debugging
#!/bin/sh
# Following command will relocate the linux kernel elf file from
# 0xc000_0000 to 0x8000_0000 which coincides with the actual load
# address on TI OMAP3 platforms.
# This should also work for debugging the second stage of u-boot
# after it has been relocated
arm-none-linux-gnueabi-objcopy --change-addresses -0x40000000 vmlinux vmlinux.2