RSSAmplifier

Blog

Daniel Schroeder’s Programming Blog

Daniel Schroeder's Programming Blog - Sharing my tips, tricks, and code to help other developers be more productive. https://blog.danskingdom.com

blog.danskingdom.comRSS feed ↗148 posts

Latest posts

Host website PR previews on GitHub Pages for free

GitHub Pages allows you to host one static website per repository for free. The URL is typically in the format https://<username>.github.io/<repository>/, and you can use it to host your project’s documentation, portfolio, or any static content. I use it to host this blog for free, along with a custom domain name.

The part of the SDLC nobody talks about, and many companies don’t do properly

The most neglected phase of the software development lifecycle (SDLC) is often the decommissioning phase. An app has reached end-of-life, users are no longer using it, and everything should be shut down and deleted. It seems straightforward enough, but many companies overlook this phase, or do it poorly.

Easily capture terminal output from users you help remotely

When helping others troubleshoot issues with their PC, you often need to see the output of commands they run. The easiest way to do this is to synchronously video call and screen share, but that’s not always possible.

Colour your kubectl output and type less

If you work with Kubernetes on the command line using kubectl, you will appreciate kubecolor. Kubecolor is a small utility that adds colour to your kubectl output, making it easier to read and understand at a glance.

Handy Windows Command Prompt commands

Below are some handy Windows Command Prompt commands that can help you troubleshoot and manage your system more effectively.

Logitech MX Master 4 vs 3s comparison by a 40 something year old

Ever since I got the Logitech MX Master 3s in December 2023, it’s been my favourite mouse of all time, beating out my previous favourites from the 2000s, the Logitech MX510 and later the Logitech MX518, both discontinued (although there’s a newer reincarnated MX518 now).

Should observability replace custom error messages?

Open Telemetry (OTEL) and observability tools have come a long way in recent years. They can provide a wealth of information about what your application was doing when an error occurred. But can they replace good custom error messages that provide additional context about what went wrong?

My favourite Windows shortcuts

Windows has a ton of keyboard shortcuts that can help you be more efficient. Below are some of my favourites.

Create an Azure app registration secret with expiry longer than 24 months

The Azure portal allows you to create app registration secrets with a maximum expiry of 24 months. This follows the security best practice of forcing you to rotate secrets regularly to minimize the risk of exposure. However, there are scenarios where you might want a secret that lasts longer than this limit.

My favourite git aliases

Git is super powerful, but can also be confusing, especially when using the command line interface (CLI). It has so many commands, and I only regularly use a handful of them.

Reclaim disk space by cleaning all your Git repos with PowerShell

Developers often have tens or hundreds of Git repositories on their machines. When we are done with a project, we often forget to clean up the repository, leaving temporary files like build artifacts, logs, packages, modules, and other files taking up valuable disk space.

Windows settings I change after a clean install

Windows has a ton of native settings and features that can make it more pleasant and efficient to use. Below are some of my favorites that I always adjust after a fresh install of Windows. These are all personal preference, and I show the settings I like, but use whatever works best for you.

Find the assembly version of a DLL file with PowerShell

Sometimes you cannot find the assembly version of a DLL by simply looking at the file properties in File Explorer. In this case, you can use PowerShell to find the assembly version of a DLL file.

Prevent NuGet package vulnerabilities from breaking the build

TL;DR: If you enable “Treat warnings as errors” in your .NET projects, NuGet audit warnings for security vulnerabilities may break your build, but there are ways to work around it if needed.

Tech podcasts I enjoy

I started listening to podcasts in the summer of 2023, and have been enjoying them while walking my dogs or exercising ever since. I have found them to be a great way to keep up-to-date with the latest trends in the tech industry, and to get perspectives on the softer side of the tech industry, such as career advice and hearing other software developers’ stories of working at other companies, both…

Updating from System.Data.SqlClient to Microsoft.Data.SqlClient

Over the past couple days I’ve been updating a .NET 8 solution from using System.Data.SqlClient to Microsoft.Data.SqlClient. The reason for this, besides the fact that the System.Data.SqlClient NuGet package is now deprecated, is that I wanted to see SQL performance counter metrics, such as how many active SQL connections my app was using. System.Data.SqlClient supports performance counters on…

Type less by using PowerShell type accelerators

I had heard the PowerShell term “type accelerators” a few times, but never really knew what that meant. I finally decided to check out the about_Type_Accelerators docs and it turns out they’re simply aliases for .NET types.

Visual Studio has a built-in EditorConfig editor

Somehow I missed it, but for years Visual Studio has had a built-in EditorConfig editor. I would typically edit my .editorconfig file in VS Code using just text, but Visual Studio’s editor provides a nice UI for it so you don’t have to remember all the setting names.

A PowerShell function to easily retry any code

Performing retries to make your code more resilient is a common pattern. By leveraging a PowerShell ScriptBlock, we can create a function to avoid constantly rewriting the same retry logic again and again.

Common Run commands to access various Windows settings and apps

There are a lot of different windows for configuring various settings in Windows. Unfortunately, finding the right window is not always easy. The Windows Settings menu often buries settings windows several layers deep, and they are often moved between major Windows updates, so it can be hard to find them. The Start menu search functionality isn’t always consistent or reliable, especially on…

Why I switched to OTBS for PowerShell brace styling

Code formatting can be a very personal choice. Some languages are very strict and enforce specific indentation and brace styles, while many others allow for different indentation styles to be used, including PowerShell. Many languages end up with a defacto style that most people use, often because it is the default style in a popular editor or IDE. You should take care when choosing your style…

A simple PowerShell script template I use when creating new scripts

I spin up new PowerShell scripts all the time, whether just for quickly experimenting and testing things out, or for projects that I know will be around for a while. There’s a few basic things that I like all my scripts to have, so I’ve created a simple template that I use when creating new standalone scripts.

PowerShell + DevOps Global Summit 2024 reflections

I’m sitting in the airport waiting for my return flight after what has been an awesome week at the PowerShell + DevOps Global Summit 2024, North American edition in Bellevue, Washington. There’s a whirlwind of things going through my mind, so I thought I would try and capture some of them here.

Easily format all files in your VS Code workspace

I recently discovered the awesome Format Files VS Code extension that allows you to format all files in your workspace. Typically you would need to open each file in Visual Studio Code and run the Format Document command manually, but with this extension you can format all files with a single command. This allows you to easily ensure all files are formatted consistently. This is especially useful…

Find your Azure resources nearing end-of-life with the Service Retirement Workbook

The Azure portal has a Service Retirement Workbook that shows all of the services you are using which are being retired within the next few years. This could be things like having to update your apps because Azure no longer supports TLS 1.0/1.1, old versions of Node.js or .NET, or the retiring of a service like Classic Cloud Services. This is extremely helpful when your organization has many teams…

Several ways to explore your Azure resources

Here I present a few ways to explore your Azure resources, for when the portal’s search and filter functionality is not enough.

I was the guest for the 100th episode of The PowerShell Podcast!

I was recently invited to be a guest on The PowerShell Podcast (Podbean) (YouTube playlist) (Apple Podcasts). I had a great time talking with Andrew Pla, and it was a bit surreal as I’ve listened to every episode. This was my first time on a podcast, and I was very nervous. You can tell because I was talking very fast, so hopefully I was still understandable to everyone 😅.

Multiple ways to setup your CI/CD pipelines in GitHub Actions

In this post I’ll show different approaches to setting up your build and deployment workflows with GitHub Actions, as well as some pros and cons of each.

First, Single, and SingleOrDefault in .NET are harmful

I’ve wasted countless hours troubleshooting exceptions thrown by the .NET First, Single, and SingleOrDefault methods. In this post we’ll look at why these methods can be harmful, and what you should do instead.

Resolve PowerShell paths that do not exist

In this post we’ll see how to resolve a file or directory path, even if it does not exist.

PowerShell class definition pros, cons, and performance comparison

There are 3 different approaches that can be used to define classes and enums in PowerShell. This article will compare the pros, cons, and performance of each approach.

Get PowerShell tips automatically in your terminal with the tiPS module

There are a lot of great PowerShell tips out there, but we often don’t proactively look for them. It’s hard to know what you don’t know, and easy to miss out on some great tips that could make your life easier. The tiPS module can be used to display a PowerShell tip on demand, or automatically when you open a new PowerShell session, helping to broaden your PowerShell knowledge and stay up-to-date.

Easily profile your PowerShell code with the Profiler module

Premature optimization may be the root of all evil, but that doesn’t mean you shouldn’t optimize your code where it matters. Rather than guessing which code is slow and spending time optimizing code that doesn’t need it, you should profile your code to find the true bottlenecks. At that point you can decide if the code is slow enough to warrant optimizing.

Automatically create new sessions to improve PowerShell development with classes in VS Code

Developing PowerShell scripts and modules that reference classes and binary modules can be a bit painful, as in order to load a new version of the class or module you need to restart the PowerShell session to unload the old version. Having to manually restart PowerShell every time you make a change to a class or binary module gets old pretty fast. Luckily, the Visual Studio Code PowerShell…

How and where to properly define classes and enums in your PowerShell modules

I recently created a PowerShell script module that defines classes and enums. Everything worked fine locally, but broke when I tested the module on a build server. This was odd, as the module did not have any dependencies.

Inherit and extend a Blazor component, add UI elements, and hijack its parameters

In this post we see how to extend a Blazor component to show additional UI elements around it, how to override some of the default property settings, and how to hijack an EventCallback property and specify a new one for component consumers to use.

Update your terminal prompt and font in Windows Terminal, VS Code, and Visual Studio

I use Oh My Posh to improve my PowerShell terminal’s prompt appearance and show additional helpful information. There are many themes to choose from, and I have even created my own theme that you are welcome to use. Mine looks like this:

Increase system fault tolerance with the Stale Cache pattern

Caching is used to improve the performance of an application. When applied properly, caches can also help increase an application’s fault tolerance, helping to prevent outages and improve the user experience.

Use Carnac to show key presses on-screen

Carnac is a free, open source, small utility that displays the keys you press on the screen. This is great for demos, presentations, and screen recordings where you want the viewers to see what keys you are pressing.

Change these VS Code default settings to make it even more awesome

This post is a collection of Visual Studio Code settings that I think are worth changing from their default values. This only includes native VS Code settings; no extensions or themes.

Prevent Admin apps from blocking AutoHotkey by always using UI Access

When an app running as Admin has focus, you may not be able to trigger your AutoHotkey (AHK) scripts, hotkeys, and hotstrings. This is a security feature of Windows where non-elevated apps cannot interact with elevated apps.

Change the default AutoHotkey script editor

The Windows context menu provides an Edit Script option for AutoHotkey .ahk files. Unfortunately, it defaults to opening in Notepad, which is not a great editor for AutoHotkey scripts.

Run PowerShell as another user

I was looking for a way to run a PowerShell script as another user in our deployment pipeline. There are many reasons you might want to do this; for me I needed to run some commands against a database that only supported Integrated Security, not SQL logins, and thus my script needed to run as the domain user with appropriate database permissions.

Ensure Windows power settings are not slowing your CPU

My computer was sometimes very slow and unresponsive. It turned out the Windows power settings were throttling my processor speed.

Use WinGet to install and update your Windows apps

I installed all my Windows apps on my new computer with one line using WinGet.

Communicate intent more effectively with Conventional Commit and Comment messages

Conventional Commits and Conventional Comments can save you and your team time and prevent miscommunications by expressing intent more clearly. Let’s look at what they are and why you would want to adopt them.

Get IIS events from Event Viewer using PowerShell

Sometimes services hosted in IIS don’t behave as we expect and we need to dig into what’s happening. If the problem lies in your application’s code, you may need to rely on your application’s logging. You can also check the IIS logs to find requests and their response codes. Sometimes however, the problem lies underneath your application, in the server or IIS infrastructure or configuration.…

Find which Windows process has file in use

When a file or directory is in use by a process (application), you will not be able to delete or modify the file / directory. Unfortunately it’s not always obvious which process is using the file. Luckily, there is an easy way to find out without the need of 3rd party tools, which is what we’ll look at in this post.

Master the Windows copy-paste clipboard

Copying and pasting is a common task that pretty much everyone does. Becoming more efficient with it is a great way to improve your productivity.

Reasons to use both a local and global editorconfig file

What is EditorConfig