254 Followers
220 Following
129 Posts
I think weird thoughts and I tell weird jokes. I write for humans in several programming languages and occasionally English.

I think jumping spiders are amazing. They're the cats of the spider world, and they will interact with you if you know how to communicate with them.

They hunt by eyesight. Today a Platycryptus undatus teleported onto my monitor, and she tried to catch a mouse.

Years ago, a hardware engineer presenting the architecture of the gpu we were building:

Him: The critical processing loop stays fast by using deferred interrupts--
Me: What's a deferred interrupt?
Him: I'll tell you after.
Everyone: *laughter*
Me: Ahh. Thank you.

I can always tell when I had time to want a script or program but not time to write it. I leave myself little notes like this. Forgetting I wrote them and running into them later is a joy.

Back in 2010 or so I said that being a programmer has led me to want to be the first person to teach a computer how to feel pain.

Now it's 2023 and we can gaslight AI language models.

We're getting there.

You ever get to work and realize "oh no, I forgot my laptop?"

tfw I'm sitting in my office staring at the first of 4 2FA challenges while my phone is at home on the charger where I forgot it:

"Oh no, I forgot to bring me to work today."

Open a programming cookbook for any scripting language and you'll find "how do I tell if I'm reading from a pipe or from the console?" In ruby I mostly ignore this by reading from ARGF, but recently I needed this in plain old bash. Turns out it exists: The -t test, check it out: https://github.com/dbrady/scrapbin/blob/master/bash/pipe-or-terminal

So then I went back to ruby and thought "man, if I ran the zoo I would make this a convenience method on IO." Oh, wait. THEY DID.

$stdin.tty?

I love it when ruby's "I love you" sees me coming.

scrapbin/pipe-or-terminal at master · dbrady/scrapbin

Random code fragments and tools. Contribute to dbrady/scrapbin development by creating an account on GitHub.

GitHub

This is true even for very small values of "team". Such as just Future You, because you jammed it into your .irbrc. I've done it. I've been bitten by it. I am old and tired and nowadays I default pretty hard to the side of "just use what everybody else already expects to be there".

But sometimes... sometimes a thing is pretty and just feels right. Always remember that Symbol#to_proc started out as a blog post.

I'm just sayin'.

You might think "oh this is easy to do". NO. No it isn't.

It is easy to CODE in ruby. That's 1% of the effort.

1% is coding up `def first(n=1); self[..n-1]; end`

1% is being conscientious and coding up String#last.

18% is adding robust error detection so maintainers don't get confused by IndexError exceptions, or by "foobar".first(-2) returning "foob" instead of raising an ArgumentError.

The other 80% is convincing your team to use a monkeypatch, forcing them to remember it's not in core.

Sometimes I reach for a tool and it isn't there because it lives somewhere else. But sometimes I reach for a tool and it isn't there and I think: maybe that tool should live here?

Today I was coding and I needed the first letter of the first symbol in the first key/value pair in a hash.

`section_title = sections.first.first.first.first`

...does not work because `String#first` does not exist. Maybe it should?

`sections.first.first.first[0]` works. And is yuck because I am right. :P

OH "What is your love language?"
Me: "Ruby."
OH "No I mean--"
Me: "and then words of affirmation and then quality time. What."