188 TILs and counting...

Collection expressions

Today I learned that C# 12 is getting some nice javascript-like syntax with collection expressions and the .. (spread operator): string[] moreFruits = ["orange", "pear"]; IEnumerable<string> fruits = ["apple", "banana", "cherry", ..moreFruits]; Note though that the spread operator is only 2 dots instead of 3 dots like in javascript.

 · 1 min · 

Local overrides in Chrome DevTools

Today I learned about the local overrides feature of Chrome Devtools that lets you “you can override HTTP response headers and web content, including XHR and fetch requests, to mock remote resources even if you don’t have access to them”. This came in handy for me when trying to debug an issue that I wasn’t able to reproduce locally. The official docs do a nice job showing how to enable the feature but just make sure you delete the override once you’re done otherwise you might wonder why the page has stopped updating. ...

 · 1 min · 

Add alt text to presentation slides

Today I learned that you can add alt text to images in PowerPoint and Google Slides by right-clicking on an image. It hadn’t occurred to me before but it makes sense that it would be as important as alt text for images on the web if you’re going to share your slides. Likewise, you should mark an image as “decorative” if you want a screen reader to ignore it. This post has some nice examples of how to write good alt text.

Display the week number in Google Calendar

Today I learned that you can configure both Google Calendar and Outlook to show the week number in the “month” view. You might find this handy for project/sprint planning — I’ve also been keeping weekly notes with the week number at the beginning of the filename.

Open a URL in vim with gx

Pressing gx while over a URL in vim will open that url. Confirmed it also works in vscode-vim.

Flow spacing and the lobotomized owl

This is another #til by proxy. A teammate asked about a CSS selector I used which has come to be referred to as the “lobotomized owl” (* + *): .flow > * + * { margin-top: var(--flow-space, 1em); } What this does is select every child element of the .flow class except the first one. You can also use newer CSS selectors to do the same thing in a way that might be more obvious: .flow > *:where(:not(:first-child)) { margin-top: var(--flow-space, 1em); } The above snippet is probably my favorite CSS utility called flow spacing. ...

Trim videos without re-encoding

Today I learned that FFmpeg is the easiest (only?) way to trim/cut a video without re-encoding it. You can specify a start and stop time like so: ffmpeg -i input.mp4 -ss 00:01:30.000 -to 00:04:05.000 -c copy output.mp4 The key is the -c copy parameter which will just copy the data frames for operations where they don’t need to be modified. This is nice because it’s way faster than decoding and re-encoding and you don’t have any loss in quality if you’re not working with a raw format. ...

The datalist HTML element

Today I learned that there’s now an HTML element called datalist that’s basically an autocomplete-like input element.

Dependency Review

Today I learned that Github has a cool dependency review feature for pull requests. If a dependency file like a package.json or .csproj has been modified, you can click on the “rich diff” button and it will list out any dependencies that changed or any vulnerabilities for those versions. It’ll even list out sub-dependencies in a package-lock.json which is otherwise pretty inscrutable.

 · 1 min ·