Using Sibling Selectors to Style the Element Before the Match

The original question for the below answer was wanting to hide a link when a button that’s next to the link has a “selected” class. This is interesting because this requires a sibling selector, but sibling selectors in CSS are a bit funky… with a sibling selector, the target element is always _subsequent_. That meansContinue reading “Using Sibling Selectors to Style the Element Before the Match”

AJAX Request Interceptor

This is a little funky script to intercept AJAX requests and raise a simple custom event for everything else in your app to listen to. To use this, you just need to listen for a custom event named `AjaxDetected`. The method, url, and any data is passed in the event detail. document.body.addEventListener(‘AjaxDetected’, function (e) {Continue reading “AJAX Request Interceptor”

Rate Limiting Googlebot Across Many Websites

Googlebot is one of the good guys. It will check your robots.txt file and respect any crawl delays you’ve asked it to use. However, if you run hundreds or thousands of websites across your infrastructure you can encounter waves of Googlebot traffic due to it coincidentally selecting many of your websites to crawl at theContinue reading “Rate Limiting Googlebot Across Many Websites”

Execute Raw SQL Scripts in Entity Framework Core

Most of the time, Entity Framework Core will just do the right thing. Every now and then, though, you’ll find that it’s doing something in a bit of a sticky way and you’ll want to take control. Usually it’s when you’re deleting a range on a table with cascading deletes. Here’s an example of theContinue reading “Execute Raw SQL Scripts in Entity Framework Core”

Simple Conditional Updates to Entities in ASP.NET Core MVC

When you accept a view model in your .NET Core MVC application, you can request that only certain fields are bound, like this [Bind(“Title”)]. Neat. But when you want to apply the changes to your domain object, you often want to do a similar thing and only update certain fields (and only if they reallyContinue reading “Simple Conditional Updates to Entities in ASP.NET Core MVC”

Use PowerShell to Send All Regex Matches to a New File

Yesterday I had to look at a list of stuff on a third-party website and match it up to a list of stuff we control. It took quite a bit of time and some Excel shenanigans to complete the task and as I know it’s going to crop up again, I decided to employ PowerShellContinue reading “Use PowerShell to Send All Regex Matches to a New File”

The type or namespace name ‘ApplicationInsights’ does not exist in the namespace ‘Microsoft’

If you uninstall the Application Insights package from a .NET Core MVC project, you might get a few errors as it can’t “remove all the references” that might have made it into your application. The changes to StartUp.cs will be pretty self-explantory, but elsewhere you will get something a bit more off-the-wall as it referencesContinue reading “The type or namespace name ‘ApplicationInsights’ does not exist in the namespace ‘Microsoft’”