Skip to content

Instantly share code, notes, and snippets.

Alfred Krohmer devkid

Block or report user

Report or block devkid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@devkid
devkid / vpn-domains.sh
Last active Oct 13, 2017
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)
View vpn-domains.sh
#!/bin/bash
set -ex
# ----------------------------------------------------------------------------
# Configuration:
case "$CONNECTION_ID"
in
"Some VPN name") # enter name of VPN connection in NetworkManager here
@devkid
devkid / gpio-send.c
Created Aug 6, 2017
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)
View gpio-send.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char **argv) {
if(argc < 4 || argc % 2) {
printf(
"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]);
@devkid
devkid / README.md
Created Mar 19, 2017
Proposal: Deduplicated storage and transfer of container images
View README.md

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:

@devkid
devkid / list-user-installed-packages.sh
Created Feb 11, 2017
List all user-installed packages on OpenWrt / LEDE
View list-user-installed-packages.sh
#!/bin/sh
FLASH_TIME=$(opkg info busybox | grep '^Installed-Time: ')
for i in $(opkg list-installed | cut -d' ' -f1)
do
if [ "$(opkg info $i | grep '^Installed-Time: ')" != "$FLASH_TIME" ]
then
echo $i
fi
@devkid
devkid / xbox-one-wireless-protocol.md
Created Nov 23, 2016
XBox One Wireless Controller Protocol
View xbox-one-wireless-protocol.md

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
@devkid
devkid / dmesg
Created Nov 16, 2016
dmesg output for mt7612u driver
View dmesg
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
@devkid
devkid / server.rb
Created Aug 23, 2016
Web Terminal for Docker container with Sinatra and Websockets
View server.rb
require 'sinatra'
require 'sinatra-websocket'
require 'docker-api'
require 'pty'
set :server, 'thin'
def new_state
{
lock: Mutex.new,
@devkid
devkid / ecs.sh
Last active Mar 10, 2019
Wrapper script for an etcd cluster on AWS ECS
View ecs.sh
#!/bin/sh
# 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 http://169.254.169.254/latest/meta-data/local-ipv4)
@devkid
devkid / synchronize_with_unique_argument.rb
Created Jul 19, 2016
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.
View synchronize_with_unique_argument.rb
# 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: Mutex.new, count: 0 })
info[:count] += 1
info
end
# do the actual locking
View ubuntu-systemd-nspawn-boot
–> 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
You can’t perform that action at this time.