Skip to content

Instantly share code, notes, and snippets.

@ajeddeloh
ajeddeloh / aqi.py
Last active Jan 23, 2021
promethesus metrics endpoint for plantower aqi sensors, depends only on pyserial
View aqi.py
#!/usr/bin/env python3
import serial, struct
from http.server import BaseHTTPRequestHandler, HTTPServer
packet_format = struct.Struct('>xxxxHHHHHHHHHHHHxxH')
cmd_format = struct.Struct('>ccBBBH')
prom_template = """# TYPE success gauge
success 1
# TYPE pm gauge
pm{{size="1.0"}} {}
@ajeddeloh
ajeddeloh / mkplot.py
Created Dec 17, 2020
Generate MTF curves from razorblade images
View mkplot.py
from numpy import fft, diff, empty, interp, arange
from imageio import imread
from matplotlib import pyplot as plt
from argparse import ArgumentParser
DPI = 6400
DPMM = DPI / 25.4
SAMPLE_SPACING_MM = 1.0 / DPMM
plt.figure(figsize=(8,6), dpi=100, constrained_layout=True)
@ajeddeloh
ajeddeloh / zmf2zmx.py
Created Dec 6, 2020
Split zmx files from a zmf catalog
View zmf2zmx.py
import numpy as np
import sys
from struct import Struct
if len(sys.argv) != 3:
print("usage: zmf2zmx in.zmf zmx_dir")
with open(sys.argv[1], 'rb') as f:
zmf_bytes = f.read()
View lrc.py
import serial, time, cmath
import universal_usbtmc
import matplotlib.pyplot as plt
kernel_tmc = universal_usbtmc.import_backend("linux_kernel")
fngen = "/dev/ttyUSB0"
startFreq = 1000
freqStep = 1000
stopFreq = 50000
View Boot FCOS with live pxe.md
  1. Make sure you have the kernel and live pxe initrd (different from normal initrd). Put them at $WORKDIR/{kernel,initrd}
  2. Put your ignition config in $WORKDIR/config.ign
  3. Put this script at $WORKDIR/boot.ipxe:
#!ipxe
kernel tftp://10.0.2.2/kernel console=ttyS0 \
  ignition.firstboot ip=dhcp rd.neednet=1 ignition.platform.id=metal \
  ignition.config.url=tftp://10.0.2.2/config.ign
initrd tftp://10.0.2.2/initrd
boot
View etcd.yaml
variant: fcos
version: 1.0.0
systemd:
units:
- name: etcd-member.service
enabled: true
contents: |
[Unit]
Description=Run single node etcd
View gist:63e5e1c142ffed3d5f757b3d5d7278d0
// ==UserScript==
// @name Echelog hide part/join
// @version 1
// @grant none
// @match *://echelog.com/*
// ==/UserScript==
console.log("asdf");
function elForEach(array, callback, scope) {
View gist:453847d4eec0ed0955aad278d4b1f44a
/etc/sysconfig/
/etc/sysconfig/chronyd
/etc/sysconfig/grub
/etc/sysconfig/ip6tables
/etc/sysconfig/ip6tables-config
/etc/sysconfig/iptables
/etc/sysconfig/iptables-config
/etc/sysconfig/nfs
/etc/sysconfig/nftables.conf
/etc/sysconfig/raid-check
View gist:db5bb2254331ebeedb451f6fcd0bd216
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBFmI9C4BEADMmZ08/sE2N4gzx8pWZYfcRy4N5g7pDDaYBYKz8ZPNvUEjRlQN
kTu+eIvEZQPDFM3mfFkU741phsAvEtT8DaB7Yalb9pd0RobSuSJIKP2OiOnaeqel
86o69lI12HLRYP1ALgYRM2fOVH2DEZ24qkYVdJbLjwSnAb/IKx3DsPoVEUOEhiBq
Mx72PcroCIpDk07xH240O30IhqveqOOH2e1pDphS8NBHx9YuHwZ+NfcL0BrOnHJX
0HM7EJTLTdjqKTS99VxNm9OnmzSZwytC23yEM+CwREh8FReXp+50eyF1pCZiBinF
2JuXKDk8sSnHxg8cmBrlxf73m9BKVMWuDCAp1iLgFk7//ZQlBd3RBWzv36l3BbEd
TioJV2ewD1UMPHta94ncU74cFl6eYyT6WDdNIitPMYrxyZuTKBvBKheu6EXYlXVe
XJSBYTCFWh6HVdcQ2w0/5Yv9SyjzpA2siVpY2ZGbOgTMaXh7zAc73c/MgdBWwCkA
View gist:36e6b49c1cf9f0963b59b30d730e992d
{
"ignition": {
"version": "2.2.0"
},
"systemd": {
"units": [
{
"name": "update-engine.service",
"mask": true
}]