Matthew Lindfield Seager

Finished reading Edgedancer by Brandon Sanderson πŸ“š

Icon Set from a single image in 15 seconds

I built some AppleScript applets to launch Gmail to a specific account and Brave to a specific Profile (could also be done with Chrome) but I didn’t like the generic “Script” icon.

Screenshot of dock icons showing the ugly default script icon between two snazzy custom icons

At first I just pasted my custom image into the “Get Info” window to update the icon but then when I made changes to the app and re-saved it, the icon got reset. I wanted to permanently updated the “applet.icns” file in the bundle but I didn’t want to spend an hour fiddling around with all the icon sizes.

Turns out, creating an icon set is super easy once you have your starting image:

  1. Copy your image
  2. Paste it onto the icon in the Get Info window
  3. Copy the new icon from the Get Info window
  4. “New from clipboard” in Preview (or just ⌘ N)
  5. Save…
  6. Option click the Format dropdown and choose ICNS
  7. Save

You now have an ICNS file with all 10 variations in it:
Screenshot showing 10 different icons

Step 2:
Paste your image onto the icon in the Get Info window

Step 3:
Copy the new icon set from the icon in the Get Info window

Step 6:
Option click the Format dropdown to expand the available types and choose ICNS

So happy to solve a longstanding performance bug! πŸŽ‰

I finally solved a hugely annoying performance bug in one of my Rails apps! To give you an idea of how bad it had gotten, just before the fix an admin page I use 5-10 times every Saturday was averaging 21,114.2 milliseconds per load!!! 😱 Although really, when the times are that large, milliseconds is probably the wrong unit of measurement… That page was taking 0.00024 days to load!!! And the trend was only getting worse!

That same page is now averaging 22.4 milliseconds, about 3 orders of magnitude quicker!

I’d been trying to figure it out for months but I was hampered by a combined lack of:

  • motivation; public facing pages were “only” taking 2-4 seconds and no one had complained
  • expertise; I’ve never had to solve performance problems on my own before
  • tooling; I had inexplicable issues getting Rack Mini Profiler flamegraphs to work on the site, in development or on production πŸ€·β€β™‚οΈ

The tooling problems were particularly frustrating so I owe a massive thank you to Nate Berkopec from Speedshop who not only puts out a ton of great content but was also very patient with my beginner questions about why my flamegraphs weren’t working. I didn’t end up figuring out that problem, but at Nate’s suggestion I switched to rbspy to create a flamegraph and within about an hour I’d figured out the problem that I’d previously spent months off and on trying to solve.

It turns out that every time I fetched a person from the database, my app was generating a random password for them. That process is a bit slow (possibly by design? to avoid timing attacks?? maybe???). Individually, 200 milliseconds to generate a password isn’t a big deal… but on the admin page I load a list of all the people, so every time a new person got added, the page slowed down by another 1/5 of a second πŸ€¦β€β™‚οΈ

In the end the fix was super simple, I now only generate the random password (and other default values) if the person isn’t already in the database:

# Before
after_initialize :set_default_values

# After
after_initialize :set_default_values, if: :new_record?

18 more characters to remove a 94,160% slow down! Plus now the user facing pages are down below 30 milliseconds too! πŸ₯³

For future reference, here’s how I tracked down the issue:

  • Installed rbspy using homebrew
  • Obtained my web server process’ PID from tmp/pids/server/pid
  • Captured a trace on my Mac using sudo --preserve-env rbspy record --pid 86229 --format speedscope --subprocesses
  • [Not tested but could maybe combine the above two steps with something like sudo --preserve-env rbspy record --pid `cat tmp/pids/server/pid` --format speedscope --subprocesses]
  • Request the offending page or pages then go back and end the rbspy recording with control-c
  • Drag the resulting speedscope file from ~/Library/Caches/rbspy into speedscope
  • Found the offending call at the very bottom of the flamegraph “stalactites”

This will be my last M.b post cross-posted to Twitter.

You can find everything I write at matt17r.com (also available via RSS) and for those on Mastodon, Micro.blog is already compatible: @matt@matt17r.com

Finished reading Words of Radiance by Brandon Sanderson πŸ“š

Over 1,000 dense pages but I thoroughly enjoyed it. Looking forward to the rest of the series arriving in country next month.

Files App on iOS/iPadOS is not limited by Screen Time restrictions or Downtime

After doing some research today it seems there is no way to block the Files app using Apple’s Screen Time settings. Even when the entire device is locked at Downtime, there is no way to block the Files app. Chlidren can therefore use the Files app at any time of the day or night to:

  • Listen to audio files
  • View images
  • Read PDFs and text files
  • View Excel, PowerPoint and Word files
  • Preview contents of Zip files

I suspect this also means that time in the Files app isn’t tracked as part of the Screen Time time limits.

Some restrictions still apply despite this fairly large loophole:

  • Videos can’t be watched; “You’ve reached your limit on Entertainment” (even if you try and cheat by choosing the “Trim” option to edit rather than view or if you put it in a Zip file and preview the contents of the Zip πŸ‘)
  • iWork files can’t be previewed unless their corresponding app is Always Allowed; “You’ve reached your limit on Keynote”
  • Anything that can’t be “Quick Looked” (previewed) in Files can’t be viewed (ePubs, Google Sheets/Slides/Docs/Sites, etc)

This seems like a pretty big gap in Screen Time to me. If you care about this and happen to know anyone at Apple you can prod, I’ve filed Feedback 11953747.

Finished reading: The Way of Kings Part Two by Brandon Sanderson πŸ“š

Finished reading: The Way of Kings Part One by Brandon Sanderson πŸ“š

In the nick of time before semester 2 starts tomorrow, I just finished The Lost Metal by Brandon Sanderson πŸ“š

Finished reading: The Bands of Mourning by Brandon Sanderson πŸ“š

Finished reading: Shadows of Self by Brandon Sanderson πŸ“š

Finished reading: The Alloy of Law by Brandon Sanderson πŸ“š

Finished reading: Mistborn, The Well of Ascension and The Hero of Ages by Brandon Sanderson πŸ“š

PSA for macOS Terminal users:

Terminal Prefs β†’ Profiles β†’ Shell:

  • Ask before closing
  • Close if the shell exited cleanly

No more accidentally killing your local dev server with ⌘Q. To close a terminal tab/window without confirmation close the shell with ^D

Thinking about ways to disambiguate the same username on different federated instances based on a question from @manton

Pic shows the same username on mastodon.social and ruby.social. Avatar colour would be dynamic but always the same for the same service…

Installing Teams for an upcoming meeting and noticed the installer is called “Teamsosx”. OS X was renamed macOS in 2016, almost a year before Teams was released. It’s inattention to details like this that make Microsoft products really stand out πŸ˜‰

Trying to stay positive online so rather than bash Hover I’ll compliment Cloudflare. Cloudflare domain registration is:

  • 47% cheaper
  • Just as private
  • More transparent
  • More convenient (since my DNS is already hosted there)

80% of my domains now transferred πŸ˜‰

Our house is all ceramic tiles and concrete, terrible for acoustics! So here’s my improvised recording studio; kneeling on the ground with my head in the sound absorbent cave…

Technology can be good but I’d be okay if I never had to do another video call… VR meetings really don’t appeal to me!

Watch out for GitGuardian. They scan public GitHub repos unbidden & send unsolicited emails about “exposed secrets” to trick you into signing up. Once you’re in, they request access to all your repos then waste your time telling you about dozens of exposed “secrets” that aren’t πŸ‘Ž

If you think you’re leading and no one is following you, then you’re only taking a walk β€” Afghan Proverb*

*Maybe, I’m choosing not to go down the rabbit hole of looking for the origin of this phrase/sentiment

A bit bummed to hear Salesforce is killing Heroku’s free tiers. Pretty sure there’s other options to prevent/minimise abuse.

I’ve narrowed down my search for nw5k.com’s new home to Railway, Render or Fly(.io)… or maybe old school with Ansible, Capistrano and Linode πŸ€·β€β™‚οΈ

A month or two in and I’m super happy to have found Nova as a capable (and native!!!) replacement for Atom.

I tried VS Code but, even without plugins, it felt busy and bloated.

Still learning not to hit ⌘ T for fuzzy open though πŸ™ƒ

Enjoyed watching WWDC this year! One nice thing about being in Cambodia is that it went from midnight to 2am, rather than 3am-5am in Sydney.

Almost time for a new laptop, struggling to decide between the 14” M1 Pro MBP or 13.6” M2 MBA πŸ€”

Almost a perfect bell curve of results in Wordle… add in my 2 misses, that I almost certainly would have got in 7, and it’s almost perfectly symmetrical!