180 TILs and counting...

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 have 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 · 

Import external stylesheet into a layer

I’m working on a legacy project that’s stuck on v3 of bootstrap and just loads the full minified css file. We wanted to make it a bit easier to override some of the builtin styles and figured that the new @layer feature of CSS would be perfect. I didn’t want to change too much about the stylesheets were aren’t and thankfully it turns out you can import a stylesheet into a layer: ...

Lowercase head behaves differently in git worktrees

Today I discovered that referencing HEAD in git commands should technically always be uppercase. On case-insensitive file systems you can use lowercase head most of the time and it just works… as long as you don’t use worktrees. If you use head while in a worktree then it resolves to the head of the main worktree and not the head of the worktree you’re currently in like you would expect. ...

You can use C# records in .NET Framework 4.x

Today I learned that you can use C# records that were introduced in C# 9 even if you’re not on .NET Core yet. NDepend has a post on how to do this which is slightly more involved. But per this Stack Overflow answer, all I did was add a file with the following: namespace System.Runtime.CompilerServices { internal class IsExternalInit { } } and that worked. I’ve been using them in unit tests like this post describes.

 · 1 min · 

ICS end dates are exclusive

Today I learned that per the spec, the DTEND value in an ICS file is exclusive for all-day events. It makes sense but it’s not how most people think of date ranges. I ran into this while making a small node script that takes a json array of events and generates an ICS file. This has been the most convenient way I’ve found to quickly bulk create events in Google Calendar. The only issue is the multi-day events were coming up a day short. ...

 · 1 min · 

Apply a patch file

Today I learned how to create and apply a patch file with Git. If you want to quickly create patch a file from your current changes just run: git diff > mypatch.patch or if like me you just want specific changes then stage them and then run: git diff --cached > mypatch.patch then to apply the changes all you need is git apply mychanges.patch Unfortunately if there are conflicts then git will just give you an error: patch does not apply ...