Boy, have I got a great show for you today! I guess. You be the judge.
If you listen to the podcast, please rate it on a scale from Good Charlotte to My Chemical Romance at podcast@searls.co.
The following links are included with your subscription:
The new Mac mini will be the first major design change to the machine since 2010, making it Apple's smallest ever desktop computer. The new Mac mini will apparently approach the size of an Apple TV, but it may be slightly taller than the current model, which is 1.4 inches high. It will continue to feature an aluminum shell. Individuals working on the new device apparently say that it is "essentially an iPad Pro in a small box."
I can't be the only person thinking "I wonder if I could plug this into a portable USB power bank, throw it in my bag, and then use run Mac Virtual Display on my Vision Pro without needing to carry a laptop… can I?
What one must pass to includes() to include Active Storage attachments
If you're using Active Storage, eager-loading nested associations that contain attachments in order to avoid the "N + 1" query problem can quickly reach the point of absurdity.
Working on the app for Becky's strength-training business, I got curious about how large the array of hashes being sent to the call to includes() is whenever the overall strength-training program is loaded by the server. (This only happens on a few pages, like the program overview page, which genuinely does contain a boatload of information and images).
Each symbol below refers to a reference from one table to another. Every one
that descends from :file_attachment
is a reference to one of the tables
managed by Active Storage for
keeping track of cloud-hosted images and videos. Those hashes were extracted
from the
with_all_variant_records scope that Rails provides.
I mean, look at this:
[{:overview_video=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob}, :preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
{:overview_thumbnail=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob}, :preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
{:warmup_movement=>
{:movement_video=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob}, :preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}},
:movement_preview=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob}, :preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}}},
{:workouts=>
{:blocks=>
{:mobility_movement=>
[{:primary_equipment=>
{:equipment_image=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
:secondary_equipment=>
{:equipment_image=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
:tertiary_equipment=>
{:equipment_image=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
:movement_video=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}},
:movement_preview=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}}],
:exercises=>
{:exercise_options=>
{:movement=>
[{:primary_equipment=>
{:equipment_image=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
:secondary_equipment=>
{:equipment_image=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
:tertiary_equipment=>
{:equipment_image=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}},
:movement_video=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}},
:movement_preview=>
{:file_attachment=>
{:blob=>
{:variant_records=>{:image_attachment=>:blob},
:preview_image_attachment=>{:blob=>{:variant_records=>{:image_attachment=>:blob}}}}}}}]}}}}}]
By my count, that's 167 relationships! Of course, in practice it's not quite this bad since the vast majority are repeated, and as a result this winds up executing "only" 50 queries or so. But that's… a lot!
Broadcasting real-time database changes on a budget
While building Becky's (yet unreleased) app for her strength training business, I've been taking liberal advantage of the Hotwire combo of Turbo and Stimulus to facilitate dynamic frontend behavior without resorting to writing separate server-side and client-side apps. You can technically use these without Rails, but let's be honest: few people do.
Here are a few capabilities this broader suite of libraries give you, in case you're not familiar:
- Rails Request.js offers a minimal
API for sending conventional HTTP requests from JavaScript with the headers Rails
expects like
X-CSRF-Token
handled for you - Turbo streams can send just a snippet of HTML over the wire (a fetch/XHR or an Action Cable socket) to re-render part of a page, and support was recently added for Custom Actions that sorta let you send anything you want over the wire
- The turbo-rails gem adds some very handy glue code to broadcast model updates in your database and render Turbo streams to subscribers via an Action Cable socket connection
- Stimulus values are synced with the DOM as data attributes on the owning controller's element, and Object serialization is supported (as one might guess) via JSON serialization. Stimulus controllers, by design, don't do much but they do watch the DOM for changes to their values' data attributes
Is your head spinning yet? Good.
In order to protect user privacy, Apple Vision Pro does not trigger hover state on UI controls other than native visionOS applications. As a result, successfully clicking links and buttons requires the user to take a Tap of Faith that they're looking at them just right.
As a result, my click failure rate is like 30%. This is so dumb. Let me turn off gaze privacy.
All 14 animated music videos for Daft Punk's Discovery album. You are welcome: youtube.com/playlist?list=PLEPP5ddwMnT3pZR63WyemBtwFlvbRorqS
A lot of people are surprised that I pronounce my last name in Japanese as サールズ ("saaruzu") instead of something that looks more like Searls (せアルス). Here's why:
In English, Searls is pronounced like "Pearls" but with an "S" instead of a "P"
So I reverse-applied the same mnemonic to Japanese: start with katakana for pearls (パールズ) and replace パ ("pa") with サ ("sa"). That way in both languages, it's "Pearls with an 'S'"
I hope you like stories about moaning during a couples massage, bugs with Apple's Home Key system, and when it's OK to duplicate code in software. Because that's most of what I got this time.
Not enough of you are writing in, and if you don't start soon I am going to CANCEL this PODCAST production PERMANENTLY: podcast@searls.co. (Write in or else.)
Some proof of work:
Writing this to demonstrate it's not "literally never" that application developers would benefit from the non-obvious data structures one might learn in a computer science program: I'm two days into a challenging feature and just realized it would have been way easier if I'd used a linked list.
First time in maybe a decade.
The Crowdstrike thing was such major news that it was the first time in a long time that non-technical family and friends texted me about software.
Do you have any takes on Crowdstrike or stories about disasters (averted or experienced) like this one that you'd like me to read on my podcast? If so, write in! podcast@searls.co