Regex in .NET: Using named capturing groups to extract data

In regex, capturing groups give you a way to save text and refer to it later. Capturing groups can be named, and referred to by their name. When they aren’t named, you refer to them by their index number. In this article, I’ll show how to use named capturing groups by solving the problem of … Read more Regex in .NET: Using named capturing groups to extract data

Solving whiteboard problems to prepare for coding interviews

Companies like to ask you to solve whiteboard problems during coding interviews. If it’s an in-person interview, they’ll ask you to solve the problem on a physical whiteboard. If it’s a remote interview, they’ll either have you solve the problem on a website like HackerRank, or they’ll ask you the question in a “digital whiteboard” … Read more Solving whiteboard problems to prepare for coding interviews

Auto-increment build numbers in Visual Studio

You need to auto-increment your build numbers in order to easily tell which code you’re working with. In this article I’ll explain how to auto-increment your build numbers in Visual Studio. I’ll be using text templating to generate the Assembly Version. 1 – Choose a versioning scheme I’m going to be using the version scheme: … Read more Auto-increment build numbers in Visual Studio

Starting the Visual Studio debugger when Attach to Process doesn’t work

Problem You’re trying to debug a program with Visual Studio but Attach to Process does not work. Most likely you’re loading your code through some third-party process (like Excel), and when you try to use Attach to Process it simply doesn’t work. Solution Instead of trying to use Attach to Process, you can launch a … Read more Starting the Visual Studio debugger when Attach to Process doesn’t work

Algorithm Explained: Counting set bits in a 32-bit signed integer

Problem statement: Given a 32-bit signed integer, how many set bits are there? Ex: The number 15 has four bits set. In this article I’ll explain how I’d approach this problem. Approach How do I know if a bit is set? A bit can either be 0 or 1. A bit is set if its … Read more Algorithm Explained: Counting set bits in a 32-bit signed integer

How to mock static methods

The need to mock static methods in order to add a unit test is a very common problem. It’s often the case that these static methods are in third-party libraries. There are many utility libraries that are completely made up of static methods. While this makes them very easy to use, it makes them really … Read more How to mock static methods

Event-driven .NET: Concurrent Producer/Consumer using BlockingCollection

With the Producer/Consumer pattern you have one or more threads producing new work and enqueuing it, and one or more threads consuming that work by dequeuing it and processing it. The consumers and producers share access to the work queue. Think of it like the Post Office. You have one or more people (producers) dropping … Read more Event-driven .NET: Concurrent Producer/Consumer using BlockingCollection

‘CREATE/ALTER PROCEDURE’ must be the first statement in a query batch

Problem You have a SQL query like this: While executing this you get the following error: ‘CREATE/ALTER PROCEDURE’ must be the first statement in a query batch Solution The error message says it all: the CREATE PROCEDURE statement cannot be executed after other queries in the same batch of queries. The solution is to execute … Read more ‘CREATE/ALTER PROCEDURE’ must be the first statement in a query batch

OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory

Problem I’m trying to use Selenium with the ChromeDriver and I’m running into the following exception: Unhandled Exception: OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html Solution The simplest solution is to install the Selenium.Chrome.WebDriver nuget … Read more OpenQA.Selenium.DriverServiceNotFoundException: The chromedriver.exe file does not exist in the current directory

OpenQA.Selenium.WebDriverException: Element is not clickable. Other element would receive click.

Problem I am using Selenium to automate navigating a website. I’m trying to click a button: When I try to click the button it’s throwing the following exception: OpenQA.Selenium.WebDriverException: Element is not clickable. Other element would receive click. The reason this is happening is because Selenium is trying to click the button by its coordinates, … Read more OpenQA.Selenium.WebDriverException: Element is not clickable. Other element would receive click.