Skip to content

Instantly share code, notes, and snippets.

qemu-img create -f raw sd.img 512M
sudo losetup /dev/loop0 sd.img
sudo kpartx -av /dev/loop0
sudo mkfs.ext4 /dev/mapper/loop0p1
mount -t ext4 /dev/mapper/loop0p1 /mnt
tuxmartin /
Last active May 25, 2024 10:12
Python UDP IPv6 client & server
import socket
UDP_IP = "::1" # localhost
UDP_PORT = 5005
MESSAGE = "Hello, World!"
print "UDP target IP:", UDP_IP
print "UDP target port:", UDP_PORT
print "message:", MESSAGE
tuxmartin / app.yml
Last active October 1, 2022 15:03
IoT: ESPHome current transformer
name: test
platform: ESP32
board: esp32doit-devkit-v1
ssid: "My_WiFi_AP"
password: "secretPassword123"
ssid: "Test Fallback Hotspot"
tuxmartin /
Last active August 31, 2022 06:47
IPTABLES - limit connections & security

syn-flood protection

Limit the number of incoming TCP connections.

iptables -N syn_flood
iptables -A INPUT -p tcp --syn -j syn_flood
iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
iptables -A syn_flood -j DROP

--limit 1/s: Maximum average matching rate in seconds

tuxmartin /
Last active April 26, 2022 14:31
Create fake /dev/videoX device from video file
# mozna neni potreba: sudo apt-get install linux-generic
sudo apt-get install v4l2loopback-dkms
sudo modprobe v4l2loopback
modprobe v4l2loopback
ffmpeg -i /home/martin/Downloads/video.mp4 -f v4l2 -vcodec rawvideo /dev/video0
ffmpeg -i rtsp:// -f v4l2 -pix_fmt yuv420p -vcodec rawvideo /dev/video0
tar xzvf alpine-uboot-3.7.0-armhf.tar.gz
mkdir fat
qemu-system-arm -M virt -m 64 -drive file=fat:fat/ -kernel boot/vmlinuz-hardened -initrd boot/initramfs-hardened -append modules=loop,squashfs,sd-mod,usb-storage
tuxmartin /
Last active January 5, 2022 20:34
Minimal Poco websocket C++ client

Stazeni a kompilace POCO

tar xzf poco-1.7.3.tar.gz
cd poco-1.7.3
./configure --minimal --static --no-samples --no-tests
time make -j4 -s
cd lib/Linux/x86_64/
for f in *.a; do "strip $f"; done
tuxmartin /
Last active November 24, 2021 07:19
Ubuntu 16.04 Xenial v QEMU-ARM (armhf)
# Download a rootfs img and a kernel:
sudo apt-get install qemu-user-static qemu-system-arm
# (
dpkg -X linux-image-4.4.0-111-generic-lpae_4.4.0-111.134_armhf.deb .
mkdir -p tmp
qemu-img convert xenial-server-cloudimg-armhf-disk1.img xenial-server-cloudimg-armhf.img
sudo kpartx -av xenial-server-cloudimg-armhf.img
sudo mount /dev/mapper/loop0p1 tmp
tuxmartin /
Last active October 7, 2021 21:14
Inno Setup on Linux (Docker)
docker run --rm -i -v "$PWD:/work" \
-e OVPN_VER="2.5.3" \
-e OVPN_BIN32="OpenVPN-2.5.3-I601-x86.msi" \
-e OVPN_BIN64="OpenVPN-2.5.3-I601-amd64.msi" \
-e OVPN_CONF="user.ovpn" \
-e OVPN_SITE="" \
-e OUT_NAME="vpn_rdp_setup" \
-e PASSWORD="asdf" \
amake/innosetup:64bit openvpn_rdp_docker.iss
tuxmartin / poco_uri_parser.cpp
Created December 16, 2015 14:01
C++ POCO URI parser
// g++ -o poco_uri_parser poco_uri_parser.cpp -L/usr/local/lib -lPocoNet -lPocoFoundation
#include "Poco/URI.h"
#include <iostream>
using namespace std;
int main(int argc, char** argv)