126 TILs and counting...

Smooth scrolling

Today I learned that you can now implement smooth scrolling purely with CSS in modern browsers. By adding the following CSS: /* Smooth scrolling IF user doesn't have a preference due to motion sensitivities */ @media screen and (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } } the browser will scroll smoothly whenever scrolling is triggered either by Javascript (with something like document.documentElement.scrollTop = 0) or by linking to elements with an internal anchor link....

January 8, 2024 · 1 min · Brandon Pugh

Easily reference upstream branch

Today I learned that you can reference the upstream branch in git with @{u}. I used this to make a convenient git alias reso for “reset to origin”: git config --global alias.reso "reset --keep @{u}" note: I’m using --keep instead of --hard because it’s a bit safer I use this when a branch I’ve pulled down has completely changed on the remote and I have no changes (for instance when reviewing a PR) and a pull would be messy (a reset is also much faster depending on the number of commits)....

January 4, 2024 · 1 min · Brandon Pugh

December 19, 2023 · 0 min · Brandon Pugh

Today I learned that Chrome is deprecating third-party cookies! I’m not sure how I’m only just hearing about this but hopefully if this directly impacts your

December 18, 2023 · 1 min · Brandon Pugh

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.

December 14, 2023 · 1 min · Brandon Pugh

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....

December 11, 2023 · 1 min · Brandon Pugh

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....

December 6, 2023 · 1 min · Brandon Pugh

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.

December 5, 2023 · 1 min · Brandon Pugh

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:...

November 29, 2023 · 1 min · Brandon Pugh

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....

November 27, 2023 · 1 min · Brandon Pugh