Qingping Air Quality Monitors in Home Assistant

Over the past few years I’ve been having lots of fun playing with Home Assistant and home automation in general. One of the things which is underdocumented but kind of interesting is how to get air quality monitors connected to Home Assistant.

I currently use two different types of air quality monitors, both made by Qingping. There are, of course, alternatives, but the Qingping devices are reasonably priced when they’re on sale and they tend to look pretty nice.

Determining the legality of shengji plays

I’ve been working on my online version of the shengji card game for a little while now. One of the more interesting aspects of the game is how a legal play is defined, and the corresponding algorithm to compute that.

Problem overview

Shengji is a trick-taking game, which means that in each round, every player plays the same number of cards. The first player in the trick sets the “format” of the trick, which subsequent players must attempt to follow. Only players whose plays match the format can win the trick (and then start the next trick).

Discord Audio Tray Sync

I’ve been using Discord for gaming and hanging out with friends. However, sometimes I want to use my computer’s speakers (for friend hangouts), and sometimes I want to use headphones (for gaming).

On Windows there’s a handy system tray widget which lets you change the default playback device – and almost everything plays from the default playback device! However, Discord uses the default communications device when set to default… and you have to go into a menu to change that. Very annoying.

Shengji Probabilities

Migrating from Kubernetes to Docker Compose

A year of Kubernetes

About a year ago I thought it would be a good idea to learn a bit more about Kubernetes. We use Kubernetes as part of our server orchestration at work, and while most of it is abstracted a way, it rarely hurts to know how the various foundational layers are actually like.

At the time, I tried to set up a three-node cluster (two computers at home, one in the cloud), connected together by Tailscale (i.e. via Wireguard). This… kind of worked, but it was super chatty, and when we moved to Seattle we no longer had an unmetered internet connection.

SIGTERM and Docker images running as PID 1

Or, why doesn’t docker stop work for my Docker image?


I’ve had a Docker image which is intended to be approximately the most basic HTTP-compatible responder for a while. But, I built this originally for playing with Kubernetes, which doesn’t really give you direct access to anything.

When actually using it with Docker, I discovered that it wouldn’t actually shut down correctly with Ctrl-C or docker stop, and Docker would eventually have to docker kill it.

Setting up a Samba share

This one’s pretty silly, but I decided I would try to use my little potato mini PC as a Samba host. And, it turns out, in the many years since I’ve configured Samba, so I forgot almost everything… and there’s some new stuff, too.

These instructions were only tested on my computer, which is currently running Ubuntu 22.04. May or may not work for you!

Setting up filesystem permissions correctly

Advent of Code 2022

Advent of Code is a pretty fun December activity – an advent calendar of programming puzzles with a story tying them all together. The puzzles are released at midnight ET, which is conveniently 9 PM PT.

I did Advent of Code for the first time last year (2021), and really enjoyed it. Since I became a manager I rarely get to write code for work (and try to minimize it, even so), and especially don’t get to write the kind of code that exercises the problem-solving part of my brain.

Setting things up again

It’s been a long while since I’ve set up a new environment, and a long while since I’ve posted much of anything on here. Things have been pretty busy since we moved up here to Seattle, and I’ve been distracted by an endless supply of home improvement projects. Maybe some of those will make it up here!

As it happens, though, I finally got on the NVMe train and swapped out the main drive for my computer at home. And that means I have to set everything up again… including all the things I forgot I like to have on a computer. And it looks like some of my projects have suffered some bitrot, too…

Silly Formatting 3: readline and canonical input modes

I’ve been pretty annoyed for the last few months with using sillyfmt from the command line on MacOS. Previously, I’d just run sillyfmt with no arguments, which reads from STDIN and attempts to format whatever gets passed in. I would then copy and paste interesting snippets into the open window.

Unfortunately, any large blocks of text would mysteriously truncate themselves and hang for a bit on MacOS. I had worked around this by piping the output from pbpaste (i.e. pbpaste | sillyfmt), but it was annoying and I tended to use the WASM version instead (in fact, this is a lot of why there’s a WASM version at all).

Building tractor (升级) as an online card game

Introduction

This COVID-19 pandemic has left me with lots of free time spent in front of a computer at home. I’d been spending time with my friends playing various videogames online (the Jackbox Party Pack games work reasonably well over Discord or Zoom), and my fiancée suggested that we try to play tractor online… but I couldn’t find one that was easily available over the internet!

What’s tractor, anyways?

Tractor is a trick-taking card game popular in China, played with four or more players and with multiple decks. It’s commonly known as 升级 (“level-up”), 打百分 (“fighting for 100 points”), 四十分 (“forty points”), 八十分 (“eighty points”), or 拖拉機 (“tractor”). You can even find it on Wikipedia! The rules of the game are pretty complicated, and they vary widely: As far as I know, there isn’t a canonical source of rules for the game, at least in English.

Silly Formatting 2

So, as a follow-up to the original silly-formatting post, I spent some time trying to figure out just how bad the LALRPOP-based sillyfmt implementation was. It turns out that there’s really nice utilities for using the afl fuzzer with Rust, so I hooked that up with some pretty basic heuristics and let it run for a few seconds. Then, since it turned out to be really bad, I got nerd-sniped into setting up a different parser called tree-sitter that uses a more generic parsing algorithm. Unfortunately, that led to another rabbit-hole: tree-sitter is a C library,and while Rust/C interop is generally good, this is much less true when you involve the WebAssembly toolchain(s).

Silly Formatting

In my time at Dropbox, I found myself fairly often trying to quickly read through “traces”, which were essentially developer-formatted text logged from the Dropbox desktop client. The Dropbox client was originally written back before structured logging was common in industry, and in any case setting up structured logs can add a fair bit of overhead to the day-to-day debugging lifecycle.

After spending an inordinate amount of time opening complicated traces in vim and using the rudimentary formatting options available there, plus a bunch of manual labor, I eventually decided to save myself a lot of time by looking for a formatter that could automate the work away.

The Slippery Slope of Building Computers

Resurrecting GLaDOS

After a little over five years, the small form factor desktop computer I built back in late 2012 refused to boot properly. For a couple of months, I resisted–I have a work-issue Macbook and iPad Pro, and I don’t play nearly as many computer games as I used to. It didn’t feel all that necessary for me to have a desktop on top of all of that.

But, it turns out, it’s really quite nice to have a computer setup of your own. I ended up cannibalizing many of the parts from that desktop into a new, mid-tower sized box with 8th-generation Intel technology. And it’s actually really nice! At work, my Linux desktop is also running a circa 2013 CPU, so I legitimately didn’t know how much faster and more power-efficient desktop computers have gotten in the last half-decade.

angercore.aeturnalus.com is dead

For the past couple of years, I’ve kept a box in DelimiterVPS’s Atlanta data center named angercore.aeturnalus.com. For just $20 a month, I had a (very old) HP BL260C blade server with plenty of disk space and RAM to run many of my random experimental projects on.

Unfortunately, angercore.aeturnalus.com has been offline for over three weeks, and it’s not looking like it will come back anytime soon.

C:\Users\Robert Ying>ping angercore.aeturnalus.com

Pinging angercore.aeturnalus.com [199.233.247.142] with 32 bytes of data:
Reply from 69.174.12.218: Destination host unreachable.
Reply from 69.174.12.218: Destination host unreachable.
Reply from 69.174.12.218: Destination host unreachable.
Reply from 69.174.12.218: Destination host unreachable.

Ping statistics for 199.233.247.142:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

So, I guess it’s time to say goodbye. If I’m really lucky I’ll manage to get some of the data that lived on the box back, but I’m not holding out hope.

Poor Man’s Breadboard Arduino

A note from July 6, 2018

When I was in high school, I wrote a short post on building a low-cost Arduino on a breadboard. It’s been quite some time since I’ve done any significant hardware hacking, but since my old blog is mostly dead at this point I reproduce that post here


I’ve burnt out a few Arduinos recently, and have found it expedient to just build my own on a breadboard rather than pay $34.95 and buy an Arduino Duemilanove online. It’s cheaper ($7.40, without FTDI or breadboard, SparkFun), and easy to fix if something goes wrong. Note that this tutorial does NOT include a voltage regulator, power will come from the FTDI board.