Skip to content

Instantly share code, notes, and snippets.

@seidler2547
seidler2547 / convert_ha_sqlite2mysql.sh
Last active April 16, 2024 02:30
One-liner to convert an existing Home-Assistant SQLite database to MySQL
# prerequisites:
## install software
apt install mariadb-server libmariadbclient-dev sqlite3
## install mysqlclient in virtualenv
su -c 'homeassistant/bin/pip3 install mysqlclient --upgrade' -l homeassistant
## create database
mysql -e 'CREATE SCHEMA IF NOT EXISTS `hass_db` DEFAULT CHARACTER SET utf8'
## create user (use a safe password please)
mysql -e "CREATE USER 'hass_user'@'localhost' IDENTIFIED BY 'hass_pw'"
mysql -e "GRANT ALL PRIVILEGES ON hass_db.* TO 'hass_user'@'localhost'"
@seidler2547
seidler2547 / _etc_network_interfaces
Created February 6, 2018 14:23
"Invisible" Bridge on Linux
auto vmbr1
iface vmbr1 inet manual
bridge_ports eth0
bridge_stp off
bridge_fd 0
up /sbin/sysctl -w net.ipv6.conf.$IFACE.disable_ipv6=1
up /sbin/sysctl -w net.ipv6.conf.$IFACE.autoconf=0
up /sbin/sysctl -w net.ipv6.conf.$IFACE.accept_ra=0
up ip link set dev $IFACE arp off
up ip link set dev eth0 arp off
@seidler2547
seidler2547 / Xresources
Created September 19, 2017 08:07
urxvt config
URxvt*scrollBar_right: True
URxvt*scrollBar_floating: True
URxvt*scrollWithBuffer: True
URxvt*scrollTtyKeypress: True
URxvt*scrollTtyOutput: False
URxvt*visualBell: True
URxvt*font: -*-fixed-medium-r-normal-*-13-*-*-*-*-70-iso10646-1
URxvt*boldFont: -*-fixed-bold-r-normal-*-13-*-*-*-*-70-iso10646-1
URxvt*background: black
URxvt*foreground: white smoke
@seidler2547
seidler2547 / etc_network_interfaces
Created September 15, 2017 13:22
HAProxy as a IPv4 gateway for IPv6-only hosts with IPv4 NAT
[ ... ]
auto vmbr0
iface vmbr0 inet static
[ ... ]
post-up echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind
post-up iptables -t mangle -N DIVERT
post-up iptables -t mangle -A PREROUTING -p tcp -m socket -j DIVERT
post-up iptables -t mangle -A DIVERT -j MARK --set-mark 74
post-up iptables -t mangle -A DIVERT -j ACCEPT
# change this to whatever you need
export DPI=165
# hardly useful
xrandr --dpi $DPI
# used by a couple of legacy applications
echo 'Xft.dpi: '$DPI | xrdb -merge -
# the point here is to increase the mouse cursor size - adjust to your preference
@seidler2547
seidler2547 / curate.sh
Last active June 14, 2017 07:31
Elasticsearch sensible curator
#!/bin/bash
[ -f "$1" ] && . "$1"
[ "$2" ] && ACTION="$2"
[ "$2" ] && OPTIM=""
for ref in $(seq $MAX -1 $MIN)
do
IDX="${PREFIX}$(date -d @$(($(date +%s)-(${INTERVAL}*${ref}))) +${PATTERN})"
@seidler2547
seidler2547 / elastic.conf
Last active February 7, 2017 12:23
rsyslog to Elasticsearch
# monthly syslog indices
template(name="logstash-index"
type="list") {
constant(value="logstash-syslog-")
property(name="timereported" dateFormat="rfc3339" position.from="1" position.to="4")
constant(value=".")
property(name="timereported" dateFormat="rfc3339" position.from="6" position.to="7")
}
# most data we can get
@seidler2547
seidler2547 / puppet_status.rb
Created December 16, 2016 12:53
Munin plugin to monitor/alert about the last Puppet run
#!/usr/bin/env ruby
require 'yaml'
require 'puppet'
if ARGV[0] == 'config'
puts <<END
graph_args --base 1000 -l 0 -M
graph_vlabel value
graph_title Puppet stats
@seidler2547
seidler2547 / itSdark256.ini
Created November 8, 2016 12:59
Midnight Commander dark theme
# This is a 256 colors MidnightCommander color scheme
# based on the Xoria256 color scheme by Alexander Glyzov (isee@inbox.ru)
# Note you'll need mc > 4.7.5 for this scheme to work (256 colors support)
# Hint: compile from the git repository
[skin]
description=itSdark256
256colors=true
@seidler2547
seidler2547 / igtalk.pl
Last active September 25, 2016 15:49
Hangouts notifications for Zabbix and Icinga
#!/usr/bin/perl
use strict;
use warnings;
use Net::Jabber;
use POSIX qw(strftime);
my %vars = map { s/^ICINGA//; $_=>$ENV{"ICINGA$_"} } grep /^ICINGA.+/, keys %ENV;
my $recip = $ENV{'JABBERADDRESS'};