Skip to content

Instantly share code, notes, and snippets.

Avatar

Daniel Nägele debugloop

View GitHub Profile
View prefix_trie_example.py
#!/usr/bin/env python
import ipaddress
class TrieNode:
def __init__(self, version=6, root=False):
self.lnode = None
self.rnode = None
self.content = None
self.__root = root
self.version = version
@debugloop
debugloop / gist:d77d35cd5f53f2d462c546586715b7e6
Created Sep 30, 2019
promql query to compare to global avg
View gist:d77d35cd5f53f2d462c546586715b7e6
# take the sum of the rate, leave stuff in irrelevant labels alone
# maybe use delta instead of rate to make it sign-aware
sum without (stuff) (rate($metric[1d]))
>
# ignore the instance on this side of the compare, would be even better without the instance of interest
ignoring (instance, stuff) group_left()
(
avg without(instance, stuff)(rate($metric[1w]))
+
# just give that some more breathing room
View subnet_volume.py
#!/usr/bin/env python3
import ipaddress
import datetime
from confluent_kafka import Consumer
from ssl import get_default_verify_paths
# The following needs to be available in PYTHONPATH
# https://github.com/bwNetFlow/protobuf
import flow_messages_enriched_pb2 as api
@debugloop
debugloop / tmux-window-names.zsh
Last active Aug 29, 2015
Naming tmux windows for the hosts you ssh to
View tmux-window-names.zsh
# The following snippet goes into your .zshrc
# You probably want to set all occurrences of 'local' to your preferred default name.
# This also works well when replacing ssh with mosh or something similar.
# To set the default window name in your .tmux.conf, use this line
# set-option -g default-command "tmux rename-window local; zsh"
ssh() {
if [[ $(tmux display-message -p '#W') = "local" ]]; then
trap "tmux rename-window 'local'" INT PIPE EXIT # clean up after ctrl-c, broken pipes and other exits
@debugloop
debugloop / bootable-thumbdrive.md
Last active Aug 29, 2015
Howto make a USB Key bootable, with multiple images and with no fancy tools
View bootable-thumbdrive.md
  1. Format the stick with FAT32, mount and go to the mountpoint (./ refers to your mountpoint)
  2. Create your grub.cfg (example below) in ./boot/grub/grub.cfg
  3. sudo grub-install --no-floppy --boot-directory=./boot /dev/sdx (use the right device, duh)
  4. Test it with sudo qemu-system-x86_64 -m 512 /dev/sdx

This will show you your menu, but obviously nothing will boot. Create ./iso (or whatever you called it in your grub.cfg) and dump some images into it. The exact versions will not matter (get the paths right), but the distribution most probably will. The grub.cfg below includes the kernel lines GRUB needs to boot Debian, Ubuntu or Archlinux Installers as well as the GRML Live System from http://grml.org/. These are the ones I need, if you want some more/others try the comments below this gist or have fun picking together working GRUB kernel line magic :)

PS: Beware a long-standing bug in the Debian-Installer which causes the bootloader to be written to /dev/sda, which i

You can’t perform that action at this time.