How to test serialization and deserialization

Newtonsoft.Json is the most popular package in 2019 yet. Because of a need to send data across different applications: browser client app or mobile app, .NET app or Node.JS server-side app, etc. They all must communicate with each other so there is only one way to go is serialization/deserialization. Since...

Sign-in via Keybase PGP key

Wandering through the Internet I have found an interesting question about Single Sign-On via Keybase. The idea behind this started to hold me tight so I decided to experiment to see how hard or easy it can be done. For the sake of simplicity, I have to skip OAuth ceremony...

@Html.Raw(json) cross-site scripting trap

Often, in ASP.NET & JavaScript apps it is required to pass the server-side model to client-side without AJAX requests. For that, the server-side model is converted to JSON and puts somewhere in JavaScript. You know that. Let’s have a quiz. What the following ASP.NET MVC Razor view will show? @using...

What is inside PGP signature?

Before a deep dive into PGP signature, I will give you a promise so you can trust all my word afterward :) -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 I Promise that, to the best of my ability and judgement: 1. I will not produce harmful code. 2. The code that...

End-to-end encrypted chat on JavaScript

As a starting point for adding end-to-end encryption, I’m going to choose minimalist chat written on bare .NET Core and JavaScript without any third party dependency. Let’s move from theory to implementation, but before that, I would like to give a bit of introduction in end-to-end encryption. What is it?...

Chat on bare .NET Core and JS via server-sent events

For a long time, I want to play with server-sent events. It seems simple and powerful technology to send out updates from a server to a client with minimum latency. Traditionally, a web page has to send a request to the server to receive new data; that is, the page...

Searching for heavy T-SQL queries

At some point, you may start to see high CPU load on the SQL server, in my case, it happened after yet another release. So how quickly is it to find such SQL queries? Of course, I can review all changes that were released but I would say it is...

Lightning-fast deployment of .NET Core app over SSH

Once in a while, I want to try some idea to implement. Having background by developing mostly in .NET stack my choice is obviously .NET Core. I always have at hand couple of Linux servers: one is in DigitalOcean, another one is MSI Cubi N under my TV set. Hence,...

Partially committed transaction trap via .NET and MS SQL

At some point, on the project where I’m working on we were starting to observe strange exception. The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION Which has even more strange stack trace, pointing to Dispose method of TransactionScope. System.Transactions.TransactionAbortedException: The transaction has aborted. ---> System.Data.SqlClient.SqlException: The COMMIT TRANSACTION request...

Partial password usability sucks

Nowadays, in order to use a service, you must provide a login and password. In Poland, I got acquainted with a partial password instead of a regular password. A partial password is a mode of password authentication. By asking the user to enter only a few specific characters from their...

Readable NUnit test cases

A test case is a specification of the inputs, execution conditions, testing procedure, and expected results that define a single test to be executed to achieve a particular software testing objective, such as to exercise a particular program path or to verify compliance with a specific requirement. — Wikipedia Simply...

100 LoC console app vs Google Alerts

It is priceless to be up-to-date and at the same time, it’s challenging due to the massive amount of information generated per second. Currently, you should look for information via search engines, for instance, Google Search. I would like the information is finding me! Google Alerts is awesome. The idea...

Self-documented state machine via PlantUML

A state diagram is a type of diagram used in order to describe the behavior of an entity. For instance, here is the example of an elevator made with the help of PlantUML. The elevator can be in Stopped or Moving states, where a transition between them is a result...

The state pattern using Entity Framework

Have you heard about if-then driven logic? Or maybe something about switch driven logic? Aha, you have even seen it. Me too. Moreover, I keep seeing such logic quite often. Despite the fact that state pattern is known for decades from the Gang of Four, developers simply ignore it. Let’s...

Akka-like state machine

Akka.NET actor has really brilliant feature - switching behavior using Become() method. Look, how expressive it is (borrowed from here). How easy to navigate through the code, just Go to Declaration, because a state is a method. Love it! class LightSwitchBehaviourActor : ReceiveActor { public LightSwitchBehaviourActor() { TurnedOff(); } private...

Adding custom data to an exception for logger

Looking at an error log, it is not obvious how to reproduce an exception just by inspecting stack trace or error message. Of course, if you are super smart or lucky you can guess or try to catch the bug, however, it is not always possible. Usually, I need more...

Self-documented system via PlantUML

How does it work? What’s going on here? I usually have such impression while looking into an unfamiliar piece of source code. It can be even worse, for instance, in event-driven systems due to a low level of coupling, or in the microservice world when you are having a huge...

Text to UML diagram via PlantUML

From time to time, I feel like a dog: understand everything but can’t explain. So draw it! Or I need to understand how a feature supposed to work but it does not fit in my brain. So draw it, come on! Or it is a huge challenge how to explain...

Process manager as async function in C#

Once I’m thinking about CQRS, event sourcing and messaging my heart starts beating very fast. I will share my love and pain in this regard. I’m a huge fan of messaging and how great it is to communicate between applications via messages. Simple from the first sight but hard when...

How to alert on long-running SQL queries in .NET

In any application, it is natural that developers change its source code quite frequently to release a new feature or to fix a bug. Along with source code changes the developers introduce new bugs :) It is also okay, we are not robots yet. In order to ensure the application...