Skip to content

Instantly share code, notes, and snippets.

View Fleshgrinder's full-sized avatar
💀

Richard Fussenegger Fleshgrinder

💀
View GitHub Profile
@Fleshgrinder
Fleshgrinder / gh-delete-workflow.sh
Last active October 6, 2022 14:45
Deletes a GitHub Workflow by deleting all its Runs.
#!/usr/bin/env bash
set -Eeuo pipefail
# There is no button in the interface of GitHub (and as it seems also no API) with which workflows can be deleted.
# They are eventually removed automatically, but in case you want to clean up your Actions UI it is sometimes nice
# to have the possibility to get rid of workflows that are not required anymore. This interactive script allows you
# to achieve exactly that by deleting each individual run of a workflow, after which GitHub deletes the workflow.
declare -ir CONCURRENCY=${CONCURRENCY:-8}
@Fleshgrinder
Fleshgrinder / ghpr
Last active September 30, 2022 07:59
#!/usr/bin/env bash
git push -u || exit 1
gh pr create --assignee @me "$@" || exit 2
gh pr merge --auto --squash || gh pr merge --auto
@Fleshgrinder
Fleshgrinder / ssmtp-debian-setup.md
Last active December 19, 2021 11:06
Set up sSMTP on Debian as replacement for sendmail and usage with PHP

sSMTP Debian Setup

The sendmail package, which comes preinstalled with many distros, is often simply too much for a simple server that should not receive emails but rather deliver them. The sSMTP package is a lightweight replacement that does not set up regular cronjobs and only reacts if a subsystem actually wants to send a mail.

Uninstall Sendmail

apt-get purge --yes sendmail*
@Fleshgrinder
Fleshgrinder / gpg.sh
Last active May 17, 2021 10:00
Create GPG Key for GitHub Commit Signing
#!/bin/sh
set -eu
#
# Commands for generating a new GPG key for GitHub commit signing.
#
# https://help.github.com/articles/generating-a-new-gpg-key/
#
gpg --full-gen-key
@Fleshgrinder
Fleshgrinder / settings.gradle.kts
Created April 2, 2021 14:04
Simple Version Management for Gradle
gradle.projectsLoaded {
@Suppress("UNCHECKED_CAST")
val versions = java.util.Properties().apply {
load(rootProject.file("version.properties").inputStream())
} as Map<String, String>
allprojects {
// We export the versions so that our tasks can access them
// programmatically as well if required.
extra["versions"] = versions
@Fleshgrinder
Fleshgrinder / build.gradle.kts
Last active March 29, 2021 08:32
Disallow transitive JUnit 4 and JUnit 5 Vintage dependencies in all Gradle configurations.
configurations.all {
// If this configuration supports transitive dependencies then we
// exclude any transitive JUnit 4 dependencies from all dependencies
// that are declared in this configuration. This means that users have
// to define an explicit dependency on JUnit 4 if they want to use it.
if (isTransitive) {
withDependencies {
forEach {
(it as? ExternalModuleDependency)
?.takeIf { it.group != "org.junit.vintage" }
@Fleshgrinder
Fleshgrinder / rmfr.bat
Created December 6, 2020 14:28
Fast recursive directory deletion in Windows
@ECHO OFF
:: https://pureinfotech.com/delete-large-folder-fast-windows-10/
ECHO Delete Folder: %CD%?
PAUSE
SET FOLDER=%CD%
CD /
DEL /F/Q/S "%FOLDER%" > NUL
RMDIR /Q/S "%FOLDER%"
EXIT
@Fleshgrinder
Fleshgrinder / gradle
Last active August 30, 2020 18:33
Global script to resolve to the closest available Gradle Wrapper script.
#!/usr/bin/env bash
set -Eeuo pipefail
if command -v jenv &>/dev/null; then
JAVA_HOME=$(jenv javahome)
export JAVA_HOME
fi
if [[ -x gradlew ]]; then
exec ./gradlew "$@"
@Fleshgrinder
Fleshgrinder / jenv-autoload.sh
Created August 28, 2020 17:31
Load Zulu JDKs into jEnv
#!/usr/bin/env bash
set -Eeuo pipefail
if ! command -v jenv &>/dev/null; then
echo 'Could not find jenv in your PATH, make sure it is installed correctly and in your PATH.' >&2
exit 1
fi
readonly JENV_HOME=${JENV_HOME:-"$HOME/.jenv"}
@Fleshgrinder
Fleshgrinder / install-zulu.sh
Created August 28, 2020 16:50
Install Azul Zulu JDKs on Ubuntu
#!/usr/bin/env bash
set -Eeuo pipefail
if ((EUID != 0)); then
echo 'You need superuser privileges (e.g. sudo) to run this script' >&2
exit 1
fi
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0xB1998361219BD9C9
apt-add-repository 'deb http://repos.azulsystems.com/ubuntu stable main'