Category: Programming
-
Iowa county seats
I got the coordinates of the county seats using the utility I previously wrote to get California county seats: The generated CSV is now available here: https://github.com/fadend/county_seat_coords/blob/main/county_seat_coords/generated/ia_usa_county_seats.csv. One complication that it doesn’t handle: Lee County has *two* county seats. A little copying pasting from the R code from the other post produced a pretty okay…
-
Save as “single file” via AppleScript is live in Chrome!
Back in December 2024, I got to submit a change to Chrome/Chromium adding support for saving as MHTML via AppleScript: https://chromium-review.googlesource.com/c/chromium/src/+/6107133/1 — Adding support for MHTML in Chrome’s Apple Script “save” action. Just now, I noticed that it’s live: It’s a little thing, but I’m excited. Woohoo!
-
California geophytes
On Reddit, bobtheturd said, “Calscape doesn’t do a good job filtering for geophytes, so wondering which are your favorites. I’m in the Bay Area, so more specifically interested in those.” (The post got some interesting replies.) Calscape describes itself like this: “Calscape is California’s hub for California native plants and native plant gardening, created for…
-
Defining a method outside of a Python class
I’m having some fun reading the source code for Whisper: https://github.com/openai/whisper. One thing I learned from it that delighted (horrified?) me: you can use a function defined outside of a class to provide the implementation for a method. (E.g., used in their Whisper class.) That’s fun. I don’t have a use case in mind yet…
-
Stripping NULLs recursively from an R list
Is there a nicer way to do this in R? I have a list where some elements are themselves lists (of lists of lists, etc.) I want to ignore entries with NULL as well as entries that are empty after stripping NULLs.
-
California County Seats
I had some fun today getting the location of each county seat in California. You can see the code here if you’re curious: https://github.com/fadend/county_seat_coords. The data are pulled from Wikipedia’s List of counties in California. I plotted them going through the tutorial here: https://eriqande.github.io/rep-res-eeb-2017/map-making-in-R.html. (Very nice!) Here’s my ugly R code for doing that, shamelessly…
-
Adding support for MHTML in Chrome’s Apple Script “save” action
MHTML is a handy format for archiving pages. In Chrome, you can get it by selecting “Save Page As…” and choosing “Webpage, single file” as the output format. In a Chrome extension, you can get it via chrome.pageCapture.saveAsMHTML, which is what I use in the gg_download extension I’ve been hacking on. In the project I’m…
-
Comparing nodes
I thought I wanted to compare the DOM trees for a couple of nodes. I ended up putting this together: How would you have done it? (I’d be unsurprised if this has some bugs.) After writing this though, I realized that comparing the HTML from n1.getHTML() vs n2.getHTML() was better for my purposes. (I don’t…
-
white-space: pre-line converts lines into spaces in Safari when pasting into a textarea
In a site I’m helping with, we encountered this weird behavior: users pasting multiline text into a textarea in Safari (but *not* in Chrome) found their newlines replaced with spaces. This was a problem because lines are used to separate items to be processed. Dropping the lines garbled the meaning of the input. My first…
-
Regex in C++
I’ve missed out on a few things. It was fun to learn (or be reminded?) today that regular expressions have been part of the C++ std library for a while: https://en.cppreference.com/w/cpp/regex