RSSAmplifier

Blog

Justin James

Recent content on Justin James

digitaldrummerj.meRSS feed ↗168 posts

Latest posts

Testing Our Node Profanity Filter

In our previous post, we create a profanity filter in NodeJS but the one thing we did not do was add any automated tests. I am huge fan of automated testing so in this article we are going to use Jest to add some automated tests to our profanity filter. Install Jest npm install jest --save-dev Create Our Test Filter Create a folder called tests Create a file called profanityFilter.test.js Add the…

Create A Profanity Filter in Node

I was recently working with a client on a Q&A submission form for student assemblies that they are running and the client needed to strip out any profanity from the question submission. We decided that we want this in the API versus on the submission form itself so that the students couldn’t just open up the browser developer tools and figure out how to skirt around the filter. The API is…

Use Powershell on Mac

This post is a Mac version of a post I wrote a couple of years ago titled Take Your Windows Terminal and Powershell to the next level . Let’s walk through the steps I took to get my shell working like Michael’s on Mac. Several items need to be installed for the profile to work: Nerd Font - this is the font that provides the icons for folders and files Starship - The minimal, blazing-fast,…

Setup Streamdeck With Companion Plug-in

When using BitFocus Companion and one or more Streamdecks , you have two ways to setup Companion to interact with the Streamdecks. The first option is to use the Streamdeck natively use Companion. For this to work you do not need to install the Streamdeck software and can not have the Streamdeck software running if you have it installed. The major downside of this configuration is that you are not…

Jenkins - Automatically Versioning Your Application

In a previous post, I showed how to use GitVersion with Jenkins but unfortunately as I got further into my Jenkins usage, I was not able to get GitVersion to consistently work across pull request, tags and main branch. Several times I thought I had it working only to find out as I fixed it for one of the places I needed to use it that I broke it for the other places. It felt like I was spending…

Cypress - Scale Your Network Mocks By Centralizing Them

As your number of Cypress test grows, if you are mocking out your API calls, it can easily and quickly become hard to maintain which is exactly what happened on one of my projects. We were mocking all of our API calls so that we could focus our tests on UI behaviors and interactions. The code for the mocks was typically in each test which was fine for a few tests but now with over 1,000 Cypress…

Cypress - Creating Your Test Strategy

One of the most essential things before jumping into writing tests is to develop your test strategy. I know it sounds like a daunting task. If you are reading this post, you are most likely a developer. We developers….we just want to write code, not spend time coming up and documenting something like a test strategy. However, not having a test strategy is like driving a car in a new city…

ASP.NET Core Environment Variables With Semicolon in Jenkins

In my ASP.NET Core project, I am using an environment variable in the form of MyProject:MyVariableName and needed to create a Jenkins pipeline but I could not get it to recognize that format. It kept making the environment variable name just MyVariableName . Below is the code from the Jenkinsfile that I tried that was causing the issue. stage('Run All Test') { environment {…

Using GitVersion on Jenkins

NOTE: This article is out of date. Click here for the new article. For my continuous integration builds I use Gitversion to determine that SemVer to use for a particular build and release. For pre-release builds the version would look like something like 0.1.5-ci0004 where the -ci is appended to the version number and the 4 is the build number in the CI system. Then for a release release version,…

Use C# to Convert PNG to Base64

For something I was working on I created a quick script to convert all PNG files in a directory to a base64 representation of the image. Since I was going to need to do this multiple times as we iterated over the image designs to get one that we were happy with, I decided to write a quick script using C# and use Linqpad to run the script. For the script output, I needed to output the following…

Better Way to Manage Database Views in EF Core Migrations

When using database views that are not directly managed by Entity Framework Core (EF Core), it is a good practice to still version control and I like to do this by including the scripts to add/drop the views in an EF Core migration script. It is easy enough to use the migration builder sql method to call the sql needed to add and drop your view but as the project grows this becomes way harder to…

Xunit Create Generic Exception Tests

Using XUnit, I was creating a bunch of exception test methods that did the same exact test with the only difference being the type of exception being thrown and I thought there has to be a way to use an XUnit theory to only write a single test method and validate the various exception scenarios. Luckily, it was really easy to accomplish the goal of having a single test method that validated…

How to Setup a Development Environment for Companion v3 and ZoomOSC/ZoomISO Module

Bitfocus Companion version 3 is in beta and they have made it way easier to do module development. In this post, we are going to get your computer set up to be able to do Companion module development. This post will be broken into 3 parts: Get Companion Module on Your Computer Compile Companion Module Use Your Version of Companion Module in Your Companion Instance Pull Changes from Module Into…

Get NDI working with OBS 29 on Apple Silicon

I just got a Mac Mini M2 and needed to get OBS 29 (latest version) working with NDI but no matter what I did I kept getting the following error everytime I started OBS. Initial Install Initially, I tried the following as this is what the OBS NDI plugin recommended but it is what led to the error above. Install OBS Install the OBS NDI 4.5 Runtime Install the obs-ndi-4.10.1-macos-arm64.pkg Upon…

How to Completely Uninstall OBS on Mac

As part of troubleshooting why on my Mac Mini M2 NDI was not workign with OBS, I needed to completely uninstall OBS (application, plugins, configurations, etc) so that there was no traces of OBS on the system and then re-install OBS. Uninstall OBS Application Open finder Click on Applications Find OBS Right click on OBS and click on Move to Trash. Uninstall OBS Plugins and Configurations To…

EF Core - Configurations That Apply to All Tables

In our previous post , we split all of the entity configurations by table into their own configuration mapping file. The next step is to create a base class that all of the configuration mappings inherit from where we can put configurations that all entities should get. An example of where we will use the global configuration is the soft deletes that we implement previously where we want to…

EF Core - Split Model Configuration Into Files By Table

With EF Core, you configure your entities (e.g. tables) using the OnModelCreating in your database context. It is easy to just put all of the configurations into that OnModelCreating method which for just a few entities works great. However, as the number of entities grows, OnModelCreating easily becomes unwieldy with thousands of lines of configuration code. In this post, I am going to show you…

EF Core - Use Enum as Column Value

When dealing with databases, there are times when you want a column to only allow certain values. When using EF Core, the easiest way to accomplish this goal is to use an enum as the type for the property. In this post, we will add a new column to an entity that is of an enum type, set the default value, and create the migration script. This post uses the sample code from our previous post . You…

EF Core - Audit Fields - Track Created By and Last Updated By Values Automatically

In several applications I work on, in addition to the soft deletes that we implemented in the previous post , we also have a requirement to implement audit tracking. Audit tracking is the tracking of who created the record, the date the record was created, who was the last person to update the record, and the last updated date of the record. In this post, we will implement audit tracking so that…

EF Core - Implement Soft Delete

In several applications I work on, we have a requirement that we are not allowed to delete any data out of the database physically. Instead, when we need to delete a record, we set an IsDeleted column to true and exclude the row from our queries. In this post, we will be implementing soft deletes on an example project. This post is designed as a step-by-step walkthrough of the implementation. If…

ASP.NET Core - AutoMapper - Handle When Property Names Are Not Same Between Objects

So far in our AutoMapper series all of the property names between the input and output objects have been the same. There are times though that the property names will not match and you will need to tell AutoMapper how to map the properties else the configuration will not be valid. In this post, we will take a look at the AutoMapper configuration need to map between property names that do not…

ASP.NET Core - AutoMapper - Test Mapping Configuration

In our previous post , we used AutoMapper to convert from a entity to a view model. In our example code, it only works as expected in happy path mode where the configuration is valid and there is no way to know the configuration is not valid until we run the application. In this post, we are going to look at how with just a few lines of code, we can write a unit test to validate our AutoMapper…

ASP.NET Core - AutoMapper - Easily Convert One Object to Another

Mapping code is boring. Testing mapping code is even more boring. AutoMapper is a simple library built to map one object to another and takes out all of the fuss of mapping one object to another. In this post, we will create a sample ASP.NET Core API project, install and wire up AutoMapper, and update the sample Weather Forecast Controller to return a view model that was converted from our…

VS Code - Favorite Extension - Github Pull Request and Issues

In this series, we are looking at some of my favorite VS Code extensions. Extensions in VS Code are invaluable to speed up your work and make you more productive. In this post, we will look at the GitHub Pull Request and Issues extension that allows you to stay where you are writing your code and manage your GitHub pull requests and issues right from VS Code What is Included This extension…

VS Code - Favorite Extension - Angular 2 Switcher

In this series, we are looking at some of my favorite VS Code extensions. Extensions in VS Code are invaluable to speed up your work and make you more productive. In this post, we will look at Angular2 Switcher which provides shortcuts to switch between the TypeScript, StyleSheet, Spec, and Html files for your Angular files. Why You Need Angular2 Switcher When coding using Angular, I frequently…

VS Code - Favorite Extension - markdownlint

In this series, we are taking a look at some of my favorite VS Code extensions. Extension in VS Code are invaluable to speed up your work and make you more productive. In this post, we are going to look at Markdown Lint which provides Markdown/CommonMark linting and style checking for markdown files. Markdownlint has make my markdown output much more predictable and easier for others dev to…

VS Code - Favorite Extension - Path Intellisense

In this series, we are taking a look at some of my favorite VS Code extensions. Extension in VS Code are invaluable to speed up your work and make you more productive. In this post, we are going to look at Path Intellisense which autocompletes file names. Having intellisense as you type a path name make it so much easier to quickly import files. Demo More Details and Install You can read more…

VS Code - Favorite Extension - FoldPlus

In this series, we are taking a look at some of my favorite VS Code extensions. Extension in VS Code are invaluable to speed up your work and make you more productive. In this post, we are going to look at Fold Plus which enables you to quickly expand or collapse sections within a file. This is one of my most used extensions. What Fold Plus Does It is such a great productivity boost to be able to…

VS Code Favorite Extension Series - Add Only

Extension in VS Code are invaluable to speed up your work and make you more productive. In this series, we are taking a look at some of my favorite VS Code extensions. In this post, we are going to look at Add Only to quickly add or remove a .Only to your tests. Usage I write and run a lot of UI tests and one of the things I am constantly doing is adding and removing .only to run sets of tests.…

ASP.NET - Health Checks - Generic Endpoint

In the previous post in the series, we have implemented our health checks that return a json response and allow us to selectively run the health checks based on tags. In this post, we are going to build on the previous post and update our endpoint mappings to use a generic endpoint builder so that we only have our filters and json response code in a single place. If you have not implemented the…

ASP.NET - Selectively Run Health Checks

In part 1 we create our basic ASP.NET Core health check and then in part 2 we changed from plain text “Healthy” or “Unhealthy” to a json response that let us know the stauts of each health check. In our previous post, we have only have a single health check so it has been ok to have all health checks run when we hit our health check endpoint. However, if we had multiple…

ASP.NET - Health Checks - Generate Better Response Than Just Text

In our previous post , we added a simple health check to our ASP.NET Core application. Although we only added a single health check, you can add multiple health checks and have multiple run as once. Regardless if you run a single or multiple health checks, the implementation out of the box, just returns a “Healthy” or “Unhealthy” string, which is not overall helpful to know…

ASP.NET Core - Add Health Checks

If your ASP.NET Core application communicates with any 3rd party systems, it is beneficial to have health checks to determine if your connection to the 3rd party system is healthy, degraded, or unhealthy. With ASP.NET Core, Microsoft references Microsoft.AspNetCore.Diagnostics.HealthChecks package implicitly for ASP.NET Core apps. This means that everything you need architecture wise is available…

Hugo - Add Google Analytics

It is really helpful to understand how your site is performing with respect to which posts are getting the most views, how long are people staying on your site, where in the world they are viewing your site from and where did your traffic come from. To get analytics for this site, I am using Google Analytics which is free. In this post, we will enable Google Analytics on our Hugo site. Create Your…

Hugo - Set Default Front Matter When Creating Post

Did you know that when you create a new post in Hugo that you can set the default front matter set for you? I didn’t know either until after I had done over 50 posts where I created all of my posts files and front matter by hand. Whereas I could have had Hugo create the files for me and set default front matter that I wanted. In this post, we will look at how you can also set your default…

Git: Delete Merged Local Branches That No Longer Exist with Powershell

Previously, I wrote about how to delete git branches that have been merged and no longer exist on the remote using git bash . Using git bash worked just fine for this. However, my normal shell is PowerShell and I want to stay in PowerShell. In this post, we will look at how to use PowerShell instead to delete your local git branches that have been merged and no longer exist on the remote. Open…

Hugo - Dynamically Add Copy Code Snippet Button

I have many posts on this site that include code snippets for the reader to cut and paste into their code. From a usability perspective, instead of always making the user select lines from the code snippet to copy and paste, we can add a copy button to the code snippet. example without line numbers: example with line numbers: This post will look at how to implement the copy button, as you see in…

Hugo - Add Preview When Sharing to Twitter

When you share your blog post on Twitter, you can attach photos, videos and media experiences to Tweets, which helps to drive traffic to your site. This is called a Twitter card and looks like: There are two types of Twitter Cards that we are concerned with for our site Summary Card : Title, Description, and Thumbnail (optional) Summary Card with Large Image : Similar to the Summary Card but with…

Hugo - Add Contact Form Using Formspree

When creating your blog, it is a good idea to have a contact me form. With static sites though you do not have server side processing available to send you an email with from the contact me form submission. To overcome not having server side processing available, we are going to use Formspress . Formspree is free for up to 50 submissions per month. First thing you need to do is sign up for a…

Hugo - Create a 404 Page

Every website should have a 404 page for when a user tries to go to a page that does not exist. Hugo out of the box does not provide you with a nice 404 page but we can create a 404 page just like any other page. Creating the page though is the easy part. The hard part is getting the 404 page to display when a user goes to an invalid url as it depends on your website host to set up the 404 page…

Hugo - Minify JS and CSS

When you think about a website’s performance, you should minify your CSS and JavaScript file so that they download as quickly as possible. This still holds true even with static sites like Hugo. Luckily, Hugo can minify files out of the box using what Hugo calls Asset Pipeline . In this post, I will show you how to take advantage of the Hugo Asset Pipeline to minify your CSS and JavaScript.…

Take your Windows Terminal and PowerShell to the next level

I was watching the Bald Bearded Builder, Michael Jolley , and I had shell envy as I watched him use PowerShell terminal. His terminal showed the git status, node version, folder/file icons, cool color scheme, and predictive completion when typing commands based on his PowerShell history. I asked Michael in chat if he would be willing to share his PowerShell profile which he was nice enough to do…

Hugo - Integrate Google Search

As your site content grows, finding content will become harder and you will need to add the ability to search your content. You could create your own client search using something like lunr.js but then you have to maintain the search code and deal with any issues that come up. To me this is a distraction from the real goal of publishing content on your site. So instead, I prefer to harness the…

Hugo - Add Additional Non-Blog Pages

So far in our Hugo series we have only looked only blog related page such as posts and archives but typically you have other pages such as an about, search, or contact us. In this post, we are going to take a look at how you can add an about page. In future post, we will look at the search and contact pages. They follow the same instructions but the layout/content is much different than just a…

Hugo - Create a Post Series

When writing a blog, sometimes you want to write a multiple part posts that are meant to be read in order and you want to display to the reader that the post is part of a series, where the post is in the series and a link to get to the other posts in the series. Out of the box, Hugo does not offer the ability to display the list of posts that are part of the series. Luckily, Hugo has all of the…

Hugo - Selectively Add Table of Contents to Post

When you are doing a longer tutorial style post, it is helpful to include a table of contents that will show all of the headings in the post and link to that portion of the post. In this post, we will look at how you can selectively add a table of contents to a post. Hugo can generate a table of contents for you by including {{ .TableOfContents }} in your html templates that are in the layouts…

Hugo - Open External Links in a New Tab

For Hugo based websites, when a link goes to an external website, I prefer to have them open in a new browser tab. To accomplish the goal of opening all external links in a new tab, you need to override the Hugo default behavior for rendering links by creating the file layouts/_default/_markup/render-link.html . In the render-link.html, we need to look at the prefix of the .Destination to see if…

Hugo - Create Custom Shortcodes

In our previous post , we took a look at Hugo shortcodes which are HTML snippets that you can use as a way to extend the html that is generated by Hugo. There are several shortcodes built-in to Hugo but you can also easily create your own custom shortcodes. In this post, we are going to take a look at how to create our own shortcode. To create a shortcode you need to create a file in thr…

Hugo - Use Shortcodes Instead of Embedding HTML in Your Markdown

Welcome back to the Hugo series . In our last post, we added an RSS feed to our site. In this post, we are going to look at how to extend the output of the HTML that is generated by Hugo for a post. When creating a post, there are times where you really wish Hugo could render something fancier than the basic HTML that markdown to html provides. Maybe you want to add a caption to an image or embed…

Hugo - Create RSS Feed for Site

If you have a Hugo site, you probably already have a working RSS feed. You just might not know about it! Hugo comes with a built-in RSS Template that generates the necessary RSS XML for you. Often, this internal template is good enough, and you just need to include the feed links in the correct places. How RSS works Before, we go into some Hugo RSS specifics, I think it’s important that you know…