Skip to content

Instantly share code, notes, and snippets.

View PhrozenByte's full-sized avatar

Daniel Rudolf PhrozenByte

View GitHub Profile
@PhrozenByte
PhrozenByte / systemd-calendar-run.sh
Last active July 6, 2023 15:40
Runs a command if a Systemd calendar specification is due.
#!/bin/bash
# systemd-calendar-run.sh
# Runs a command if a Systemd calendar specification is due
#
# This script checks whether a given Systemd calendar specification (pass the
# '--on-calendar SPEC' option) relative to either the current, or a given time
# (pass the '--base-time TIMESTAMP' option) yields a past elapse time and runs
# the given command (pass as arguments: 'COMMAND [ARGUMENT]'). Otherwise the
# script exits with return code 254. When an invalid option is given, the
# script exits with return code 255.
@PhrozenByte
PhrozenByte / rdiff-backup-to-borg.sh
Created January 15, 2023 15:01
Converts rdiff-backup backups to Borg Backup.
#!/bin/bash
# rdiff-backup-to-borg
# Converts rdiff-backup backups to Borg Backup
#
# This script was created to ease switching from `rdiff-backup` to `borg`. It
# restores all increments of a rdiff-backup repository and backs it up using
# Borg Backup.
#
# More info about Borg Backup: <https://borgbackup.readthedocs.io>
# More info about rdiff-backup: <https://rdiff-backup.net/>
@PhrozenByte
PhrozenByte / btrfs-snapshot-run.sh
Last active September 29, 2023 21:02
Creates snapshots of a btrfs filesytem and runs a given command.
#!/bin/bash
# btrfs-snapshot-run
# Creates snapshots of a btrfs filesytem and runs a given command
#
# This script was created to ease backing up a btrfs filesystem. It expects
# Snapper's subvolume layout, with subvolumes directly below in the hierarchy
# of the top level subvolume (ID 5), all prefixed by '@'. Other subvolumes are
# being ignored.
#
# This script will create readonly snapshots for either all, or the provided
@PhrozenByte
PhrozenByte / systemd-wait-unit-active.sh
Created November 26, 2021 21:56
Waits until a systemd system or user unit is active.
#!/bin/bash
# systemd-wait-unit-active.sh
# Waits until a systemd system or user unit is active.
#
# Notice: When using this script with user units you must ensure that `sudo`
# can call `systemctl` proberly. This often fails due to `systemctl` not
# finding the user's D-Bus socket. Ensure that the user runs a D-Bus daemon
# and that the '$XDG_RUNTIME_DIR' environment variable is defined.
#
# Copyright (C) 2021 Daniel Rudolf (<https://www.daniel-rudolf.de>)
@PhrozenByte
PhrozenByte / coverage-badge.sh
Created January 28, 2021 01:32
Creates a coverage.svg badge from a clover.xml.
#!/bin/bash
# coverage-badge.sh - Creates a coverage.svg badge from a clover.xml.
#
# Copyright (C) 2021 Daniel Rudolf (<https://www.daniel-rudolf.de>)
# License: The MIT License <http://opensource.org/licenses/MIT>
#
# SPDX-License-Identifier: MIT
function print_usage {
echo "Usage:"
@PhrozenByte
PhrozenByte / PicoRedirect.php
Last active November 17, 2021 21:59
A simple Pico plugin to create redirection pages to arbitrary URLs.
<?php
/**
* Pico redirect plugin
*
* Adds a `Redirect` meta header to redirect to other URLs. The meta header
* supports URL substitution variables, namely %base_url%, %plugins_url%,
* %themes_url%, %assets_url% and %theme_url%.
*
* Example:
@PhrozenByte
PhrozenByte / 6to4-daemon
Created April 22, 2020 12:06
Establishing an IPv6 tunnel using 6to4
#!/bin/bash
# 6to4-daemon - Establishing an IPv6 tunnel using 6to4
# Copyright (C) 2011 Daniel Rudolf <http://www.daniel-rudolf.de/>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@PhrozenByte
PhrozenByte / gta-empty-lobby.ps1
Created January 11, 2020 19:47
Creates a empty public lobby in Grand Theft Auto Online.
# Creates a empty public lobby in Grand Theft Auto Online.
# by Daniel Rudolf <https://github.com/PhrozenByte>
#
# This PowerShell v3+ script suspends `GTA5.exe` for 8 seconds, causing
# GTA Online to create a empty public lobby. For undisturbed fun
# without modders, griefers and other pathetic pip-squeaks.
#
# License:
# Creative Commons CC0
# <https://creativecommons.org/publicdomain/zero/1.0/deed>
@PhrozenByte
PhrozenByte / FigureExtParsedown.php
Created September 2, 2019 15:01
A simple Pico plugin to wrap Markdown images in <figure> elements. Pico is a stupidly simple, blazing fast, flat file CMS. http://picocms.org/
<?php
/**
* Parsedown figure extension
*
* Parsedown extension to wrap single-image lines in <figure>, not <p>.
*
* @author Krzysztof Antoniak
* @link https://gist.github.com/kantoniak/b1a5c7889e5583824487dc78d93da7cd
* @license Public Domain
@PhrozenByte
PhrozenByte / PicoPageModPlugin.php
Created July 14, 2019 12:21
A simple Pico plugin adding a page's last modification time to its page data. Pico is a stupidly simple, blazing fast, flat file CMS. http://picocms.org/
<?php
/**
* Pico page modification time plugin
*
* Adds a page's last modification time to its page data.
*
* Example:
*
* ```twig