173 TILs and counting...

Ignore commits in Git Blame with –ignore-revs-file

Today I learned that you can ignore commits in Git blame on Github with a .git-blame-ignore-revs file in the root of your repo! I’d known about the git config blame.ignoreRevsFile config option where you can point it to a file with a list of commit IDs to ignore which is especially useful for those annoying commits in a repo where whitespace was cleaned up or every tab in the codebase was replaced with spaces. You have to run the config command locally but now apparently Github does it automatically. ...

Git branch –force

Today I learned about the --force parameter of git branch which will take an existing branch and point it to a different commit. This is another handy alternative to git reset --hard for some common scenarios. For example, if I forgot to create a new feature branch and accidentally made some commits onto main, I can run the following: git checkout -b new-branch # create the new branch and switch to it git branch --force main origin/main # fix main back to what it should be vs what I would do before: ...

Find all CSS changes in Chrome DevTools

Today I learned about the Changes tab in Chrome devtools. When you’re tweaking CSS styles in Chrome DevTools, you can see all the changes you’ve made by clicking the “Changes” tab in the bottom “drawer” in DevTools. It’s especially nice because you can then copy the changes to your clipboard and paste them into your actual source file. You can open it from the command palette (ctrl+shift+p) and typing “show changes”. ...

 · 1 min · 

Javascript Array.prototype.with()

I just discovered the with() method which takes an index value and a value to insert at that index and returns a new array with the value inserted at the index. const arr = [1, 2, 3, 4, 5]; const newArr = arr.with(2, 'a'); console.log(newArr); // [1, 2, 'a', 4, 5] You could do this before with something like arr[2] = 'a' but that would modify the original array. The with() method became widely supported in 2021. Read more about the with() method and alternatives in Stefan Judis’ post.

 · 1 min · 

Awesome AZD templates

Today I discovered the Awesome AZD templates site which is essentially a curated gallery of a bunch of templates for deploying to Azure with the new Azure developer cli. There are even several for integrating with ChatGPT like ChatGPT + Enterprise Data with Azure OpenAI and Cognitive Search.

Git reset –keep

I just learned that git reset has a --keep parameter. This works the same as --hard except that it won’t discard any uncommitted changes. It’s meant to be used when we want to remove some of the last commits in the current branch but if there could be conflicts between the changes in the commits we want to remove and our uncommitted changes, then the reset is blocked. I’d been using git reset --hard and just double checking I didn’t have anything uncommitted but I’ll be defaulting to --keep except if I’m intentionally trying to clear out my changes.

Comment styles in React

I recently learned that there are actually several ways to add comments in JSX in React. I had known about the {/* comment */} syntax but didn’t realize you could use // within a jsx element: function MyComponent() { return ( <div> <Hello message="Hello, World!" // message prop requires a string /> </div> ) }

Git pickaxe

You can search through git history not only by the text of a commit message but by the contents of the diff of commits. This is commonly referred to as the git pickaxe and you invoke it with the -S parameter to git log i.e. git log -S 'public void SomeMethod and you’ll get every commit that touched that method signature or even one that deleted it. Some git clients will expose this as an option in a search field but if that fails the git cli lets you include additional filters like author or file path or even use regex with the --pickaxe-regex switch. ...

Bram Moolenaar has passed

I just found out about the passing of Bram Moolenaar, the core maintainer of Vim for the last 30 years 😞 I like what a commenter posted: Vim has soul. It is that chisel you inherited from your grandpa that you keep using. It fits well in your grip and is comfortable, even though it lacks the soft rubber that the new ones in the store have. It’s a tool with its own history. ...

Multi-line string in YAML

It turns out there are actually several different ways to handle multiline strings in YAML. I had noticed varying forms of the syntax but didn’t realize they process the strings differently. YAML multiline strings is a handy site with interactive examples of the different forms.