Skip to content

Instantly share code, notes, and snippets.

@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 "$@"
@stbuehler
stbuehler / registry-ciphers.xslt
Created October 26, 2013 09:50
Generate javascript tables for gnutls and official TLS ciphersuites
<?xml version="1.0" encoding="UTF-8"?>
<!-- saxonb-xslt http://www.iana.org/assignments/tls-parameters/tls-parameters.xml registry-ciphers.xslt > registry-ciphers.js -->
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:iana="http://www.iana.org/assignments"
>
<xsl:output method="text" omit-xml-declaration="yes" encoding="UTF-8"/>
<xsl:variable name='nl'><xsl:text>&#xa;</xsl:text></xsl:variable>
@stbuehler
stbuehler / hackage-upload-docs.sh
Last active October 6, 2017 22:48
Generate and upload docs for hackage packages
#!/bin/bash
# Options / Usage
# put this script in the same directory as your *.cabal file
# it will use the first line of "cabal info ." to determine the package name
# custom options for "cabal haddock" (cabal haddock --help,
# http://www.haskell.org/haddock/doc/html/invoking.html)
CUSTOM_OPTIONS=(--haddock-options='-q aliased')
# hackage server to upload to (and to search uploaded versions for)