Friday, November 29, 2024

Caltrain Electrification

Caltrain is a large publicly owned train service in California. For the past few years Caltrain has been installing electrical lines above the tracks running up the San Francisco peninsula. Train electrification was proposed thirty years ago, began work seven years ago and completed in September 2024 with the retirement of diesel and replacement by electric engines.

The electric train engines have considerably better acceleration, important given the number of stops along the peninsula, and can complete the journey from San Jose to San Francisco in 30% less time than the diesel engines could. This allows trains to be scheduled more frequently.


 

Induced Demand

Studies have previously shown that service frequency has a significant impact on ridership, and indeed, Caltrain ridership is up 54%. On weekends it is up even more, by more than double.

We talk about the Braess paradox, where adding a lane to a busy roadway will further increase traffic and result in more congestion not less. Building massive highways doesn't resolve traffic congestion for car travel.

Yet increased ridership does not trigger the Braess paradox in train networks. Inherent in the paradox is that moving entities choose their own route, and will optimize for their individual outcome even at the expense of the whole. The trains are not making individual optimization choices, they just run faster.


 

Electrified Trains are Better Neighbors

As a family we enjoy a restaurant right next to the San Carlos Caltrain station, one with outdoor seating. The most recent trip there was a revelation: the electric train is quiet while getting underway, and with no diesel fumes. Electric trains fit into the cityscape more cleanly, quietly whisking passengers on their way.


 

Thursday, November 28, 2024

Tailscale certificates with NextCloud

I run a self-hosted NextCloud instance within the home, and use Tailscale to access it while out and about. This entailed editing /var/www/nextcloud/config/config.php to add trusted_domains:

'trusted_domains' =>
array (
  0 => 'localhost',
  1 => 'nextcloud.tails-scales.ts.net',
),

As using the default self-signed certificate is annoying, I installed a Tailscale certificate instead. A script run from crontab each week automatically renews the certificate:

#/bin/bash

out=$(tailscale cert --cert-file /etc/ssl/certs/tailscale.crt \
                     --key-file /etc/ssl/private/tailscale.key \
                     nextcloud.tails-scales.ts.net)

if [ $? -ne 0 ]; then
  echo tailscale cert failed
  exit 1
fi

# No new certificate needed, just quietly exit
if echo ${out} | grep -q unchanged ; then
  exit 0
fi

echo tailscale cert updated, reloading apache
systemctl reload apache2

Wednesday, November 27, 2024

Backup Google Photos to immich

I have over a century's worth of pictures in Google Photos. I am not immortal or anything, I just inherited a trove of family photos and digitized them all. The oldest photos are from the late 19th century.

I honestly do very much respect Google, the company and the services, but one concern about Google is the horror stories when their systems decide a user should be suspended. I want to minimize irreplaceable losses were I to lose access to my data stored there. The first steps of this have been:

  1. Google Takeout of files in my Drive, to store it in a self-hosted NextCloud.
  2. Google Takeout of my Photos, to store in a self-hosted immich.

This post is about the second item, getting photos into immich.


 

immich

I went with immich primarily because of its good commonality with Google Photos — I've mostly liked Google's product, just looking for more control of the ownership of my data. Immich presents a chronological view of photos, and allows organization into albums. It provides facial recognition which has honestly been top notch so far.

I host immich on a Proxmox machine at my home, and use Tailscale to get access to it from anywhere. The primary immich developers prefer to package it as a set of docker containers, which Proxmox doesn't natively support. Instead I created a Debian 12 LXC for immich and installed docker, using Docker Compose to get a working system.


 

Google Takeout for Photos

This was actually the most time-consuming step in the process: I used Google Takeout to export my photos collection and schedule five more Takeouts every two months, spanning a year in total. The first export took a few hours to prepare, and then an entire day to download. It comprised fifteen ZIP files in all, the first fourteen being 50 Gigabytes in size and the last being the rest.

The ZIP files are so large because they are full of duplicates. The entire photo library is included, and every album. Every time a photo appears in an album, an entire additional copy of it is added to the ZIP file. For over a decade I've zealously made albums for every trip to the Zoo, every school event, every trip, and the duplication of a substantial percentage of the photo library adds to the size of the download. Don't worry though, the process of importing the collection into immich will deduplicate them as well.

Being Google, the Takeout also contains JSON files for any metadata about photos it has. For example if you manually add a location Photos does not add that location to the JPEG EXIF data, it provides it in the JSON file instead.

Once downloaded, the ZIP files can be left as-is — the next step can process the ZIP files directly. You don't need to unpack them.


 

immich-go

Immich-go is an alternative CLI for immich written by Jean François Cassan. One of the things it can do is import Google Takeout ZIP files. It makes a first pass collecting images and their associated JSON. Given an immich API key it then uploads the deduplicated images, creating all Albums contained within the Takeout.

After about 12 hours running, immich0go had uploaded about 60,000 photos to immich.


 

immich facial recognition

Over the next several days, immich gradually recognized faces in photos and began associating them together. This, unfortunately but understandably, is not something exported from Google Takeout. The carefully curated set of identified people from Photos is left behind at Google, instead I'll need to recontruct it afresh within immich.

On the bright side, immich thus far appears to be very accurate in its groupings, even moreso than Google's implementation. It doesn't conflate different individuals together quite so often.


 

Next steps

I've been happy with the results thus far. Google Takeout's first scheduled incremental export a the two month mark is coming up in a couple weeks. I'll export another, presumably much smaller, Takeout and see how well immich-go handles it.

Monday, November 18, 2024

California Driver's License reciprocity with Germany current status

A number of US states and territories have full or partial reciprocal driver’s license agreements with Germany, allowing a US license to be exchanged for German and vice-versa. Among these are:

AlabamaIowaNew MexicoUtah
ArizonaKansasOhioVirginia
ArkansasKentuckyOklahomaWest Virginia
ColoradoLouisianaPennsylvaniaWashington
DelawareMarylandSouth CarolinaWisconsin
IdahoMassachusettsSouth DakotaWyoming
IllinoisMichiganTexasPuerto Rico

California, notably, is not on the list. I believe the current status is as follows.

  1. California Vehicle Code §12804.9 does not allow the DMV to negotiate reciprocity agreements with foreign governments, only with US territories.
  2. There have been several attempts to update the Vehicle Code to allow this, most recently CA AB 639 in the 2023-2024 legislative session — which was passed out of committee but ultimately not voted on in the House and died at the end of the 2024 legislative session.
  3. In the prior legislative session, AB-723 in 2021-2022 made it through several committees and the first few steps of a vote of the House, but was also not acted on before the end of the term.
  4. AB-629 of the 2019-2020 session passed in one committee but did not proceed further.
  5. The earliest such bill I can find came in the 2017-2018 session, and appears to also be the one which made it the furthest. SB-1360 passed the California Senate and through several committees in the House, but was not brought to a vote in the full House before the end of the legislative session.

 

The Experience in Washington State

The state of Washington passed a law allowing negotiation of reciprocal driver's licenses in 2005, in RCW 46.20.125. The full text of the change is considerably simpler than the proposed changes in California law, which additionally requires a consular letter and driving history.

Washington state and Germany signed a Memorandum of Understanding in 2005 relatively soon after passage of the enabling legislation. It was renewed in 2019, which notes the agreement as having been in place for 14 years.


 

Next Steps in California

The sponsor of the most recent Assembly Bill 639 was Representative Evan Low, who will not be returning to the state congress next year. I wish him well. I am writing to several other state representatives to encourage an effort in the next legislative session.

I believe framing this as a positive approach to mutually beneficial immigration would be productive.

There is recent momentum within the United States in this area. The American Association of Motor Vehicle Administrators publishes a guide of best practices for foreign driver’s license reciprocity, last updated in 2021 after its initial publication in 2009. It includes the treaty and legislative background for such agreements, and samples of a Standard Operating Practice and a Memorandum of Understanding. It also includes survey data of the number of agreements signed each year, which shows consistent interest over time.

If you live in California or are registered to vote in California from abroad and interested in advocating for this change in the California Vehicle Code, please get in touch: denton.gentry@gmail.com. I'm writing to representatives of how it might be carried forward.

Sunday, November 10, 2024

Charles Schwab brokerage debit card

When traveling overseas a debit card from Charles Schwab is quite useful:

  • no fees for use of overseas ATMs
  • refunds fees charged by the owner of the ATM
  • withdraw in dollars and let Schwab do the currency exchange at a favorable rate

If you apply for a Schwab debit card, by default it will be tied to a checking account with Charles Schwab Bank. If you don't have a checking account Schwab will ask permission to set one up. This is fine for many people, but if you might at some point move overseas it is a problem. Schwab offers International Brokerage accounts for US citizens living overseas, but banking regulations mean that Charles Schwab Bank cannot do so and will close a checking account if they determine that the holder resides outside of the US.

However, one can also get a Schwab debit card with the same terms and conditions but attached directly to the brokerage account and not through Charles Schwab Bank at all. A debit card attached to the brokerage account will still work if it later becomes a Schwab International Brokerage account. I had to call Schwab to make this happen, the web form didn't provide an obvious way to do so.

The card looks similar but is issued by Charles Schwab Corporation not Charles Schwab Bank, and says "Schwab One brokerage" on it.