Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# This script can be used as wrapper for rsync in authorized_keys. It restricts rsync the following way:
# - restrict target directory to be under /backups/backup-rsync-push/${1}/target/ where $1 is an argument from authorized_keys
# - restrict target directory to be exactly 1 level below this directory
# - restrict flags
# - restrict arguments
# - force --fake-super argument
err() {
@micw
micw / provision_wheezy_base.sh
Last active August 29, 2015 14:08
Script to provision a wheezy base box (e.g. a VPS) with ansible.
#!/bin/bash
#
# USAGE:
# [ -f /usr/bin/curl ] || apt-get -y install curl
# curl -sSL https://gist.githubusercontent.com/micw/987af53361c1d7de1369/raw/ | /bin/bash
set -e
if [ ! -f /etc/apt/sources.list.d/wheezy-backports.list ]; then
echo "Adding wheezy backport repository"
@micw
micw / gist:b323a67a8dc522218bb8
Created December 10, 2014 10:50
Ansible: shinken-setup
- hosts: default
vars:
- NSCA_PASSWORD: topsecret
handlers:
- name: Restart shinken
service: name=shinken state=restarted
tasks:
- apt_repository: repo='deb http://http.debian.net/debian wheezy-backports main contrib' state=present update_cache=yes
- apt: name=python-pip
- apt: name=python-pycurl
@micw
micw / gist:37d55a21a2253d3cce1d
Last active August 29, 2015 14:11
Rsync push backup client (python)
#!/usr/bin/python
import fcntl
import time
import sys
import os
import yaml
import subprocess
basedir=os.path.dirname(os.path.realpath(__file__))
@micw
micw / nagios-json-check-ok
Created February 3, 2015 11:00
nagios-json-check: Response that indicates 'OK' with some metrics
{
status: 'OK'
message: 'everything is fine'
metrics: [
{ name: 'value1', unit: '%', value: 65.7, warn: 70, crit: 90, min: 0, max:100 }
{ name: 'value2', value: 10, min: 5, max:15 }
]
}
@micw
micw / gist:a8b20720db900762a29d
Created September 17, 2015 10:20
WebMvcRequestDispatcherForwardFix
package testutils.mvc;
import static org.mockito.Matchers.anyString;
import javax.servlet.Filter;
import javax.servlet.RequestDispatcher;
import javax.servlet.Servlet;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequestWrapper;
#!/usr/bin/ruby
hash=eval(ARGV[0])
hash.each do |key, value|
puts "["+key+"]"
value.collect do |host|
puts host+" ansible_connection=local"
end
puts
end
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <PacketSerial.h>
boolean initialized;
PacketSerial serial;
WiFiUDP Udp;
import static org.hamcrest.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import org.junit.Test;
public class TestTheAnswerToTheUltimateQuestionOfLifeTheUniverseAndEverything
{
final int LEET = 1337;
final double PI = Math.PI;
/* https://www.youtube.com/watch?v=s8a6txkGqOI */
#include <Servo.h>
Servo servoDreh;
Servo servoHochRunter;
int DREH_UBER_BECHER=170;
int HOCHRUNTER_IN_BECHER=140;
int HOCHRUNTER_UBER_BECHER1=100;