Skip to content

Instantly share code, notes, and snippets.

View bodsch's full-sized avatar

Bodo Schulz bodsch

View GitHub Profile
@soxofaan
soxofaan / sdiff.py
Last active June 22, 2023 03:52
Python implementation of side-by-side diff
# Code licensed MIT 2023 Stefaan Lippens
import difflib
import itertools
from typing import List, Tuple, Iterator
class Sdiffer:
def __init__(self, max_width:int = 80):
# Two columns with a gutter
@jpmens
jpmens / arpaname.py
Created December 1, 2022 15:10
Ansible filter convert IP to arpaname
# arpaname.py, (C)2022 by Jan-Piet Mens <jp@mens.de>
# Convert an IPv4 or IPv6 address in textual form into a string whose value is
# the reverse-map domain name of the address.
#
# - debug: msg="{{ "192.168.1.3" | arpaname }}"
# "3.1.168.192.in-addr.arpa."
#
# - debug: msg="{{ "2001:DB8::7" | arpaname }}"
# "7.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa."
@jlumbroso
jlumbroso / diff_side_by_side.py
Created May 8, 2022 02:18
Side-by-Side Diff Comparison in Python
# Code licensed LGPLv3 by Jérémie Lumbroso <lumbroso@cs.princeton.edu>
import difflib
import itertools
import textwrap
import typing
def side_by_side(
left: typing.List[str],
@waja
waja / check_smart.conf
Last active February 21, 2022 04:42
example check_smart configuration for a icinga2
object CheckCommand "check-smart" {
import "plugin-check-command"
command = [ "/usr/lib/monitoring-plugins" + "/check_smart" ]
arguments = {
"--device" = {
value = "$smart_device$"
set_if = {{ macro("$smart_device_is_glob$") == false }}
description = "A physical block device to be SMART monitored, eg /dev/sda. Pseudo-device /dev/bus/N is allowed."
- 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"
@ruanbekker
ruanbekker / dnsmasq.conf
Last active March 20, 2024 18:38
Tinkering with Loki, Promtail, Grafana, Prometheus, Nginx and Dnsmasq
log-queries
log-facility=/var/log/dnsmasq.log
no-resolv
server=8.8.4.4
server=8.8.8.8
address=/router/10.1.1.1
address=/server/10.1.1.2
@abeluck
abeluck / playbook.yml
Last active September 21, 2023 13:11
Ansible tasks to create and delete alertmanager silences
# creates a silence in alertmanager that starts `now` and lasts for 10 minutes
- hosts: localhost
gather_facts: yes
tasks:
- set_fact:
start_datetime: "{{ ''| local_time_iso8601 }}"
future_datetime: "{{ ''|local_time_iso8601 | add_time_iso8601(minutes=10) }}"
- debug:
var: future_datetime
@jzelinskie
jzelinskie / config
Last active January 18, 2024 19:23
generate a knot-resolver (kresd) blacklist.rpz from pihole sources
-- Refer to manual: https://knot-resolver.readthedocs.io/en/latest/daemon.html#configuration
-- Listen on all interfaces (localhost would not work in Docker)
net.listen('0.0.0.0')
net.listen('0.0.0.0', 853, {tls=true})
-- Auto-maintain root TA
trust_anchors.file = '/data/root.keys'
-- Load Useful modules
@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.

@visualskyrim
visualskyrim / modify_ulimit.yml
Last active August 18, 2022 09:27
A ansible playbook to modify ulimit
- hosts: all
become: true
tasks:
- name: configure system settings, file descriptors and number of threads
pam_limits:
domain: <--your-username-->
limit_type: "{{item.limit_type}}"
limit_item: "{{item.limit_item}}"
value: "{{item.value}}"
with_items: