In C# we have two ways to initialise a dictionary. While both give us a dictionary in the end, there is a small but important difference when it comes to duplicated values. Let us explore the difference.
GUIDs are great for generating unique identifiers across distributed systems, since they need no centralised coordination and are globally unique. But their randomness comes with a price tag when we use them in relational databases: fragmented indexes, slower inserts, and no sense of order.
Since .NET 9 we get an out of the box solution that fixes this problem: UUID version 7. We can keep the upsides of a GUID while we can get rid of the downsides - by just using a different method to create our identifiers. Let us explore how that works.
stringCombine(stringaddress,stringcity,stringzipCode){if(address==null){thrownewArgumentNullException(nameof(address));}if(String.IsNullOrEmpty(city)){thrownewArgumentNullException(nameof(city));}if(String.IsNullOrWhiteSpace(zipCode)){thrownewArgumentNullException(nameof(zipCode));}// Do the workreturn$"{address} - {zipCode} {city}";}
That works, but as you can see in this little example, this uses many more lines to check the data than it uses to do the work itself. Is there a better way to get this functionality?
A few months back I reviewed an application. It was sad to see in how little time you could create a mess that is not only hard to work with, but that can only be changed with a lot of effort. In this post we focus on one tiny little detail that can help you as a warning sign early on: having test code directly in the production code.
When we run Linux on a Docker container, we may not know what terminal application or shell currently runs. If we want to find out, we can run two commands to get an answer.
When we want to connect from the host system to an API inside a Docker container, we can map the port with
the -p option and then access it through localhost. So far, so good. But what do we need to do if we want
to make the connection in the reverse direction?
As I moved to a larger SSD, I had a problem: How can I move the systems partition of Windows at the end of the SSD so that I can use the free space to extend my existing C: drive on Windows?
In Windows, we sometimes run into files or folders we can not access, even with elevated privileges. The takeown tool helps us solve this problem by letting us take ownership of those files or directories. Once we own them, we can adjust permissions or grant access as needed.
If you search for a value with an _ in the name, you learn something new about SQL Server, but end up with a result that does not match your expectation:
If we run this query, we do not get back everything with an _ in it. Instead, we get back everything. How is that possible? The _ is a placeholder that stands for any character, what gives us back every row that has any character anywhere in the column we search for. That is most likely not what we try to do.
If you have two repositories with the same name in GitHub Desktop, you have a hard time to figure out which one is which:
This can happen when we need to work on a fork of the project and the original one at the same time or when we have a backup in a different folder where we need to check something but do not want to do the work in our main repository.