Skip to content

Instantly share code, notes, and snippets.

@stbuehler
stbuehler / abi-tag.patch
Last active December 14, 2015 16:37
clang abi-tag support.patch
Author: Stefan Bühler <stbuehler@web.de>
add gcc abi_tag support
- parse abi_tag attribute
- emit abi tags in name Itanium Mangling (but not for namespaces)
- for functions the abi tags from the return type need to be added
to the mangling of the function name, as long as they are not part of
the mangled function name otherwise (as tag on any involved namespace
or parameter type). Use nested "null" mangling of the signature to
@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 / hacker-evolution-checksum.hs
Created June 4, 2015 19:57
hacker evolution safegame checksum calculation
-- take all numbers from the 3rd until the second last line, multiply each
-- number with the associated multiplier from the list [10,5,6,7,8,9,11,13,14,15,16,2,3,17,18,19]
-- and sum everything up (modulo Int32) to get the checksum.
-- (hint: line 11, the 9th number in the list, is the cash amount)
-- in haskell:
import Data.Int
checksum :: [Int32] -> Int32
checksum nums = sum $ zipWith (*) nums [10,5,6,7,8,9,11,13,14,15,16,2,3,17,18,19]
@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 / 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 / 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 / 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 / systemd-spawn-fcgi.sh
Created March 28, 2015 09:09
systemd to FastCGI socket passing compatibility script
#!/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 / bma2otp.rb
Created January 25, 2014 14:10
Decode the Battle.net Mobile Authenticator (android) secret data into an otpauth url. Requires a way to access the private data of the application (i.e. a rooted android).
#!/usr/bin/ruby
# REQUIRES:
# * rooted android, as otherwise you can't read the applications private data
# * to display the qr code "qrencode" (http://fukuchi.org/works/qrencode/)
# and "display" from ImageMagick
# This script "decrypts" the token from the internal state of the
# Battle.net Mobile Authenticator on android application, converting
# it into an "otpauth" url (https://code.google.com/p/google-authenticator/wiki/KeyUriFormat)
@stbuehler
stbuehler / fix_umask.c
Created January 21, 2014 13:38
Workaround sublime text 3 umask bug, always adding 0022 to the mask (deny write to group/others) with LD_PRELOAD hack.
/*
compile with:
gcc -shared -fPIC fix_umask.c -o fix_umask.so
edit /usr/bin/subl to include (fix the path to fix_umask.so if necessary):
#!/bin/sh
export LD_PRELOAD=/opt/sublime_text/fix_umask.so
exec /opt/sublime_text/sublime_text "$@"