Skip to content

Instantly share code, notes, and snippets.

View lazyfrosch's full-sized avatar
📢
Hack the planet! Hack the planet!

Markus Frosch lazyfrosch

📢
Hack the planet! Hack the planet!
View GitHub Profile
@lazyfrosch
lazyfrosch / net.go
Created December 20, 2022 16:50
golang: Calculating network usable area from
package net
import (
"encoding/binary"
"fmt"
"net"
)
// GetNetworkRange returns begin and end address for hosts in a network.
//
@lazyfrosch
lazyfrosch / test-dict-similar.py
Last active November 7, 2022 17:44
Example class for a strange problem passing **kwargs to a class init function, when other args are passed as keywords too.
"""
Example class for a strange problem passing **kwargs to a class init function, when other args are passed as keywords too.
DictSimilar behaves as a wrapper around dict, to provide an object for dict structures.
Works in CPython 3.10.8
Does NOT work in Pypy:
Python 3.9.12 (05fbe3aa5b0845e6c37239768aa455451aa5faba, Mar 29 2022, 08:15:34)
[PyPy 7.3.9 with GCC 10.2.1 20210130 (Red Hat 10.2.1-11)]
@lazyfrosch
lazyfrosch / flatcar_content.tf
Last active October 18, 2022 16:53
Example of creative loops and local variables, here updating Flatcar Container Linux images in a vSphere Content Library
variable "flatcar_stages" {
type = list(string)
default = [ "stable", "beta", "lts" ]
}
data "http" "flatcar_version_data" {
for_each = toset(var.flatcar_stages)
url = "https://${each.key}.release.flatcar-linux.net/amd64-usr/current/version.txt"
}
@lazyfrosch
lazyfrosch / flatcar_content.tf
Created October 18, 2022 16:52
Example of creative loops and local variables
variable "flatcar_stages" {
type = list(string)
default = [ "stable", "beta", "lts" ]
}
data "http" "flatcar_version_data" {
for_each = toset(var.flatcar_stages)
url = "https://${each.key}.release.flatcar-linux.net/amd64-usr/current/version.txt"
}
@lazyfrosch
lazyfrosch / config.yaml
Last active January 18, 2024 21:08
Fail2Ban configuration for Grafana's Loki promtail
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /data/positions.yaml
clients:
- url: ${LOKI_HOST}/loki/api/v1/push
basic_auth:
@lazyfrosch
lazyfrosch / test-playbook.yml
Last active February 24, 2022 08:43
Debugging Ansible - simple test with parts from https://galaxy.ansible.com/cloudalchemy/node_exporter
- name: Manage node_exporter on servers
hosts: localhost
vars:
node_exporter_version: 1.3.1
go_arch: amd64
node_exporter_local_tmp_directory: "{{ ansible_env.HOME }}/.cache/ansible/node_exporter/{{ node_exporter_version }}"
tasks:
@lazyfrosch
lazyfrosch / docker-compose.yml
Created January 18, 2022 12:48
Grafana with Image Renderer plugin
version: '2'
services:
grafana:
image: grafana/grafana
volumes:
- storage:/var/lib/grafana
ports:
- 3000:3000
environment:
@lazyfrosch
lazyfrosch / docker-compose.yml
Created December 16, 2021 13:52
Icinga Web development example
---
version: '2'
services:
web:
image: lazyfrosch/icingaweb2
#environment:
# XDEBUG_ENABLED: 1
ports:
- 8080:80
@lazyfrosch
lazyfrosch / README.md
Created May 30, 2020 08:28
Unifi Controller in Docker
@lazyfrosch
lazyfrosch / check_logfiles.cfg
Last active April 21, 2020 13:19
check_logfiles for the slightly magical usage, when files are named with the current date, but we can't expect a static filename
## Config
$seekfilesdir = '/var/tmp';
my $logdir = '/var/log/app';
my $search_defaults = {
tag => 'prefix',
criticalpatterns => 'someerror',
options => 'sticky=3600,allyoucaneat',
};