.NET hot-reload with Docker

I had issues in my .NET projects while using hot-reload functionality and Docker. Everytime I would update the code, all the references on my host machine would get broken and everything inside my IDE would get red lines. I’ve realized this was due to how I set up the volumes - I mounted all the files, and everytime my app was rebuilt inside the container, it would overwrite the paths with the container paths. ...

September 2, 2025 Â· 2 min Â· 235 words

.NET CancellationToken

I am currently going through a .NET/React course and one lesson was about CancellationToken which I have seen before but never really understood. I decided to take some notes. Cancellation Token A CancellationToken in .NET is a mechanism that lets you signal to running code that it should stop work, usually because the operation is no longer needed or the user canceled it. It’s commonly used in asynchronous and long-running operations to make them cooperative and cancellable. ...

September 1, 2025 Â· 2 min Â· 227 words

Simple SQL tips

Nothing ground breaking, but hey, simplicity and basics are the most important. Reader Rules Don’t run select * queries without filters You might not know how big the table you are querying is. Therefore, in order not to negatively impact the performance of the whole system, limit the amount of the query. Instead of 1 select * from myTable; use 1 select * from myTable limit 10; Writer Rules Use transactions Even simple & tested queries might have unintentional side-effects. ...

April 20, 2024 Â· 2 min Â· 231 words

How to do a null check

Checking for null is important in programming to avoid potential runtime errors, prevent crashes, and ensure the reliability and robustness of your code. In C#, we can check for null in few different ways, depending on the context. So far I have been using following methods: Using the equality operator 1 2 3 4 5 6 7 object obj = null; if (obj == null) { // if null, do something } Using the is keyword 1 2 3 4 5 6 7 object obj = null; if (obj is null) { // if null, do something } Using the ReferenceEquals() method 1 2 3 4 5 6 7 object obj = null; if (ReferenceEquals(obj, null)) { // if null, do something } Using the != opeartor 1 2 3 4 5 6 7 object obj = null; if (obj != null) { // object is not null } Using the null-conditional operator ?. 1 2 3 var text = null; int? length = text?.Length; // length will be null, if text is null Using the null-coalescing operator ?? 1 2 3 var text = null; var result = text ?? "default non-null value"; // if text is null, use the default value

March 11, 2024 Â· 1 min Â· 203 words

Update PIP Packages

I am trying to implement inifinite scroll functionality to some of my blog pages and at the same time decided to do some maintanance work for my blog, which includes upgrading the packages I am using. I have found a lot of ways, but really simple one is to use an external library called pip-review. First install the lilbrary: pip install pip-review{.single} To upgrade packages manually run: pip-review --local --interactive{.single} To upgrade all packages automatically run: ...

March 10, 2024 Â· 1 min Â· 79 words

Access Modifiers

I have recently started learning C# language, which, compared to python, is a lot more verbose and structured. C# syntax is influenced by C and C++ languages. Part of CS50 Introduction to Computer Science course used C language, so having seen the syntax before helps a lot. However, working mostly with Python, there is a lot of difference. As I like to do, I will try to summarize key points as it helps me to learn and understand the language more. ...

February 25, 2024 Â· 3 min Â· 486 words

Inspecting temporary pop-up

I needed a selector for a temporary pop-up, but it was impossible to get it in time as it would disappear quickly. Found a small trick using browser devtools. Open console Run the following javascript: setTimeout(() => { debugger; }, 5000){.single} Click the element that calls the pop-up Browser will enter debugger mode in 5 seconds (you can adjust), freeze the page and you can inspect the pop-up.

November 25, 2023 Â· 1 min Â· 68 words

PyTest - Parametrizing Test Functions

One of key features of PyTest is the ability to create parametrized tests, meaning running test cases with various input values without having to write separate test cases. Main goal of my most recent Django project is to develop better understanding of testing principles and tools. I have already built few Django applications, however never really focused on testing my own code - I was just happy the app “worked”. Knowing what and how to test is a skill in itself. It is quite a challenge. One can write hundreds of test cases which are not really covering the essential functionalities, or they repeat. Just as most of the things, it comes with a practice. However, I understand the long-term value of writing and having effective tests. ...

October 6, 2023 Â· 2 min Â· 417 words

Dump & Restore PostgreSQL database in a Docker

I was updating my blog and needed to use the same database which I currently have in production. Since my blog is fully dockerized, managing the state of the application between production & development environment is a lot easier. For this purpose, I have researched and learned two handy commands, one to export the database and the other one to import the database. Export (dump) with pg_dump{.single}: 1 docker exec -i container_name /bin/bash -c “PGPASSWORD=actual_password pg_dump —username actual_username database_name” > /path/of/export/export.sql Import (restore) with psql{.single}: 1 docker exec -i container_name /bin/bash -c “PGPASSWORD=actual_password psql —username actual_username database_name” > /path/of/export/export.sql I have noticed successful import even with errors (default PostgreSQL behaviour), because I already had some migrations (in my Django app). Therefore I would recommend first resetting the whole DB and then importing the database. If you want to overwrite this default behaviour and stop upon error, add -set ON_ERROR_STOP=on{.single} to your command. ...

September 13, 2023 Â· 1 min Â· 152 words

Django Password Validators

By default Django comes with an advanced password validator, meaning user must enter password with a minimum length of 8 characters, some special sign, number. For production environment this is very important, however for development environment a simpler password would do and it wouldn’t take so much time. Today I have learned how to turn the advaced password protection off (remember to remove this line for production). Add the following line to your settings.py file: ...

August 31, 2023 Â· 1 min Â· 79 words