173 TILs and counting...

push.autoSetupRemote

Today I learned about the git config setting push.autoSetupRemote that was added in version 2.37.0. Like Tekin mentions in his post, I’ve had a git alias to do create my upstream branch but I still forget sometimes. To me this seems safe to enable by default with: git config --global --add --bool push.autoSetupRemote true and git will now set the upstream tracking branch for you!

Use the valueAsNumber property of html number inputs

Today I learned about the valueAsNumber property of html number inputs. So instead of having to parse the value like: const num = parseFloat(e.target.value) You can do: const num = e.target.valueAsNumber For example in react: return ( <input type="number" value={number} onChange={(e) => { // ✅ const num = e.target.valueAsNumber setNumber(num) }} /> ) Work With Number and Date Inputs in JavaScript

Format a paragraph

In vim you can format a paragraph of prose text with gq. This basically will hard-wrap the lines to the configured textwidth for the filetype. I use this all the time when writing git commit messages so the body of the message has the recommended max line length of 72.

Preserve case with find and replace

Today I learned that vscode has an option to preserve case with find and replace (I somehow never noticed the “AB” button before). I’ve always wanted this when having to rename an entity in a file with instances both capitalized and lowercase. I actually discovered this because I saw that this feature was just added to the latest Visual Studio 2022 preview And for vim users, there’s Vim Abolish 😁

 · 1 min · 

SVG sprites

Today I learned about the <use> element and how you can use it to create SVG sprites. It turns out that my preferred way of working with svgs in react by embedding them in the components, is not great for performance or bundle size. But as Ben Adam’s post shows, it looks like inline svgs using sprites gives you the best performance to development experience tradoff.

One-time code autocomplete

I just discovered that there is a autocomplete="one-time-code" value you can use on mobile devices where the operating system will autopopulate the field with a code that the user receives via SMS. I haven’t had a chance to test it out but it seems pretty cool and I wish every banking site would just add this one html attribute (since they seem unable to add any MFA option other than SMS). ...

–update-refs won’t update a ref if it’s currently checked out in a working directory

Today I learned that if you’re using the fairly new --update-refs feature of git to update multiple refs during a rebase, git won’t update a ref if it’s currently checked out in another working directory for that repo. This makes sense but git currently doesn’t give you any feedback that it wasn’t updated or why. It wasn’t until I tried to manually update it with a git branch --force that it told me the issue: ...

Highlight text in markdown

I just learned that you can highlight text in PR descriptions and comments on Azure devops by using the <mark> element in your markdown: <mark>Notice this!</mark> I don’t think I was even aware of the mark html element even though it’s been around for a while now.

 · 1 min · 

Specify timestamp in Google Drive video URL

Today I learned that Google Drive uses the same video player as YouTube so if you want to link to a specific timestamp in a video you can append a URL parameter like t=<number of seconds>. So to share a link to a video and have it start playing at 10:44, the URL will look like /view?t=644. A colleague also pointed out that you don’t have to calculate the timestamp in seconds — the t parameter accepts a shorthand like so t=10m44s

 · 1 min · 

Disabling browser autofill in a form

Today I learned that autocomplete="off" tends to be completely ignored by browsers these days because they seem to have the attitude that websites don’t use it correctly. Apparently the best way to prevent a browser from trying to autofill a field is to tell the browser it’s not the field it thinks it is with something like autocomplete="something-else". If it’s anything the browser doesn’t recognize it won’t try to fill it. It looks like autocomplete="new-password" is one people tend to use especially for any type="password" fields that aren’t actually meant to be a user’s login password. See this StackOverflow question for more discussion. ...