Skip to content

Instantly share code, notes, and snippets.

View mjf's full-sized avatar

Matouš Jan Fialka mjf

View GitHub Profile
@mjf
mjf / HtUPg12wTsDBExtCMngbyPtPg13oEL8S.md
Last active May 28, 2024 08:01
Upgrade PostgreSQL 12 with TimescaleDB Extension Cluster Managed by Patroni to PostgreSQL 13 on CentOS 8 Stream

How to Upgrade PostgreSQL 12 with TimescaleDB Extension Cluster Managed by Patroni to PostgreSQL 13 on CentOS 8 Stream

Flag Meaning
[---] Holds for nothing (i.e. work in progress)
[M--] Holds exclusively for master
[-S-] Holds exclusively for slave
[--C] Holds exclusively for cluster management
[MS-] Holds for both master and slave
@mjf
mjf / haproxy-pgsql-tcp-check
Last active June 9, 2022 19:51
Generate HAProxy PostgreSQL TCP Check
#! /bin/sh
# haproxy-pgsql-tcp-check - Generate HAProxy PostgreSQL TCP Check
# Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz/>
# Released under the terms of "The MIT License"
#
# See https://www.postgresql.org/docs/current/protocol-message-formats.html
if [ $# -lt 2 -o $# -gt 3 ]; then
printf -- 'Usage: %s USER DATABASE ["leader"]\n' "${0##*/}" >&2
@mjf
mjf / pingfmt
Last active January 20, 2021 09:41
pingfmt - Format output of the ping(1) program
#! /usr/bin/awk --exec
# pingfmt - Format output of the ping(1) program
# Copyright (C) 2012, 2021 Matouš J. Fialka, <https://mjf.cz/>
# Released under the terms of The MIT License
BEGIN {
# ----- HELP SCREEN -----
help = help "Usage: pingfmt [-h|-help|-usage] [+[no][show]<opt>[=<val>]]\n"
@mjf
mjf / move-centos8-to-stream.sh
Last active January 20, 2021 12:53
Move CentOS 8 to Stream
#! /bin/sh
# Script "memo" to move CentOS 8 to AppStream
# Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz/>
# Released under the terms of "The MIT License"
dnf update -y && \
dnf install -y centos-release-stream && \
dnf distro-sync -y
@mjf
mjf / Postgres.md
Last active May 8, 2025 15:20
Postgres

⚠️ WARNING
The ordering of listed projects or documents is random and has no connection to relevance or maturity levels!

Postgres

Extensions

Extension Description
pgaudit Postgres auditing extension
@mjf
mjf / postgresql_gimmicks.sql
Last active October 1, 2021 11:46
PostgreSQL "gimmicks"
-- PostgreSQL Gimmicks
-- Copyright (C) 2021 Matous Jan Fialka, <https://mjf.cz/>
-- Released under the terms of "The MIT License"
-- 1. BEWARE USING BETWEEN OPERATOR WITH DATE AND TIME TYPES
-- 1.1 INCORRECT
-- Note: intervals are written in ISO 8601 format
@mjf
mjf / mysqlgrants
Created December 4, 2020 11:33
mysqlgrants - Lists all MySQL grants
#! /bin/sh
# mysqlgrants - Lists all MySQL grants
# Copyright (C) 2020 Matous Jan Fialka, <https://mjf.cz/>
# Released under the terms of the MIT license
mysql -B -N $@ -e "SELECT DISTINCT CONCAT('SHOW GRANTS FOR \'', user, '\'@\'', host, '\';') AS query FROM mysql.user"|
sort -V|
mysql $@|
sed 's/\(GRANT .*\)/\1;/;s/^\(Grants for .*\)/## \1 ##/;/##/{x;p;x;}'
@mjf
mjf / prometheus.spec
Last active November 6, 2020 12:29
RPM specfile for Prometheus
# RPM specfile for Prometheus
# Copyright (C) 2020 Matous Jan Fialka, <[email protected]>
# Released under the terms of the "MIT License"
Name : prometheus
Version : 2.22.1
Release : 1%{?dist}
Group : Network Servers
License : ASL 2.0
Source : https://github.com/prometheus/%{name}/releases/download/v%{version}/%{name}-%{version}.linux-amd64.tar.gz
@mjf
mjf / pushgateway.spec
Last active November 6, 2020 12:30
RPM specfile for Prometheus Pushgateway
# RPM specfile for Prometheus Pushgateway
# Copyright (C) 2020 Matous Jan Fialka, <[email protected]>
# Released under the terms of the "MIT License"
Name : pushgateway
Version : 1.3.0
Release : 1%{?dist}
Group : Network Servers
License : Apache License 2.0
Source : https://github.com/prometheus/%{name}/releases/download/v%{version}/%{name}-%{version}.linux-amd64.tar.gz
@mjf
mjf / promscale_extension.spec
Last active November 6, 2020 12:31
RPM specfile for Promscale Postgres extension
# RPM specfile for Promscale Postgres extension
# Copyright (C) 2020 Matous Jan Fialka, <[email protected]>
# Released under the terms of the "MIT License"
Name : promscale_extension
Version : 0.1.1
Release : 1%{?dist}
Group : PostgreSQL Database Server 12 PGDG
License : Timescale License
Source : https://github.com/timescale/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tgz