Skip to content

Instantly share code, notes, and snippets.

@BH1SCW
BH1SCW / git-rpm-changelog.sh
Created February 24, 2023 12:41 — forked from jflemer-ndp/git-rpm-changelog.sh
generate a rpm spec compatible changelog from git history
#!/bin/bash
merge_commit() {
git show --no-patch --format='%P' "$@" | head -1 | grep -q ' '
}
commit_meta() {
git show --no-patch --format="* %cd %aN <%ae> - %H" --date=local "$@" | \
head -1 | \
sed -E 's/^(\* [a-z0-9 ]{9,10}) \d{2}:\d{2}:\d{2}/\1/i'
@BH1SCW
BH1SCW / rpmgpgsign.sh
Created February 24, 2023 12:36 — forked from jflemer-ndp/rpmgpgsign.sh
Wrapper for non-interactive signing of RPMs
#!/bin/bash
##############################################################################
# Wrapper for non-interactive signing of RPMs.
#
# _NOTE: This uses environment variables for sensitive information (the GPG
# passphrase), so should not be used on an untrusted or shared host._
#
# Prep
# ----
@tropicbliss
tropicbliss / archcheck.sh
Last active April 3, 2024 18:02
Checks your linux architecture. Code taken from rustup installation script, and emits an arch code that corresponds to what rustc expects. Useful for checing cross compilation arch.
#!/bin/sh
if [ "$KSH_VERSION" = 'Version JM 93t+ 2010-03-05' ]; then
# The version of ksh93 that ships with many illumos systems does not
# support the "local" extension. Print a message rather than fail in
# subtle ways later on:
echo 'archcheck does not work with this ksh93 version; please try bash!' >&2
exit 1
fi
@evindunn
evindunn / get_firewalld_state.py
Last active December 20, 2023 19:41
Poll Firewalld State as JSON
#!/usr/bin/env python3
import dbus
import json
FIREWALLD_BUS = "org.fedoraproject.FirewallD1"
FIREWALLD_RUNTIME_OBJ = "/org/fedoraproject/FirewallD1"
FIREWALLD_CONFIG_OBJ = "/org/fedoraproject/FirewallD1/config"
@pmarreck
pmarreck / wh_darktide_quote.bash
Created January 29, 2023 21:19
Bash function to generate a random Warhammer Darktide loading screen quote
warhammer_quote() {
local whquotes
whquotes=(
"A coward's only reward is to live in fear another day"
"A dagger in the dark is worth a thousand swords at dawn"
"A pity it is that we can die but once in the Emperor's service"
"A small mind is a tidy mind"
"A suspicious mind is a healthy mind"
"A swift execution is worth a hundred interrogations"
"Abhor the mutant"
@panzi
panzi / rekey.py
Last active August 9, 2024 13:12
Re-key all the embedded vaults in an Ansible vars file.
#!/usr/bin/env python3
# derived from https://stackoverflow.com/a/67161907/277767
# Changes to the StackOverflow version:
# * delete temporary files that contain vaults!
# * prompt for passwords instead of passing them as program argument
# * more precise vault replacement
# * a bit nicer error messages that points at the line where re-keying failed
# * decryption if no password is provided
@milesrichardson
milesrichardson / inherit_environment_variables_from_pid_1.md
Created January 21, 2023 07:35
inherit environment variables from PID 1

You can inherit the environment variables from PID 1 by iterating over the list of null-terminated strings in /proc/1/environ, parsing the first characters up to the first = as the variable name, setting the remaining value as that variable, and exporting it.

The Code Snippet

This works with multiline environment variables, and environment variables with arbitrary values, like strings, including = or JSON blobs.

Paste this in your current terminal session to inherit the environment variables from PID 1:

@vyach-vasiliev
vyach-vasiliev / ReadMe.md
Last active April 22, 2023 00:44
One element CSS Snow by Keith Clark
@DavidBuchanan314
DavidBuchanan314 / figlett.py
Last active August 18, 2024 03:00
Demo of rendering TrueType fonts in the terminal, in a figlet-like way. (p.s. it segfaults occasionally, lol)
import cairocffi
import pangocffi
import pangocairocffi
import sys
import os
try:
width, height = os.get_terminal_size().columns, 1024
except OSError:
# There doesn't seem to be a neat way of figuring out the size of some text without
#!/usr/bin/awk -f
# https://unix.stackexchange.com/a/495105
# usage: match_block START END MATCH [FILE]
# output a whole block of text enclosed by START and END that contains MATCH
BEGIN {
pstart=ARGV[1];
pstop=ARGV[2];
pmatch=ARGV[3];
ARGV[1]=ARGV[4];
ARGC=2;