Skip to content

Instantly share code, notes, and snippets.

@n-st
n-st / ds18b20
Last active December 28, 2015 15:19
Munin plugin that reads any number of DS18B20 temperature sensors using the w1-gpio and w1_therm kernel modules.
#!/usr/bin/env python
import sys
import os
import re
from syslog import syslog
temperatureRegex = r't=(-?\d+)'
sensorNames = {
@n-st
n-st / post-receive
Last active January 3, 2016 07:29
Git post-receive hook to rebase dev branch onto master (if no changes have been made to the working copy)
#!/bin/bash
cd ..
GIT_DIR='.git'
while read oldrev newrev ref
do
if [ "$ref" != "refs/heads/dev" ]
then
echo -e "\e[33mPushed branch isn't 'dev'. Skipping rebase dev->master.\e[0m"
@n-st
n-st / snmp-tunnel.sh
Last active December 3, 2022 18:07
Forward SNMP requests over a SSH connection (e.g. for use with Observium or other monitoring tools).
#!/bin/bash
# This script will make a local SNMP server accessible on a remote system by
# forwarding its UDP traffic over an SSH connection.
# To do this, the following port forwardings are applied (in this order):
# - local TCP port 42061 (arbitrary) to local UDP port 161 (SNMP)
# - remote TCP port 42061 to local TCP port 42061 (via SSH connection)
# - remote UDP port 42061 to remote TCP port 42061
@n-st
n-st / replace-master-branch.sh
Created February 8, 2014 17:19
Merge 'dev' into 'master', discarding the state of 'master'. Created by https://gist.github.com/ojacobson/.
git commit-tree dev^{tree} -p master -p dev <<'MESSAGE'
Replace master with dev branch.
MESSAGE
% Lorenz curve
% by n.st, originally created on 2014-02-08
% based on
% - http://www.texample.net/tikz/examples/line-plot-example/
% - http://tex.stackexchange.com/a/51766
\documentclass[crop,tikz,convert={outext=.svg,command=\unexpanded{pdf2svg \infile\space\outfile}},multi=false]{standalone}
\usepackage[utf8]{inputenc}
@n-st
n-st / dont-blink.sh
Created March 10, 2014 23:38
Disable blinking "heartbeat" LED on BeagleBone Black. (Requires root privileges.)
@n-st
n-st / update-all.sh
Last active August 29, 2015 13:57
Quickly update multiple remote Debian/Ubuntu systems.
#!/bin/bash
# Uncomment the next line to start any pending updates automatically:
#yes="--yes"
for host in host1 host2 # etc.
do
echo -e "\e[0;33m$host\e[0m"
ssh "$host" -t "
@n-st
n-st / README
Last active August 29, 2015 14:01
TARDIS Cloister Bell clock/alert script
Usage:
./tardis-bell.sh [ clock | <number of chimes> ]
This script requires the 'play' command and accompanying mp3 format plugin from
Sound eXchange (sox).
The sound used is a shortened version of the Doctor Who TARDIS Cloister Bell
from http://dannystewart.com/2009/09/01/doctor-who-ringtones.
@n-st
n-st / intcat.py
Last active August 29, 2015 14:01
"interval cat": print every n-th character received on stdin
#!/usr/bin/env python
# intcat = interval cat:
# Prints a human-readable character for every n-th character received on stdin.
# Throughput depends heavily on n (faster for larger n).
n = 1000000
import sys, os
@n-st
n-st / pianobar-notify-send.sh
Last active August 29, 2015 14:02
Display title, artist and station via the default notification tool when pianobar starts playing a new song.
#!/bin/bash
# Modify the following line for your system and add it to your pianobar config
# (usually ~/.config/pianobar/config):
# event_command = /home/johndoe/bin/pianobar-event.sh
[ "$1" = "songstart" ] || exit 0
while read line
do