Skip to content

Instantly share code, notes, and snippets.

View ZsBT's full-sized avatar
💭
💙 💛

ZS ZsBT

💭
💙 💛
View GitHub Profile
@ZsBT
ZsBT / outlook_thread_index.class.php
Last active January 12, 2017 13:44 — forked from brettp/thread-index.php
PHP class implementation for Outlook's bogus proprietary thread-index for message threading
<?php /*
encode/decode Outlook thread index.
GUID must be 32 bytes long
forked from brettp/thread-index.php
*/
@ZsBT
ZsBT / installed-packages.sh
Created September 22, 2017 12:38
show manually installed packages under debian
#!/bin/sh
#
# show manually installed packages under debian
#
aptHistory(){
install_or_remove=$1
for pkg in $(zgrep -hoE "apt(-get)? (-y )?$install_or_remove .*" /var/log/apt/history.log*gz);do
echo "$pkg"
done | sort|sort -u | grep -v '^-'
@ZsBT
ZsBT / setup-opendkim.sh
Last active May 22, 2018 13:25
Create opendkim configuration under Debian.
#!/bin/bash
#
# to use with Postfix.
# Exim users, get out of here! Write your own scripts.
#
set -e
serviceIP="127.0.0.2"
servicePort=1051
@ZsBT
ZsBT / setup-mysql-replication.sh
Last active November 28, 2022 07:30
create mysql/mariadb master-master replication
#!/bin/bash
#
# setup mysql replication.
# run this script parallel on both servers as we need log file name and position on the other node
#
#
ROOT_PASS="rootP@ssw0rd"
REPLI_PASS="replicationP@ssw0rd"
SIBLING_IP="1.2.3.4"
@ZsBT
ZsBT / systemd.service
Last active January 23, 2018 06:51
systemd unit cheatsheet
[Unit]
Description = fotók betöltése
After=postgresql.service
Requires=postgresql.service
Wants=postgresql.service
[Service]
ExecStart = /home/szerver/foto-devtolt.py
ExecReload = /bin/kill -HUP $MAINPID
@ZsBT
ZsBT / db-size.pg.sql
Last active June 9, 2022 00:27
show occupied space in a postgresql database
create view v_sizeof_dbs as
select datname dbname
,pg_size_pretty(pg_database_size(datname)) hsize
from pg_database
order by pg_database_size(datname) desc;
create view v_sizeof_tables as
SELECT table_catalog,table_schema,table_name
,pg_size_pretty(pg_table_size(table_schema||'.'||table_name)) table_hsize
FROM information_schema.tables
@ZsBT
ZsBT / mosquitto.conf
Last active May 3, 2018 19:50
mosquitto SSL server using Letsencrypt certificate
listener 1883 localhost
listener 2883
certfile /etc/letsencrypt/live/my.example.com/cert.pem
cafile /etc/letsencrypt/live/my.example.com/chain.pem
keyfile /etc/letsencrypt/live/my.example.com/privkey.pem
@ZsBT
ZsBT / hactl.sh
Last active June 9, 2022 00:27
socket control script for HAproxy backends
#!/bin/bash
#
# control script for HAproxy backends.
#
# rare usage does not allow me to remember socket commands...
# @author ZsBT@GitHub
#
_socmd(){ echo "$*" | socat stdio $(egrep -o '[^ ]+\.sock' /etc/haproxy/haproxy.cfg); }
[ -z "$(which socat)" ] && { echo "error: socat not installed";exit 1; }
@ZsBT
ZsBT / scrubtrfs.sh
Last active July 31, 2019 11:36
btrfs maintenance shell - functions only
#!/bin/bash
#
# BTRFS maintenance
# scrub or balance all btrfs fs present on system
#
scrub() {
for device in $(mount -t btrfs | cut -d ' ' -f 1 |sort -u) ;do
echo "scrub $device"
btrfs scrub start -B -c 3 -n 9 -d $device || exit 1
@ZsBT
ZsBT / install-dc.sh
Created January 18, 2020 08:07
install docker&compose packages on Debian
#!/bin/sh
sudo apt -y install apt-transport-https ca-certificates curl gnupg2 software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
sudo add-apt-repository -y \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"