Skip to content

Instantly share code, notes, and snippets.

@stbuehler
stbuehler / systemd-spawn-fcgi.sh
Created March 30, 2015 13:24
systemd to FastCGI socket passing compatibility script, with AppArmor profiles
#!/bin/bash
set -e
if [ "${LISTEN_PID}" != $$ ]; then
echo >&2 "file descriptors not for us, pid not matching: '${LISTEN_PID}' != '$$'"
exit 255
fi
if [ "${LISTEN_FDS}" != "1" ]; then
@stbuehler
stbuehler / Makefile
Last active August 29, 2015 14:18
Run a command with arguments expanded like shell wildcard expansion but no other (sub)command evaluations
CFLAGS=-O2 -Wall
all: glob-exec
clean:
rm -f glob-exec
.PHONY: all clean
@stbuehler
stbuehler / keybase.md
Created April 14, 2015 17:52
Keybase proof

Keybase proof

I hereby claim:

  • I am stbuehler on github.
  • I am stbuehler (https://keybase.io/stbuehler) on keybase.
  • I have a public key whose fingerprint is C7CA 1E9E 29DC 77F5 4808 94B2 E0E7 D017 1E95 BAD7

To claim this, I am signing this object:

@stbuehler
stbuehler / sensors
Last active August 29, 2015 14:22
munin sensors plugin
#!/bin/bash
#
# munin plugin
#
# [sensors_*]
# env.sensors - override default sensors program
# env.ignore_[temp|fan|volt|power]<n> - disable some graphs
set -e
@stbuehler
stbuehler / capture-output.sh
Created July 12, 2015 09:11
Capture stdout/stderr of a command while keeping the exit code
#!/bin/bash
syntax() {
echo "$0 [options] [--] cmd..."
echo "Options:"
echo " --stdout <logfile>: append stdout to logfile"
echo " --stderr <logfile>: append stderr to logfile"
echo "Returns exit code returned by captured command"
exit 1
}
@stbuehler
stbuehler / torrent-announce-info.rl
Created April 10, 2011 13:42
Torrent Announce Info extractor
/*
Torrent Announce Info extractor
lists all announce urls from torrents on stdout
Build with ragel (http://www.complang.org/ragel/) and a c compiler:
ragel -T1 torrent-announce-info.rl && CFLAGS='-O2' make torrent-announce-info
list torrent files on stdin:
ls -1 /path/to/torrents/*.torrent | torrent-announce-info
@stbuehler
stbuehler / Makefile
Created April 11, 2011 00:13
analyse/fix torrent files
override LDFLAGS += -lssl -lpcrecpp
override CPPFLAGS += -O2 -Wall
all: torrent-sanitize
clean:
rm torrent-sanitize
.PHONY: all clean
@stbuehler
stbuehler / ipkdesc
Created April 20, 2011 19:26
ipk package feed
#!/bin/bash
IPKG=$1
FILENAME=$(basename "$IPKG")
X=$FILENAME
PACKAGE=${X%%_*}
X=${X#*_}
VERSION=${X%%_*}
X=${X#*_}
@stbuehler
stbuehler / future-nest-fix.js
Created April 20, 2011 21:59
webos Mojo: Foundations.Control.Future - make nest usable
/* wait for "this" future to reach this point, run "inner" in background; copy result from "inner" future */
Future.prototype.nest = function(inner) {
var succ, result, exc, wait = 2, f = this;
this.then(function () {
f.exception;
if (0 == --wait) { if (succ) f.result = result; else f.exception = exc; }
});
inner.then(function (future) {
if (future.exception) { succ = false; exc = future.exception; } else { succ = true; result = future.result; }
if (0 == --wait) { if (succ) f.result = result; else f.exception = exc; }
@stbuehler
stbuehler / ipkbuild
Created April 30, 2011 12:21
palm-package recode in ruby
#!/usr/bin/env ruby
require 'optparse'
require 'tmpdir'
require 'json'
require 'fileutils'
require 'zlib'
require 'rubygems' rescue nil
require 'libarchive'