Skip to content

Instantly share code, notes, and snippets.

@Programie
Programie / pa-app-sink-switcher.py
Last active December 24, 2022 08:57
Toggle PulseAudio output sink for the active application
#! /usr/bin/env python3
# This script toggles the PulseAudio output sink of the currently active application (guessed by the currently active X window) between the given output sink and the default output sink.
# The output sink is passed as first argument to the script.
#
# Requirements:
#
# xdotool (on Ubuntu install via "sudo apt install xdotool")
# pulsectl ("sudo pip3 install pulsectl")
@Programie
Programie / reorganise-music.sh
Created August 25, 2014 00:00
Reorganise music from ID3 tags
#! /bin/bash
BASEPATH="/data/music" # Replace with your music directory
for FILE in $BASEPATH/*.mp3; do
ID3_INFO="`id3info \"$FILE\" | grep -i \"===\"`"
TITLE=$(echo "$ID3_INFO" | grep -i TIT2)
ARTIST=$(echo "$ID3_INFO" | grep -i TPE1)
ALBUM=$(echo "$ID3_INFO" | grep -i TALB)
@Programie
Programie / require.sh
Last active March 8, 2022 18:04
A simple function for Bash to require specific commands
#! /bin/bash
set -e
# This is a simply function to require a specific command
# The script will print an error message "Command x not found!" and exit if the command does not exist
function require()
{
which $1 > /dev/null 2>&1 || (echo "Command '$1' not found!"; exit 1)
}
@Programie
Programie / link-ssl-ca.sh
Created March 11, 2017 17:57
Find the right issuing CA certificate for the given certificate (based on the subject) and symlink it to the specific target file.
@Programie
Programie / git-log-since.sh
Created August 29, 2017 07:37
Show all commits since a specific date in all cloned git repositories (cloned to $GIT_HOME)
#! /bin/bash
SINCE="$1"
if [ -z "${SINCE}" ]; then
echo "Usage: $0 <since>"
exit 1
fi
for REPO in `find ${GIT_HOME} -name .git -type d`; do
@Programie
Programie / samp-initd.sh
Last active August 16, 2021 19:39
Init.d Script for SA-MP server
#! /bin/bash
# This is a simple daemon script for Linux to start you SAMP servers as daemons.
# So it is possible to auto start the SAMP servers if you restart you Linux server.
# It will also prevent you from multiple launchings of the same SAMP server.
#
# Login to you Linux server using SSH or whatever you want to use to get a terminal of you server.
# Create a directory "/opt/samp/port-of/your/samp-server".
# Download the SAMP server for Linux from the SAMP website (http://www.sa-mp.com) using wget (Example: "wget http://files.sa-mp.com/samp03bsvr_R2.tar.gz").
# Extract the archive using "tar -xf samp03bsvr_R2.tar.gz".
@Programie
Programie / Experience.java
Last active April 26, 2021 21:12 — forked from Jikoo/Experience.java
A utility for managing experience with Bukkit.
package com.github.jikoo.experience;
import org.bukkit.entity.Player;
/**
* A utility for managing Player experience properly.
*
* @author Jikoo
*/
public class Experience {
@Programie
Programie / check_docker_images.py
Last active January 18, 2020 14:41
Local Check_MK check to check whether Docker container images are up to date
#! /usr/bin/env python3
import docker
client = docker.from_env()
containers = client.containers.list(all=True)
outdated_containers = []
for container in containers:
@Programie
Programie / loxone2influxdb-nodered.json
Created January 3, 2019 20:18
Node-RED Flow for sending data from Loxone Miniserver to InfluxDB
[
{
"id": "77643d95.63b8d4",
"type": "tab",
"label": "Loxone",
"disabled": false,
"info": ""
},
{
"id": "c7f2764c.9bda68",
@Programie
Programie / fix_rrd_ds.sh
Created December 13, 2018 14:36
Increase number of data sources in RRD files created by PNP4Nagios (and possible other tools)
#! /bin/bash
set -e
file_owner="nagios"
rrd_file="$1"
required_ds="$2"
if [[ -z ${rrd_file} ]] || [[ -z ${required_ds} ]]; then
echo "Usage: $0 <rrd file> <no required data sources>"