188 TILs and counting...

NPM 11.10.0 adds min-release-age

You can now specify a minimum age for installing package versions in NPM. This is a concept known as dependency cooldowns that has gained popularity with the rise in supply chain attacks. You need to be running at least v11.10.0 of npm but then you can add the following to your .npmrc file: min-release-age=7 or set it globally with: npm config set min-release-age=7 Now NPM won’t install any package version that was released less than 7 days ago. ...

Insert the last argument of the previous terminal command

Today I learned that you can use !$ in bash to use the last argument of the previous command. The simplest example is: mkdir /some/long/path cd !$ You can do something similar in powershell by using a PSReadline binding: Set-PSReadLineKeyHandler -Chord "Alt+." -Function YankLastArg

 · 1 min · 

Display git commit dates in local timezone

Most Git commands accept a --date= option with accepted values of relative, local, default, iso, or rfc to control how dates are displayed. For example: git show --date=local And as usual, if you want Git to always display dates this way then you can set it globally with: git config --global log.date local

List installed node versions with Volta

Volta is my preferred node version manager these days but the commands are a bit different to what I’m used to. volta list - show the current tool versions in use volta list node - show all the versions of node downloaded to the machine volta install node@version - use the specified version of node. It will download and install it if hasn’t before otherwise it will just select it (there is no separate use command).

 · 1 min · 

Enable markdown in Google Docs

Today I learned that you can enable markdown in Google Docs. This isn’t really full markdown support but it does make interoperating with markdown easier. The best feature is it enables the “Paste from markdown” right-click option.

 · 1 min · 

Rebuilding a 6v Power Wheels battery

We bought the “Fisher-Price Thomas & Friends Ride-On Train” for our toddler, and after some time, the battery stopped charging. It uses a Power Wheels 6V 2400 mAh NiMH battery (Model No. 1102822518 / Part No. 3900-8218). Apparently, this battery was fairly unique (and problematic) to this toy and has since been discontinued. I, of course, did not want to scrap an entire Power Wheels toy that worked just fine except for the battery. ...

 · 2 min · 

datetime-local doesn’t have full cross-browser support

I recently discovered the datetime-local input type doesn’t actually have full browser support. If you have a form value that needs both a date and time component, then you might be tempted to rely on the platform to simplify your implementation and use datetime-local to avoid needing two separate inputs, the values of which you’ll need to combine at some point. Unfortunately I don’t think it’s supported enough to be usable in most applications. ...

Splice wires with solder seal connectors

After setting the Christmas tree this, a section of the builtin lights weren’t turning on and found two of the wires had been chewed through. I didn’t want to have to throw out the whole tree so I set about fixing it. I wasn’t looking forward to it though as I thought I would have to solder the wires together and cover them with heat shrink tubing… a process that was going to be very annoying under a Christmas tree. I debated just taping them together with some electrical tape but I didn’t want to deal with it maybe coming loose while taking it in and out of storage. ...

 · 1 min · 

Fix ‘value’ does not exist on type ‘HTMLElement’

It’s common to see the error Property 'value' does not exist on type 'HTMLElement' when working with react testing library. Common advice online is to cast result using the as operator. const title = getByPlaceholderText("test") as HTMLInputElement; This is fine but feels incorrect and when using eslint-typescript will complain that the cast is unnecessary: This assertion is unnecessary since it does not change the type of the expression. Then, thanks to this SO answer, I learned that the react testing library query methods can now take an optional type parameter: ...

 · 1 min · 

Sessions don’t end when the browser closes

There seems to be a common misunderstanding about how session cookies usually work. Closing the browser doesn’t necessarily clear out session cookies because the user can have the option of “Continue where you left off” enabled for Chrome startup. Folks usually enable this if they don’t want to lose their open tabs when Chrome closes, but Chrome also continues the session so session cookies could potentially persist indefinitely. So if a user is having issues related to a site’s cookies, the most reliable solution is having them delete the cookies for this site. You can get to that fairly easily by clicking the settings icon on the left side of the address bar. ...

 · 1 min ·