Skip to content

Instantly share code, notes, and snippets.

@lancechentw
lancechentw / runbook.md
Created August 13, 2026 17:51
Fix HDMI Output Through a KVM on Ubuntu Server

Fix HDMI Output Through a KVM on Ubuntu Server

If Ubuntu sees the HDMI connector as disconnected when using a KVM, force-enable the HDMI output with a fixed resolution.

1. Identify the HDMI connector

Check the available DRM connectors:

ls /sys/class/drm/
@lancechentw
lancechentw / runbook.md
Created August 13, 2026 17:43
TPM2 LUKS Auto-Unlock — Ubuntu 24.04 on MSI Cubi

TPM2 LUKS Auto-Unlock — Ubuntu 24.04 on MSI Cubi

Uses Clevis, not systemd-cryptenroll: Ubuntu's initramfs is initramfs-tools, which has no systemd-cryptsetup, so tpm2-device=auto in /etc/crypttab is silently ignored.

Machine facts

Item Value
@lancechentw
lancechentw / farm observations upload api curl sample
Last active March 20, 2026 01:09
farm observations upload api sample
curl -X POST "https://api.example.com/upload" \
-H "Content-Type: application/json" \
--data-raw '{
"token": "35b15075d577cf2f0af0249a9c35dd72e19a89f8",
"datetime": "2026-03-20T10:30:00+08:00",
"temperature": {
"value": 26.4,
"unit": "°C",
"ObsTime": "2026-03-20T10:25:00+08:00"
},
@lancechentw
lancechentw / equipment_scrapes.csv
Created October 4, 2023 06:52
Plot subplots grouped by a pandas dataframe column
We can't make this file beautiful and searchable because it's too large.
time,equipment_id,produced_quantity,data
2023-10-03 00:00:00+00,eq1,0.00,
2023-10-03 00:00:10.064+00,eq1,0.00,
2023-10-03 00:00:20.612+00,eq1,0.00,
2023-10-03 00:00:30.045+00,eq1,0.00,
2023-10-03 00:00:40.93+00,eq1,0.00,
2023-10-03 00:00:51.775+00,eq1,0.00,
2023-10-03 00:01:01.703+00,eq1,0.00,
2023-10-03 00:01:11.148+00,eq1,0.00,
2023-10-03 00:01:20.897+00,eq1,0.00,
@lancechentw
lancechentw / variable_vel.src
Created November 8, 2022 10:03
KUKA SLIN variable velocity
&ACCESS RVP
&REL 5
&PARAM EDITMASK = *
&PARAM TEMPLATE = C:\KRC\Roboter\Template\vorgabe
&PARAM DISKPATH = KRC:\R1\Program
DEF lance( )
int errorcode
decl axis joint_pos_tgt
struc TRAJ_PT_TYP axis joint_pos, real velocity
decl TRAJ_PT_TYP traj_pts[61]
// Change the viewport temporarily, use browser's developer console to
// decide what width would fit your content to a A4 size pdf better.
// You will probably need to redesign the layout of your website under this breakpoint.
document.querySelector("meta[name=viewport]").setAttribute("content", "width=1000px");
// I have 2 Chart.js objects on my website, and they work bad under
// this viewport, so I am resizing them. You could probably do similar
// thing to your images here.
if (temperatureChart && pressureChart) {
temperatureChart.resize(640, 320);
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 10: htb default 256
tc class add dev eth0 parent 10: classid 10:1 htb rate 100mbit ceil 100mbit
tc class add dev eth0 parent 10:1 classid 10:10 htb rate 300kbit ceil 300kbit prio 1
tc qdisc add dev eth0 parent 10:10 handle 101: sfq perturb 10
tc filter add dev eth0 parent 10: protocol ip prio 10 handle 1 fw classid 10:10
# Limit speed of downloading to 192.168.1.100
iptables -t mangle -A POSTROUTING -d 192.168.1.100 -j MARK --set-mark 1
iptables -t mangle -A POSTROUTING -d 192.168.1.100 -j RETURN
apt-get update
apt-get install libexpat-dev
ln -s /usr/lib/x86_64-linux-gnu/libexpat.so /usr/lib/libexpat.so
su - builder -c "
mkdir -p build \
&& cd build \
&& ct-ng arm-unknown-linux-gnueabi \
&& ct-ng build"
@lancechentw
lancechentw / inside.c
Created January 2, 2016 04:33 — forked from stephenR/inside.c
32c3 docker exploit
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static void err_quit(const char * const msg) {
puts(msg);
exit(-1);
}