Bookmarks, links, snippets, reminders and lessons learned


Last updated: 31 August 2021

 

Here are some snippets and tools that I find useful, that might be worth sharing. On the Resources for being a great developer page you'll find a more general collection of useful reading.

 

GIT Commands

Some GIT commands are a little harder to remember than others, and I find myself regularly searching for some operations. Hopefully this list will help me do less searching in future! 

  • Delete remote tag

    Yes, I regularly push the wrong tag and for the life of me can't remember how to delete a remote tag.

    git push --delete origin [tag name]

    For a bonus, check out DevDocs - a useful tool (also available in offline mode if needed) when needing command references: Git on DevDocs


  • Filename is too long (Windows)

    This limitation sometimes catches me on big projects with complex long file names.

    git config --system core.longpaths true

    Taken from here: Filename too long in Git for Windows


  • Create patch files for n number of commits

    Need to merge code on unrelated branches? Or if your branches are so far removed from each other that you need to slowly and carefully apply changes to catch up, rather than a full blown merge or rebase? Patch files can be your friend!

    git format-patch -x where x represents the number of commits back from HEAD.

    Taken from here: Create Patch Files From Multiple Commits In Git


  • Some more useful tools for GIT. Check out git-imerge, a tool for step by step merging, and git-sweep, a tool for deleting branches that have previously been merged to main.


 

NuGet Notes

 

  • Re-install a package without updating

    Sometimes needed after upgrading the .Net version of a project, or messing around with code sharing between solutions.

    Run from the Package Manager Console window in Visual Studio:

    Update-Package -reinstall

    To reinstall only a single project, do:

    Update-Package -reinstall -Project ProjectName

    See How to reinstall and update packages on the Microsoft docs site.


 

PowerShell Snippets

 

  • Powershell If Not syntax

    So I'll be the first to confess that the If syntax in PowerShell is not entirely intuitive, well, to me anyway. Starting with Not

    If(-Not $something) { ... }

    There's a nice article over at Microsoft Docs All about If


  • List all personal profile locations

    Every so often I need to add or remove something from my PowerShell startup profile ($PROFILE), and for the life of me can never remember the syntax for listing them:

    $PROFILE | Format-List * -Force

    Taken (this time) from this handy article Undestanding the six PowerShell profiles on Microsoft DevBlogs


  • List all files and folders even hidden and system

    I miss the old quick dir /a options from command line. Here's how to do it with Get-ChildItem (aka dir): Use the -Force, Luke

    Get-ChildItem -Force
    or
    dir -Force

    See the Get-ChildItem documentation


  • Curl replacement using Invoke-RestMethod

    For when you need to quickly check the results of an endpoint without installing tools. Invoke-RestMethod is your friend.

    Invoke-RestMethod -Method Get -Uri $uri -Headers @{Authorization = "Basic $base64AuthInfo"; "Content-Type" = "application/json"; "Accept" = "application/json"}

    You might want to remember some common mime types:

    • application/json
    • application/msword
    • application/octet-stream
    • application/pdf
    • application/octet-stream
    • application/vnd.ms-excel (Gotcha!)
    • text/html
    • text/javascript

    What's that, you don't remember how to base 64 encode the authorization parameter?

    $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

    Invoke-RestMethod documentation on the Microsoft docs site.

    Common mime types on the Mozilla developer network.


  • See what version of .Net Framework is installed on a PC

    For .Net 4.5 onwards you can see the version of the framework installed this way:

    Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" -Name "Release" | Get-Member Release

    How to determine .Net framework version documentation

    The value grows larger with each successive release, similar to these minimum values:

    .NET Framework version Minimum value 
    .NET Framework 4.5 378389
    .NET Framework 4.5.1 378675
    .NET Framework 4.5.2 379893
    .NET Framework 4.6 393295
    .NET Framework 4.6.1 394254
    .NET Framework 4.6.2 394802
    .NET Framework 4.7 460798
    .NET Framework 4.7.1 461308
    .NET Framework 4.7.2 461808
    .NET Framework 4.8 528040

  • Check out my miscelaneous PowerShell utilities repo github.com/grahammcallister/powershellutil for more.

 

Tools

 

  • AutoHotKey

    AutoHotKey is one of those essential time savers for Windows based development or work life. You can use it to create and manage shortcuts for several commands or really almost any repetitive task. Check it out.

    AutoHotKey: www.autohotkey.com


  • Chocolatey

    If you develop on Windows and don't know about Chocolatey, please go now and install it. It's like NPM, but for Windows applications. It's a time saver.

    Read about Chocolatey here: Chocolatey.org


  • Postman

    Use this tool to save API request samples and call out to back end API's

    Postman.com


 

Windows 10

 

  • Start up program folder location

    There are always apps and utilities you need to run on startup; there are multiple ways to achieve this but a simple way is to place an item in the startup folder. If you can remember where to find it!

    In the Windows run window (Win+R) paste:shell:startup

    Add Windows startup apps from Microsoft support.


 

IPC (Inter process communication)

 

  • .Net WCF Named Pipes

    Pipes are widely used but seem to me to be not so well understood. WCF hides some complexity but also adds some of its own abstractions that can be hard to remember.

    Process Explorer from SysInternals can inspect the named pipes owned by any process.
    Chrome allows inspection of pipes by putting file://./pipe/ in the address bar.
    For a great article on how WCF names pipes under the covers: Named Pipes in WCF are named, but not by you! (Blog post)