Toby's Log page 86

Quick regex to strip html tags

Recently, I needed to strip some HTML tags from some data. The goal was to make a field in a database that was a WYSIWYG text area into plain text content that could go inside a link. I did it using a simple regex of /<\/?[^>]+>/ to find the tags so I could replace them with an empty string. In PHP, this looked like:

$string = preg_replace('/<\/?[^>]+>/', '', $string);

This is perhaps a naïve implementation, but it served my purposes fine. Of course, I had totally forgotten about PHP’s built in strip_tags() function, but on comparing it, it also seems to not do exactly what I want. For instance, it seems to get rid of the content of <a> tags.


I was relieved today (yesterday) to find out that a document from my health insurance company that said something about a claim being denied did not mean I owed $700+ dollars for some minor blood tests I got last year.


Abstractions: interfaces as lists, details, and flows

I read a post recently of Dave Rupert lamenting that he can describe any digital interfaces as lists, details, or flows. This is, of course, an abstraction. Abstractions can be useful for reducing complexity and making things understandable. In code, they also can be used to reduce duplication and provide reason for limited responsibility, improving maintainability. But if everything is fit into a small number of buckets, it can certainly make it seem like there is a lack of diversity, a sameness to everything.

With any good abstraction, everything can fit into it with a certain level of mental effort. Some might be more willing to go further than others to make a given classification work. In code, too heavy abstraction can lead to a given abstraction trying to do too much, or conversely, functionality being limited to fit a simple concept of the abstraction.

Continue reading post "Abstractions: interfaces as lists, details, and flows"

Long day downtown today (yesterday). I took the day off for the Cavs parade, then went to an Indians game after. I may post more later, but to summarize: packed rapid transit, lots and lots of people, lots of waiting, lots of sun, hot, lots of walking, lots of garbage, saw a few Cavs players from afar, kinda heard some speeches, confetti and loud fireworks, saw people running from what turned out to be gunshots, large colorful animal statues, kid running across baseball field and climbing home run wall to escape into stands.


Woo, the Cleveland curse broken after 52 years. Such a close game all the way to the end. Stressful, back and forth. Worked out that the Cavs were ahead at the end. A battle. Something for the Cleveland 52 years in the making. Don’t know if this will change things for the future of the city and area, but it at least changes something of the feeling that being a Clevelander / Northeast Ohioan is.


Cavs

I think I’ve watched or listened to more basketball this playoff season than in any previous entire season. Last year I watched the finals but this year I’ve been more into it. It has been surprisingly time consuming, especially when I get caught up in the pre-/post-game news and speculation. It has been rather stressful, even when the Cavs win, especially these finals. It is easy to get caught up in the game and want the local team to win. It can feel like their identity is part of my identity and their success is part of my success, in part because of the city’s renowned “Cleveland curse” and broader “rustbelt” identity against a desire for the area to succeed. I sometimes have to remind myself that their game is not my game and their success is not my success. It can feel great when they succeed and might have an influence on the city’s morale, but it is unrelated to success in my own life. Just watching the games has been entertaining, some of the plays and records broken have been exciting, and so has how far the Cavs have come against expectations. If they lose game 7, I think it was still worth it to watch. That said, I do hope the Cavs defy the odds and finally break the “Cleveland curse”. Go Cavs.


</toby>