Skip to content

Instantly share code, notes, and snippets.

View jplitza's full-sized avatar

Jan-Philipp Litza jplitza

View GitHub Profile
@jplitza
jplitza / 41-firefox-callback.lua
Created November 24, 2022 14:16
Make Wireplumber route Firefox' voice output to internal ALSA output
stream_defaults.rules = {
{
matches = {
{
{ "application.name", "matches", "Firefox" },
{ "media.name", "matches", "AudioCallbackDriver" },
{ "media.class", "matches", "Stream/Output/Audio" },
}
},
apply_properties = {
#!/bin/sh
set -eu
REPO="$1"
ARCHIVE="$2"
FILE="$3"
# Fetch the latest version using GitHub API
VERSION="$(curl -s "https://api.github.com/repos/${REPO}/releases" | jq -r 'map(select(.prerelease | not)) | .[0].tag_name' | cut -c 2-)"
@jplitza
jplitza / nc.sh
Created February 23, 2024 14:10
Netcat in Bash
#!/bin/bash
set -eu
PROXY=false
usage() {
echo "Usage: $0 [-X connect -x <proxy:port>] <host> <port>"
}
@jplitza
jplitza / webhook.php
Created January 7, 2015 14:36
A basic PHP webhook handler for Github, just verifying the signature and some variables before calling another command to do the actual work
<?php
// where to log errors and successful requests
define('LOGFILE', '/tmp/github-webhook.log');
// what command to execute upon retrieval of a valid push event
$cmd = 'update-jekyll.sh 2>&1';
// the shared secret, used to sign the POST data (using HMAC with SHA1)
$secret = '00000000000000000000000000000000';
@jplitza
jplitza / co2mon.init
Last active October 11, 2022 20:54 — forked from librarian/hidapi_co2mon.py
Basic programm to use hidapi and report temp/co2 from Holtek Semiconductor, Inc. USB-zyTemp (hidapi is python3-hidapi in debian buster)
#!/bin/sh /etc/rc.common
START=50
USE_PROCD=1
NAME=co2mon
PROG=/root/co2mon/hidapi_co2mon.py
start_service() {
local url=$(uci -q get co2mon.@co2mon[0].url)
@jplitza
jplitza / tplink.rb
Created December 17, 2021 15:34
Slightly modified Oxidized model for TP-Link switches
#!/bin/bash
set -eu
declare -a STATES=(OK WARNING CRITICAL UNKNOWN)
declare -i STATE_OK=0
declare -i STATE_WARNING=1
declare -i STATE_CRITICAL=2
declare -i STATE_UNKNOWN=3
@jplitza
jplitza / flash_router.sh
Created August 29, 2018 08:35
Flash a router running OpenWrt via SSH
#!/bin/sh
set -eu
if [ "$#" != 2 ]; then
echo "Usage: $(basename "$0") <iface> <file>"
exit 1
fi
IFACE="$1"
@jplitza
jplitza / git-word-stat.sh
Last active June 28, 2018 19:56
Do a git diffstat based on words (using git diff --word-diff and wc -w). Might break on merge commits!
#!/bin/bash
# Copyright (c) 2014 Jan-Philipp Litza <janphilipp@litza.de>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#!/bin/sh
SERVER="$1"
INTERVAL=10
# read once and ignore result, as it is bogus at first
cat /sys/bus/w1/devices/*/w1_slave > /dev/null
while sleep "$INTERVAL"; do
for DEV in /sys/bus/w1/devices/*/w1_slave; do