Skip to content

Instantly share code, notes, and snippets.

View noniq's full-sized avatar

Stefan Daschek noniq

View GitHub Profile
@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"
#!/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 / 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"
@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'
Return-Path: <Euroms130@outlook.jp>
Delivered-To: <XXXXXXXXXXXXXXX>
Received: from mail.die-antwort.eu
by die-antwort.eu (Dovecot) with LMTP id 0G9bCjrWeVSBLwAAot0D+g
for <XXXXXXXXXXXXXXX>; Sat, 29 Nov 2014 15:20:42 +0100
X-Envelope-To: <XXXXXXXXXXXXXXX>
Received: from mogw0133.ocn.ad.jp (mogw0133.ocn.ad.jp [118.23.109.107])
by mail.die-antwort.eu (Postfix) with ESMTP id 6F60219F96B9
for <XXXXXXXXXXXXXXX>; Sat, 29 Nov 2014 15:20:40 +0100 (CET)
Received: from mv-osn-hkg002.ocn.ad.jp (mv-osn-hkg002.ocn.ad.jp [122.28.30.180])
@noniq
noniq / gist:06599767a2e6e99409cb
Created August 21, 2014 11:54
Oh Austria, you really love your titles, don’t you?
TITLE_GENDER_SUFFIX_REGEXP = %r{
(?<= Mag\. ) (a) |
(?<= ADir\. | Dipl\.-Ing\. | Dipl\.-Päd\. | Dr\. | FInsp\. | FOInsp\. | Ing\. | OKontr\. ) (in) |
(?<= AL | AR | HR | IR | MinR | OR | OStR | RL | RgR | SektChef) (in)
}x
GEM
remote: https://rubygems.org/
specs:
actionmailer (4.1.1)
actionpack (= 4.1.1)
actionview (= 4.1.1)
mail (~> 2.5.4)
actionpack (4.1.1)
actionview (= 4.1.1)
activesupport (= 4.1.1)
@noniq
noniq / gist:9289157
Last active August 29, 2015 13:56
RSpec + Capybara: Include link to saved HTML and screenshot for failed examples.
# Add this to your spec_helper.rb (needs Ruby 2 because of `Module#prepend`)
#
# It does two things:
#
# 1. For each failed feature spec, save the HTML page and (if possible) a screenshot
# to "#{Rails.root}/tmp/capybara/".
#
# 2. Extend RSpec’s HTML output to include links to the saved HTML page and screenshot
# for failed examples. Works with both the regular HTML formatter and the TextMate
# formatter.
@noniq
noniq / gist:9282811
Created March 1, 2014 00:32
Fun with dates.
gem "rails", "~> 3.2" # It’s fixed in Rails 4, btw :)
gem "timecop", "~> 0.7"
require "action_view"
require "active_support/core_ext"
require "timecop"
extend ActionView::Helpers::DateHelper
Time.zone = "CET"
Timecop.travel("2014-03-01 00:30 CET")
@noniq
noniq / human_nr.html
Last active December 21, 2015 16:28
Convert numbers from 1 to 999999 into german strings. Script should prompt for a number and show result using an JavaScript-alert. Must run in Chrome out of the box, just by loading the HTML file.
<pre>
<script>
function human_nr(n){
// Make `prompt` and `alert` no-ops when run in test mode
prompt = function() { return n };
alert = function() {};
// To extract the bare, minimized, executable script:
// * Copy the lines between the markers into a new file