Skip to content

Instantly share code, notes, and snippets.

alfredkrohmer /
Last active October 13, 2017 21:53
NetworkManager dispatcher script to add certain domains for a VPN device when using systemd-resolved (place in /etc/NetworkManager/dispatcher.d, make it executable and adapt VPN domains and connection name)
set -ex
# ----------------------------------------------------------------------------
# Configuration:
"Some VPN name") # enter name of VPN connection in NetworkManager here
alfredkrohmer / gpio-send.c
Created August 6, 2017 15:50
Send an arbitrary series of 0's and 1's to a GPIO with given intervals between the level change (e.g. for sending a code over a 433 MHz sender)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char **argv) {
if(argc < 4 || argc % 2) {
"Usage: %s <path to GPIO value file> <interval 1> <interval 2> ... <interval n>\n\n"
"Provide the path to the 'value' file of the GPIO in sysfs and an even number of intervals\n", argv[0]);
alfredkrohmer /
Created March 19, 2017 22:25
Proposal: Deduplicated storage and transfer of container images

Proposal: Deduplicated storage and transfer of container images

Docker uses layers to build containers and images on top of other images. This saves storage and transfer of layers already existing on the system. Rkt uses no layers and needs to fully download any new image.

This document proposes to use deduplication to store and transfer container images. This has multiple advantages over layering:

alfredkrohmer /
Created February 11, 2017 13:39
List all user-installed packages on OpenWrt / LEDE
FLASH_TIME=$(opkg info busybox | grep '^Installed-Time: ')
for i in $(opkg list-installed | cut -d' ' -f1)
if [ "$(opkg info $i | grep '^Installed-Time: ')" != "$FLASH_TIME" ]
echo $i
alfredkrohmer /
Created November 23, 2016 21:52
XBox One Wireless Controller Protocol

Physical layer

The dongle itself is sending out data using 802.11a (5 GHz WiFi) with OFDM and 6 Mbit/s data rate:

Radiotap Header v0, Length 38
    Header revision: 0
    Header pad: 0
    Header length: 38
    Present flags
alfredkrohmer / dmesg
Created November 16, 2016 17:41
dmesg output for mt7612u driver
Nov 16 17:56:39 desktop kernel: rtusb init mt7610u --->
Nov 16 17:56:39 desktop kernel:
=== pAd = ffffc90003e34000, size = 1371608 ===
Nov 16 17:56:39 desktop kernel: <-- RTMPAllocTxRxRingMemory, Status=0
Nov 16 17:56:39 desktop kernel: <-- RTMPAllocAdapterBlock, Status=0
Nov 16 17:56:39 desktop kernel: ==>rlt_wlan_chip_onoff(): OnOff:1, Reset= 1, pAd->WlanFunCtrl:0x0, Reg-WlanFunCtrl=0x20a
Nov 16 17:56:40 desktop kernel: RtmpChipOpsEepromHook::e2p_type=0, inf_Type=2
Nov 16 17:56:40 desktop kernel: RtmpEepromGetDefault::e2p_dafault=1
Nov 16 17:56:40 desktop kernel: NVM is EFUSE mode
alfredkrohmer / server.rb
Created August 23, 2016 19:07
Web Terminal for Docker container with Sinatra and Websockets
require 'sinatra'
require 'sinatra-websocket'
require 'docker-api'
require 'pty'
set :server, 'thin'
def new_state
alfredkrohmer /
Last active December 11, 2022 10:40
Wrapper script for an etcd cluster on AWS ECS
# This script decides if we are part of the process of bootstrapping a new etcd cluster
# or if we are joining an already existing cluster.
set -eux -o pipefail
# own IP address
own_ip=$(curl -f -s
alfredkrohmer / synchronize_with_unique_argument.rb
Created July 19, 2016 20:09
Runs the given block synchronized with the argument given; i.e. for the same argument the block is never run in multiple threads simultaneously, while for different arguments the block can run in parallel in multiple threads.
# synchronizes the given block, but only when called with the same argument
def synchronize_with_unique(arg, mutex, map, &block)
# get the lock for the supplied argument while increasing the refcount
lock_info = mutex.synchronize do
info = (map[arg] ||= { lock:, count: 0 })
info[:count] += 1
# do the actual locking
–> systemd-nspawn -bD ubuntu1404_test
Spawning container ubuntu1404_test on /frzclient/images/ubuntu1404_test.
Press ^] three times within 1s to kill container.
init: Unable to create device: /dev/kmsg
* Stopping Send an event to indicate plymouth is up [ OK ]
* Starting Clean /tmp directory [ OK ]
* Stopping Clean /tmp directory [ OK ]
* Stopping Populate /dev filesystem [ OK ]
* Starting Signal sysvinit that virtual filesystems are mounted