avatar

Mike Tsao

Rust Getters and Setters

Avoid getters and setters in Rust. Thanks to Java, I reflexively add getters and setters regardless of language. But I recently started to understand why it’s better to avoid them in Rust. Suppose you’re building a calendar: struct Day { n: u8, is_moon_full: bool, } struct Month { days_in_month: Vec<Day>, blue_moon: bool, } impl Default for Month { // not shown: populating days_in_month fn default() -> Self { Self { days_in_month: Vec::default(), blue_moon: false, } } } fn main() { let mut m = Month::default(); let mut saw_full_moon = false; for day in m.

VS Code - adulation and a tip

I like VS Code. It runs on Linux. It’s fast enough for an Electron app. It’s extensible. It doesn’t try to push me toward Microsoft technologies. Most important to me, it feels like the people who build it also use it. A great example of that last point is keyboard focus. In VS Code, it’s always where it should be. Many poorly implemented apps present a form for you to fill out, and then do nothing when you start typing.

Ubuntu lockscreen not unlocking

Another upgrade/uninstallation problem: when my screensaver kicked in, the password prompt would no longer appear when I pressed a key on the keyboard. I was locked out. In /var/log/syslog: cs-backup-locke[2921]: unable to monitor screensaver window: Failed to execute child process “xprop” (No such file or directory) $ dpkg -S xprop nothing $ apt-cache search xprop says something about x11-utils $ sudo apt install x11-utils Then try locking the screen… and it works!

Restoring Debian/Ubuntu networking from the command line

I recently upgraded from Ubuntu 20.04 LTS to 22.04 LTS, and a bunch of stuff broke. As with my last problem, it’s probably because I had used third-party repositories or .debs that pulled in different versions of dependencies, so that updating to new standard packages couldn’t figure out how to also update the dependencies. Anyway, I was tired of the standoff, and just went ahead and removed a critical package (python3.

libcbor.so.0.6 not found

If you upgraded from Ubuntu 20.04 LTS to 22.04 LTS, and you’re no longer able to ssh-add -K because you’re getting this error: $ ssh-add -K Enter PIN for authenticator: /usr/lib/openssh/ssh-sk-helper: error while loading shared libraries: libcbor.so.0.6: cannot open shared object file: No such file or directory then you might try this: $ ldd /usr/lib/openssh/ssh-sk-helper linux-vdso.so.1 (0x00007ffd985a9000) libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007feca56be000) libfido2.so.1 => /usr/local/lib/libfido2.so.1 (0x00007feca567a000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007feca5452000) libcbor.so.0.6 => not found … which will lead to this:

Old Blog

I’m importing some posts from my old sowbug.org blog, which ended in 2011. Most posts were garbage, or from the good old days of the Oversharing Internet. Those will stay offline. But a few had some thought put into them, and they’re worth republishing. Notes from scanning the rejects: Almost all the links to external sites are dead. I spent a lot of time learning and redocumenting how to use Emacs.

Groovebox, chapter 2

One of my June 2022 ideas was to build a groovebox. I’ve made some progress on the software side, and I’d like to talk about some of the interesting parts of the work. First: I’m developing in Rust. Choosing Rust was actually a no-brainer; it’s the right choice for new projects intended to compile directly to native machine instructions. So far, it’s been a great experience. I can see why people become Rust zealots.

Stable Diffusion on Google Cloud

These instructions are for setting up a Stable Diffusion instance on Google Cloud. I created an n1-standard-4 instance with an nVidia Tesla T4 GPU, which has 16GB of VRAM. I chose the “c0-deeplearning-common-cu110-v20220806-debian-10” image and sized it to 80GB. If I had it to do over again, I’d make a separate disk for the models and the generated output, but it’s not a big deal. Here are the (cleaned up) commands I used.

E-Paper Printer

Idea: an e-paper printer. You can print to it, same as any printer, but instead of producing paper, it displays the last page printed. That’s pretty much it. I’d hang it on the wall in the kitchen, and I’d print recipes to it. It has no buttons or input, so I wouldn’t get food on it. I think the virtual-printer interface is important. I don’t want to write an app or curl to it.

Potato Diet

On May 18, I started a four-week potato-only diet. I thought it sounded interesting, and right now has been a good time in my life to try an slightly unusual eating regime. I didn’t really care about losing weight, but I am overweight, so I wouldn’t mind it if I did, either. It’s now the first day after the four-week mark. I lost 7.8 pounds, or 4.3% of my starting weight.