Skip to content

Instantly share code, notes, and snippets.

View bodsch's full-sized avatar

Bodo Schulz bodsch

View GitHub Profile
# Benchmarking for http://stackoverflow.com/questions/9538090
require 'benchmark'
require 'active_support/core_ext'
events = [{id:2, start:"3:30",break:30,num_attendees:14},{id:3, start:"3:40",break: 40,num_attendees:4},{id:4, start:"4:40",break:10,num_attendees:40}]
time = Benchmark.bm(10) do |bm|
bm.report("amarshall 1") do
10000.times do
@dnsmichi
dnsmichi / icinga2-apply-for-in-dictionary
Last active June 25, 2019 21:24
Using icinga2 2.2 features with apply for in dictionary and attribute assignment
# cat 7560.conf
object Host "7560-server" {
import "test-generic-host"
address = "127.0.0.1"
check_command = "hostalive"
vars.interfaces["eth0"] = {
//vars.interfaces.eth0 = {
"2dcoord" = "3,5"
port = 1
@jonatanblue
jonatanblue / docker_py_to_docker.md
Last active July 18, 2019 12:15
Resolve docker-py older version naming conflict

Problem

When running docker-compose I get this error:

docker-compose --version
> ERROR: Dependency conflict: an older version of the 'docker-py' package is polluting the namespace. Run the following command to remedy the issue:
> pip uninstall docker docker-py; pip install docker
@jjmaestro
jjmaestro / whisper-calculator.py
Last active November 26, 2019 07:13
whisper-calculator.py: Calculates the size of the whisper storage for the given retention (in frequency:history format)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def archive_to_bytes(archive):
def to_seconds(s):
SECONDS_IN_A = {
's': 1,
'm': 1 * 60,
'h': 1 * 60 * 60,
@brandonrich
brandonrich / gist:67c0ae24b5abfef65134
Created July 5, 2015 02:22
Ruby AWS SDK v2 IAM user MFA example
# shows how to use the Ruby AWS SDK to list EC2 instance IDs
# when your API credentials have been placed under MFA requirements
# Prerequisites:
# you are running on a host that already has the AWS CLI set up with an IAM key pair
# that can describe EC2 instances (OTHERWISE, just pass a
# secret_access_id / secret_access_key pair to the STS client initializer)
# You have installed the Ruby AWS SDK Gem
# http://aws.amazon.com/sdk-for-ruby/
- name: schedule downtime
uri:
url: "https://{{ icinga_host }}:{{ icinga_port | default(5665) }}/v1/actions/schedule-downtime"
user: "{{ icinga_user }}"
password: "{{ icinga_password }}"
force_basic_auth: True
validate_certs: False
method: POST
headers:
Accept: "application/json"
@jmervine
jmervine / nginx.conf
Last active March 19, 2020 06:17
Nginx config to test regex.
# Usage:
#
# Start with:
#
# sudo /use/local/sbin/nginx -c /path/to/this/nginx.conf
#
# Tail logs:
#
# $ sudo tail -f /tmp/access.log /tmp/error.log /tmp/match.log
#
@JonTheNiceGuy
JonTheNiceGuy / AAA_Cachet_on_Docker_with_Ansible.md
Last active August 10, 2020 11:04
A "simple" shared-hosting Ansible setup for Cachet

Cachet on Docker with Ansible

This is not a "best-practice" example of doing any of these tasks. The nginx stuff could probably do with being moved into roles, and I could probably move the variables into a file handling that... however, as a POC, it works.

@SaroLiao
SaroLiao / fontconfig.properties
Created September 14, 2014 00:10
JAVA fontconfig.properties
# %W% %E%
#
# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
#
# Version
version=1
# Component Font Mappings
@jhrcz
jhrcz / tmux-ansible.sh
Last active September 22, 2020 08:08
combining tmux, tmux-cssh and ansible - cluster ssh alternative with ansible inventory, uses https://github.com/dennishafemann/tmux-cssh
#!/bin/bash
login=root
grp="$1"
shift
tmux-cssh -u $login -sc `ansible ${grp:-all} -i ${CSSH_ANSIBLE_INVENTORY:-hosts.ini} --list-hosts` "$@"