Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@mjf
mjf / .lftprc
Last active January 12, 2022 07:13
LFTP RC file
set cmd:prompt '\U \S\n$ '
set ftp:port-range 21000-21999
set ftp:sync-mode off
set ssl:verify-certificate off
debug 4
alias ledit 'local edit'
alias lls 'local ls'
alias nocertverify 'set ssl:verify-certificate off'
@mjf
mjf / dip
Created December 6, 2021 10:30
DIP - Docker IP (petite tool to list container IP addresses)
#! /bin/sh
# DIP - Docker IP (petite tool to list container IP addresses)
# Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz>
# Released under the terms of the "MIT License"
printf -- '%-12s %-47s %-15s\n' 'CONTAINER ID' 'NAME' 'IP ADDRESS'
printf -- '------------ '
printf -- '----------------------------------------------- '
printf -- '---------------\n'
@mjf
mjf / pgbouncer_lookup.sql
Last active October 27, 2021 08:43
PgBouncer Lookup Function
-- Create login role, schema and security definer function for PgBouncer
-- Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz/>
-- Released under the terms of the "MIT License"
-- PER CLUSTER
CREATE ROLE
pgbouncer
WITH
LOGIN
@mjf
mjf / README.md
Last active October 8, 2021 09:15
Rclone server for Restic
cp [email protected] /etc/systemd/system
systemctl daemon-reload
systemctl enable [email protected]
cp rclone@restic /etc/sysconfig
vi /etc/sysconfig/rclone@restic
systemctl start rclone@restic
journalctl -xefurclone@restic
@mjf
mjf / anna
Created September 23, 2021 12:12
anna - Annonymize IPv4 and IPv6 addresses
#! /bin/sed -f
# anna - Annonymize IPv4 and IPv6 addresses
# Copyright (2020) Matous Jan Fialka, <https://mjf.cz/>
# Released under the terms of the "MIT License"
# See RFC 5737 for the replacements explanation.
s/\(\(\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)\.\)\{3\}\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)\)/192.0.2.1/g
s/\(\([0-9a-f]\{1,4\}:\)\{6\}\(\([0-9a-f]\{1,4\}:[0-9a-f]\{1,4\}\)\|\(\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)[.]\)\{3\}\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)\)\|::\([0-9a-f]\{1,4\}:\)\{5\}\(\([0-9a-f]\{1,4\}:[0-9a-f]\{1,4\}\)\|\(\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)[.]\)\{3\}\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)\)\|\([0-9a-f]\{1,4\}\)\?::\([0-9a-f]\{1,4\}:\)\{4\}\(\([0-9a-f]\{1,4\}:[0-9a-f]\{1,4\}\)\|\(\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)[.]\)\{3\}\([0-9]\|[1-9][0-9]\|1[0-9]\{2\}\|2[0-4][0-9]\|25[0-5]\)\)\|\(\([0-9a-f]\{1,4\}:\)\?[0-9a-f]\{1,4\}\)\?::\([0-9a-f]\{1,4\}:\
@mjf
mjf / haproxy-postgres-binary-checks.cfg
Last active October 24, 2023 15:09
HAProxy TCP Binary Check for Postgres Replica Instance
# HAProxy TCP Binary Check for Postgres Replica Instance
# Copyright (C) "2021" Matous Jan Fialka, <https://mjf.cz/>
# Released under the terms of "The MIT License"
# https://www.postgresql.org/docs/current/protocol-message-formats.html
backend postgres
bind :5432
@mjf
mjf / dockercat
Last active July 13, 2021 11:48
Docker Object Tools
#! /bin/sh
# dockercat - Print Docker config or secret object
# Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz/>
# Released under the terms of the "MIT License"
PROGRAM="${0##*/}"
if [ $# -eq 0 -o $# -ne 2 ]; then
echo "Usage: $PROGRAM { config | secret } OBJECT" >&2
@mjf
mjf / hp4pid
Last active July 9, 2021 11:40
Huge Pages for PID
#! /bin/sh
[ $# -eq 1 ] && {
grep -B 11 'KernelPageSize' "/proc/$1/smaps" |
awk '/^Size:/ { sum += $2 } END { printf("%.2F GiB\n", sum / 1024 / 1024) }'
} || {
printf "Usage: %s PID\n" "${0##*/}" >&2
exit 1
}
@mjf
mjf / prom_api_extras.pgsql
Last active May 14, 2021 10:26
Promscale API Extras
-- PL/PgSQL Functions for Promscale API Schema
-- Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz/>
-- Released under the terms of "The MIT License"
-- LABEL VALUES FUNCTIONS
--
-- label_values([<metric>,] <label>[, <time from>[, <time to>]])
--
-- Where:
-- <metric> is name of a metric
@mjf
mjf / PromQL_to_SQL_Idioms_for_Promscale.md
Last active August 23, 2022 19:48
PromQL to SQL Idioms for Promscale

PromQL to SQL Idioms for Promscale

Legend

Variable Meaning
METRIC Metric name (i.e. cpu_usage_system)
NAME Name for the metric value (corresponds to AS "NAME" in SQL)