Skip to content

Instantly share code, notes, and snippets.

@wojtekka
wojtekka / gist:3c5197daefc631b3ed10b2ce1d03700a
Created April 1, 2019 10:29
Generate self-signed certificate
$ openssl req -new -x509 -days 365 -nodes -out server.crt -keyout server.key
@wojtekka
wojtekka / am2320.py
Created April 15, 2019 19:20
Simple code to read AM2320 connected to Raspberry Pi in Python without external libraries
# AM2320 connected to Raspberry Pi pin 3 (SDA) and 5 (SCL)
# Public domain
import sys
import fcntl
import time
import struct
I2C_SLAVE = 0x0703
AM2320_ADDR = 0x5c
@wojtekka
wojtekka / index.html
Last active October 21, 2020 09:30
Simple WebSocket console, self-contained, desktop/mobile, Firefox/Chrome, public domain
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta charset="utf-8" />
<script type="text/javascript">
var url = "ws://" + location.host + location.pathname + "websocket";
var connected = false;
var ws;
var ready = false;
@wojtekka
wojtekka / booklet.py
Created August 3, 2024 13:08
Prepare page numbers to print a booklet using n-up option in print dialog
#!/usr/bin/python3
import sys
# 4 -> odd -> 4,1
# even -> 2,3
# 8 -> odd -> 8,1 6,3
# even -> 2,7 4,5
@wojtekka
wojtekka / lvm.md
Last active May 30, 2026 11:09
LVM for dummies

LVM for dummies

# pvcreate /dev/nvme0n1pX
# vgcreate foo /dev/nvme0n1pX
# lvcreate --name bar -l '100%FREE' foo
# mkfs.ext4 /dev/foo/bar

Copy GPT

@wojtekka
wojtekka / gist:d08612f6a108507cbc8e67e737e92700
Created November 13, 2025 20:47
Building out-of-tree Linux kernel module
cat > Kbuild << EOF
obj-m := foo.o
EOF
cat > Makefile << EOF
KDIR ?= /lib/modules/`uname -r`/build
default:
$(MAKE) -C $(KDIR) M=$$PWD
EOF
@wojtekka
wojtekka / raspberry-pi.md
Last active May 30, 2026 11:39
Raspberry Pi

Headless configuration

cd .../boot
echo "enable_uart=1" >> config.txt
touch ssh
echo "user:$(echo -n password | openssl passwd -6 -stdin)" > userconf.txt
cat > wpa_supplicant.conf << EOF
country=<iso code>
network={