Skip to content

Instantly share code, notes, and snippets.

natanlao /
Created Sep 15, 2019
Caffeinating a process that is already running
bash-3.2$ caffeinate -d $(while true; do if ! kill -0 $PID; then sleep 5; exit; fi; done)
natanlao /
Last active Mar 22, 2020
A non-comprehensive list of bugs with NETGEAR ReadySHARE
  • ReadySHARE only supports drives up to 4TB in size. Some routers have an even smaller limit.
  • If you are using a drive with multiple partitions, ReadySHARE can, between firmware upgrades (or maybe reboots?) switch which partition is presented in which Samba folder.
  • ReadySHARE seems to change the mount point / "share name" of attached devices based on the the current phase of the moon.
natanlao / data.tsv
Last active Mar 22, 2020
NearlyFreeSpeechNET deposit scraping
View data.tsv
payment grossfee rebate netfee deposit
$0.50 -$4.00 +$3.58 -$0.42 $0.08
$0.51 -$4.00 +$3.58 -$0.42 $0.09
$0.52 -$4.00 +$3.58 -$0.42 $0.10
$0.53 -$4.00 +$3.58 -$0.42 $0.11
$0.54 -$4.00 +$3.58 -$0.42 $0.12
$0.55 -$4.00 +$3.58 -$0.42 $0.13
$0.56 -$4.00 +$3.58 -$0.42 $0.14
$0.57 -$4.00 +$3.58 -$0.42 $0.15
$0.58 -$4.00 +$3.58 -$0.42 $0.16
natanlao /
Last active Mar 22, 2020
Sticker genius quote crawler
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
# Get quotes from Sticker Genius for the kind of sticker we are going to buy so that
# we can pay less money for more stickers.
# Should be easy enough to tweak this code for different products - I used Firefox
# developer tools to inspect requests made to getPrice.php.
from decimal import Decimal, ROUND_05UP
import time
import requests
natanlao / candidates.tsv
Last active May 30, 2020
UC Santa Cruz Student Union Assembly elections history (1999-2020)
View candidates.tsv
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 10 columns, instead of 9. in line 6.
Election Term Position Function Name Votes Proportion Winner Links Comments/Notes
1999 1999 - 2000 Campus Office Director Internal Affairs Eric Gonzalez 2046 100 TRUE
1999 1999 - 2000 Chair President Maria Catalina 720 28.1 FALSE
1999 1999 - 2000 Chair President Dylan Smith 881 34.4 FALSE
1999 1999 - 2000 Chair President Kirti Srivastava 957 37.4 TRUE
1999 1999 - 2000 Lobby Corps Director External Affairs Carolyn Boyd 655 30.4 FALSE
1999 1999 - 2000 Lobby Corps Director External Affairs Patrick McHugh 522 24.2 FALSE https://deanofstu
natanlao /
Created Aug 8, 2020
Multi-stage Dockerfiles with perl and perl-slim

The benefits of using multi-stage Docker builds is well-known. Using multi-stage builds with a pure Perl setup is trivial -- all it involves is copying the /usr/local/lib/perl5 directory:

FROM perl:5.28 as builder
COPY cpanfile cpanfile
RUN cpanm --installdeps .
natanlao /
Last active Aug 11, 2020
Tips for working with s3cmd on

Working with s3cmd on

This document lists some problems I encountered using s3cmd on and how I solved them.

Uploading with the ONEZONE_IA class

s3cmd sync doesn't support the --storage-class argument, and even that doesn't support the ONEZONE_IA storage class. You can still upload objects to that class by specifying the x-amz-storage-class header, but s3cmd sync will ignore that. The best solution I have is to upload your files as you normally would, then use s3cmd modify to set the storage class after upload.

natanlao /
Created Sep 29, 2020
Tracking recurring reminders

I use my Fastmail calendar to track recurring reminders, like regular maintenance, or scheduling a doctor's appointment, or requesting a credit report, etc. I create each reminder as an all-day event on a calendar only for reminders, and configure each event to send me an email reminder on the day of the event.

This approach is simple and flexible:

  • Recurrence rules make it trivial to configure a task to repeat at any interval, whether it be on the nth day of the month every m months, or every other year, etc.
  • With an Inbox Zero approach, reminders stay out of the way until they're relevant, and can be
natanlao /
Last active Oct 9, 2020
Importing birthdays and contact images from Google Contacts to Fastmail

Fastmail offers an automated Google Contacts [import feature][import], and also supports importing contacts by CSV and vCard. Unfortunately, I've noticed that all of these import features are lossy. Regardless of import method:

  • Contact profile pictures stored in Google Contacts are not imported. (Google exports profile photos by including a link to the photo in the CSV.)
  • Birthdays without associated years (i.e., just the month and day) are sometimes not imported at all.
  • Empty ('') phone numbers are sometimes added to contacts. (This issue may have been a result of me trying to fix the two issues above, and not Fastmail
natanlao /
Created Oct 23, 2020
Cross-platform filesystem

I spent some time recently looking for a cross-platform filesystem to store some personal data. After some deliberation, I settled on a single-volume ZFS "pool" and I'm pretty happy with it. Here's why:

  • Strong cross platform support. Works natively on Linux, macOS, and Windows.

  • [Native encryption][encryption]. ZFS supports encryption out of the box. It would have been possible to use something like VeraCrypt to encrypt a