Skip to content

Instantly share code, notes, and snippets.

Martin Vancl tuxmartin

Block or report user

Report or block tuxmartin

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tuxmartin
tuxmartin / socket_client.py
Last active Aug 20, 2019
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'"
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 Jul 29, 2019
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
@tuxmartin
tuxmartin / Test.py
Created Jun 10, 2015
Python ORM example (Python + SQLAlchemy + SQlite/MySQL)
View Test.py
from sqlalchemy.ext.declarative import declarative_base
#from sqlalchemy import *
#from sqlalchemy.orm import *
# Pro entity v podadresari. Podaresar *musi* obsahovat prazdny soubor __init__.py !
#from entity.User import User
'''
Zavislosti:
# apt-get install python-sqlalchemy
@tuxmartin
tuxmartin / udp_ipv6_client.py
Last active Jun 14, 2019
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
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 nyni.php
public function checkIfSeznam():bool
{
return $this->get('utm_source') === 'www.seznam.cz' && in_array($this->get('utm_medium'), ['sekce-z-internetu', 'z-boxiku']);
}
@tuxmartin
tuxmartin / readme.md
Created Jan 14, 2019
Nahrazeni/pridani parametru u systemd sluzby
View readme.md

Priklad: chceme zmenit hodnotu Nice pro sluzbu zabbix-agent.service

Vychozi je /lib/systemd/system/zabbix-agent.service, na ten nesahame, protoze by nam ho prepsalo apt pri aktualizaci.

Vyvorime adresar a soubor s nastavenim:

mkdir -p /etc/systemd/system/zabbix-agent.service.d
touch /etc/systemd/system/zabbix-agent.service.d/10-custom-nice.conf

Syntaxe je JMENO.service.d, tedy zabbix-agent.service.d.

@tuxmartin
tuxmartin / gist:674b220fad08b89c8328bf72b26e461c
Created Dec 18, 2018
zabbix proxy 4.0 on debian 7 x86_64
View gist:674b220fad08b89c8328bf72b26e461c
apt-get install curl sudo build-essential libsqlite3-dev libxml2-dev libsnmp-dev libcurl4-openssl-dev libpcre3-dev
groupadd zabbix
useradd -g zabbix zabbix
cd /usr/local/src/
wget https://netix.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.0.1/zabbix-4.0.1.tar.gz
tar xzvf zabbix-4.0.1.tar.gz
cd /usr/local/src/zabbix-4.0.1/
./configure --help
./configure -prefix=/usr --enable-proxy --enable-agent --with-openssl --with-sqlite3 --with-net-snmp --with-libcurl --with-libxml2 --enable-ipv6 --with-ssh2 --sysconfdir=/etc/zabbix --bindir=/usr/bin
make
@tuxmartin
tuxmartin / gist:a4be301079495fc0e129a944f6b6c984
Last active Nov 14, 2018
iptables - pocitani prenesenych bajtu z definovane IP
View gist:a4be301079495fc0e129a944f6b6c984
root@cameras-lcd:/# iptables -nvL
Chain INPUT (policy ACCEPT 24808 packets, 26M bytes)
pkts bytes target prot opt in out source destination
16884 24M camera-line1 all -- * * 10.54.6.147 0.0.0.0/0
0 0 camera-line2 all -- * * 10.54.6.148 0.0.0.0/0
1528 1986K camera-line3 all -- * * 10.54.6.149 0.0.0.0/0
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
You can’t perform that action at this time.