a clipboard roundup

To write to the system clipboard from the command line, you can pipe to the standard input of a program. But the name of that program is different on different operating systems, because honestly so is everything.

  • Windows
    clip.exe
  • MacOS
    pbcopy
  • ChromeOS
    wl-copy, from the package wl-clipboard. This might work on other Unixy systems using Weyland for interprocess stuff.
  • Linux / XWindows
    It looks like xclip or xsel. It's weird not to have a Linux computer handy anywhere.

So an Emacs person would do M-| pbcopy to send the current region to the clipboard.

Read more…

the old and the __new__

I occasionally want to subclass str for one reason or another. A working toy example:

import colorama, enum

class ColorData(str):
    def __new__(cls, name, terminal_setup_code):
        self = super().__new__(cls,name)
        self.setup_code = terminal_setup_code
        self.reset_code = colorama.Style.RESET_ALL
        return self

    def print(self, *args, **kwargs):
        """Print text wrapped in the appropriate color codes."""

        file = kwargs.pop('file', None)
        flush = kwargs.pop('flush', None)

        print(self.setup_code, end='', file=file)
        print(*args, **kwargs)
        print(self.reset_code, end='', file=file, flush=flush)

class Color(ColorData, enum.ReprEnum):
    RED = R = 'red', colorama.Fore.LIGHTRED_EX
    BLUE = B = 'blue', colorama.Fore.LIGHTBLUE_EX
    ...

if __name__ == "__main__":
    for color in Color:
        color.print("This text is", color)

The thing is that I usually want to override __init__ rather than __new__:

class Subclass(str):
    def __init__(self, value, *args): # wrong!
        super().__init__(self, value)
        ... # do stuff with *args

This wrong code fails with the error

TypeError: decoding str is not supported

Read more…

spiders and mercy

Allowables

by Nikki Giovanni

I killed a spider
Not a murderous brown recluse
Nor even a black widow
And if the truth were told this
Was only a small
Sort of papery spider
Who should have run
When I picked up the book
But she didn't
And she scared me
And I smashed her

I don't think
I'm allowed

To kill something

Because I am

Frightened

Mercy

after Nikki Giovanni

by Rudy Francisco

She asks me to kill the spider.
Instead I get the most
peaceful weapons I can find.

I take a cup and a napkin.
I catch the spider, put it outside,
and watch it walk away.

If I am ever caught in the wrong place
at the wrong time, just being alive
and not bothering anyone,

I hope I am greeted
with the same kind
of mercy.

the significance of the three circles

In college I took a freshman philosophy class from a professor who was terrifically distractable. One day, he turned to the whiteboard to write down three points, and drew the bullets first:

Then he turned to the class, and apropos of nothing, said, "Have you ever noticed that boring people drive Fords? Whenever you see a Ford, it's being driven by a boring person." He talked for a minute or two about Fords and boring people, turned back to the whiteboard, and said, "I have no idea what these three circles mean. … They must mean that boring people drive Fords. Remember that! It'll be on the final."

Read more…

great trees

by Wendell Berry, 1934–2026

Slowly, slowly, they return
To the small woodland let alone:
Great trees, outspreading and upright,
Apostles of the living light.

Patient as stars, they build in air.
Tier after tier a timbered choir.
Stout beams upholding weightless grace
Of song, a blessing on this place.

They stand in waiting all around,
Uprisings of their native ground,
Downcomings of the distant light;
They are the advent they await.

Receiving sun and giving shade,
Their life's a benefaction made,
And is a benediction said
Over the living and the dead.

In fall their brightened leaves, released,
Fly down the wind, and we are pleased
To walk on radiance, amazed.
O light come down to earth, be praised!

the statues remain when the arguments have faded

I was reminded today of this thing I wrote in 2017, early in the first Trump administration, shortly after the violent pro-Nazi rally in Charlottesville, Virginia.

There's an image macro floating around that says we should "never remove memorials," and gives the example of the death camp at Auschwitz, which still stands thanks in part to the efforts of the few who survived there, who wanted the world to remember that such a disaster should never be repeated.

I'm all for keeping Auschwitz up as a reminder of the things that happened there. But now imagine that when you leave Auschwitz (which is kind of out in the country) and go into Myslowice or Katowice or Kraków, you find at the center of town a stone Nazi soldier, saluting from a plinth, over this inscription:

Read more…

nary a glance

Image: screenshot of text. Highlighted: "then the Glance
 overlay appears with headlines about death, war, shopping, or celebrity trivia.
 Screenshots show only black."

The "Glance" advertising tool for lockscreens on Motorola phones crosses the line from "dark patterns" to "malware." Unacceptable.

I submitted a "policy violation" complaint in addition to this dumb review, but I'm not optimistic.

Read more…

a letter!

Me: Wow, a hand-addressed envelope! With a handwritten letter on blue-lined paper inside!

Letter: would you like to be a Jehovah's Witness

an unexpected theory

Paraphrased from this interview:

NPR: Would you say there's a fingerprint, where a Pat Wilson song is different from a Rivers Cuomo song?

WEEZER/CUOMO: Well, Pat loves Mixolydian mode, where I write in major.

dag, gone

Where I grew up people would say "daggone" as a kind of mild swear word — sometimes shortened to one syllable. "You failed the test? Dag." "Yeah, it was really important." "Daaaag, that's terrible."

My partner does not know this word. Also their PNW dialect has a vowel merger where "leg/beg" have the same vowel as "lag/bag."

This person is excited about a restaurant call "Deg Thai," and I cannot figure out why the excitement is so strong that they are using a West Virginia pseudo-cuss about it.

we've languaged successfully

I've decided I mostly disbelieve in "bad grammar," and that people who write things like this grammarian's lament are doing something different from what they claim they're doing (perhaps unknowingly).

Language is a biological phenomenon that happens in meat. It's kind of miraculous that there are rules we can articulate at all. If an idea gets from my head to yours, then you and I have languaged successfully.

Read more…

not what i said

Left a voicemail at two-thirty that said "on my way, see you about quarter after." The recipient teased me for having said I would arrive at 1:15, in the past. Turns out they were reading an automated transcription, "upgraded" to use an LLM, which invented a nonsense hour and signed my name to it.

I was recently reading a discussion about how court stenographers generally do not speak African American English (AAE or sometimes AAVE) and frequently mistranscribe the words of speakers who do. What's in the transcript is the legal record, and apparently a consequence is that witnesses can be required to explain or defend remarks they did not make and whose meaning they did not intend.

Now, this mistreatment is also available to speakers of Schoolbook English! You're welcome!

i can see clearly now

Here's a really excellent weather forecast graphic that the NOAA website has been producing for ages. I haven't found anyone else who makes one as useful. To find yours, go to weather.gov (easier to remember than to bookmark), put in your zip code, and search the forecast page for the word "hourly."

Image: A plot of several different species of weather forecast, described
in detail in the main text.

I talk frequently about my wise acquaintance who says "I believe weather reports, like 'it rained.'" But if I want to dissect how much to believe a forecast, this is the best one. Let's break it down.

Read more…

wisdom from fiction

A couple of months ago I listened to Brandon Sanderson's "Oathbringer" as an audiobook. I found myself wanting to be a snob about it (there's plenty of self-important silliness), but I kept thinking "wow, that's a real banger of a line." Eventually I started scribbling them on scraps of paper, which I then promptly lost. But here's a few.

Failure is the mark of a life well-lived.

Blasphemy! Art is not art if it has a function.

Sometimes a hypocrite is nothing more than a man who is in the process of changing.

the james-stein estimator

I am reminded today by a video by "Mathemaniac" about the James-Stein estimator.

Suppose I'm trying to estimate a number $n$ of independent parameters simultaneously, by taking a sample from each one-dimensional normal distribution with unknown means $\mu_n$ and unit standard deviations $\sigma_n=1$. The naïve estimator is to use each sample $x_n$ as an estimate $\hat\mu_n$ of the mean. However, if my number of parameters is large enough, the zero-biased estimator

$$ \left(\begin{array}{c} \hat \mu_1 \\ \vdots \\ \hat \mu_n \end{array}\right) = \left( 1-\frac{n-2}{x_1^2 + \cdots + x_n^2} \right) \left(\begin{array}{c} x_1 \\ \vdots \\ x_n \end{array}\right) $$

actually produces a smaller mean-squared error on the ensemble as a whole.

Read more…

a repulsive attraction

sales photo

Found a monthly "board game club" today. Met some strangers and played Gravwell (review, amazon), which is a space-flavored racing game where the mechanic is you play cards which move you towards or away from the other players. Everybody puts down their cards at the same time, so there is a risk that other players' positions will change before it's time for you to move, and you'll move the wrong way.

Pretty fun, honestly.

in with the new

I thought it would be cute to follow last night's post with a dawn … but I slept through it. So, another dusk.

I learned the other day about sunwait, a command-line tool for predicting local sunrise and sunset times.

A sunset.

Read more…

the wide wide southern sea

Watch the reflection of the sun move from the center of the field of view to the Indian Ocean and become an ocean sunset thousands of miles across.

Then, because it's solstice season, the twilight zips around Antarctica on its way to becoming the dawn.

(source)