Skip to content

Instantly share code, notes, and snippets.

@k9ert
k9ert / 700-stable.pp
Created September 15, 2012 18:58
Defining reasonable apt-archives
# stable.pp
class 700-stable {
include apt
# deb http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
# deb-src http://debian.mirror.iweb.ca/debian/ testing main contrib non-free
# Key: 55BE302B Server: subkeys.pgp.net
# debian-keyring
# debian-archive-keyring
Package: *
Pin: release a=stable
Pin-Priority: 700
Package: *
Pin: release a=testing
Pin-Priority: 100
Package: *
Pin: release a=unstable
@k9ert
k9ert / gist:3964597
Created October 27, 2012 13:19
Backup Git based on a script by Alter White
#!/usr/bin/env ruby
#credits: Walter White, Updates: Addy Osmani
# dependencies
require "json"
require "open-uri"
# your github username
username = "k9ert"
@k9ert
k9ert / sample-output
Created October 29, 2012 22:32
a ruby-script working as a check_mk-plugin to monitor zookeeper, place it in /usr/lib/check_mk_agent/local
$ ./zkmon.rb
0 zk_version - OK 3.4.3-1240972, built on 02/06/2012 10:48 GMT
0 zk_avg_latency count=5 OK 5
0 zk_max_latency count=265 OK 265
0 zk_min_latency count=0 OK 0
0 zk_packets_received count=2158687 OK 2158687
0 zk_packets_sent count=2319327 OK 2319327
0 zk_outstanding_requests count=0 OK 0
0 zk_server_state - OK standalone
0 zk_znode_count count=10078 OK 10078
@k9ert
k9ert / recentVersions.js
Created December 31, 2012 13:46
A very hackish and basic frontend. Can be used to embed version-information gathered by report_mongo.sh https://github.com/example42/puppi/blob/master/files/scripts/report_mongo.sh into a wiki with the help of iframes, for confluence e.g. (per environment) {iframe:width=950|height=95|scroling=false|marginheight=1|frameborder=0|src=http://check.s…
getVersions = function(query) {
var map = function() {
emit( this.value.project, {project:this.value.project, fqdn:this.value.fqdn, ts:this.value.ts,version:this.value.version,environment:this.value.environment} );
};
var reduce = function(k,vals) {
version = vals[0].version;
vals.forEach(function(val) { if (val.version != version) return "inconsistent" } ) ;
return version;
};
return db.versions.mapReduce(
@k9ert
k9ert / tpd.rb
Created May 23, 2013 17:47
Tweets per day in ruby
#!/usr/bin/env ruby
# This snippet can be used to feed a megabitmeter
# with the number of tweets on a feed
# see also http://megabitmeter.de/
# Twitter-API: https://dev.twitter.com/apps
require 'rubygems'
require 'twitter'
@k9ert
k9ert / gist:6389470
Created August 30, 2013 12:46
maven one-liner to download an artifact from a maven-repo to the current working-directory
org.apache.maven.plugins:maven-dependency-plugin:2.8:copy -Dartifact=de.company.rest.of.groupid:the-artifactid:1.2.4.0:zip: -DrepoUrl=https://repository.company.com/therepo -DoutputDirectory=.
@k9ert
k9ert / gist:7689464
Last active December 29, 2015 15:19
you don't want to grep but grab which basically gives you all the lines below your pattern Can e.g. be used like this: cat catalina.out | grab 4:02:14.989 | tail -100
#!/usr/bin/perl
my @grabbed;
while (<STDIN>) {
if (/$ARGV[0]/) {
print $_;
while (<STDIN>) {
last if /^$/;
print $_;
}
}
@k9ert
k9ert / gist:3e6d64f620b0254d4ad7
Created June 24, 2014 22:11
example for a Pre-send Script in the JENKINS/Email-ext+plugin
// https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin
// An example for a Pre-send Script
// Assume output log-output like:
// ERROR: yourmail@company.com please fix
import javax.mail.internet.*
logger.print("This ends up in the log as well");
String encodingOptions = "text/html; charset=UTF-8;";
// msg.setContent("please check!!!!", encodingOptions);
@k9ert
k9ert / gist:567a3f0471ab914b21c7
Created June 26, 2014 16:00
some shell-effort to be able to run vagrant up/destroy on a jenkins, improvable!!
#!/bin/bash
vagrant destroy -f
timeout 3600 vagrant up
VAGRANT_RESULT=$?
echo "==============================================================="
if [ $VAGRANT_RESULT -eq 124 ]; then
echo "vagrant up timed out: 3600 seconds"
else
echo "Vagrant exited with code: $VAGRANT_RESULT"