185 TILs and counting...

Github supports alerts in markdown

Today I learned that Github supports alerts in markdown using the blockquote syntax: > [!NOTE] > Useful information that users should know, even when skimming content. This is an extension to the standard markdown syntax that’s I’ve supported more and more in various markdown tools like Obsidian and vscode (they’re also referred to as callouts or admonitions).

npmpackage.info

I recently discovered this handy site that aggregates all usual info I tend to look at when deciding whether or not I want to pull in an NPM package as a dependency. npmpackage.info Some things I tend to look at: When was the last version published? How many sub-dependencies does it have? With the rise in supply chain attacks, newer packages try to minimize these with some advertising zero dependencies How much will it add to bundle size? I usually check Bundlephobia and this displays the stats from there along with everything else How widely used is it?

uv package manager

I recently came across this post, Uv has a killer feature you should know about, which led me to discover the uv package and project manager for Python. This seems to be the new preferred tool for managing python versions/dependencies as it’s faster and can replace pyenv, pip, virtualenv, and others. It just saved me some headache as I tend to mostly use python for various tools and I tried to install a package the other day with pip install but it failed with some inscrutable error. Then I realized the package wouldn’t work with python 3.13 which I’d been using — and python 3.12 was causing a sub dependency to throw warnings — but 3.11 turned out to be the lucky version which uv made it easy to setup with: ...

A single input in a form can submit

Today I learned that if you have a single text field in a form then browsers will automatically submit it when you press enter. <form> <label> Search <input type="text"> </label> </form> This is kinda handy since normally you need to add a submit button to be able to submit a form — but, you should be aware that if you add another field then you do need to add a submit button for the form to work. ...

Type check and cast

Today I learned that you can use pattern matching in C# to check for a type and cast to it in the same expression. See the docs for more details. Microsoft even has a lint rule for it. if (x is Fruit) // Noncompliant { var f = (Fruit)x; // or x as Fruit // ... } if (x is Fruit fruit) { // ... }

 · 1 min · 

setSelectionRange in Safari will focus the input

Apparently in Safari, setSelectionRange() will focus the element even when not focused despite MDN stating that “The element must be focused for the call to have any effect”. According to this bug, this is considered intended behavior even though it’s inconsistent with MDN and the other browsers. It’s worth noting though, during my testing, I noticed that Chrome/Firefox will update the selection and cursor position you just won’t see it unless you programmatically call .focus() on the element.

Stash changes in the index

I just recently discovered that Git 2.35 added the --staged option to the git stash command. This makes it easy to quickly stash only the changes that you’ve staged.

Vim sets auto marks

Today I learned that Vim has some special marks which it sets automatically: Command Description `. jump to position where last change occurred in current buffer `" jump to position where last exited current buffer `0 jump to position in last file edited (when exited Vim) `1 like `0 but the previous file (also `2 etc) '' jump back (to line in current buffer where jumped from) `` jump back (to position in current buffer where jumped from) '[ or '] jump to beginning/end of previously changed or yanked text '< or '> jump to beginning/end of last visual selection The funny thing is VsVim displays these in the gutter by default and I never knew what the symbols meant. Vscode-vim has an option to display marks in the gutter but only the regular marks and not these.

Selectively restoring changes from another branch or commit

Today I learned that you can use the --patch parameter with several git commands. The --patch parameter is probably most known for interactively staging changes from the cli, but I’ve never really used it because I find GUI clients are much more convenient for this. But apparently you can also use it with restore/checkout to grab specific changes from another branch. git restore --source=branch-name --patch This is something I haven’t seen easily done in any git client. ...

Personal git ignore per repository

Today I learned that git has a $GIT_DIR/info/exclude file can contain additional patterns of files to ignore but isn’t committed to the repository. For me this is handy for some tooling configuration files that I use personally but don’t want to clutter the main .gitignore of the repo. If there are some files that you want to always ignore, then you can specify a global ignore file in your git config with core.excludesFile. ...