InternetException

Posts

Purging smtp services from Debian

· 323 words · ~1 min read · in debian, DevOps

#mailcow

Lately I purchased mew dedicated server with intention to use it as my new running mail email server - mailcow, my blog, and some other services. When I was migrating mailcow suite everything was fine except postfix image failed to start.

I had problem like that already on Debian and usually I was dealing with that by disabling exim:

sudo systemctl disable exim.service

This was fine till major Debian update that was reinstalling exim and causing it to steal port 25 again. So this time I decided to uinstall it completely.

Read the whole thing →

Enhancing your .NET API with query language

· 1690 words · ~8 min read · updated · in .NET, ASP.NET, Hamster Wheel

#NuGet #LINQ #API design #HLinq

What is query language? SQL is Structured Query Language and you use it to query your database for data you are interested in. It does not have to do anything with your API. If you ever were working with big XML files you probably used XQuery or XPath, query languages designed to XML for data. There are specialized languages that are designed to work with APIs to query them for data. For example, you probably heard about GraphQL or even used it when you were working with some API.

Read the whole thing →

HLinq design

· 4639 words · ~23 min read · in .NET, ASP.NET, Hamster Wheel

#LINQ #delegates #reflection #Entity Framework

A bit of history

I remember the day when I started writing the HLinq query language. It was weekend and I was experimenting with writing Single endpoints for Hamster Wheel. Single endpoints were almost done and next step was to write List endpoint. This would allow to get list of records of specific type. After I got single GET returns correct data for chosen record id, list should not be hard to implement. Then just create, update and delete. Basic CRUD API in Hamster Wheel would be finished. I was thrilled that I actually was able to do such thing.

Read the whole thing →

Disable Xunit Test on specific OS

· 253 words · ~1 min read · in .NET, C#, debian, linux, testing

#Unit tests

Lately I was having a problem with some of my tests causing problems for other developers on the project I am working on. They were using Windows for their development while I am using Debian for my work. The application that was being tested was not designed for non Unix system - now rarely anybody is hosting they production code on Windows Server - everybody is using Unix for .net.

Read the whole thing →

Writing a simple C# source code generator with Fluent API

· 1812 words · ~9 min read · updated · in .NET, C#

#source generators #NuGet

Introduction

Usually in .NET world when you want to write generic code you use generic method or classes. But sometimes it is still not enough when you want to automate some things. I.e. you want to dynamically register in DI all the classes that implements some interface. Probably, in this case, you would do something like that:

var implementations = typeof(MyClass).Assembly.Types
   .Where(t => t.GetInterfaces().Any(i => i == typeof(IMyInterface))
foreach(var implementation in implementations)
{
   services.AddScoped<IMyInterface>(implementation);
}

And it would be completely fine. Even if Reflection is pretty slow, your application would not be getting significantly slower because of that. Certainly you would not notice the slow down.

Read the whole thing →

HamsterWheel.FluentCodeGenerators is out

· 159 words · ~1 min read · in Hamster Wheel, .NET

#source generators #NuGet

I released today first new Nuget package connected to my new project that I am working on for sometime: dynamically configurable, zero-downtime API, with low-code flows to write small pieces of logic - Hamster Wheel.

System heavily relies on dynamic source code generation. For that I wrote
https://www.nuget.org/packages/HamsterWheel.FluentCodeGenerators and https://www.nuget.org/packages/HamsterWheel.FluentCodeGenerators.Abstractions
small package that helps with writing C# incremental source code generators for Roslyn compiler.

Original Roslyn APIs are a bit hard to use so this package helps with that. Also it helps with:
\

Read the whole thing →

Convert LVM logical volume Raid 10 to Raid 5

· 692 words · ~3 min read · in debian, linux, lvm

#RAID

Two weeks ago I was running out of space on my main raid matrix on my server. Server was configured and assembled few years back, and at that time I had about 700GB of data there so having RAID 10 of 4 1TB disks (that account for about 1,7TB of actual space for data) was enough. Especially when you count in a price of 2TB (or 4TB) NVME M2 disk back then.

Read the whole thing →

No Display Manager in Debian Trixie

· 376 words · ~1 min read · in debian, linux

Lately I decided to try Podman Quadlets. It seemed to be really interesting way to achieve similar results as with Docker and Compose, but it have nicer integration with the system (i.e. ability to see container in Cockpit along with other systemd services, or triggering container by socket, so less frequently used containers won’t be running all the time).

Everything went fine except for unavailability of buildah package in Debian stable apt channel (or the version that were needed for podman at least). Quick search on the internet and I found the answer is to reference this specific package from the testing channel of apt.

Read the whole thing →

Monitoring vs Observability

· 237 words · ~1 min read · in DevOps

#observability

What is the difference between monitoring and observability?

Monitoring is process of collecting live events from your application, traces, debug messages, warnings and exceptions. The same process may involve sending those events to some storage or application that analyze or visualize those messages. I.e. in asp.net core applications monitoring of application involves calling a ILogger and sending those logs or critical exceptions to AppInsights. Monitoring may also involve activity of development team members to active watch those logged messages for any potential errors or problems that may impact availability of production environment.

Read the whole thing →

Solid

· 69 words · ~1 min read · in interview, patterns

#SOLID #pattern

The single-responsibility principle - piece of software should have only one responsibility The open–closed principle - things should be open for extension but closed for modification The Liskov substitution principle - changing interface implementation should not brake software The interface segregation principle - it is better to have more specialized interfaces than single big one The dependency inversion principle - dependencies should be abstracted via interfaces Further read: https://en.wikipedia.org/wiki/SOLID

.NET/C# interview questions

· 146 words · ~1 min read · updated · in .NET, interview

#generics #reflection #async #Entity Framework

Read the whole thing →

Equals and GetHashCode

· 89 words · ~1 min read · in .NET, interview

Custom implementation is usually only necessary if default, reference equality is not enough. In example: entities value based equality value equality of deserialized objects custom comparisons based on other criterias public class ImaginaryNumber : IEquatable&lt;ImaginaryNumber&gt; { public double RealNumber { get; set; } public double ImaginaryUnit { get; set; } public override bool Equals(object obj) { return Equals(obj as ImaginaryNumber); } public bool Equals(ImaginaryNumber other) { return other != null &amp;&amp; RealNumber == other.RealNumber &amp;&amp; ImaginaryUnit == other.ImaginaryUnit; } public override int GetHashCode() { return HashCode.Combine(RealNumber, ImaginaryUnit); } }

Kestrel

· 36 words · ~1 min read · in .NET, interview

#ASP.NET

default application server for .net cross platform best performance and memory utilization may not have some advanced features of HTTP.sys on Windows may be used with proxy server or as internet facing server Further read: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/servers/kestrel?view=aspnetcore-6.0

ASP.NET Core controller level exception handling

· 43 words · ~1 min read · updated · in .NET, interview

#ASP.NET MVC #ASP.NET

To handle exceptions on Controller/Action level Exception Filters are used. [TypeFilter(typeof(SampleExceptionFilter))] public class ExceptionController : Controller Exception Filters are implemented using IExceptionFilter with OnExcetion method override to handle exceptions. Exception Filters can be applied to Controller and Action level. Further read: https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-7.0#exception-filters https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.mvc.filters.iexceptionfilter?view=aspnetcore-7.0