Tools cover

ripgrep: Search for a String Literal

Doing a literal search with ripgrep is easy and can be done with the -F parameter. To search for a string literal and not a regex, use: rg -F 'my string literal' Searching for a string literal is useful when you have to look for a string that ripgrep would interpret as regex (this behavior is by default). This is often the case when searching for snippets of code. For example, ...

October 29, 2024
Tools cover

jq: Validate JSON

Quick tip today. I wanted to validate my JSON file with jq. I think the common usage is to pipe text into jq but this is slow. jq has the ability to read the file directly, which is great if your json file is large. Next, we need to tell jq print out the loaded file. We use empty to not display any output. By default if there are any errors in the json file jq will output where the error is. ...

October 28, 2024
Tools cover

ripgrep: Suppress 'Access is Denied' error message

Ripgrep (rg) is a popular command-line search tool based on the popular GNU grep tool. The Access is denied. (os error 5) is a common error message that appears when trying to read a file or directory that ripgrep does not have permission to access. This can be annoying when doing a system wide search when many system directories or other protected directories may be searched, littering the results with many “access is denied” error messages. Luckily the messages can be suppressed. ...

September 10, 2024
Tools cover

ripgrep: Search Stats and Match Count

When searching through large code bases or directories, it’s helpful to get a sense of how many matches were found by your search query. While tools like ripgrep can give you the exact lines where a match was found, they don’t always provide an easy way to see the total number of hits. This is where ripgrep --stats and --count comes in. With these arguments we can get stats about what was found and results per file. ...

September 9, 2024
Tools cover

Cleaning Up Your Visual Studio 2019 Build with a Script

Clean the Visual Studio 2019 x64 Release or Debug build directory using Clean-Build.bat batch script. Place in the x64 directory and run the bat. Great if you need to archive your project before sending and don’t want to send a bunch of extra files. Tested with Visual Studio 2019 and 2022. The script can be expanded to remove other kinds of files. Files Removed File type Usage *.ipdb Incremental Link-Time Code Generation - Program database (PDB) file *.iobj Incremental Link-Time Code Generation - Object file *.pdb Program database (PDB) *.idb Intermediate debug file / state file used for minimal rebuild and incremental compilation *.ilk Intermediary linker files *.exp DLL exports *.obj Object file - compiled code that the linker uses *.tlog Used for incremental builds - information about all inputs / outputs *.FileListAbsolute.txt List of files built in current build *.recipe Used in Guidance Automation Toolkit Notes Important to use .\ before paths, otherwise it will execute from the drive’s root directory If there is more than one condition that needs to be used an if statement then must use nested if statements can use defined to check if a variable is defined or not defined if not defined. Clean-Build.bat @echo off setlocal enableextensions setlocal EnableDelayedExpansion set ExecutableName=%1% set BuildType=%2% if not defined BuildType ( echo Usage: Clean-Build.bat ExecutableName BuildType exit /b 1 ) if not "%BuildType%" == "Debug" ( if not "%BuildType%" == "Release" ( echo Usage: Clean-Build.bat ExecutableName BuildType echo Build must be Release or Debug exit /b 1 ) ) if not defined ExecutableName ( echo Usage: Clean-Build.bat ExecutableName BuildType exit /b 1 ) echo Cleaning: %ExecutableName% echo Build type: %BuildType% :: Release builds if "%BuildType%" == "Release" ( del .\%BuildType%\*.iobj del .\%BuildType%\*.ipdb ) :: Debug builds if "%BuildType%" == "Debug" ( del .\%BuildType%\*.ilk del .\%BuildType%\*.idb ) :: Both builds del .\%BuildType%\*.tlog del .\%BuildType%\*.obj del .\%BuildType%\*.recipe del .\%BuildType%\*.pdb del .\%BuildType%\*.log del .\%BuildType%\*.FileListAbsolute.txt rmdir /S /Q .\%BuildType%\%ExecutableName%.tlog echo Done

May 29, 2023