Skip to content

Instantly share code, notes, and snippets.

Avatar

Martin Vancl tuxmartin

View GitHub Profile
View alpine-qemu-arm.sh
wget http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/armhf/alpine-uboot-3.7.0-armhf.tar.gz
wget http://dl-cdn.alpinelinux.org/alpine/v3.7/releases/armhf/alpine-minirootfs-3.7.0-armhf.tar.gz
qemu-img create -f raw sd.img 512M
sudo losetup /dev/loop0 sd.img
sudo kpartx -av /dev/loop0
lsblk
sudo mkfs.ext4 /dev/mapper/loop0p1
mount -t ext4 /dev/mapper/loop0p1 /mnt
@tuxmartin
tuxmartin / README.md
Last active Oct 24, 2020
Minimal Poco websocket C++ client
View README.md

Stazeni a kompilace POCO

wget http://pocoproject.org/releases/poco-1.7.3/poco-1.7.3.tar.gz
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
View gist:d3fd5975bccee1441a302e76faa3d874
# https://plugins.svn.wordpress.org/wp-fail2ban/trunk/filters.d/wordpress-hard.conf
# https://github.com/TrogloGeek/fail2ban-apache-sqlinject
# Test: fail2ban-regex /var/log/apache2/access.log /etc/fail2ban/filter.d/wordpress.conf
[INCLUDES]
before = common.conf
[Definition]
View poco_uri_parser.cpp
// g++ -o poco_uri_parser poco_uri_parser.cpp -L/usr/local/lib -lPocoNet -lPocoFoundation
// http://pocoproject.org/slides/160-URIandUUID.pdf
#include "Poco/URI.h"
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
@tuxmartin
tuxmartin / udp_ipv6_client.py
Last active Sep 15, 2020
Python UDP IPv6 client & server
View udp_ipv6_client.py
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
tuxmartin / .htaccess
Created Aug 25, 2020
apache http basic auth for url wp-login.php
View .htaccess
# --- HTTP BASIC AUTH /wp-login.php ------------------
SetEnvIf Request_URI "/wp-login.php" auth=1
AuthName "Please login."
AuthType Basic
AuthUserFile /var/www/.htpasswd
Order Allow,Deny
Satisfy any
Allow from all
View add_hosts.py
from pyzabbix import ZabbixAPI
import sys
import argparse
url = 'http://localhost/'
user = 'Admin'
password = 'zabbix'
CLI=argparse.ArgumentParser()
CLI.add_argument(
@tuxmartin
tuxmartin / v4l.sh
Last active May 20, 2020
Create fake /dev/videoX device from video file
View v4l.sh
# 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://10.104.103.138/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp -f v4l2 -pix_fmt yuv420p -vcodec rawvideo /dev/video0
@tuxmartin
tuxmartin / app.yml
Last active Apr 27, 2020
IoT: ESPHome current transformer
View app.yml
esphome:
name: test
platform: ESP32
board: esp32doit-devkit-v1
wifi:
ssid: "My_WiFi_AP"
password: "secretPassword123"
ap:
ssid: "Test Fallback Hotspot"
@tuxmartin
tuxmartin / socket_client.py
Last active Apr 11, 2020
Python socket - server and client example (push notifications)
View socket_client.py
import socket
host = 'localhost'
port = 1234
buf = 1024
clientsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
clientsocket.connect((host, port))
print "Sending 'test1\\n'"
You can’t perform that action at this time.