188 TILs and counting...

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.

Paste a URL as a markdown link

Today I learned that the latest version of VS code added a smart option to detect when you’re pasting a URL and automatically paste it as a markdown link in markdown files. You can enable it by setting the markdown.editor.pasteUrlAsFormattedLink setting to smart or always. See the release notes.

The C4 model for visualizing software architecture

Today I learned about the C4 model for visualizing software architecture. It looks like a nice framework for thinking hierarchically about the architecture of a system and how best to go about conveying it visually.

 · 1 min · 

Nominal types in Typescript

Today I learned about a pattern in Typescript called “Branded Types” which lets you create “nominal” types. Typescript’s type system is structural which is incredibly flexible and powerful when working with javascript patterns, but occasionally you want to add some extra strictness where even if the shape of the data is the same, you’ll get a type error if the name of the types don’t match (like in C# which is a nominal type system). ...

 · 1 min · 

You can save window layouts in Visual Studio

If you go to Window > Save Window Layout, it’ll save your current window layout in Visual Studio. For example, when I have to go from my monitor setup to just my laptop, I tend to set the solution explorer to auto-hide and make the Test Explorer smaller. Now I can do it with just a keyboard shortcut!

 · 1 min · 

You can easily wrap text with HTML tags

Using the builtin Emmet functionality, you select any arbitrary text or HTML and wrap it with new markup by executing the command Emmet: Wrap with Abbreviation and typing an Emmet abbreviation. I’m going to be using this all the time now! It even understands JSX so it’ll output className if you specify a css class.