Skip to content

Instantly share code, notes, and snippets.

View jplitza's full-sized avatar

Jan-Philipp Litza jplitza

View GitHub Profile
local function timeout_popen(timeout, ...)
local outerpiper, outerpipew = nixio.pipe()
if nixio.fork() == 0 then
outerpiper:close()
local innerpiper, innerpipew = nixio.pipe()
local pid = nixio.fork()
if pid == 0 then
outerpipew:close()
innerpiper:close()
nixio.dup(innerpipew, nixio.stdout)
#!/bin/sh
CMD="${@:-bash}"
unshare -unpirf --mount-proc sh -c '
hostname sandbox
TMPNAME=$(mktemp -d)
# replace /dev by minimal dummy version
mount -t tmpfs -o nosuid,mode=755 none $TMPNAME
@jplitza
jplitza / global_toc.rb
Created February 11, 2016 21:33
Gollum better Global ToC
module Gollum
class Macro
class GlobalTOC < Gollum::Macro
def render(title = "Global Table of Contents")
pages = @wiki.pages.sort do |a,b|
if a.path.include?('/') and b.path.include?('/') then
a.path <=> b.path
elsif a.path.include?('/') then
1
elsif b.path.include?('/') then
@jplitza
jplitza / zbell.zsh
Last active February 4, 2017 20:47 — forked from oknowton/zbell.zsh
#!/usr/bin/env zsh
# This script prints a bell character when a command finishes
# if it has been running for longer than $zbell_duration seconds.
# If there are programs that you know run long that you don't
# want to bell after, then add them to $zbell_ignore.
#
# This script uses only zsh builtins so its fast, there's no needless
# forking, and its only dependency is zsh and its standard modules
#
#!/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
@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"
#!/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 / 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
@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 = {