173 TILs and counting...

Press ctrl+enter to submit a comment on Azure DevOps

Pressing ctrl+enter in a comment field on Azure DevOps will submit the comment! For some reason, this isn’t listed on their keyboard shortcuts page but it’s so much nicer than using the mouse or pressing tab four times.

 · 1 min · 

Git Extensions git client

The Git Extensions git client is actually pretty powerful and has a lot more features than I thought. I’d seen others using it before but never looked into it until I saw a StackOverflow answer suggesting to use Git Extensions to view the git reflog… a feature I’ve only ever seen in Smartgit. Some nice features I noticed while playing with it for a bit: View commits from the reflog in the log view (makes it really easy to recover commits) Option to view First Parent only in the log view Stage individual lines Option to launch external editor for commit message The commit message window can autocomplete file names Show/Filter any number of branches in the log view Windows file explorer integration Completely free and open-source and cross-platform I think I still prefer Smartgit over Git Extensions but it’s tough to recommend Smartgit since it requires a license for Commercial use so I’m always keeping an eye out for good free options to recommend to others and now Git Extensions is my new recommendation (much better than SourceTree).

Strong typing with JSDoc and Zod

You can get pretty good type checking in Javascript with just JSDoc comments and an editor like VS code or Visual Studio. You’ll get most of the same intellisense and warnings in your editor as you would with Typescript. Combine this with a library like Zod which can infer validation schemas from your types and you’ll have runtime checking also! See: https://blog.jim-nielsen.com/2023/types-in-jsdoc-with-zod/ https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html

 · 1 min · 

Visual Studio 2022 can stage individual lines in git

Visual Studio added support for staging to commit individual chunks of changes (also known as interactive staging). This essentially lets you commit only parts of the changes you’ve made to a file or easily undo those changes. This is probably my most-used feature in a git gui client. One caveat, it took me a minute to figure out how to use it in VS because if you have an external diff tool configured in git then clicking to view the diff in VS will open that tool instead of the VS diff viewer. But you can also stage lines by clicking on the margin annotations: ...

 · 1 min · 

Use the Chrome devtools recorder to automate UI testing

Chrome devtools has a pretty decent recorder feature that can record and playback your UI interactions. It’s currently in preview but it’s been working well for me so far. It’s especially handy if you have to keep repeating the same 5 steps every time you reload the page to test your code. It automatically waits for UI elements to load and it’s pretty easy to tweak the recorded steps and export as a puppeteer script: https://developer.chrome.com/docs/devtools/recorder/

Run a bash script from Powershell

You can execute a bash script from Powershell on Windows by typing bash if you’ve enabled WSL. For example bash ./new-til.sh. Some caveats though: Make sure you use / instead of \ in the file path Make sure the bash script was saved with unix line-endings You can also make a wrapper script for scripts you regularly execute like new-til.ps1: bash ./new-til.sh $args If you don’t or can’t enable WSL, you can use sh.exe that’s optionally installed with Git for Windows. For example sh ./new-til.sh ...

Create new files faster

You can use ctrl+shift+a to open the new quick add dialog in VS 2022: https://devblogs.microsoft.com/visualstudio/adding-new-files-just-got-a-lot-faster/

 · 1 min · 

Hide a table in sql server management studio

Apparently in sql server you can mark any table as a system table using EXEC sys.sp_MS_marksystemobject and then Management studio will hide it automatically. I ran into this because the docs say that Entity Framework 6 stores its code-first migration snapshots in a table called __MigrationHistory but I couldn’t find it because it’s hidden since it’s marked as a system table.

Use ChatGPT to explain bash scripts

Today I learned that chatGPT is pretty good at explaining cryptic bash scripts and commands. I was trying to understand exactly how a git prepare-commit-msg hook was working so I asked chatGPT to “explain the following git hook to me” and it did a pretty good job. For example, it returned tidbits like: [[ $BRANCH_NAME =~ $BRANCH_REGEX ]]: This conditional statement checks if the branch name matches the BRANCH_REGEX pattern. If the branch name starts with one or more digits, this condition will be true. and: sed -i.bak -e "1s/^#${BASH_REMATCH[1]}: //I" $1: This line uses the sed command to replace the branch number (captured by the BRANCH_REGEX pattern) and a colon at the beginning of the commit message with an empty string. The I flag makes the replacement case-insensitive. The -i.bak option creates a backup of the original commit message file with a .bak extension. ...

Use a table variable to hold a list of values

You can store a “list” of values in sql with a table variable. DECLARE @listOfIDs TABLE(id INT); INSERT INTO @listOfIDs SELECT id FROM Transactions WHERE USER='bob';