Web pages are marvelous beasts that can be rendered at any pixel width on all sorts of devices. Designs on the other hand tend to be done at 1 or 2 sizes where text is hardcoded and can be placed with exacting precision. As a result, it’s a common scenario to build something that looks…

like this on desktop:

full width headline

like this on mobile:

mobile width headline

and then like this at some in-between browser size:

mobile width headline

Usually some sort of dance ensues where the designer asks how to prevent that awkward single-word line break and the engineer says that it’s a responsive design and we can’t account for every potential width for line breaks.

If you dig into CSS options, there’s a morbidly named, but promising sounding feature for “widows & orphans”, but that’s mostly just for column layouts and instructs on whether to have a whole paragraph show in a new section or not.

I’ve been using a solution for this for years with the following CSS class that utilizes the white-space property:

.nowrap {
    white-space: nowrap;

And then in any text that I want to target, I just wrap the last two words in a span with this class:

    The best thing since <span class="nowrap">sliced bread!</span>

This makes anything inside it stick together and get treated like one word. As long as you’re not putting too much stuff inside it that might overflow its container, then you should be good to go.

You can get more surgical by combining this idea with media queries, but it’s best to keep things as simple as possible until you need something more!

cooking as code

The busy New Yorker who never cooks and lives off of takeout is definitely a thing. During the pandemic, I‘ve made a point to spend more time learning to cook meals beyond breakfast and pasta.

Initially I made the mistake of being too much of a software engineer about it all. Computers are exacting, compilers require that code actually compiles, code formatters make everything consistent. Additionally, code can live forever and often needs to be architected to scale. I would make all my measurements as exact as possible to the recipe, I’d scrape every last bit of sauce out of a bowl or can, the timer was precise, I’d agonize over what exactly was medium-high on the range.

In contrast, one of the beauties of cooking a meal is that it’s consumed exactly once (if not over a night or two as leftovers). There’s no build up of technical debt, because the product is gone. Since you have to make it each time, being proficient is necessary and it’s OK that you didn’t spatula every last drop out of that can of tomato paste. You also learn that the measurements and times are really just guidelines, as if the cookbook is shrugging at you with a smile as you read its directions (I am aware that baking is a different story…)

With the above realizations and some foundational knowledge—such as preparing & cooking chicken, cooking rice—I was able to transform cooking a dinner from a daunting task into something I could enjoy.

If I had to try and compare cooking and coding, I’d say it’s more like a hackathon than building a real application—time is a real constraint, the product isn’t meant to be something that lasts, however it is meant to delight people. I sometimes fall into the trap of being a tech person trying to force their understanding of the world into matching tech, but maybe I can just enjoy cooking as the wonderful, completely different, and essential thing it is!

Bonus - for a cookbook that really embraces the approach I described above, I’ve had great success as well as some learning moments with a number of recipes from the NYTimes No Recipe Recipes cookbook.

A helper function in Python for escaping variables in formulas when calling the Airtable API. read full post…
Sometimes when you’re given a Google Sheets file from another person, it’s unclear which cells are meant to be inputs and which aren’t without clicking around and inspecting the sheet. Here’s a trick to expose likely inputs by using conditional formatting. read full post…
A quick look into the Stripe API with the Subscription status enum, and how to understand the differences between the values. read full post…

Peter Coles

Peter Coles

is a software engineer living in NYC who is building Superset 💪 and also created GoFullPage 📸
more »

github · soundcloud · @lethys · rss