<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[myblog]]></title><description><![CDATA[myblog]]></description><link>https://mateusz-czernek.pl</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 08:46:47 GMT</lastBuildDate><atom:link href="https://mateusz-czernek.pl/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Is Polish the best language for AI prompts?]]></title><description><![CDATA[Based on the University of Maryland and Microsoft, the answer seems to be yes (tak). For details, see this paper.
This is the earliest recorded sentence in the Polish language:

Daj, niech ja pomielę,]]></description><link>https://mateusz-czernek.pl/polish-language-llm-prompts</link><guid isPermaLink="true">https://mateusz-czernek.pl/polish-language-llm-prompts</guid><dc:creator><![CDATA[Mateusz Czernek]]></dc:creator><pubDate>Sun, 08 Mar 2026 18:14:21 GMT</pubDate><content:encoded><![CDATA[<p>Based on the University of Maryland and Microsoft, the answer seems to be yes (tak). For details, see <a href="https://arxiv.org/pdf/2503.01996">this paper.</a></p>
<p>This is the earliest recorded sentence in the Polish language:</p>
<blockquote>
<p>Daj, niech ja pomielę, a ty odpoczywaj.</p>
<p>Let me do the grinding, while you take your rest.</p>
</blockquote>
<p>, given the results of the research, this sentence could be expressed as:</p>
<blockquote>
<p>Let me process the load, while you sit back and relax.</p>
</blockquote>
<p>, in context of LLM prompts :-)</p>
]]></content:encoded></item><item><title><![CDATA[.Net WebApi - SignalR & Angular]]></title><description><![CDATA[Source code
Code available at GitHub
About SignalR
Full documentation available here
Fundamental concepts
SignalR acts as an abstraction layer over remote procedure calls (RPC), streamlining their use. It primarily employs the WebSocket network proto...]]></description><link>https://mateusz-czernek.pl/net-webapi-signalr-and-angular</link><guid isPermaLink="true">https://mateusz-czernek.pl/net-webapi-signalr-and-angular</guid><category><![CDATA[.net core]]></category><category><![CDATA[SignalR]]></category><category><![CDATA[Angular]]></category><dc:creator><![CDATA[Mateusz Czernek]]></dc:creator><pubDate>Tue, 27 May 2025 20:57:53 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1748380991129/e6cb6639-597a-45c6-a13b-03c46a6a1811.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-source-code">Source code</h2>
<p>Code available at <a target="_blank" href="https://github.com/mat-czernek/angular-signalR">GitHub</a></p>
<h2 id="heading-about-signalr">About SignalR</h2>
<p>Full documentation available <a target="_blank" href="https://learn.microsoft.com/en-us/aspnet/signalr/overview/getting-started/introduction-to-signalr">here</a></p>
<h3 id="heading-fundamental-concepts">Fundamental concepts</h3>
<p>SignalR acts as an abstraction layer over remote procedure calls (RPC), streamlining their use. It primarily employs the WebSocket network protocol, but can fallback to other transport protocols like HTML5 or Comet when necessary. A key concept in SignalR is the Hub, which facilitates communication between clients and the server, allowing clients to invoke server methods and vice versa. Hubs are transient, meaning they should not store state. To call methods outside a hub, IHubContext is used. SignalR supports strongly typed hubs, reducing the risk of runtime errors - there is no need to use strings for method names. Hubs can target all connected clients, specific connections, groups, or individual users. Additionally, SignalR integrates with ASP.NET Core authentication, associating users with each connection. Authentication data is accessible within the hub via HubConnectionContext.User, similar to WebApi.</p>
<h3 id="heading-supported-platforms">Supported platforms</h3>
<p>Server side:</p>
<ul>
<li>any server platform that ASP.NET Core supports</li>
</ul>
<p>Client side:</p>
<ul>
<li><p>JavaScript/TypeScript</p>
</li>
<li><p>.NET runs on ASP.NET Core</p>
</li>
<li><p>Java</p>
</li>
<li><p>Swift</p>
</li>
</ul>
<h2 id="heading-use-cases-from-sample-project">Use cases from sample project</h2>
<h3 id="heading-retrieving-status-of-executed-tasks-with-single-client">Retrieving status of executed tasks with single client</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748289044542/21537377-9818-41c9-9fe3-d8df6285187c.gif" alt class="image--center mx-auto" /></p>
<h3 id="heading-retrieving-status-of-executed-tasks-with-two-clients-plus-run-request-that-returns-result-only-to-caller">Retrieving status of executed tasks with two clients plus run request that returns result only to caller</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748289636662/d09f4f38-3f30-4623-bdb0-ee2f5e44d596.gif" alt class="image--center mx-auto" /></p>
<h3 id="heading-client-executes-method-on-server-side-to-get-number-of-running-tasks">Client executes method on server side to get number of running tasks</h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1748376986654/ea8eeeca-b896-45e8-9fe9-d50754c2c460.gif" alt class="image--center mx-auto" /></p>
<h2 id="heading-requirements">Requirements</h2>
<h3 id="heading-net">.NET</h3>
<p>Install SignalR NuGet package</p>
<pre><code class="lang-plaintext">Microsoft.AspNetCore.SignalR
</code></pre>
<h3 id="heading-angular">Angular</h3>
<p>Install SignalR npm package</p>
<pre><code class="lang-plaintext">npm install @microsoft/signalr
</code></pre>
<h2 id="heading-configuration">Configuration</h2>
<p>This section describes the application setup details related specifically to SignalR - surprisingly there is not much to do in scope of configuring the app. Things like CORS, HTTPS redirection, etc. are not covered here. For sake of the sample project simplicity the authorization concept was ignored.</p>
<h3 id="heading-net-1">.NET</h3>
<blockquote>
<p>Program.cs</p>
</blockquote>
<pre><code class="lang-csharp"><span class="hljs-comment">// ...</span>
<span class="hljs-comment">// Add SignalR services</span>
builder.Services.AddSignalR();

<span class="hljs-comment">// ...</span>
<span class="hljs-comment">// Map incoming requests with a specific hub</span>
app.MapHub&lt;TasksHub&gt;(<span class="hljs-string">"/tasksHub"</span>);

app.Run();

<span class="hljs-comment">// ...</span>
</code></pre>
<h2 id="heading-core-parts-of-the-sample-project">Core parts of the sample project</h2>
<h3 id="heading-net-side">.NET side</h3>
<p><code>webapi/Api/TasksApi.Core/TasksHub.cs</code></p>
<p>Contract for strongly typed Hub</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title">ITasksStatusClient</span>
{
    <span class="hljs-comment">// Called on client-side by server</span>
    <span class="hljs-function">Task <span class="hljs-title">TasksStatuses</span>(<span class="hljs-params">IReadOnlyCollection&lt;TaskDto&gt; tasks</span>)</span>;

    <span class="hljs-comment">// Called on client-side by server</span>
    <span class="hljs-function">Task <span class="hljs-title">TaskStatus</span>(<span class="hljs-params">TaskDto task</span>)</span>;

    <span class="hljs-comment">// Called on server-side by clients</span>
    <span class="hljs-function">Task&lt;<span class="hljs-keyword">int</span>&gt; <span class="hljs-title">RunningTasksCount</span>(<span class="hljs-params"><span class="hljs-keyword">int</span> tasksCount</span>)</span>;
}
</code></pre>
<p>Hub implementation</p>
<pre><code class="lang-csharp"><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title">TasksHub</span> : <span class="hljs-title">Hub</span>&lt;<span class="hljs-title">ITasksStatusClient</span>&gt;
{
    <span class="hljs-keyword">private</span> <span class="hljs-keyword">readonly</span> ITasksStatusService _taskStatusService;

    <span class="hljs-comment">// Task service injected into the Hub to fetch data from in-memory storage</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">TasksHub</span>(<span class="hljs-params">ITasksStatusService taskStatusService</span>)</span>
    {
        _taskStatusService = taskStatusService ?? <span class="hljs-keyword">throw</span> <span class="hljs-keyword">new</span> ArgumentNullException(<span class="hljs-keyword">nameof</span>(taskStatusService));
    }

    <span class="hljs-comment">// This method can be called by clients</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">async</span> Task&lt;<span class="hljs-keyword">int</span>&gt; <span class="hljs-title">RunningTasksCount</span>(<span class="hljs-params"></span>)</span>
    {
        <span class="hljs-keyword">return</span> <span class="hljs-keyword">await</span> Task.FromResult(_taskStatusService.RunningTasksCount);
    }
}
</code></pre>
<p><code>webapi/Api/TasksApi.Core/TasksStatusService.cs</code></p>
<p>Example of calling the method on client side</p>
<pre><code class="lang-csharp"><span class="hljs-comment">// Call method for all clients</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> Task <span class="hljs-title">ExecuteTask</span>(<span class="hljs-params">TaskDto task</span>)</span>
{
    <span class="hljs-keyword">return</span> ExecuteTaskInternal(task, (t) =&gt;
        _tasksStatusHubContext.Clients.All.TaskStatus(t));
}

<span class="hljs-comment">// Call method only for specific connection (caller)</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> Task <span class="hljs-title">ExecuteTask</span>(<span class="hljs-params">TaskDto task, <span class="hljs-keyword">string</span> connectionId</span>)</span>
{
    <span class="hljs-keyword">return</span> ExecuteTaskInternal(task, (t) =&gt;
        _tasksStatusHubContext.Clients.Client(connectionId).TaskStatus(t));
}

<span class="hljs-comment">// Call method for all clients</span>
<span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">async</span> Task <span class="hljs-title">RemoveTask</span>(<span class="hljs-params"><span class="hljs-keyword">int</span> id</span>)</span>
{
    _taskStorage.Delete(id);
    <span class="hljs-keyword">await</span> _tasksStatusHubContext.Clients.All.TasksStatuses(_taskStorage.GetAll());
}
</code></pre>
<h3 id="heading-angular-side">Angular side</h3>
<p><code>angular/src/app/services/signalR/tasks-signalr.service.ts</code></p>
<p>Build hub connection</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">constructor</span>(<span class="hljs-params"></span>) {
    <span class="hljs-built_in">this</span>.hubConnection = <span class="hljs-keyword">new</span> HubConnectionBuilder()
      .withUrl(environment.signalRBaseUrl + <span class="hljs-string">"tasksHub"</span>)
      .build();
  }
</code></pre>
<p>Establish connection with hub, executed in root component under OnInit method.</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">public</span> start() {

    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.hubConnection == <span class="hljs-literal">null</span>) {
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-comment">// Start Hub connection</span>
    <span class="hljs-built_in">this</span>.hubConnection
      .start()
      .then(<span class="hljs-function">() =&gt;</span> {
        <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Connected to tasks hub.'</span>);
        <span class="hljs-comment">// We can store connection ID to make further calls with response only for caller</span>
        <span class="hljs-built_in">this</span>.connectionId = <span class="hljs-built_in">this</span>.hubConnection.connectionId ?? <span class="hljs-string">''</span>;
      })
      .catch(<span class="hljs-function"><span class="hljs-params">error</span> =&gt;</span> <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Tasks hub connection error: '</span> + error));

    <span class="hljs-comment">// Register hub method that can be called by server on client side</span>
    <span class="hljs-built_in">this</span>.hubConnection.on(<span class="hljs-string">'TasksStatuses'</span>, <span class="hljs-function">(<span class="hljs-params">tasks: TaskDto[]</span>) =&gt;</span> {
      <span class="hljs-built_in">this</span>.tasksStatusesSubject.next(tasks);
    })

    <span class="hljs-comment">// Register hub method that can be called by server on client side</span>
    <span class="hljs-built_in">this</span>.hubConnection.on(<span class="hljs-string">'TaskStatus'</span>, <span class="hljs-function">(<span class="hljs-params">task: TaskDto</span>) =&gt;</span> {
      <span class="hljs-built_in">this</span>.taskStatusSubject.next(task);
    });
}
</code></pre>
<p>Close connection to hun, executed in root component under OnDestroy method</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">public</span> stop() {
    <span class="hljs-keyword">if</span> (<span class="hljs-built_in">this</span>.hubConnection == <span class="hljs-literal">null</span>) {
      <span class="hljs-keyword">return</span>;
    }

    <span class="hljs-built_in">this</span>.hubConnection.stop().then(<span class="hljs-function">() =&gt;</span> {
      <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Disconnected from tasks hub.'</span>);
    });
}
</code></pre>
<p>Call method on service-side</p>
<pre><code class="lang-typescript"><span class="hljs-keyword">public</span> getRunningTasksCount(): Observable&lt;<span class="hljs-built_in">number</span>&gt; {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> Observable&lt;<span class="hljs-built_in">number</span>&gt;(<span class="hljs-function">(<span class="hljs-params">subscriber</span>) =&gt;</span> {
      <span class="hljs-built_in">this</span>.hubConnection
        <span class="hljs-comment">// Provide expected return type and method name</span>
        <span class="hljs-comment">// See webapi/Api/TasksApi.Core/TasksHub.cs for Hub contract</span>
        .invoke&lt;<span class="hljs-built_in">number</span>&gt;(<span class="hljs-string">'RunningTasksCount'</span>)
        .then(<span class="hljs-function">(<span class="hljs-params">count</span>) =&gt;</span> {
          subscriber.next(count);
          subscriber.complete();
        })
        .catch(<span class="hljs-function">(<span class="hljs-params">err</span>) =&gt;</span> {
          subscriber.error(err);
        });
    });
  }
</code></pre>
]]></content:encoded></item></channel></rss>