Weblog & site updates
This blog serves mostly as a sort of “meta log” to list updates I’ve made elsewhere on the site, with some interspersed thoughts. If you’re curious about what I’ve added since your last visit, this is the place to check.
Getting stuck on an approach
Once I start trying to solve a problem in a particular way, I find it very difficult to give up and look for an alternative approach—even though the alternative approach often ends up being much simpler.
I have an html file containing the lyrics to Radiohead’s Fitter Happier:
Fitter, happier, more productive
Comfortable (not drinking too much)
Regular exercise at the gym (3 days a week)
Getting on better with your associate employee contemporaries
Eating well (no more microwave dinners and saturated fats)
A patient, better driver
A safer car (baby smiling in back seat)
Sleeping well (no bad dreams)
And I wanted to transform it such that each word/phrase is a link to a Google search for that same word/phrase, as such:
<a href="https://google.com/search?q=Fitter&btnI">Fitter</a>, <a href="https://google.com/search?q=happier&btnI">happier</a>, <a href="https://google.com/search?q=more productive&btnI">more productive</a>
<a href="https://google.com/search?q=Comfortable&btnI">Comfortable</a> (<a href="https://google.com/search?q=not drinking too much&btnI">not drinking too much</a>)
<a href="https://google.com/search?q=Regular exercise at the gym&btnI">Regular exercise at the gym</a> (<a href="https://google.com/search?q=3 days a week&btnI">3 days a week</a>)
…and so on (let’s not worry about why right now). Of course this would be a pain in the ass to do manually, but I knew Vim would help me out.
It was clear upfront that a one-size-fits-all RegEx wouldn’t do the trick here, since some of the links need to be a single word, while some are a phrase, and there’s no obvious pattern—I need to decide for each one what I want the link to consist of.
My first approach, and the one that I got stuck on, was trying to use a visual selection in a search & replace expression. I figured that I could select a word or phrase, and then run a search & replace within that visual selection, replacing the selection with the appropriate HTML for a link to the selection. In Regular Expression terms, I’d be looking for
(.*) within the selection (in other words, the entire selection), and replacing it with
I tried to make this work for almost two hours—the issue was that I couldn’t get Vim to save the entire visual selection to a single capture group, no matter what I tried. There’s probably a way to do it, but I don’t know it. Finally, it occured to me that macros would probably provide a solution. Macros allow you to record and reply a set of keystrokes. By this point I was frustrated and ready for a break, so I took Tawny for a walk, and while walking the (easy) solution came to me:
v2e " Make any visual selection---in this case, we're selecting the next two words
qa " Begin recording a macro to register A
"zc " Yank the selection to the Z register, delete it, and switch to Insert mode
<a href="https://google.com/search?q= " Start typing our replacement string
^rz " Paste the contents of the Z buffer without leaving Insert mode
&btnI"> " Continue typing our replacement string
^rz " Again paste the contents of the Z buffer
</a> " Finish typing our replacement string
<esc> " Leave Insert mode
q " Stop recording our buffer
Now that we have our macro built, all we have to do to make the rest of the changes is select a word or phrase we want to “linkify”, and execute our macro with
Here’s the magic in action:
I was walking Tawny just a couple blocks from home when we discovered a network of trails through a wooded area that I previously had no idea about. The wooded area is only about a block and a half wide by maybe three blocks long, but it’s a secret little wilderness. This is the sort of thing only discovered on meandering walks.
Site update log
Added a feature to automatically include records of new pages and updated pages in the blog. Now the blog can really function as a log of site updates, which is cool.
It works really nicely. Sometimes it will go along time between blinks and you can have a staring contest. Sometimes it blinks twice in quick succession.
But through some quirk in the code that I don’t understand, if you don’t interact with the site for a while it defaults to the eyes-closed state, and the eyes stay closed until you interact again. It sleeps. I don’t understand how this happens—the function is written so after 150 miliseconds, the eyes should reopen. I don’t understand it, and I love it.
Sort pages by date updated
It’s been bothering me for a while that the pages on this site were sorted by the date created rather than the date updated (if there was one), so that the first created pages are always at the bottom of the list regardless of how recently they were updated. I want fresh stuff at the top! The only date that Eleventy provides out of the box is the date created—there is no concept of date modified by default. I had created a “modified” value in the YAML frontmatter for each page for display purposes, but there wasn’t a way to sort by those dates…until now!
It required creating a custom Eleventy filter that takes the supplied array of pages and sorts them by my “date modified” value, and I’m super proud of myself for getting there. It’s pretty basic stuff, but it felt good to figure it out.
Migrated site to Github Pages
Wheeee! I migrated the site from Netlify to Github Pages. More info coming on the /how page soon.
Every year passed without a house with a terrace in the sun is another year of my life wasted.
Hey, wow, I’m honored! And I hope you appreciate that on my Links page I literally just have the word “Kickscondor” because I was too lazy to turn it into a link. Heck, I was even too lazy to just type a space. And today I told a friend about your site, but I just scribbled “Kicks Condor” on a scap of paper and handed it to him. That’s gotta be worth something, right?
Hey, maybe that’s the answer. Maybe we need to take the h out of href. Maybe we need to take the hyper out of hyperlink. If someone really cares, they’ll have to manually type the words into their search engine. That’ll stop those link cowboys!
Incidentally, I’m pretty sure I can handle at least 20 links before certain destruction—so feel free to keep on linking.
Yesterday was just a gorgeous day—sunny, temps above freezing, everything melting and flowing. I didn’t get to spend much time outside, but I walked down to the liquour store to meet Caroline on her way into town (quotes for wedding booze), and I savored the walk down.
I’m spending a lot of time and having a lot of fun building this site, but I’m a little bit concerned about whether I’ll actually make content to populate it. But maybe the more excited about the site I am, the more likely I’ll be to make content for it?
Edit: Or maybe half of the value is just in the building of it anyway.
this content has moved to misc/gifs
I was thinking about how personal assistants—Siri, et al.—have almost exlusively female voices by default. I’m sure it’s because in general people tend to be less threatened by women and so are more likely to be comfortable with a woman’s voice living in their pocket. Isn’t that a little sexist though? Anyway, I changed my Siri’s voice to a male’s a few weeks ago, and my life is still fine.