algorithm
C# - Normalize Whitespace Inside String
· ☕ 2 min read
Simple task - replace all sequential whitespace (tabs, spaces, newlines) with your character of choice, usually a space. Fact - StackOverflow is on top in google results, when searching for “C# normalize whitespace”. How to replace multiple white spaces with one white space c# Fastest way to remove extra white spaces Why this article? Highest voted answers are not the best performing, and some answers are just wrong.

C# - Capture Full Stack Trace Inside Catch
· ☕ 3 min read
When you catch an exception, you only have stack trace relative to the catch point. The problem is very clearly described in this article on CodeProject: .NET: Exception stack trace has no frames above the catch point. Why is this important? Suppose the error occurs when sending email and this is a non-critical part of your application. Let’s say you send confirmation emails to clients as part of the ordering process.

PowerShell - Print All Odd/Even Lines
· ☕ 1 min read
As a little brainstormer, suppose you have a variable with the following test content. Here is how you can print all odd lines from it. Or, if you want all even lines, change the initial $f value to 1.

VB.NET - Thread Safe Progress Bar
· ☕ 1 min read
Normally, when you are using .NET built-in progress bar in a multi-threaded application without Callback tricks, you are likely to get an exception on value assign. I recently wrote a fairly simple wrapper class, which solves the problem.

PowerShell - Get MAC Address Of Any Remote IP
· ☕ 2 min read
Here is a PowerShell one-liner [...] If you need to dynamically resolve a host IP from its name [...] The whole script may look like the following [...] Because it's WMI based, computer can be from any network. But you must have necessary account permissions and firewall rules.