Skip to content

Instantly share code, notes, and snippets.

View eqvinox's full-sized avatar

David Lamparter eqvinox

View GitHub Profile
@eqvinox
eqvinox / no_madv_guard.c
Created February 13, 2026 19:51
LD_PRELOAD snippet to deny MADV_GUARD_INSTALL (rr does not support it yet)
// SPDX-License-Identifier: Unlicense
/* compile_command: gcc -Wall -Wextra -shared -O2 -ggdb3 -o no_madv_guard.so no_madv_guard.c */
/* deny madvise(MADV_GUARD_INSTALL) - rr (rr-project.org) does not support it yet */
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
#include <linux/audit.h>
#include <linux/bpf.h>
#include <linux/filter.h>
#include <linux/seccomp.h>
@eqvinox
eqvinox / tar-multivolume-bug-repro.sh
Created January 21, 2026 11:51
reproducer script for GNU tar generating invalid tar files in multi-volume mode
#!/bin/sh
set -x
TAR="${1:-tar}" # allow pointing at a different tar version for convenience
cat > info.sh <<EOF
#!/bin/sh
printf '%s.%d\n' "\$TAR_ARCHIVE" "\$TAR_VOLUME" >&\$TAR_FD
EOF
chmod +x info.sh
@eqvinox
eqvinox / termsize.py
Created December 23, 2025 18:21
set terminal size via CSI query
#!/usr/bin/python3
import sys
import os
import tty
import termios
import re
import struct
import fcntl
stdin = sys.stdin.fileno()
@eqvinox
eqvinox / juniper_data_list_strip.py
Last active December 23, 2025 18:19
Flatten [{"data": foo}] to foo
import json
def flatten_data(pairs):
for i, (k, v) in enumerate(pairs):
if not isinstance(v, list) or len(v) != 1 or not isinstance(v[0], dict):
continue
kk, vv = next(iter(v[0].items()))
if kk == "data":
pairs[i] = (k, vv)
# SPDX-License-Identifier: Unlicense
# netbox add-on to set up superuser/staff state & groups from keycloak
#
# necessary setup in keycloak:
# Clients -(netbox client)-> Roles-> create superuser; assign users/groups/... to that role
# Clients -(netbox client)-> Roles-> create staff; assign users/groups/... to that role
# Clients -(netbox client)-> Client scopes -(the "dedicated" one)-> Add Mapper, ->
# by configuration, Group Membership, Token Claim Name = "groups", full group path = off
# (for the last one, alternatively, groups can be mapped through roles, if the indirection is nedeed)
#

FRRouting telemetry considerations

Warning

This document is a work in progress.

Scope and goals

@eqvinox
eqvinox / zammad-greasemonkey-fold-open.js
Last active March 29, 2024 07:26
Greasemonkey script to fold open zammad ticket items by default
// ==UserScript==
// @name Zammad ticket items expand-by-default
// @match https://requests.cccv.de/*
// @version 1
// @grant none
// ==/UserScript==
let seen_before = new Set();
function direct_text(parent) {
/* compile: gcc -o creds creds.c -lcap */
#define _GNU_SOURCE 1
#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@eqvinox
eqvinox / h3c_comware_ssh_pubkeys.sh
Created August 30, 2022 17:38
Convert OpenSSH public key to H3C/HPE/3Com Comware config format
#!/bin/sh
KEYNAME="$1"
PUBKEYFILE="$2"
echo "public-key peer $KEYNAME"
echo "public-key-code begin"
< $PUBKEYFILE ssh-keygen -e -f /dev/stdin -m PKCS8 | openssl pkey -pubin -outform DER | hexdump -e '37/1 "%02X" "\n"'
echo "public-key-code end"
@eqvinox
eqvinox / shellescaping.sh
Created July 9, 2022 15:27
POSIX shell escaping demo-sheet
#!/bin/sh
# shell escaping "demo-sheet"
# "args" just prints argv[]
filename="/tmp/some file"
echo 'foo echo some file contents' > "$filename"
set -x
args $(echo foo echo wrong)