Skip to content

Instantly share code, notes, and snippets.

@beddari
beddari / listdisks.sh
Created January 8, 2015 20:08
listdisks.sh
#!/bin/bash
# Lists Linux block devices and for each one the controller
# it is connected to.
set -o pipefail
for i in /sys/block/sd*; do
# Find the path that contains the PCI ID of the controller.
link=$(readlink $i)
# Assume that the PCI ID of the controller is the path part
# right before the /host... part.
@beddari
beddari / dict_merge.py
Created October 17, 2017 13:29 — forked from angstwad/dict_merge.py
Recursive dictionary merge in Python
import collections
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct
@beddari
beddari / learning.yaml
Last active October 30, 2017 09:14
Ansible THW
---
- name: test
hosts: localhost
connection: local
gather_facts: False
tasks:
# Test each key in a hash for existence, works fine ... I'll accept doing this!
- name: do something based on the existence of nested dict key nested.config.hash.key
debug: msg="{{ nested.config.hash.key }}"
@beddari
beddari / format_list.py
Created December 2, 2017 18:19
Ansible list formatting filter_plugin
def format_list(list_, pattern):
return [pattern % s for s in list_]
class FilterModule(object):
def filters(self):
return {
'format_list': format_list,
}
@beddari
beddari / convert_filenames.py
Created October 17, 2018 06:33
ascii filenames
#!/usr/bin/env python
# convert unicode filenames to pure ascii
import os
import sys
import glob
import unicodedata
EXT = u'*.*'
https://hackmd.io/qbggcyozQr6M1mfy3GcHIA#
{
"key": "ctrl+v tab",
"command": "type",
"args": { "text": "\t" },
"when": "editorTextFocus"
}
@beddari
beddari / nope.yaml
Created September 1, 2020 11:07
Role authors, don't do this in your role
# If you specify a variable for users to set outside your role
# DO NOT overwrite it later.
#
# Due to precedence rules the combined value here will
# never be set in some cases, e.g when using include_role
#
- name: Set netbox_config.SECRET_KEY to generated SECRET_KEY
set_fact:
netbox_config: "{{ netbox_config | combine({'SECRET_KEY': _netbox_secret_key_file['content'] | b64decode}) }}"
@beddari
beddari / hfsc-shape.sh
Created October 7, 2020 11:06 — forked from eqhmcow/hfsc-shape.sh
HFSC - linux traffic shaping's best kept secret
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.
@beddari
beddari / GNUPG_agent_forwarding.md
Created September 27, 2021 11:22 — forked from TimJDFletcher/GNUPG_agent_forwarding.md
GnuPG agent forwarding

Forward GnuPG agent from macOS to Linux

On the remote machine

Run gpg once as your to create the directory structure

gpg --list-keys

For headless systemd based hosts