Skip to content

Instantly share code, notes, and snippets.

View noniq's full-sized avatar

Stefan Daschek noniq

View GitHub Profile
@noniq
noniq / gist:1bba7ddeb84a2cbf0abe
Created January 14, 2015 16:02
snmpd configuration fix (Ubuntu 12.04)
diff --git a/default/snmpd b/default/snmpd
index 14f2b86..4ad43a6 100644
--- a/default/snmpd
+++ b/default/snmpd
@@ -8,7 +8,7 @@ export MIBS=
SNMPDRUN=yes
# snmpd options (use syslog, close stdin/out/err).
-SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid'
+SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'
@noniq
noniq / gist:4e9f3eb6076bef63451d
Created February 16, 2015 10:36
Ubuntu init script for botasciistats
#! /bin/sh
### BEGIN INIT INFO
# Provides: botasciistats
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
# Do NOT "set -e"
#!/usr/bin/env ruby
require "rubygems"
require "active_support"
require "highline/import"
require "mechanize"
# Wartezeit in Sekunden zwischen wiederholten Aufrufen der Formularseite, wenn sie gerade nicht verfügbar ist
FORM_RETRY_TIMEOUT = 30
@noniq
noniq / botascii.cfg
Last active August 29, 2015 14:16
Monit config for BotAsciiStats: /etc/monit/conf.d/botasciistats.cfg
check process botasciistats with pidfile /var/run/botasciistats.pid
start program = "/usr/bin/env PATH=/home/noniq/.rbenv/shims:/sbin:/usr/sbin:/bin:/usr/bin start-stop-daemon --start --pidfile /var/run/botasciistats.pid --chuid noniq --background --make-pidfile --startas /home/noniq/botasciistats/bin/run"
stop program = "/sbin/start-stop-daemon --stop --pidfile /var/run/botasciistats.pid"
GEM
remote: https://rubygems.org/
specs:
activesupport (4.1.9)
i18n (~> 0.6, >= 0.6.9)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 1.1)
celluloid (0.16.0)
@noniq
noniq / gist:13e5587f8f45bb49f677
Created March 29, 2015 17:10
HTT and HTH spin-off
var trials = 10000; // Number of times to try the process
var heads = 1;
var tails = 0;
var hth_first = 0;
var htt_first = 0;
var success_hth = 0;
var success_htt = 0;
@noniq
noniq / Sample output
Last active September 20, 2015 23:32
STAY, 4989 relevant rounds (= 49.9%)
2531 successes (= 50.7%)
CHANGE, 4989 relevant rounds (= 49.9%)
2493 successes (= 50.0%)
@noniq
noniq / cleanup-old-containers.sh
Last active January 15, 2016 11:54
A shell script to remove all exited docker containers that are older than a certain threshold. Customize the filter expression to restrict this to a certain group of containers. Should work on Linux and Mac OS.
#!/bin/bash
FILTER="--filter label=myapp"
THRESHOLD=$((7 * 24 * 60 * 60))
NOW=$(date +%s)
USE_BSD_DATE=$(date -j >/dev/null 2>&1 && echo 1)
function date_to_timestamp {
if [[ $USE_BSD_DATE ]]; then
@noniq
noniq / erb_zip_file_generator.rb
Last active June 9, 2016 15:04
Zip file generator in ruby, suitable for templating OOXML documents (DOCX, XLSX, …)
# This is a simple example which uses rubyzip to recursively generate a zip file from the contents of a specified directory. The
# directory itself is not included in the archive, rather just its contents.
#
# The generator has been extended to support ERB templates: Files with an extension ending in `.erb` will be processed by ERB
# before they are added to the archive (the filename in the archive will have `.erb` stripped).
#
# Suitable for templating OOXML documents (eg. DOCX or AXSLX): Just create the template document in the office application of your
# choice, rename the extension to ".zip" and unzip the file. Now add ERB code to individual files as needed (for DOCX you’ll most
# likely want to edit `word/document.xml`). Don't forget to also add an additonial `.erb` extension to those files! Then run
# ErbZipGenerator on the top level directory and with a suitable output filename – done!

Keybase proof

I hereby claim:

  • I am noniq on github.
  • I am noniq (https://keybase.io/noniq) on keybase.
  • I have a public key ASBaNOMZ1twHzYDHXdFvNQCqBA0TDcZQlk6NMSptpLxN3wo

To claim this, I am signing this object: