The Blog

Clean Architecture in .NET Core 3.0 by Jason Taylor

This video is truly one of the best ones I've ever seen. I am not fully sold on using EF Context everywhere. There are quite a few databases (e.g. MongoDB, ElasticSearch) that do not have an EF Driver. However, since .NET Core has amazing support for integration testing and each handler is nicely isolated, so

Continue Reading

ToByteArrayAsync() - a more 'efficient' approach to converting Streams

Frequently, there is a need to convert a stream into an array of bytes. I came across this problem when uploading files in ASP.NET Core. StackOverflow has certainly a number of answers. In most cases, these answers require copying the array, which is no longer needed. .NET Core 2.0 introduced the concept of Span<T> and

Continue Reading

Select Multiple Properties using Linq - Fun C# Code #3

C#'s Linq is an simply amazing. However, as far as I know, there is no built-in ability to select multiple fields (of the same type) and return them, so here you go

Continue Reading

ASP.NET Core - Optimisation Hacks

Google has developed a tool called PageSpeed. It highlighted couple of quick wins I could do to improve website's loading time. Website loading times are one of the most deceptive metrics to measure during development. Website development is frequently done on a local machine when download times are neligiable. It is only once the website

Continue Reading

ConcurrentDictionary - Get Snapshot and Clear - Fun C# Code #2

Recently, I was asked to write a 'real-time' calculator and the output value was to be stored in Redis. For legacy reasons, it also had to be stored in the database though, only the latest value had to be kept. As the calculator was spewing values, they were stored in a ConcurrentDictionary. When the timer

Continue Reading

Fun C# Code #1 - Infinite Delay (until cancelled)

I came across this code when reading 'Concurrency in C# Cookbook' by Stephen Cleary. Did you know you can have an infinite Task.Delay without loops?

Obviously, there isn't much point in spinning a task that litterally will do nothing. You can use a CancellationToken to cancel the task.

No point. It's just one

Continue Reading

Customise Semantic-UI

Semantic UI appears to be no longer under active development. However, thanks to the Open Source community it is still getting deveoped by under a different name - Fomantic UI. I never had the need customise Semantic-UI. I only ever used it within internal apps and it worked well. Recently, I decided to use it

Continue Reading

How to change time-zone on Ubuntu servers?

Servers US tend to be considerably cheaper in US than in Europe. This has its drawbacks, not least of all, your application will be reporting wired times for various events. However, this is something that can be easily fixed on Ubuntu servers. Our goal is to change date from EST to GMT:

I am

Continue Reading

How to select the active links using jQuery

There are numerous ways in which one can add active class to a link. One way is to use if statements to do so. Modern JS frameworks such as Angular, React and VueJS support route-link  designed to manage routes in the application. The same effect can also be achieved with jQuery. It is certainly a

Continue Reading

Maintaining user session on msdeploy in ASP.NET Core (in SQL Server)

Using TeamCity, Bitbucket and msdeploy, I have been able to develop a satisfactory CI process for my web apps. However, I found that whenever an application was deployed to production, the user sessions would expire. Initially, it was not a big issue, but as the number of users grew so did the issue. We want

Continue Reading