Skip to content

Instantly share code, notes, and snippets.

View bluecmd's full-sized avatar

Christian Svensson bluecmd

  • Stockholm, Sweden
View GitHub Profile
@bluecmd
bluecmd / tuneable.c
Last active February 9, 2024 13:13
Simple utility to test tuneable SFP modules implementing SFF-8690
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
int main(int argc, char *argv[]) {
int fd = open(argv[1], O_RDWR);
if (fd < 0) {
perror("open");
@bluecmd
bluecmd / dmesg
Last active November 17, 2023 10:11
ALFA AWUS036ACU USB AC1200 Wireless Dongle data
[ 2625.068487] usb 3-1: new high-speed USB device number 5 using xhci_hcd
[ 2625.198966] usb 3-1: New USB device found, idVendor=0bda, idProduct=b812, bcdDevice= 2.10
[ 2625.198971] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 2625.198972] usb 3-1: Product: 802.11ac NIC
[ 2625.198974] usb 3-1: Manufacturer: Realtek
[ 2625.198975] usb 3-1: SerialNumber: 123456
[ 2625.306462] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[ 2625.308354] Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[ 2625.383895] rtw_8822bu 3-1:1.0: Firmware version 27.2.0, H2C version 13
[ 2626.076899] usbcore: registered new interface driver rtw_8822bu
@bluecmd
bluecmd / usr.share.audiobookshelf.audiobookshelf
Created August 25, 2023 17:06
AppArmor profile for audiobookshelf
$ cat /etc/apparmor.d/usr.share.audiobookshelf.audiobookshelf
#include <tunables/global>
# vim:syntax=apparmor
/usr/share/audiobookshelf/audiobookshelf {
#include <abstractions/base>
#include <abstractions/nameservice>
#include <abstractions/openssl>
#include <abstractions/user-tmp>
@bluecmd
bluecmd / test.dts
Created June 18, 2023 16:15
simple-mfd issue
cpld: cpld@6,0 {
compatible = "n821,cpld", "syscon", "simple-mfd";
reg = <0x06 0x00 0x50>;
#address-cells = <1>;
#size-cells = <1>;
cpldi2c: n821-cpld-i2c@30 {
compatible = "n821,cpld-i2c";
reg = <0x30 0x8>;
};
@bluecmd
bluecmd / gp700.py
Last active June 5, 2023 10:03
Dicon GP700 GPIB Scanning script for I-matrix
#!/usr/bin/env python3
import pyvisa
import subprocess
import re
import time
def optical_data(iface):
# no json support in ethtool for eeprom dump yet :(
for _ in range(10):
@bluecmd
bluecmd / exporter.py
Last active May 22, 2023 17:13
Example exporter for Smartoptics T-4900 / PacketLight PL1000
from prometheus_client import start_http_server
from prometheus_client.core import GaugeMetricFamily, CounterMetricFamily, REGISTRY
import math
import re
import requests
from urllib.parse import urlparse
class XpdrCollector(object):
@bluecmd
bluecmd / run.sh
Created December 9, 2022 13:49
One-liner dnsmasq DHCP server
sudo dnsmasq --port 0 --no-daemon --dhcp-range=192.168.1.100,192.168.1.200 --dhcp-leasefile=/dev/null -z --conf-file=/dev/null --interface enp36s0
@bluecmd
bluecmd / README.md
Last active September 21, 2022 19:27
Loading coreboot payload over USB mass storage

Testing in QEMU

mkdir disk/
cp coreinfo.elf disk/boot.elf

qemu-system-x86_64 \
  -enable-kvm -M q35 -cpu host -m 4096 -serial stdout \
  -device qemu-xhci \
  -drive file=fat:rw:disk/,if=none,id=usbdisk \
@bluecmd
bluecmd / lifetime.rs
Last active September 4, 2022 10:08
Rust Lifetime question
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() {
x
} else {
y
}
}
fn min_length_string(x: &str) -> &str {
// Why does this not violate the lifetime checker?
@bluecmd
bluecmd / pcap-docker.sh
Created July 31, 2022 09:54
PCAP a docker container
sudo nsenter --net=$(docker inspect --format='{{.NetworkSettings.SandboxKey}}' $(docker ps | awk '/the-container-name/ {print $1}')) tshark -i eth0 -n -w /tmp/capture.pcap