Cody Casterline: Posts

Cody Casterline

Time Travel

Me, minutes before a meeting: Just one more line. One more line of code.

(15 minutes later, seeing a clock): Dangit, I'm late for my meeting.

Cody Casterline

Habits

Me: "Why do I put the cap back on my water bottle after every sip? This is annoying even to myself."

Also me: Knocks over the full bottle I just minutes before had placed between me and my keyboard and yet had somehow forgotten existed.

(Thankfully, the cap was on! 😆)

Cody Casterline

FeoBlog & Deno

For a while I'd been maintaining 2 versions of the FeoBlog TypeScript client:

  • The "main" one, in Node.js, used by the web UI.
  • A port of that code to Deno.

But maintaining two codebases is not a great use of time. So now the Deno codebase is the canonical one, and I use DNT to translate that into a node module, which I then import into the FeoBlog UI, which you are probably using right now to read this post. :)

Cody Casterline

A Phone Number is a Liability

Is it weird that I'm starting to feel like having a phone number is not worth it?

First, I use actual phone conversations VERY rarely. If I'm home and want to have a voice conversation with someone, I usually use VoIP (usually: FaceTime Audio) because it has higher quality than cell phone calls. If I'm out and about and want to communicate meeting time/place with someone, I'm going to send (or expect) a text message. So there's the question about whether it's worthwhile continuing to pay for a service that I don't use.

But the real problem is that modern apps and online services use your phone number as if it's a unique ID. If you give some organization your phone number, they'll definitely use it to uniquely identify you. Possibly to third parties.

And, even if you don't give them your phone number directly, since apps can slurp your contact info from any of your friends' contact lists, they've still got it.

And if companies can store this data about you, that data can get hacked and leaked. "HaveIBeenPwned" recently added phone numbers to their search because it's become such a concern.

If you worry about giving out your Social Security number, you should probably worry just as much about giving out your phone number. To companies or your friends.

This doesn't even touch on the problem of spam/phishing/fraudulent calls, which is another real problem w/ the phone system.

So, despite having the same phone number since 1998, I'd love to get rid of mine. Unfortunately, I can't yet because so many systems (ex: banks, messaging apps) do use it to identify you.

Plus, imagine you give up (or just change) your phone number. Now your old number is available for re-use. If someone were to claim it, they could then use it to impersonate you on any systems that haven't been updated with your new (lack of) phone number.

Cody Casterline

Happy Thanksgiving

I’m thankful for when the cat comes and gets me to come to bed, as if to say: “uh? Hey. I’m sleepy and I need some warm legs to curl up on. Can you get in bed already?” ❤️

Cody Casterline

Twitter

So recently Elon has:

  • Removed twitter identify verification (blue checkmarks are now meaningless?)
  • Shut down 2FA
  • Removed the information about what app someone tweeted from.

It sure is starting to seem like he paid a lot of money to delegitimize it as a communication platform.

Guess you can't get "cancelled" if people and bots are indistinguishable.

Cody Casterline

The weather finally got decently cold and we turned on the heat in the new house. Woke up at 3:15am broiling in my own bed. It turns out the previous owner had programmed the thermostat to go up to 75°F at some point in the night.

75!? I barely let the house get that warm during the summer! So I’m currently in the living room with the sliding door to the back patio cracked so I can cool off. 🥵

Cody Casterline

IDE Inlay Hints

Am I weird in disliking inlay hints?

They're those little notes that your IDE can add to your code to show you what types things are, but they're not actually part of your source code. For an example, see TypeScript v4.4's documentation for inlay hints.

My opinion is that:

  • for well-written code, they fill my screen with redundant noise that makes it more difficult to see the simple code in front of me.
  • for poorly-written code, they're a crutch that you can rely on instead of refactoring the code to be more readable and less fragile.

As an example, take this code:

function main() {
    console.log(foo("Hello", "world"))
}

// Imagine this function is in some other file, so it's not on the same screen.
function foo(target: string, greeting: string) {
    return `${greeting}, ${target}!`
}

If you're looking at just the call site, there's a non-obvious bug here because the foo() function takes two arguments of the same type, and the author of main() passed them to foo() in the wrong order.

Inlay hints propose to help with the issue by showing you function parameter names inline at your call site, like this:

function main() {
    console.log(foo(target: "Hello", greeting: "world"))
}

(target: and greeting: are added, and somehow highlighted to indicate that they're not code.)

Now it's more clear that you've got the arguments in the wrong order. But only if you're looking at the code in an IDE that's providing those inlay hints. If you're looking at just the raw source code (say, while doing code review, or spelunking through Git history), you don't see those hints. The developer is relying on extra features to make only their own workflow easier.

Without inlay hints, it's a bit more obvious that, hey, the ordering here can be ambiguous, I should make that more clear. Maybe we should make foo() more user-friendly?

Lots of languages support named parameters for this reason. TypeScript/JavaScript don't have named parameters directly, but often end up approximating them with object passing:

function foo({target, greeting}: FooArgs) {
    return `${greeting}, ${target}!`
}

interface FooArgs {
    target: string
    greeting: string
}

Now the call site is unambiguous without inlay hints:

foo({greeting: "Hello", target: "world"})

And, even better, our arguments can be in whatever order we want. (This syntax is even nicer in languages like Python or Kotlin that have built-in support for named parameters.)


The prime use of these kinds of hints is when you're forced to use some library that you didn't write that has a poor API. But IMO you're probably still better off writing your own shim that uses better types and/or named parameters to operate with that library, to save yourself the continued headache of dealing with it. Inline hints just let you pretend it's not a problem for just long enough to pass the buck to the next developers that have to read/modify the code.

Cody Casterline

Is Windows 11 Just This Slow?

I have a desktop gaming machine that runs Windows 11. It's not bad at games but it's so slow at things like, opening apps, opening settings, etc.

Is Windows 11 just this slow, or is something wrong?

It's so bad that I ran winsat formal to see if my nvme "hard drive" was somehow misconfigured:

image.png

Results:

> Run Time 00:00:00.00
> Run Time 00:00:00.00
> CPU LZW Compression                          1139.80 MB/s
> CPU AES256 Encryption                        15057.26 MB/s
> CPU Vista Compression                        2834.34 MB/s
> CPU SHA1 Hash                                10656.56 MB/s
> Uniproc CPU LZW Compression                  100.19 MB/s
> Uniproc CPU AES256 Encryption                986.78 MB/s
> Uniproc CPU Vista Compression                250.19 MB/s
> Uniproc CPU SHA1 Hash                        774.01 MB/s
> Memory Performance                           29614.11 MB/s
> Direct3D Batch Performance                   42.00 F/s
> Direct3D Alpha Blend Performance             42.00 F/s
> Direct3D ALU Performance                     42.00 F/s
> Direct3D Texture Load Performance            42.00 F/s
> Direct3D Batch Performance                   42.00 F/s
> Direct3D Alpha Blend Performance             42.00 F/s
> Direct3D ALU Performance                     42.00 F/s
> Direct3D Texture Load Performance            42.00 F/s
> Direct3D Geometry Performance                42.00 F/s
> Direct3D Geometry Performance                42.00 F/s
> Direct3D Constant Buffer Performance         42.00 F/s
> Video Memory Throughput                      279385.00 MB/s
> Dshow Video Encode Time                      0.00000 s
> Dshow Video Decode Time                      0.00000 s
> Media Foundation Decode Time                 0.00000 s
> Disk  Sequential 64.0 Read                   4159.90 MB/s          9.5
> Disk  Random 16.0 Read                       1007.15 MB/s          8.8
> Total Run Time 00:00:11.67

When it can read a Gagabyte per second when doing random access, I don't think the disk is the problem. The CPU is an "AMD Ryzen 7 3700X 8-Core Processor" at 3.59 GHz, which also shouldn't be a problem.

Anybody have tips beyond "LOL don't run Windows"?

Cody Casterline

FeoBlog Upgrades

Well, I started this morning fixing a minor bug in FeoBlog. But then the GitHub Action build failed which sent me down a day-long rabbit hole that ended up with me upgrading from ActixWeb v3 to v4.

It's a bit disappointing because Rust is in theory not supposed to break backward compatibility. But I guess some bits of their API leaked and then got used by libraries I was using.

Not really what I had planned for my Sunday but glad to be on newer versions of things, I guess? 😅

Cody Casterline

Cody Casterline updated their profile.

Cody Casterlinecommented

Silly me for reading this title and thinking this would have some good advice along the lines of:

  • "Bring Your Whole Self" is good in theory. Making women and minorities feel welcomed/respected in workplaces that have traditionally not done so is a good goal.
  • However, in reality, HR is not your friend.
  • Despite "Bring Your Whole Self" posturing from companies, women and minorities are still at risk of repercussion when they actually do that in ways that make their white/male/cis/het/conservative/neurotypical coworkers uncomfortable.

But no. Trust the NYT to share the viewpoint from some Old/Big Money HR Handbook:

That’s right! Defy the latest catchphrase of human resources and leave a good portion of you back home. Maybe it’s the part of you that’s grown overly attached to athleisure. The side that needs to talk about candy (guilty). It could be the getting-married part of you still agonizing over whether a destination wedding is morally defensible in These Times.

Leave those things behind and I promise: No one in your workplace will miss them.

This comes off as: "Please don't talk about anything outside of work. I would prefer to view you as a cog (or in HR terms: "resource") rather than a human being."

[BYWS] dovetails with fortified corporate diversity, equity and inclusion (D.E.I.) programs. Both purport to make employees feel comfortable expressing aspects of their identity in the workplace, even when irrelevant to the work at hand.

Comfort sure sounds nice.

"You namby-pamby youngsters! How dare you want a comfortable working environment!"

So here’s an alternative: Let’s everyone bring only — or at least primarily — the worky parts. [...] It’s that old-fashioned thing we used to call “being professional.” Heck, it’s the you you were for your entire corporate history, until the prevailing H.R. doctrine abandoned buttoning things up.

The problem is that "being professional" used to be decided by "the good ol' boys" so used to mean things like:

  • Women must wear makeup and skirts, and not acknowledge that they have families at home.
  • Black hair styles are "not professional".
  • Definitely no queers.
  • Or non-Christians.

D.E.I. & BYWS are meant to counter those.

While I'm wary of it (because companies may espouse it as a value, but then not actually follow through) I'd much rather work at a company that claims to be inclusive rather than one that doesn't!


Anyway, this is just another reminder that I need to unfollow NYT. I think I'll do that now.

Cody Casterline

Me: You should remain professional and avoid burning bridges.

Facebook recruiter: Hi! Want to use ML to moderate virtual social spaces?

Me: On second thought, …

Cody Casterlinecommented

Nobody used it because the UI wasn't surfaced anywhere.

Overwatch did a good job of making its similar feature front and center after matches. I used it all the time.

Of course if you hide a thing in a UI that no one is ever directed to, no one will use it.

Cody Casterlinecommented

“oh you’d” → Oculus

😣

The hazards of posting from a phone with autocorrect.

Cody Casterlinecommented

The hours-long splitting headache you get from playing oh you’d games? Still free! 😆

Cody Casterline

Fresh Looks Cool!

When Node became popular, I never understood the hype around server-side JavaScript, other than that it took what had before then been mostly client-side and making it usable on the server.

But the pitfalls of writing large systems on the server without type checking seemed too great. And I wasn't that fond of JavaScript at the time.

By the time I got around to playing with Node more seriously, TypeScript was a thing. In FeoBlog I wanted to write a browser-based client that would both be a nice UI and a great demo of the client/server capabilities of the system. I chose Svelte as my UI toolkit, and I very much enjoy the features it offers. However, bundling JavaScript for the browser is still a pain to get working. And if you ship everything as a Single-Page Application, you lose out on indexing, and old/underpowered browsers.

FeoBlog actually has remnants of an early server-side template system which it falls back on for that purpose, but you lose out on a lot of features, and it's lost parity with the new Svelte UI. It would be nice if I could write code once and have it render on the server OR the client.

So now I'm starting to see the appeal of server-side JS. But... I don't really want to run Node. Thankfully there's Deno, which I've already enjoyed writing some scripts for.

AND, there's a cool new web framework called Fresh. It's got the same super-fast dev cycle that I've enjoyed with Deno, and the result is code that can render things on the server OR client.

If you want to see a(n incidental) demo of Fresh, take a look at Deno Deploy: Crazy Fast Cloud Functions - Architecture Speedun, which is where I first discovered it.

Looking forward to see where this goes!

Cody Casterlinecommented

LOL. The two things Trump loves most are himself and an audience. He'll be back the second they allow him.

Cody Casterline

I do not have a kind view of anyone who brags about not voting. And anyone trying to convince you not to vote has motives you should definitely question.

… But watching the Democrats just roll over on every damned thing is really making it feel like a pointless ritual. Democracy Theater.

  • Continued and renewed efforts at voter suppression
  • Packing the supreme court
  • The timid handling of Jan. 6th insurrectionists. (Including a supreme court justice and former president!)
  • Now, their reaction to Roe v. Wade is
    • "Still not time to end the filibuster"
    • "Need more police protection for these poor SCOTUS judges!"
    • "Let's talk about something else."

They're guaranteed the vote of anyone like me who is against what Republicans are doing, so won't throw away their vote on a further-left party. But as a result they keep moving right to try to pick up more "middle" voters.

Feeling a bit frustrated and hopeless about the future for the U.S.

Just to be clear, though: I'll still be voting.

Cody Casterline

Uhh, WaPo… is this an ad for Trump? "Inaction" as democracy "came under attack"? He was and is continuing to attack democracy by continuing to lie about the legitimacy of the election. He spoke at the rally that ended up invading the capitol while the election was being finalized! And told them to do it! WTF kind of reframing is this?

This is as bad as the bootlicking "shots were fired and someone died at an altercation involving police" trope.

Screen Shot 2022-05-09 at 1.57.32 PM.jpg

Cody Casterline

I've been writing Java since before Generics and still ran into this landmine:

Coworker (reviewing my code): container.contains(null) can throw a NullPointerException.

Me: I don't think so, the docs say:

Returns true if this collection contains the specified element. More formally, returns true if and only if this collection contains at least one element e such that (o==null ? e==null : o.equals(e)).

And this code works as I expect:

import java.util.*;

public class Contains {
    public static void main(String[] args) {

        // Interestingly, List.of requires all its elements be non-null. Weird.
        // var list1 = List.of("foo", "bar", "baz");
        // var list2 = List.of("foo", "bar", null);

        var list1 = makeCollection("foo", "bar", "baz");
        var list2 = makeCollection("foo", "bar", null);
        
        check(list1);
        check(list2);
    }

    private static Collection<String> makeCollection(String... args) {
        // return Arrays.asList(args);
        return new HashSet<String>(Arrays.asList(args));
    }

    private static void check (Collection<String> list) {
        System.out.println(list.contains(null));
    }
}

Coworker: read a bit further. Docs also say:

Throws […] NullPointerException - if the specified element is null and this collection does not permit null elements (optional)

… sure enough. In my case I'm actually using a Set.of(predefined, elements), and that particular implementation will throw if passed a null.

UGHHh. NULLS.

FWIW, Kotlin handles this much more nicely:

fun main() {
    val c1 = setOf("foo", "bar")
    val c2 = setOf("foo", null)

    
    val value: String? = null
    println(c1.contains(value))
    println(c2.contains(value))
}

… though you can only depend on that sane behavior when using its setOf() constructor. If you might ever be passed a non-null-safe Java Collection you're back to needing to protect yourself against NPEs.

Cody Casterline

Roe v. Wade

So the Supreme Court is going to overturn Roe v. Wade and basically let religious fundamentalists control women's bodies.

I feel the need to write something about it.

But then the next thought is: Oh, I should take some time, really organize my thoughts, find links to sources, etc, etc. That way lies me never writing anything. "Perfect is the enemy of good [enough]", etc.

So instead, here's my stream-of-thought braindump.


First, this is terrible. It's terrible for women. Especially in states that want to ban abortion. (And even with RvW many had already effectively banned it by making it practically unavailable.) Especially poor women who don't have the means and connections to leave for more liberal states.

If the court is saying there is no right to privacy, next you'll have states start outlawing contraception.

Then they'll pass laws saying it's illegal to travel to another state to get an abortion. (I think some already exist for minors?)

Without a right to privacy, anti-sodomy laws are back on the table, and also gay marriage bans.

Without a right to privacy, the government can regulate all sorts of personal details about your life with … what limits?

The permissibility of abortion, and the limitations, upon it, are to be resolved like most important questions in our democracy: by citizens trying to persuade one another and then voting.

Yeah, because that worked out so well for slavery, and interracial marriage, and segregation, and gay marriage. And, oh, what's that? Abortion.

It's just such a big "fuck you". "If you want rights, you should merely convince the majority to stop taking them from you."

And, as I've seen others point out, that's a double "fuck you" in the context of the court recently gutting the Voting Rights Act and states ramping up voter suppression and gerrymandering.

The political process is broken and I don't see it getting better any time soon.

Cody Casterline

$OurProduct is a love letter to $audience. ❤️

Look, if you're describing something as a "love letter" and then charging money for it, that's "solicitation".

Cody Casterline

Cool flower

A803E7AA-3945-482A-A96A-005F8E7932B6.jpeg

Saw this one while out yesterday. Anybody know what kind of flower it is?

Cody Casterline

Uh-oh. "Svelte" has taken over as the language with the most lines of code in FeoBlog.

image.png

It's funny. I started FeoBlog because I wanted the data structure to be the way that distributed social networks work. But in order to make using that appealing, you've got to have a nice UI. And it turns out there's a lot involved in working toward one of those. Who knew?

Cody Casterline

Twitter

So sounds like Twitter's getting bought in a hostile takeover.

I've been working on the next version of FeoBlog and I had a couple more features that I wanted to sneak in, but I should just release what I've got. (Agile! (lulz))

If you want to help me test it, or just want to play around with an open, distributed platform let me know!

Cody Casterline

I've been working on the next version of FeoBlog quite a bit lately. It's been fun!

One of the new features will be allowing FeoBlog to remember your private key for you, since working with them can be a bit cumbersome. I enjoyed this little experimental UI for letting users configure that behavior based on their preferred security level:

SecurityLevel.gif.gif

However, it ended up being a bit cumbersome to use in practice, so I'm going to change it to instead give you all the options, and then details about the security implications of the options you set. That way, it's less about shaming the user to choose the higher security level, and more about letting them configure it how they want and informing them of the consequences.

Another of the new features is Windows support! I switched to using ESBuild instead of Snowpack. Not only is it able to properly bundle, on Windows, I think it's actually faster as well. AND I found a plugin that lets me write my web worker as a module and inline it within the app bundle. 🎉 Definitely would recommend trying it if you're deploying JS to the browser.

Cody Casterlinecommented

"The same rules apply to you and me" said the rich man to the poor, as if needing to say it out loud weren't proof that it wasn't so.

Cody Casterlinecommented

Their own article contradicts their headline:

Removing Trump from Twitter and other platforms surely spared us a year’s worth of lies and incitements to violence; it was and remains the right thing to do.

But I do agree that:

But in a larger sense, it’s clear that deplatforming Trump did little to improve the underlying political situation in this country. It seems that situation is getting worse all the time.

Cody Casterlinecommented

Not even going to click on that clickbait-y title, but:

On the one hand: Yes, his presidency is a disappointment. I wanted Warren or Sanders. I wanted stronger action against the Jan. 6th attackers & organizers. I wanted voting rights legislation.

On the other hand: I'm still quite happy that he's president vs. the alternative. And isn't that what most of us were voting for?