Tag: snippet

List & export your subreddits

2 minute read    Published: 2021-03-01

The last few years I've been wanting to export the list of subreddits I joined. It's fun to share with friends having a similar interest, as I've collected many gems throughout the years.

To achieve this I've set-up a simple script. It exports your subreddits to a plain text list.

Snippet: Correctly capitalize names in PHP

5 minute read    Published: 2019-07-17

When building websites with any kind of user registration, it's fascinating what people enter in name fields. no casing, Random CASING, a dozen spaces    between     words, or nospacingatall. Seeing this always irritates me, I'd fancy things to nice and be consistent.

It appears that correctly normalizing name capitalization is an unsolvable puzzle. There is no consistency in name casing, or for any kind of name formatting for that matter. See Falsehoods programmers believe about names.

I always wonder how big social networks handle this.

Okay, so this isn't solvable. But at least I could try to make it better. I came across this wonderful PHP snippet for name capitalization a while back, but it had a few shortages. It didn't correctly case with just a person's last name for instance (needed when storing first/last names separate). I love challenges like this and decided to improve, here is my take on it: