Skip to content

Instantly share code, notes, and snippets.

@mdpuma
mdpuma / generate_network_config.py
Last active November 17, 2025 14:06
Script that generate network-scripts file for required ip range
#!/usr/bin/env python
import os
import sys
import getopt
if __name__ == "__main__":
options, remaining = getopt.getopt(sys.argv[1:], 'r:i', ['range=', 'iface='])
#print('ARGV :', sys.argv[1:])
@mdpuma
mdpuma / gist:6ed8f634e0f8c9dae26476c3ca710383
Created March 15, 2018 16:11
rewrite document root to /public_html/public
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
@mdpuma
mdpuma / syslog-ng.conf
Created March 16, 2018 13:00
cacti syslog module using syslog-ng
source remote {
udp(ip(0.0.0.0) port(514));
};
log {
source(remote);
destination(d_sql);
};
destination d_sql {
@mdpuma
mdpuma / sleep_until.sh
Created March 16, 2018 20:20
sleep_until.sh
#!/bin/bash
current_time=$(date +%s)
target_time=$(date -d "$*" +%s)
seconds=$(( $target_time - $current_time ))
echo "sleeping $seconds (`date -d "$*"`)"
sleep $seconds
@mdpuma
mdpuma / gist:bcc38803b9627a13914b4124b893d769
Created March 17, 2018 19:12
Disable vim automatic visual mode using mouse
# http://www.varesano.net/blog/fabio/disable%20vim%20automatic%20visual%20mode%20using%20mouse
If you also want do the same you can either:
issue the command :set mouse-=a
insert the directive set mouse-=a into your ~/.vimrc file
@mdpuma
mdpuma / collectd-mysql.conf
Last active November 14, 2025 12:05
collectd modbus/modbus_exporter
CREATE USER 'collectd'@'localhost' IDENTIFIED BY 'Fat4ohse';
-- Give appropriate permissions
-- ("GRANT USAGE" is synonymous to "no privileges")
GRANT USAGE ON *.* TO 'collectd'@'localhost';
-- Permissions for the MasterStats and SlaveStats options
GRANT REPLICATION CLIENT ON *.* TO 'collectd'@'localhost';
# mysql.conf
@mdpuma
mdpuma / gist:39eb6c07030857c4915dcd5940a5d729
Last active August 8, 2018 16:08
socat connecting unix socket to tcp socket
#!/bin/bash
socat TCP-LISTEN:1234,reuseaddr,fork UNIX-CLIENT:/tmp/foo
telnet localhost 1234
# https://github.com/memcached/memcached/blob/master/doc/protocol.txt
@mdpuma
mdpuma / create_template.sh
Created August 11, 2018 18:22
make solusvm template from vm
#!/bin/bash
LVM=vg_solus1-kvm533_img
DISTRO=debian-8
DATE=$(date +%Y-%m-%d)
virt-sysprep -a /dev/mapper/$LVM
virt-sparsify -v /dev/mapper/$LVM --convert qcow2 --compress /home/solusvm/kvm/template/linux-$DISTRO-$DATE-x86_64-min-gen2-v1.gz
@mdpuma
mdpuma / htaccess rewrite
Created August 29, 2018 13:07
Rewrite public_html to public_html/public
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
@mdpuma
mdpuma / httpd.conf
Created November 28, 2018 16:00
http2 issue safari browser Upgrade RFC 7230
# Hello, when you will open website from which you will receive multi line http header, for example Upgrade: h2, h2c,
# safari will return error.
# fix:
Header unset Upgrade