花花花 SuperLaserNino 花花花

Don’t manually hunt around for yarn.lock or package-lock.json

27 Aug 2024

#!/usr/bin/env perl

# Node dependency manager. Never wonder whether to use `yarn` or `npm` again.

# Usage:
# np        --> runs `yarn` or `npm i`
# np <args> --> runs `yarn <args>` or `npm run <args>`

use strict;
use warnings;

if (!-e 'package.json') {
  my $did_run = 0;
  my @dirs = grep { -d $_ } glob('*');
  for my $dir (@dirs) {
    $did_run = 1;
    chdir($dir);
    if (-e 'package.json') {
      print "Running `np` in $dir\n";
      my $exit_code = system('np ' . join(' ', @ARGV));
      exit($exit_code >> 8) if $exit_code != 0;
    }
    chdir('..');
  }

  if ($did_run == 0) {
    print "No package.json found. Exiting.\n";
    exit(1);
  }
  exit(0);
}

my $exit_code;
if (-e 'package-lock.json') {
  if (@ARGV) {
    $exit_code = system('npm run ' . join(' ', @ARGV));
  } else {
    $exit_code = system('npm i');
  }
} else {
  $exit_code = system('yarn ' . join(' ', @ARGV));
}

exit($exit_code >> 8);

Catio Chronicles 1: Let’s make a plan

18 Aug 2024

Our cat Jinx keeps getting sick and vomiting, and the vets are saying this is most likely because young cats like to eat random stuff outside. We really don’t want to restrict Jinx to being an indoor cat, so we decided we would build him a little outside enclosure, a “catio”.

Continue reading →

Finally you can remember whether the lift will ding once or twice

18 Aug 2024

Elevators Lifts have this cool accessibility feature where, depending on whether they’re going up or down, they’ll ding once or twice when they arrive. This is so you know the direction without having to look at the display above the doors.

I’ve finally come up with a mnemonic for remembering which is which:

  • One ding for going up – think “to one-up someone”
  • Two dings for going down – think “to double down on something”

🤯

Thoughts on Texts (a multi-platform instant messaging app)

05 Jun 2024

Having a handful of different instant messaging clients on your computer is inconvenient. There is Ferdi Ferdium, but that’s basically just a browser with a tab for each service. I want something like Adium: an app that transparently talks to all your IM services, so you don’t have to think about it.

For years this seemed to be impossible, but recently I heard about Texts, and decided to give it a go.

My first thoughts were:

  • I’m baffled at how they managed to make this app, given that all modern IM services have their own custom features, and most of them are proprietary/closed-source/etc. I still can’t quite believe this is real.
    • And Texts is owned by Automattic, which also owns WordPress, Tumblr, Pocket Casts, etc. So it’s at least probably not a total scam.
  • Seeing the screenshot on their homepage, I got excited that this might actually be a native Mac app, but it turns out it’s a 350 MB Electron app.

Setup and first impressions

The setup was relatively smooth. Adding accounts worked fine. The UI is pretty ok.

There are some nice settings:

  • “Decrease sidebar density”, which you obviously don’t turn on, because density is good.
  • “Distinct bubble color for each participant in groups”, which is great.
  • You can add custom CSS (I guess that’s an advantage of it being an Electron app)
  • “Optimized message rendering (beta) — Only render on-screen messages, to improve app performance. Might have some visual glitches.” This seems like a good thing to include. They’re right about the glitches tho.
  • “Run with Safari renderer — Use a different rendering engine that consumes less CPU and RAM. Might have playback bugs for some messaging platforms.” This is a weird one. Do they have a special mode where it’s Electron, but not using Chromium to render?? I’m turning it on to see what it’s like.

The UI is pretty nice and feels almost like a normal app, except for the very modern-web-app-feeling tooltips:

A tooltip for a magnifying-glass icon. The tooltip says “Command Bar: Search Threads”.

I may be the only person on Earth with this opinion, but I do actually like the native tooltips you get on macOS (and, I assume, Windows and Linux), that only show up after you point your mouse at a thing for a second, and look a bit more subtle.

The app has a bunch of other interesting features like automatic reminders, labels, undo for sending messages (via a delay), etc. Also there are keyboard shortcuts for everything and you can change the app icon to whatever you like.

The notification settings seem reasonable too:

Text’s notification settings. Items are:
	A toggle for “Message notifications”. A dropdown for “Sound”. A toggle for “Group message notifications”. Another dropdown for “Sound”. A toggle for “Notify when app is in focus”. A toggle for “Notify when someone reacts to a message”. A toggle for “Notify when someone starts typing (supported platforms only)”. A dropdown for “Delay notifications for x seconds”, with explanation “Instead of getting notified for each message, delay and batch notifications for successive texts from someone”. There are also buttons “Open Notifications in System Preferences” and “Restart Notification Center”.

Glitches

When first setting up my accounts, the unread counter badge in the Dock icon was stuck on 1, but that eventually resolved itself.

Compatibility

So the app seems nice and things broadly work. But how well does Texts support all the custom features of the various IM services?

Replies

Yep:

Screenshot of a chat conversation (with all the text blurred).
	The first item is a turquoise bubble containing a white box with a quoted message from Nino. The bottom half of the turquoise bubble contains the reply to Nino's message. Below the bubble is a button titled “Show reply”.

	Next is a right-aligned blue bubble, also containing a white box with a quoted message and some response text.

This is Telegram, but it seems to work just as well with Messenger. Also, the original message gets a “Show reply” button and a “Show All Replies” button. “Show All Replies” opens a little popup with all replies to that particular message. (Would be nice if the UI team could make up their minds on whether they want sentence case or title case for their button labels tho.)

Forwarded messages

Nope. At least in Telegram, forwarded messages just show up as regular messages. This can be confusing, but people in my circles mostly use forwarding to quickly send a message to multiple people (i.e., send long message to person A, then forward to person B, C, etc.). In that case, it doesn’t matter that it’s not marked.

Stickers

The Telegram integration even gives you an extra button for stickers.

Reactions

Working totally fine in Telegram and Messenger (haven’t checked others), but the emoji picker looks a bit odd:

Screenshot of a reaction-emoji-picker like you'd see in most chat apps, but a random subset of the emoji are rendered as unsettling black-and-white line drawings instead of full-color pictures.

Spoilers

Yep. Text marked as a spoiler/redacted works with Telegram. You can click to reveal it.

Resource usage

CPU usage seems ok, but it uses 1 GB of RAM. But then again, what doesn’t, these days? My browser uses 5½ GB.

Pricing

Texts is free for up to 10 accounts, and £12 per month if you have more. This seems fair. I don’t have 10 accounts in the app, so I’m using the free tier. But, assuming I don’t find any big issues, I’d absolutely be willing to pay £12 per month for an app like this.

Conclusion

Using Texts really does revive some of that Adium feeling from the early 2000s. I’ll keep using it for now and see how it goes.

Trying to stop my glasses sliding down my face

03 May 2024

For some reason, my glasses really don’t like staying on my face. Since this is especially bad when I’m sweating, I wanted to figure out a way to improve the situation before the summer. It looks like wrapping a hair tie around each temple, just behind the place that rests on the ear, might help keep the glasses in place a bit more.

So far this seems to work for me, and it doesn’t feel like it adds too much pressure on my head. One drawback is that now my glasses sometimes come off when I take off my headphones, but that is probably overall still better than constantly fighting the glasses.

A pair of glasses with cream-colored plastic frames sitting on a white surface. Each temple has a black hair tie wrapped around it, just behind the part where it bends.

Mostly objective things to appreciate about Python

Created: 14 Dec 2023

Modified: 27 Mar 2024

I really don’t like Python1, but I have to use it for work, and so I have set myself the goal of learning to appreciate it. This is a list of mostly objective claims about Python that I appreciate. Submissions are welcome, but I’ll only add them if I agree that they’re basically objectively true.

  • Python starts up in less than 0.1s, so it can be used for short scripts.
  • I guess it is more readable than APL or Cobol.
  • You can FFI into better other languages relatively easily.
  • It has a more complete standard library than OCaml or C.
  • Package management is easier than it used to be, I think.
  • It has lots of libraries.
  • Some apps (e.g., Blender) use Python for scripting, so knowing Python will help there.
  • It has official Qt bindings, so should be one of the easier language-choices for making little GUIs.
  • Type annotations + Pyright is better than nothing.
  • This is not really an objective thing, but I appreciate the fact that the culture has agreed to import whole namespaces (e.g. import pandas as pd, import numpy as np), so you can always tell where a function or class is coming from (e.g. pd.DataFrame, etc). This also probably helps avoid using “private” APIs: if the top of my file says from whatever import _hello, a thousand lines further down, it won’t look out of place to call _hello() (“maybe it’s just a private helper function defined in this file!”). But if you do import whatever, you’ll have to write whatever._hello(), which will stick out like a marginally sore thumb.
  • zip is a built-in function.

I’ll add more points as I think of them.

  1. I have an unfinished post titled “Unhinged rant about the Python community” explaining some of my feelings. Maybe one day I’ll publish that too. 

Words that German does have and English does not

04 Sep 2023

You’ve heard me complain about how, while people will tell you that “the Germans have a word for that”, German actually has too few words, and one thing that makes English so beautiful is its rich vocabulary.

(If you haven’t heard me rant about it, all of those “the Germans have a word for that” words are just compound words that work just as well in English – German just makes things confusing by leaving out the spaces or hyphens. (E.g., “Schadenfreude” is just “damage-joy”. It sounds weird in English, but that’s just because it’s not established as a common phrase.) This compound-word game can be a lot of fun at parties, but it doesn’t help you when you realize German doesn’t really have different words for “proof” and “evidence”.)

So, after two paragraphs of preamble, here’s the list (at the time of writing, this list has only two items, but I may extend it over the years):

  1. “schmatzen” (verb). This word refers either to the act of chewing with your mouth open, or mouth sounds that sound like it. E.g., your cat might pounce on your chest and wake you up with schmatz sounds, even though he’s not actually eating at the time.
  2. “lutschen” (verb). To lick or suck on something that is predominantly or entirely in one’s mouth, e.g. a bon-bon, lollipop, or dick.

Modifier keys are named all wrong

17 Jan 2020

The option key in macOS should be called alt like on Windows, because it is used to type alternative characters, or to run alternative commands when used in conjunction with the command key. On Windows, the alt key should be called command because you use it to move focus to the menus to execute commands. The alt gr key on Windows should become the alt key because that’s what you use to type alternative characters. The shift key should be called caps because nobody has used a typewriter in decades, and nothing is being shifted anymore. (The name isn’t perfect because you also use that key to type alternative symbols on the number row, but we already have an alt key. Maybe we could use our new alt key to type all the symbols from the number row and the number keys can produce old-style figures without caps and lining figures with – though that would require changes to unicode, so that might be out of scope for this project.) The caps lock key should be dropped entirely and replaced with an escape key that functions as ctrl or command when held down, according to user preferences. On keyboards that have one, the fn key should be renamed to something like alt-ctrl because it’s usually like a ctrl or command key, but it does different things. Maybe special would work, as a nod to the old “Special” menu in Classic Mac OS.

And while we’re renaming keys, the tab key should be renamed to shift because we make tables using the “Insert table” command, not by pressing the tab key. The tab key is used to shift text to the right, or to shift focus to the next input element. (On the other hand, ctrl + tab is used to navigate between browser tabs, but that’s one bit of elegance we can probably do without. (You can still say you’re “shifting” focus to the next browser tab, so it all works out in the end.))

Muscle memory

03 Sep 2019

Fun things I discovered about my muscle memory.

Continue reading →

Are rails partials actually slow?

04 Mar 2018

At my previous job, we were told not to use partials to clean up our view code, because each rendering of a partial would add around 10ms to the overall response time. After I was told this I did a quick test in my dev environment, but I’d never actually tested the claim on production … until today!

Continue reading →