• Develop and test loaded PowerShell modules

    I have a slowly evolving PowerShell script, more of a set of copy-paste commands at this point, that is evolving into a full-fledged module. I’m working on this module from my usual code location, but I still wish to be able to test it as if it were a registered module.

    There are probably a few ways to do this, but here is how I’m making it work, as well as a bonus method that might be a solution for more serious PowerShell module developers. For the primary approach, we’ll make Windows think the PowerShell script file is actually in a proper module location.

  • Copy command line output to the clipboard on macOS, Windows, and Linux

    NOTE: Updated for PowerShell 7, with Set-Clipboard available to supported platforms (Linux still requires xclip).

    You’ve just figured out the exact piece of information you need from a command line call. Now, how do you get it out of your terminal and take it somewhere else, like an email, chat, or document?

    Fortunately, there are already programs out there to make this easy. You can send the output from any command to one of these applications, and the output will be available in your clipboard. From there, you can paste it anywhere you please. In the case of Windows and macOS, there are programs to do this that come with the OS. On Linux, you can install a tool to have the same functionality.

  • Determine SHA hash of file on Windows, Linux, and macOS

    While it doesn’t guarantee a download hasn’t been compromised, sometimes you feel better knowing the file you downloaded matches the expected SHA hash.

    Full disclosure here: while I haven’t been paid or provided anything for this blog post, I am only creating this post for me. If it helps you, great! I just keep looking this up every time I need it. Instead of wading through a bunch of Stack Overflow answers to find the exact magic command I need, I’m hoping I’ll start finding my own blog post in my search results.

  • Workaround: Xamarin.Android long paths on Windows

    Quick answer (TL;DR)

    Create a symbolic link from your deeply-nested folder to a shorter path using one of the following commands in an Administrator prompt.

    Command Prompt

    mklink /D {desired-path-location} {actual-path-location}
    

    PowerShell [Core]

    New-Item -ItemType SymbolicLink -Path {desired-path-location} -Value {actual-path-location}
    

    After you create the symbolic link, drag the desired solution into Visual Studio rather than navigating through the link in the Open dialog, which will override to the original path.

  • Play Japanese Famicom games with your US Nintendo Switch Online account

    If you’re looking for more retro gaming than the NES games that come free with your Nintendo Switch Online subscription, you might be interested in playing some Japanese Famicom games. Turns out you can do this without any additional cost. I’m not suggesting you load an emulator on your Switch, though that seems like an option these days. It’s not totally straightforward, but it’s not too challenging either. And it definitely won’t leave your Switch in a state where you’re afraid to let it update.

    Famicom games app launch screen on a US-based Nintendo Switch

    One warning, though. The ads on your Switch home screen now have the ability to show up in either English or Japanese.

  • Fallback variables in `dotnet new` templates

    Previously, we created our first custom dotnet new template and added our first input parameter for it. Next, let’s get a little more advanced with our parameters to make our life easier. In this post, we’ll create a template symbol that will function like a coalesce operator, taking a preferred input but falling back to a different input if the preferred value is not found.

    This is the third in a collection of posts about creating custom templates for the dotnet new system.

  • Add variables to your custom `dotnet new` template

    Previously, I covered creating your first custom dotnet new template. Now, let’s work on customizing the content our template generates based on inputs provided via the command line. I’ll be working from the same custom template from that post, which is just a dotnet new console output with its own .template.config setup. If you want a starter template project to get you going, use the template from the 1-custom-template folder from the Git repo from that blog post.

    This is the second in a collection of posts about creating custom templates for the dotnet new system.

  • Making a custom `dotnet new` template

    Why make a template

    I am a bit biased these days, but once I spin up a folder structure and/or text document manually more than twice, I give some thought to templating it. If I need to keep making more of something, the time to get all the boilerplate content in place is time taken away from the good stuff I want to write.

    This is the first in a series of posts about creating custom templates for the dotnet new system.

  • Cleaning up unused images in your Markdown content with PowerShell

    I was recently tasked with cleaning up some Markdown content with a bunch of screenshots. Sometimes as content was revised, an image would no longer be used, but the image wasn’t deleted. As a result, the images folder would often be packed with files that were no longer used in the final Markdown content.

    On a few blocks of content, I would do this manually in VS Code. From the file list (Ctrl+Shift+E), I’d select the file, copy the file name (F2, then Ctrl+C), search all the files for that file name (Ctrl+Shift+F, then Ctrl+V). This was painful to do for more than a few blocks, so I decided to turn to automation, Powershell in this case.

    PowerShell is available on Windows and Linux/macOS, so it’s great for wherever I need it. It even seems to properly translate my path separators on different platforms.

  • Adding HTTPS to WordPress with Cloudflare

    patridgedev.com with a fancy green "Secure" padlock

    With some helpful pursuasion from Planet Xamarin, I decided my blog needed to support HTTPS requests. I’ve wanted to find a way to support HTTPS traffic on my blog for a while, but I wanted to find a solution that would Just Work™ without me doing the leg work. I’ll stick to writing the blog posts and let someone else worry about hosting details.

    Just like anything security-related, setting up SSL intimidates me a bit (more so because this often involves the dark magic of DNS records). I’ll do security when I have to, but my prerequisite is always that I read so much about the topic I feel comfortable explaining every decision I make to either an expert or someone completely unfamiliar with the topic.