<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ciklum CZ&amp;amp;SK</title>
    <description>The latest articles on DEV Community by Ciklum CZ&amp;amp;SK (@ciklum_czsk).</description>
    <link>https://dev.to/ciklum_czsk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F3903%2F05cdddcb-5a49-43f5-bf71-9ff62656ea5a.png</url>
      <title>DEV Community: Ciklum CZ&amp;amp;SK</title>
      <link>https://dev.to/ciklum_czsk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ciklum_czsk"/>
    <language>en</language>
    <item>
      <title>Creating Modern Accordion Components with CSS and HTML only</title>
      <dc:creator>Tomas Rezac</dc:creator>
      <pubDate>Wed, 21 Feb 2024 09:32:11 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/creating-modern-accordion-components-with-css-and-html-24pb</link>
      <guid>https://dev.to/ciklum_czsk/creating-modern-accordion-components-with-css-and-html-24pb</guid>
      <description>&lt;p&gt;Welcome to the first instalment of a series dedicated to crafting common components using only modern CSS and HTML.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Note: I am the author of Sugar.css, a minimalistic CSS Framework built with the latest CSS. You can explore a more advanced implementation of a similar accordion on &lt;a href="https://sugar-css.com/doc/components/accordion"&gt;Sugar.css&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Assignment
&lt;/h2&gt;

&lt;p&gt;What are the essential features of a proper &lt;strong&gt;Accordion&lt;/strong&gt;?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Toggle content on user input or programmatically&lt;/li&gt;
&lt;li&gt;Accessibility (toggle on Enter and Space)&lt;/li&gt;
&lt;li&gt;Disable access to accordion content (by keyboard) when the accordion is collapsed&lt;/li&gt;
&lt;li&gt;Stacking multiple accordions after each other&lt;/li&gt;
&lt;li&gt;Auto close other accordions in the group when one is opened&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Toggling Content
&lt;/h2&gt;

&lt;p&gt;Gone are the days when the only way to toggle styles permanently was through a label with a hidden checkbox. For the past few years, we've been able to use a combination of &lt;code&gt;details&lt;/code&gt; and &lt;code&gt;summary&lt;/code&gt; HTML elements to achieve this. The &lt;code&gt;details&lt;/code&gt; element hides all its content by default, except for a &lt;code&gt;summary&lt;/code&gt; element if placed as a direct child. The &lt;code&gt;summary&lt;/code&gt; serves as a toggle button; if not present, the text &lt;strong&gt;details&lt;/strong&gt; is added as a default toggle. By clicking the toggle, the rest of the hidden content is revealed. Let's observe the default behavior and design:&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/rezi-the-lessful/embed/eYXoyBp?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Accessibility
&lt;/h2&gt;

&lt;p&gt;All accessibility features are built-in; the summary has a default tabindex and can be toggled by Space and Enter keys, so no additional work is needed here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Disabling Access to Content When Collapsed
&lt;/h2&gt;

&lt;p&gt;While this functionality should work out of the box, there's an exception with Safari. If the &lt;code&gt;details&lt;/code&gt; element is collapsed and contains focusable elements like &lt;code&gt;input&lt;/code&gt; or &lt;code&gt;button&lt;/code&gt;, tabbing in Safari will be consumed by those hidden elements. To ensure consistent accessibility across browsers, a simple JavaScript solution is required. The content is wrapped, and the &lt;code&gt;inert&lt;/code&gt; attribute needs to be set to the wrapper once the &lt;code&gt;details&lt;/code&gt; is collapsed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Styling
&lt;/h2&gt;

&lt;p&gt;Let's apply some CSS to enhance the appearance. First, we'll remove the original triangle indicator. This can be done differently in various browsers, but the following CSS accomplishes this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;summary&lt;/span&gt;&lt;span class="nd"&gt;::marker&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nt"&gt;summary&lt;/span&gt;&lt;span class="nd"&gt;::-webkit-details-marker&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;summary&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;list-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we'll style the summary to resemble an accordion header and prepare it for a new chevron:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;summary&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;list-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;space-between&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;padding-block&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--padding&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nb"&gt;bold&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;details&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.75rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;--chevron-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.8rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;system-ui&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To implement the new chevron for the base accordion, we'll create a rotated box with just two borders. The state of the opened accordion is selected by &lt;code&gt;details[open]&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;details&lt;/span&gt; &lt;span class="nt"&gt;summary&lt;/span&gt;&lt;span class="nd"&gt;:after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;margin-inline-end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--padding&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--chevron-size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--chevron-size&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;currentColor&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-width&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-45deg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;translateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-30%&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt; &lt;span class="m"&gt;0.3s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-shrink&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;details&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nt"&gt;open&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="nt"&gt;summary&lt;/span&gt;&lt;span class="nd"&gt;:after&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;45deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Lastly, we'll add separators between accordions if there are more consecutive ones:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;details&lt;/span&gt;&lt;span class="nd"&gt;:not&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;:last-of-type&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--padding&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--padding&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--border-width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="no"&gt;gray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Grouping Accordions
&lt;/h2&gt;

&lt;p&gt;Another useful feature of &lt;code&gt;details&lt;/code&gt; is its acceptance of a &lt;code&gt;name&lt;/code&gt; attribute. All &lt;code&gt;details&lt;/code&gt; with the same name behave as a group. When you open one, the others in the same group automatically close.&lt;/p&gt;

&lt;p&gt;Check out the result &lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/rezi-the-lessful/embed/MWxRbyo?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Additional styles like colours and spacings can make it more vivid&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/rezi-the-lessful/embed/GReLaJL?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;




&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;As demonstrated, &lt;code&gt;details&lt;/code&gt; and &lt;code&gt;summary&lt;/code&gt; are fully capable of replacing JavaScript-driven accordions. They make implementation easier and provide immediate accessibility (with the exception of Safari, which requires a workaround for a specific edge case).&lt;/p&gt;

&lt;p&gt;However, there's one potential drawback: the lack of animation support. If animation is applied to collapsed content within &lt;code&gt;details&lt;/code&gt;, it runs only once when opened and cannot be rerun when opened next time. This limitation may need to be considered based on the specific design and functionality requirements of your project.&lt;/p&gt;

&lt;p&gt;Next time we will check the &lt;code&gt;dialog&lt;/code&gt; element. See you soon.&lt;/p&gt;

</description>
      <category>css</category>
      <category>a11y</category>
      <category>webdev</category>
      <category>html</category>
    </item>
    <item>
      <title>How to Use Docker during Development</title>
      <dc:creator>Karel Šťastný</dc:creator>
      <pubDate>Mon, 07 Mar 2022 15:36:11 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/how-to-use-docker-during-development-1e0o</link>
      <guid>https://dev.to/ciklum_czsk/how-to-use-docker-during-development-1e0o</guid>
      <description>&lt;p&gt;During development, it is very advantageous to be able to develop everything locally on the developer’s own machine. &lt;/p&gt;

&lt;p&gt;This would be very easy if the application to be developed had no external dependencies, but most systems do not live in vacuum and depend on other systems. These may be external APIs that provide us some data, data storage applications of any kind (SQL or NoSQL), message queues, distributed caches and others. &lt;/p&gt;

&lt;p&gt;While we may not always want to simulate external APIs locally, it is very useful for each developer to have his or her own database or RabbitMQ instance that they may play with without constantly stepping on a colleague’s toes. &lt;/p&gt;

&lt;p&gt;This may not be possible for bigger or more complex projects, but for a lot of applications it is easily doable. One way to do this is of course installing every dependency locally but this may quickly become unwieldy if you need to work on multiple projects or have to use multiple versions of a given system. &lt;/p&gt;

&lt;p&gt;Therefore we prefer to use containers, namely Docker, for quickly spinning up these dependencies. This allows us not only to protect our computers from the software bloat but also helps unify the development environment between different developers. &lt;/p&gt;

&lt;p&gt;In this article, I would like to show you how this can be easily done (with just a handful of shortcuts and cut corners :)) &lt;/p&gt;

&lt;h2&gt;
  
  
  What do we want to do?
&lt;/h2&gt;

&lt;p&gt;As an example, we will use a small (work in progress) application for managing users‘ book library, &lt;a href="https://github.com/kstastny/alexandria"&gt;https://github.com/kstastny/alexandria&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;We want to be able to develop everything locally and for that we need access to MariaDB database and an Adminer instance for accessing it. We want to run these two without going through the hassle of installing everything. &lt;/p&gt;

&lt;p&gt;I will assume that you already have Docker installed and have some knowledge of what a Docker image is and how to run Docker containers. If not, just go to &lt;a href="https://duckduckgo.com/"&gt;https://duckduckgo.com/&lt;/a&gt; and search for “docker basics”. I will wait for you to get back. &lt;/p&gt;

&lt;h2&gt;
  
  
  Local infrastructure setup
&lt;/h2&gt;

&lt;p&gt;Now, how do we actually use Docker to spin up a local copy of our external systems so we can develop our bit of a bigger system? We could, of course, run a container for each dependency but that would be a bit unwieldy if we have more than one or two. &lt;/p&gt;

&lt;p&gt;Instead, what we’re going to use is “docker compose”. This helps us with multi-container environments (i.e setting up a system with more than one container). &lt;/p&gt;

&lt;p&gt;Since we’re talking about local developer machines here, we really only need to spin up the supporting infrastructure and not the services that we are in fact developing. &lt;/p&gt;

&lt;p&gt;To run the infrastructure, we need to do the following &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a file called “docker-compose.yml” that will contain the definition of our containers. For example, it can look like this:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# format version https://docs.docker.com/compose/compose-file/compose-versioning/&lt;/span&gt;
&lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;3.8'&lt;/span&gt;

&lt;span class="c1"&gt;# define list of services (containers) that compose our application&lt;/span&gt;
&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;

  &lt;span class="c1"&gt;#identifier of database service  &lt;/span&gt;
  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;#Specify what image and version we should use; we use 10.5 due to https://jira.mariadb.org/browse/MDEV-26105&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mariadb:10.5&lt;/span&gt;
    &lt;span class="c1"&gt;#container restart policy https://docs.docker.com/config/containers/start-containers-automatically/&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="c1"&gt;#setup environment variables&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;MYSQL_ROOT_PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mariadbexamplepassword&lt;/span&gt;
    &lt;span class="c1"&gt;#define port forwarding (host:container)&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;3306:3306&lt;/span&gt;
    &lt;span class="c1"&gt;#bind volume `alexandria-db` to directory `/var/lib/mysql`&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;alexandria-db:/var/lib/mysql&lt;/span&gt;

  &lt;span class="na"&gt;adminer&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;adminer&lt;/span&gt;
    &lt;span class="na"&gt;restart&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;always&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;8090:8080&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;alexandria-db&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example modified from &lt;a href="https://github.com/kstastny/alexandria/blob/master/docker-compose.infrastructure.yml"&gt;https://github.com/kstastny/alexandria/blob/master/docker-compose.infrastructure.yml&lt;/a&gt;  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To run the infrastructure, just run “docker-compose up –d” &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If all went well, we now have a running MariaDB instance and an Adminer running on &lt;a href="http://localhost:8090/?server=db&amp;amp;username=root"&gt;http://localhost:8090/?server=db&amp;amp;username=root&lt;/a&gt; that we can use to manage MariaDB. We can now run our application and use the databasewe have on our side. &lt;/p&gt;

&lt;p&gt;When we need to change the dependencies or upgrade the DB engine, we will just update the docker compose file and everything will be magically provided for us. &lt;/p&gt;

&lt;p&gt;For simplicity, I have stored the DB root password in docker compose, but for production ready deployments we should be managing our secrets in a more secure way. A bit safer way would be to use an environment variable to pass the password into the docker compose (see an example below). &lt;/p&gt;

&lt;p&gt;Even that is not enough though. To provide the password securely, we should use “docker secrets” and pass the secret file using an environment variable MARIADB_ROOT_PASSWORD_FILE. But that’s a topic that has to wait for another article 😊 &lt;/p&gt;

&lt;h2&gt;
  
  
  Running the whole stack
&lt;/h2&gt;

&lt;p&gt;Sometimes we might want to run the whole stack including our application. In that case, we can either modify our docker-compose.yml file so that it also contains the app, or we can store the definition in a separate file and combine both when needed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;alexandria&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# build context. Either local directory or url to git repository&lt;/span&gt;
      &lt;span class="na"&gt;context&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
      &lt;span class="na"&gt;dockerfile&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dockerfile&lt;/span&gt;
    &lt;span class="c1"&gt;#https://docs.docker.com/compose/startup-order/&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;db"&lt;/span&gt;
    &lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;./wait-for-it.sh"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;db:3306"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;--"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;python"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;app.py"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;8080:5000&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;DB__CONNECTIONSTRING&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Server=db;Port=3306;Database=alexandria;Uid=root;Pwd=${MYSQL_ROOT_PASSWORD};SslMode=none&lt;/span&gt;
      &lt;span class="na"&gt;ASPNETCORE_ENVIRONMENT&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${ASPNETCORE_ENVIRONMENT}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;n this example, we will create a file “docker-compose.app.yml” with the content above.&lt;br&gt;&lt;br&gt;
This time, we are injecting the environment variable from the inside so we also need to define a file “.env” that will contain the password &lt;/p&gt;

&lt;p&gt;MYSQL_PASSWORD=mariadbexamplepassword &lt;/p&gt;

&lt;p&gt;To run the whole application stack including dependencies, we will use the following command: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;docker-compose -f docker-compose.yml -f docker-compose.app.yml --env-file .env up --build -d &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  That’s it?
&lt;/h2&gt;

&lt;p&gt;Yes, that’s it. I hope that you can see that using Docker to support your local development is fairly easy and worth it even if you don’t plan to deploy your application in Docker. &lt;/p&gt;

</description>
      <category>docker</category>
      <category>devops</category>
      <category>beginners</category>
    </item>
    <item>
      <title>What is consensus in blockchain technology</title>
      <dc:creator>Lucian Gruia</dc:creator>
      <pubDate>Mon, 07 Mar 2022 11:16:34 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/what-is-consensus-in-blockchain-technology-512i</link>
      <guid>https://dev.to/ciklum_czsk/what-is-consensus-in-blockchain-technology-512i</guid>
      <description>&lt;h2&gt;
  
  
  Consensus mechanisms
&lt;/h2&gt;

&lt;p&gt;Sometimes a confusion appears between the blockchain type and its consensus mechanism. This is why it is important to understand what consensus is and its role in a blockchain.&lt;br&gt;
The consensus mechanism makes sure all nodes are synchronised with each other and agree on which transactions are legitimate and added to the blockchain. It makes sure that everyone in the network uses the same blockchain.&lt;br&gt;
In a centralised system, a central administrator has the authority to maintain and update the database.&lt;/p&gt;

&lt;p&gt;Consensus assures that the protocol rules are being followed and guarantees that all transactions occur in a trustless way. There are some specific goals in the Blockchain consensus protocol, such as agreement, collaboration, cooperation, equal rights for each node, and mandatory participation of each node in the consensus process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types of consensus algorithms:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Proof of Work (PoW)&lt;/strong&gt; — is a decentralised consensus mechanism that requires members of a network to expend effort solving an arbitrary mathematical puzzle to prevent anybody from gaming the system. Proof of work is used widely in cryptocurrency mining, for validating transactions and mining new tokens.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof of Stake (PoS)&lt;/strong&gt; — protocols are a class of consensus mechanism for blockchains that work by selecting validators in proportion to their quantity of holdings in the associated cryptocurrency. Unlike a proof of work (PoW) protocol, PoS systems do not incentivise extreme amounts of energy consumption.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delegated Proof of Stake (DPoS)&lt;/strong&gt; — is a popular evolution of the PoS concept, whereby users of the network vote and elect delegates to validate the next block. Delegates are also called witnesses or block producers. Using DPoS, you can vote on delegates by pooling your tokens into a staking pool and linking those to a particular delegate. You do not physically transfer your tokens to another wallet, but instead, utilise a staking service provider to stake your tokens in a staking pool.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof of Importance (PoI)&lt;/strong&gt; — is a cryptocurrency term defined as a blockchain consensus technique — essentially, proof of important works to prove the utility of nodes in a cryptocurrency system, so that they can create blocks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Other consensus mechanisms:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Proof-of-Capacity(PoC)&lt;/strong&gt; — PoC is another consensus algorithm used in blockchains that allows mining devices in the network to decide mining rights and validate transactions with the help of their available hard drive space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proof-of-Activity (PoA)&lt;/strong&gt; — PoA is a consensus algorithm used in Blockchain technology that ensures that all transactions occurring on the network of Blockchain are genuine and authentic. PoA consensus, which is a combination of proof-of-work and proof-of-stake, ensures that all miners arrive at a consensus. In other words, PoA is an attempt to consolidate the best features of PoW and the PoS systems.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Blockchain main concepts</title>
      <dc:creator>Lucian Gruia</dc:creator>
      <pubDate>Mon, 07 Mar 2022 11:11:55 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/blockchain-main-concepts-1egm</link>
      <guid>https://dev.to/ciklum_czsk/blockchain-main-concepts-1egm</guid>
      <description>&lt;p&gt;Every day we hear about blockchain, and lately some convergent concepts have become buzzwords.  But let’s look at their actual meanings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Merkle tree
&lt;/h2&gt;

&lt;p&gt;A Merkle tree is a fundamental concept of blockchain. It is a structure that allows secure verification and efficient content in a large body of data. It helps to verify the consistency and content of the data. [1] It summarises all the transactions in a block by creating a fingerprint of the entire set of transactions, which allows a user to verify whether a transaction is included in a block. [2]&lt;/p&gt;

&lt;p&gt;A Merkle tree is created by repeatedly hashing pairs of notes until there is only one hash left, known as Root Hash or Merkle Root.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbe54crof9cowz1qeets.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbe54crof9cowz1qeets.png" alt="Image description" width="438" height="256"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ehbufl7af99mgi1it2m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8ehbufl7af99mgi1it2m.png" alt="Image description" width="499" height="426"&gt;&lt;/a&gt;&lt;br&gt;
Using a Merkle Tree we are significantly reducing the data that a trusted authority has to store for verification purposes. It helps in verifying data consistency in an optimal way since we are not checking the real amount of data — so we are reducing the computational effort. Also, it is more optimal than creating a hash on all transactions, because the risk of collisions increases proportionally with the number of transactions. [3]&lt;/p&gt;

&lt;p&gt;An example of a transaction is shown below. Instead of storing all hashes for all transactions, we are creating the hash of hashes and so on, till the root hash.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9gr56m4ay94cqnjlmn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv9gr56m4ay94cqnjlmn0.png" alt="Image description" width="700" height="353"&gt;&lt;/a&gt;&lt;br&gt;
After we calculate a hash of the entire block, then we are taking into account the difficulty, which is set by the blockchain algorithm.&lt;/p&gt;

&lt;p&gt;The important role of the Merkle tree is that it greatly compresses the amount of data we have to store. Otherwise, all nodes of a blockchain should keep a copy of every single transaction that has ever occurred and compare them line by line in order to validate the integrity of data.&lt;/p&gt;

&lt;p&gt;This is actually separating the proof of data from the data itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hashing
&lt;/h2&gt;

&lt;p&gt;This is a function that converts an input item of any length into an output item of a fixed length. [4] The values returned by a hash function are called hash values, hash codes, digests, or simply hashes. [5]&lt;/p&gt;

&lt;p&gt;Note that a hash function is not injective, not surjective and will return the same output every time you apply it to the same input, but using an output, you cannot know which was the original input.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5abow1lgixa517k5sl5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5abow1lgixa517k5sl5b.png" alt="Image description" width="700" height="536"&gt;&lt;/a&gt;&lt;br&gt;
Source: &lt;a href="https://en.wikipedia.org/wiki/Hash_function"&gt;https://en.wikipedia.org/wiki/Hash_function&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Nonce value
&lt;/h2&gt;

&lt;p&gt;Miners are trying to guess the hash, based on difficulty. This can be set initially as n number of zeros a hash of a block should start with. The difficulty increases with the number of zeros. So, in this case, miners have all the transaction data, but they do not know one value, the so-called Nonce. They have to guess the specific nonce value that makes the block start with a specified number of zero. Because of the enormous volume of the number space, the only way to get the nonce value is random.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s finally see what a block is
&lt;/h2&gt;

&lt;p&gt;The block is the building group for any blockchain.&lt;/p&gt;

&lt;p&gt;It has 2 main components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Block header&lt;/li&gt;
&lt;li&gt;Block body&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3iuwnhr0wepo3r3psljk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3iuwnhr0wepo3r3psljk.png" alt="Image description" width="700" height="395"&gt;&lt;/a&gt;&lt;br&gt;
The Block header has 6 sub-components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Block version&lt;/strong&gt; — does not matter in most cases, but it can signal which protocol decisions it supports&lt;/li&gt;
&lt;li&gt;Merkle tree root hash — encodes the blockchain data in a secure matter. It enables nodes to quickly check the current block for integrity. [6]Simplified, it serves the same role as a hash of archive files downloaded from an internet repository.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Previous block hash&lt;/strong&gt; — this is the hash of the previous block, without which there will be no connection between blocks and no chronology.&lt;/li&gt;
&lt;li&gt;*&lt;em&gt;nBits *&lt;/em&gt;— this is the encoded target threshold under which a block is considered valid. The lower the target, the greater the difficulty to generate a block. Generating a block is more like a lottery. It generates numbers between 0 and 256-bit numbers and a hash is considered valid if it is under the target. Please note, as the target decreases (so the number is smaller), the number of zeros increases, so the difficulty increases.&lt;/li&gt;
&lt;li&gt;*&lt;em&gt;Nonce *&lt;/em&gt;— is the variable increment for the PoW (Proof of Work).&lt;/li&gt;
&lt;li&gt;*&lt;em&gt;Timestamp *&lt;/em&gt;— this not only adds some randomness to the block hash, but it also makes it difficult for an adversary to manipulate the blockchain. A timestamp is considered valid if it is greater than the median timestamp of the previous 11 blocks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So based on these components of Block Header, this is how blocks are linked:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs59jii8q32dyp4whwt49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs59jii8q32dyp4whwt49.png" alt="Image description" width="700" height="238"&gt;&lt;/a&gt;&lt;br&gt;
In this scenario, if a hacker wants to attack a specific block number, they will have to alter not only preceding blocks, but also following blocks, as other miners are constantly checking hashes and the longest chain of blocks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xvdyu6uudza3fdrj96l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4xvdyu6uudza3fdrj96l.png" alt="Image description" width="700" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Wallets
&lt;/h2&gt;

&lt;p&gt;A wallet is a program that allows users to buy, sell or monitor balances. This only makes sense in cases where we are storing values in the digital ledger of the blockchain. [7]&lt;/p&gt;

&lt;p&gt;Wallets use a private-public keys pair to authenticate users.&lt;/p&gt;

&lt;p&gt;There are 3 types of wallets, available to store/reflect the transactions on blockchain:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;software — mobile, desktop or web apps&lt;/li&gt;
&lt;li&gt;hardware — stores private keys on hardware devices, such as USB&lt;/li&gt;
&lt;li&gt;paper — the pair of keys are generated by the software and then they are printed, to make transaction possible (by sending funds to the address on paper)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How a transaction is executed&lt;br&gt;
Transactions are part of the block body and are the most important component of a blockchain. Any other components have the role of contributing to the safety of transactions.&lt;/p&gt;

&lt;p&gt;Transactions are data structures that encode the transfer of value between participants in the blockchain system. The process of transaction verification and recording is immediate and permanent. [8] The transaction is approved through a process known as consensus.&lt;/p&gt;

&lt;p&gt;A transaction is committed in 4 stages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initiation of transaction proposal. At the initial stage, the transaction is created and signed by the owner.&lt;/li&gt;
&lt;li&gt;At this stage, the transaction is broadcasted to the network.&lt;/li&gt;
&lt;li&gt;The transaction is verified. Once the transaction is broadcasted to the network, other authorised nodes verify it. If the transaction is valid, it is added to a Block, and if not, nodes reject the transaction. [8]&lt;/li&gt;
&lt;li&gt;The transaction is committed. Finally, the Block is added to the Blockchain, and the transaction is committed.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Mining
&lt;/h2&gt;

&lt;p&gt;This is a process of recording new transactions on the blockchain ledger. When two  users make a transaction, nobody can see it until a miner puts it in a block. It is only after confirming the nonce value by the miner, which matches a valid hash (under target encoded in nbits).&lt;/p&gt;

&lt;p&gt;For example, if the difficulty is 4, in this case, the hash will be valid.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftrd1pdtgokug7wmwcvdj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftrd1pdtgokug7wmwcvdj.png" alt="Image description" width="700" height="125"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As described below, a hash function always generates the same output for the same input. So, the miners have to change something in the content of the Block in order to find a valid hash, so that would be the nonce value. They are endlessly checking values in order to find a match that would generate the desired hash value. Also, note that the timestamp is constantly changing during the miner’s effort to find (to mine) the nonce value.&lt;/p&gt;

&lt;p&gt;By creating a block, a miner receives a monetary reward, so they will have an interest in investing effort in this process.&lt;/p&gt;

&lt;p&gt;The mining process is not essential for a blockchain to exist. This is a way of validating transactions especially used for public blockchains. In private blockchains, there can be customised rules to validate transactions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Longest chain rule
&lt;/h2&gt;

&lt;p&gt;For adding a new block to the blockchain, we need to use a lot of effort to generate the blocks. As a rule, nodes will always select the longer chain over the shorter one.&lt;/p&gt;

&lt;p&gt;Adopting the longest chain rule allows every node on the network to agree on what the blockchain looks like. [9] So, they agree in this way on the same transaction history. This means that nodes that are acting independently can maintain a globally shared view of a file.&lt;/p&gt;

&lt;p&gt;Let’s assume, there are 100 blocks on the chain and a malicious node gets corrupted on node 23. Affecting node 23 on a local node will also break the next node, so if this node tries to broadcast its blockchain to the network, the other nodes will reject it as they already have longer chains on their local nodes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ks16akv8hkp489wtskj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6ks16akv8hkp489wtskj.png" alt="Image description" width="590" height="170"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, sometimes the longest chain rule does not necessarily mean the blockchain that requires the most energy to be created. [9] This is the case when nodes have to check 2 versions of the blockchain with multiple difficulty periods. In this case, nodes will select the one with the most cumulative chainwork (the total number of hashes that are expected to have been necessary to produce the chain).&lt;/p&gt;




&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;p&gt;[1] &lt;a href="https://www.javatpoint.com/blockchain-merkle-tree"&gt;https://www.javatpoint.com/blockchain-merkle-tree&lt;/a&gt;&lt;br&gt;
[2] &lt;a href="https://medium.com/@PrinceChioma4/blocks-all-you-need-to-know-3-d32dae9a4271"&gt;https://medium.com/@PrinceChioma4/blocks-all-you-need-to-know-3-d32dae9a4271&lt;/a&gt; &lt;br&gt;
[3] &lt;a href="https://towardsdatascience.com/mechanisms-securing-blockchain-data-9e762513ae28"&gt;https://towardsdatascience.com/mechanisms-securing-blockchain-data-9e762513ae28&lt;/a&gt;&lt;br&gt;
[4] &lt;a href="https://www.investopedia.com/terms/h/hash.asp"&gt;https://www.investopedia.com/terms/h/hash.asp&lt;/a&gt; &lt;br&gt;
[5] &lt;a href="https://en.wikipedia.org/wiki/Hash_function"&gt;https://en.wikipedia.org/wiki/Hash_function&lt;/a&gt; &lt;br&gt;
[6] &lt;a href="https://www.investopedia.com/terms/m/merkle-root-cryptocurrency.asp"&gt;https://www.investopedia.com/terms/m/merkle-root-cryptocurrency.asp&lt;/a&gt; &lt;br&gt;
[7] &lt;a href="https://www.investopedia.com/terms/b/blockchain-wallet.asp"&gt;https://www.investopedia.com/terms/b/blockchain-wallet.asp&lt;/a&gt; &lt;br&gt;
[8] &lt;a href="https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch05.html"&gt;https://www.oreilly.com/library/view/mastering-bitcoin/9781491902639/ch05.html&lt;/a&gt; &lt;br&gt;
[9] &lt;a href="https://learnmeabitcoin.com/technical/longest-chain"&gt;https://learnmeabitcoin.com/technical/longest-chain&lt;/a&gt; &lt;/p&gt;

</description>
      <category>programming</category>
      <category>blockchain</category>
    </item>
    <item>
      <title>Components of the blockchain ecosystem</title>
      <dc:creator>Lucian Gruia</dc:creator>
      <pubDate>Mon, 21 Feb 2022 12:49:06 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/components-of-the-blockchain-ecosystem-3od0</link>
      <guid>https://dev.to/ciklum_czsk/components-of-the-blockchain-ecosystem-3od0</guid>
      <description>&lt;p&gt;Like any other software platform, blockchain has an ecosystem where components are dependent on each other.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r5l4wzv8d8u946dbv9f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0r5l4wzv8d8u946dbv9f.png" alt="Image description" width="700" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Projects&lt;/strong&gt; — The Blockchain ecosystem is currently running with some major projects and more are in the pipeline. Bitcoin, Neo, Stellar are some popular names.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Users&lt;/strong&gt; — Blockchain users are ordinary people, who make use of the blockchain or cryptocurrency to achieve some results.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Exchanges&lt;/strong&gt; — Every Blockchain project has a robust ecosystem working under it, that includes a decentralised exchange. Exchanges are developed by the Blockchain team or the community of other developers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Miners&lt;/strong&gt; — Blockchain requires a large network of independent nodes around the world to maintain it continuously. In private blockchains, a central organisation has authority over every node on the network. In public blockchains, anyone can set up their computer to act as a node and these computers are called miners.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Developers&lt;/strong&gt; — Currently there are two types of developers in the blockchain ecosystem: blockchain developers and dApps developers&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Applications&lt;/strong&gt; — Industries, developers and communities build blockchain applications to serve a specific purpose. They are called dApps and are the foundation of Web3.0&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Architectural view
&lt;/h2&gt;

&lt;p&gt;These are the most common layers available with every platform:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;App layer&lt;/strong&gt; — most commonly contains legacy and enterprise apps.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration platform&lt;/strong&gt; — layers with different kinds of protocols, like REST, governance and API management.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blockchain access layer&lt;/strong&gt; — features to fetch and write data to the blockchain&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Analytics&lt;/strong&gt; — reporting, dashboard or analytics-based system&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0v03artookdpyyg9cvl5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0v03artookdpyyg9cvl5.png" alt="Image description" width="560" height="728"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Palette generator you will ️</title>
      <dc:creator>Tomas Rezac</dc:creator>
      <pubDate>Mon, 21 Feb 2022 08:47:45 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/palette-generator-you-will-5gmc</link>
      <guid>https://dev.to/ciklum_czsk/palette-generator-you-will-5gmc</guid>
      <description>&lt;p&gt;You can check it straight away &lt;a href="https://palette.rocks/"&gt;palette.rocks&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I made yet another Palette generator
&lt;/h2&gt;

&lt;p&gt;I have been using color generators for years. There are many great ones: Coolors, Adobe color, Color hunt, Paletton, Material color tool, Dopely, to name a few.&lt;/p&gt;

&lt;p&gt;They have eased my color palette selection a lot. But maybe they could help me even more.&lt;/p&gt;

&lt;p&gt;With such a tooling one would expect to generate the right palette within minutes. In reality, it is more like hours.&lt;/p&gt;

&lt;p&gt;Maybe you know the feeling of generating super nice palette, transferring it to an accessibility checker and finding out it has too low contrast or it doesn't pass color blind test. &lt;br&gt;
And once you generate a palette, which pass all the accessibility checks, it simply doesn't look well in your particular web project.&lt;/p&gt;

&lt;p&gt;I have been thinking about how to make the color selection easier and how to save some time. How to try hundreds of palettes in my web projects in fraction of time I used to need? I decided I would create my own generator, which would be able to achieve that!&lt;/p&gt;
&lt;h2&gt;
  
  
  What a color palette generator should do
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;It needs to generate palettes easily.&lt;/li&gt;
&lt;li&gt;It needs to give you all the accessibility feedback in real time.&lt;/li&gt;
&lt;li&gt;It should show all the necessary data and feedback in one place (colors, their relations, accessibility report, preview, ...)&lt;/li&gt;
&lt;li&gt;It should be easy to transfer generated palette to you project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most of the palette generators - mentioned in the introduction part - cover up to 2 of the above mentioned points. Mostly they don't provide any accessibility feedback. And if they do, they struggle with showing all the data at one place and in real time.&lt;/p&gt;

&lt;p&gt;None of the palette generators make it very easy to transfer the generated palettes to your web. In better cases, they generate CSS variables for you. But you still need to copy paste them; reload your browser; remember how it looks like; generate new palette... and repeat the process until you are happy with result.&lt;/p&gt;

&lt;p&gt;So I made my own palette generator, and tried to cover all the points.&lt;/p&gt;
&lt;h2&gt;
  
  
  The killer feature
&lt;/h2&gt;

&lt;p&gt;Probably the most innovative palette.rocks feature is the possibility to &lt;strong&gt;connect it to your web and remote control its color theme in real time&lt;/strong&gt;. Just spin the color wheel or generate random palette and see how it looks like in your web.&lt;/p&gt;

&lt;p&gt;&lt;iframe src="https://player.vimeo.com/video/678093527" width="710" height="399"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;In order to connect your web to palette.rocks you need to fulfill following requirements:&lt;/p&gt;

&lt;p&gt;1) Your web needs to use CSS variables for colors&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
:root {
  --your-color: #1ab291;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Add this script to your page, it will expose a global function &lt;code&gt;mapPaletterRocks(mappingObject)&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://palette.rocks/script.js"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Call the &lt;code&gt;mapPaletterRocks(mappingObject)&lt;/code&gt; function with mapping object.&lt;br&gt;
Keys of that object are colors in pallete.rocks.&lt;br&gt;
Values are pairs of color variables used in your app.&lt;br&gt;
To the first in pair, a color from palette.rocks is mapped. To the second in pair, the most contrast color (white or black) is mapped.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mapPaletterRocks({
    a:['--primary-color', '--primary-contrast'],
    b:['--secondary-color', '--secondary-contrast'],
    c:['--tertiary-color', '--tertiary-contrast'],
    d:['--quaternary-color', '--quaternary-contrast'],
    customColors:[['--custom-color-1', '--custom-color-1-contrast']]
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4) Click the &lt;strong&gt;Connect YOUR WEB to live preview&lt;/strong&gt; button in palette.rocks page. Paste your web's url into the input in top of the modal and submit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it out
&lt;/h2&gt;

&lt;p&gt;You can try it on my other project. Just go to &lt;a href="https://palette.rocks/"&gt;palette.rocks&lt;/a&gt;, follow the point 4 from above and submit this url &lt;br&gt;
&lt;code&gt;https://fluid-grid.com/&lt;/code&gt;&lt;br&gt;
Then click on the &lt;strong&gt;Desktop preview&lt;/strong&gt; on the 'mobile phone' to see it in full size. And start changing colors ;)&lt;/p&gt;

&lt;h2&gt;
  
  
  More unique features:
&lt;/h2&gt;

&lt;p&gt;And there are more advanced features in palette.rocks&lt;/p&gt;

&lt;h3&gt;
  
  
  1) Color Blender
&lt;/h3&gt;

&lt;p&gt;Blender mixes all your primary colors and generates colors in between. You can then easily pick some of those as custom supplementary colors.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwow3tbywg3e52m6a32l.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwow3tbywg3e52m6a32l.gif" alt="Color Blender" width="372" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2) Reversed Backgrounds
&lt;/h3&gt;

&lt;p&gt;This - not that well known color phenomenon - is based on something called &lt;code&gt;color subtraction&lt;/code&gt;. I won't go for explanation, as it would require more than another article ;)&lt;br&gt;
You better see it in two following examples:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvomqa3euwe07003q0ib.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpvomqa3euwe07003q0ib.gif" alt="Reversed colors" width="350" height="356"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the inner squares are perceived as identical colors, until you compare them side by side.&lt;br&gt;
In real world design, you would need such inner colors if you wanted to present just three colors in some kind of split color design. This tool helps to find 4 colors which are perceived as 3. &lt;br&gt;
On the other hand, if you manually find a mid color between those two backgrounds and use it as the inner squares, you end up with 3 colors which will be perceived as 4 by your brain :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Future of palette.rocks
&lt;/h2&gt;

&lt;p&gt;There are definitely areas for more improvements: different color formats (LAB, CMYK) for manual inputs; locking custom colors (if you lock a custom color, it would change automatically, as you change your primary color); and there are probably more features, I don't think about now.&lt;br&gt;
I'll be glad for your feedback. What are YOU missing in palette.rocks?&lt;/p&gt;

</description>
      <category>html</category>
      <category>design</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Types of blockchains</title>
      <dc:creator>Lucian Gruia</dc:creator>
      <pubDate>Mon, 14 Feb 2022 12:30:02 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/types-of-blockchains-5dji</link>
      <guid>https://dev.to/ciklum_czsk/types-of-blockchains-5dji</guid>
      <description>&lt;p&gt;When we build a blockchain solution, inevitably the decision must be made as to what type is best suited to meet the business needs. It is fairly common for there to be confusion about blockchain types, most often associated with consensus algorithms. Hence, it is important to have a clear understanding of the available choices.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Public blockchain&lt;/strong&gt; — permissionless; anybody can access and read, write or participate without explicit permission or authorization. A public blockchain is decentralised and has no single network-controlled entity. It has more complex rules and consensus algorithms for better security. It is computationally expensive to mine and adds a new block because the computational power is distributed globally, e.g. Bitcoin, Etherum etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are also other types of blockchain that play an important role in replacing some classical models of centralised networks. Private institutions are leveraging the main idea behind the blockchain and applying it to upgrade their legacy systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Permissioned (private) blockchain&lt;/strong&gt; — only the members of the network can read/write/audit the blockchain. Consensus is based on a multi-party consensus algorithm. There are critics who do not consider private blockchain as “real” blockchain technology. With its centralised and exclusive nature, it defeats the purpose of the original blockchain idea. This model is faster and more cost-effective because it is hard to tamper with data and easy to validate transactions. In this model, there are permissions for nodes that can be part of the network. Also, this is less secure than a public blockchain as we make it accessible to a bigger group of users. A fine representation of a private blockchain is Linux Foundation's implementation, &lt;a href="https://www.hyperledger.org/use/fabric"&gt;Hyperledger Fabric&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Federated/Consortium blockchain&lt;/strong&gt; — this is also a private and permissioned blockchain where entities can become members of the network by prior approval or voting. This type provides all the benefits of a private blockchain but adds another major one: removing the consolidation of power to only one company. This is a good model for organisational collaboration.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjard1zsvq0tv6hh1pjn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyjard1zsvq0tv6hh1pjn.png" alt="Image description" width="700" height="264"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Use cases of blockchain technology</title>
      <dc:creator>Lucian Gruia</dc:creator>
      <pubDate>Mon, 07 Feb 2022 17:42:39 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/use-cases-of-blockchain-technology-4ona</link>
      <guid>https://dev.to/ciklum_czsk/use-cases-of-blockchain-technology-4ona</guid>
      <description>&lt;p&gt;The application of Blockchain is not limited to cryptocurrencies. There are many other implementations of it, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Banking and Finance&lt;/strong&gt; — although this was the first sector to benefit from the advantages brought by the blockchain, it is somehow also the most endangered. Currently, the cryptocurrency market is constantly growing, and centralised banking systems are in a position to adopt the new technology, or to be taken over by it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Currency&lt;/strong&gt; — it’s not only about some cryptocurrencies, or some countries that are acting cool and adopting their “official” cryptocurrency. One day one currency may emerge as the only currency. And we do not even know if “currency” will be a proper name for that representation of value, or “that currency” may be the value itself.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Healthcare&lt;/strong&gt; — healthcare and data privacy are becoming more and more correlated. Worldwide systems are relying on electronic systems to store data, which are vulnerable to attacks, or to data loss. A decentralised approach may even have implications in the integrity of priority lists for vaccinations, access to medication, and so on. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Data privacy&lt;/strong&gt; — probably one of the hottest topics of the moment that is changing because of the blockchain, and this is only the beginning. There will be the increasing need to securely store data when healthcare services and processing DNA become widespread.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Records of Property Ownership and Transfer&lt;/strong&gt; — public notary, lost or burned papers, or forged documents must become history soon, and blockchain has the capability to change all of these.&lt;br&gt;
Smart Contracts — when it comes to contracts we can even think further, about laws, constitutions of sovereign states, public declarations or international agreements.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Supply Chains&lt;/strong&gt; — humans are moving objects daily from one place to another, from country to country and keeping track of all of these may be challenging and vulnerable to many types of fraud.&lt;br&gt;
Voting — although voting is the basis of democracy, there are still no bulletproof electronic systems that may prevent fraudulent voting. This is a very complex topic and probably deserves a dedicated article on its own. Fortunately, I can recommend two very well made videos discussing this: &lt;a href="https://www.youtube.com/watch?v=w3_0x6oaDmI"&gt;Why electronic voting is a bad idea&lt;/a&gt; and &lt;a href="https://www.youtube.com/watch?v=LkH2r-sNjQs"&gt;why electronic voting is &lt;strong&gt;still&lt;/strong&gt; a bad idea&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>programming</category>
    </item>
    <item>
      <title>What is blockchain?</title>
      <dc:creator>Lucian Gruia</dc:creator>
      <pubDate>Mon, 07 Feb 2022 12:05:10 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/what-is-blockchain-1lgp</link>
      <guid>https://dev.to/ciklum_czsk/what-is-blockchain-1lgp</guid>
      <description>&lt;p&gt;You will find on Google many definitions of ‘blockchain’, so many that I will only try to summarise some of them.&lt;/p&gt;

&lt;p&gt;Blockchain is &lt;strong&gt;a system of recording information in a way&lt;/strong&gt; that makes it difficult or &lt;em&gt;impossible&lt;/em&gt; to change, hack, or cheat a system. A blockchain is essentially a &lt;strong&gt;digital ledger&lt;/strong&gt; of transactions that is duplicated and distributed across an entire network of computer systems on the blockchain. (&lt;em&gt;Source: &lt;a href="https://www.euromoney.com/learning/blockchain-explained/what-is-blockchain#:~:text=Blockchain%20is%20a%20system%20of,computer%20systems%20on%20the%20blockchain."&gt;euromoney.com&lt;/a&gt;&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Note: this is a widely accepted definition, but “impossible” is not actually the exact word to use. Maybe we can agree the statement is true in production implementations, where there are many contexts and also, a lot of physical limitations. However, it is not necessarily mathematically impossible to cheat, there’s a good description &lt;a href="https://arxiv.org/pdf/1612.06244.pdf"&gt;here&lt;/a&gt; by J.H. White in chapter 4.3.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;You can think of the blockchain as a specific type of database. It is storing data using &lt;strong&gt;blocks&lt;/strong&gt; that are chained together. New data is entered into new blocks, and once the block is filled with data, this is chained onto a previous block and this makes the data chained together in chronological order.&lt;/p&gt;

&lt;p&gt;Simplified, is a list of data blocks that are linked together with a timestamp.&lt;/p&gt;

&lt;p&gt;As common databases have already known data types, the most common use for blockchain so far has been as a ledger for transactions.&lt;/p&gt;

&lt;p&gt;Decentralised blockchains are immutable, which means that the data entered is irreversible. For Bitcoin, this means that transactions are permanently recorded and viewable by anyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The main difference between a blockchain and a database
&lt;/h2&gt;

&lt;p&gt;Actually, it depends on what you mean by “a database”. Of course, we can refer to any organised group of files linked by some logic and maybe an API, as a database; right? We can even consider an Excel document, with formulas and links between sheets, as a database as well. Technically speaking, both of these are correct. Actually, in literature, there are many opinions regarding classification models, so I can recommend this &lt;a href="https://www.c-sharpcorner.com/UploadFile/65fc13/types-of-database-management-systems/"&gt;article&lt;/a&gt; to you, it should help you get a better idea about this.&lt;/p&gt;

&lt;p&gt;However, in this comparison, we will focus more on the differences between a common SQL/NoSQL DBMS and a blockchain.&lt;/p&gt;

&lt;p&gt;A key difference is in the way data are structured. A blockchain collects and groups data in blocks that have a certain capacity in terms of storage. When a block is filled, then it is linked to the previous block, using a hash of the entire previous block content.&lt;/p&gt;

&lt;p&gt;Another key difference is that the blockchain is distributed: it does not store data in a single place and does not have a single point of failure. Of course, there are also other distributed DBMS, such as Cassandra, for example, which stores data using multiple nodes and provides a lot of support for data consistency. &lt;/p&gt;

&lt;p&gt;But there is one more key difference; an important one that makes blockchain technology so famous and revolutionary — it makes data immutable. There is no DML that allows you to modify the data, no matter what permission levels you have. You cannot cheat, you cannot root.&lt;/p&gt;

&lt;p&gt;And what is more fascinating is that the solution was there with us all the time and it is a mathematical one. We do not need to struggle to make systems more secure, to hide sensitive data, to use more and more powerful servers to handle security and block attacks. We actually only needed to do the reverse: to share them with everyone and to create links between blocks of data, so if anyone changed anything, all the others would know. It is security by transparency and hiding things where everyone can see them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some history
&lt;/h2&gt;

&lt;p&gt;The history of blockchain as a popular trend started with the publication of the whitepaper &lt;a href="https://bitcoin.org/bitcoin.pdf"&gt;Bitcoin: A Peer-to-Peer Electronic Cash System&lt;/a&gt;, written by someone calling themselves &lt;a href="https://en.wikipedia.org/wiki/Satoshi_Nakamoto"&gt;Satoshi Nakamoto&lt;/a&gt; in 2008. The bitcoin project started the cryptocurrency era being the first implementation of a peer-to-peer network as a solution to the double-spending problem. Even though this project continues to function and circulate successfully to date, Nakamoto’s ideas behind the creation of bitcoin have exceeded the original use case. Now, these ideas are known collectively and independently as &lt;strong&gt;the blockchain&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;However, the underlying maths concepts are older than the bitcoin implementation; the P2P concept was already known and other implementations existed before blockchain, but they did not become so popular and also, did not have the same technical results in terms of benefits.&lt;/p&gt;

&lt;p&gt;So, were there predecessors of blockchain? The answer is &lt;strong&gt;yes&lt;/strong&gt;. Here were some:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;DigiCash — founded in 1989 by David Chaum, an American cryptographer. It was based on the mechanism named “Blind Signature”, an innovation that eventually led to the development of blockchain technology. The &lt;a href="http://www.hit.bme.hu/~buttyan/courses/BMEVIHIM219/2009/Chaum.BlindSigForPayment.1982.PDF"&gt;whitepaper&lt;/a&gt; describing it was written even earlier, in 1983.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HashCash — an email &lt;a href="https://ethereum.org/en/developers/docs/consensus-mechanisms/pow/"&gt;PoW&lt;/a&gt; system designed to figure out spam emails and &lt;a href="https://www.paloaltonetworks.com/cyberpedia/what-is-a-denial-of-service-attack-dos#:~:text=A%20Denial%2Dof%2DService%20(,information%20that%20triggers%20a%20crash.)"&gt;DoS attacks&lt;/a&gt;. It was developed in 1997 by Adam Back but the &lt;a href="https://www.researchgate.net/publication/2482110_Hashcash_-_A_Denial_of_Service_Counter-Measure"&gt;documentation&lt;/a&gt; was released 5 years later.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;B-Money — an early age distributed cash system proposed by Wei Dai in 1998, who also developed Crypto++. The smallest subunit of &lt;strong&gt;&lt;a href="https://en.wikipedia.org/wiki/Ethereum#:~:text=Ether%20(ETH)%20is%20the%20cryptocurrency,which%20also%20go%20to%20miners."&gt;Ether&lt;/a&gt;&lt;/strong&gt; is &lt;strong&gt;wei&lt;/strong&gt; named after him.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;E-Gold Ltd — digital gold currency founded in 1996 by Douglas Jackson and Barry Downey. They were using precious metals as the underlying currency as these are globally acceptable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Bitgold — although not implemented, it was proposed by Nick Szabo in 1998. It is one of the best known decentralised virtual currency projects undertaken before blockchain. Bitgold and bitcoin &lt;a href="https://nakamotoinstitute.org/bit-gold/"&gt;are so similar&lt;/a&gt; that at one point, people thought Nick Szabo actually was the anonymous Satoshi Nakamoto.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>blockchain</category>
      <category>programming</category>
    </item>
    <item>
      <title>From UIKit to SwiftUI</title>
      <dc:creator>Jakub Fišer</dc:creator>
      <pubDate>Sat, 11 Dec 2021 10:46:14 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/from-uikit-to-swiftui-4plm</link>
      <guid>https://dev.to/ciklum_czsk/from-uikit-to-swiftui-4plm</guid>
      <description>&lt;p&gt;Many SwiftUI tutorials exist on the internet these days. This is &lt;strong&gt;not&lt;/strong&gt; going to be one of them! Instead, today I’d like to share with you my personal story of how someone with 5-year prior development experience in UIKit (an older UI framework for iOS) learned an entirely different concept for the first time – SwiftUI (a new UI framework for all Apple platforms).&lt;/p&gt;

&lt;h2&gt;
  
  
  Many hands make light work
&lt;/h2&gt;

&lt;p&gt;I joined CN Group this year and was assigned to a project written in SwiftUI. It was both exciting and a little scary at the same time, as SwiftUI introduced an entirely different paradigm to iOS and all my prior UIKit knowledge was of no help. Thankfully, my new and more experienced colleagues were at hand since CN Group is an early adopter of SwiftUI.&lt;/p&gt;

&lt;p&gt;Since its introduction in June 2019, they have developed several applications of various types in SwiftUI. For example, CN Group released an application for e-commerce, requiring pixel-perfect design and tons of animation. Then there is an IoT (Internet of Things) application building upon BLE (Bluetooth Low Energy) communication with an external smart device. And last but not least there is an AR (Augmented Reality) application for construction workers that leverages a LiDAR scanner.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons learned
&lt;/h2&gt;

&lt;p&gt;Since SwiftUI is entirely different from UIKit, I had to start from the very beginning. A &lt;em&gt;SwiftUI Views Quick Start&lt;/em&gt; guide [1] was recommended to me as a great starting point - and indeed, it was. I discovered lots of useful information about basic UI controls, layout components, view sizing, view modifiers and much more. Another help was &lt;em&gt;All SwiftUI property wrappers explained and compared&lt;/em&gt; [2] that is very handy as a great overview. Here’s an example of how to use the @EnvironmentObject property wrapper to pass values down the view hierarchy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Pass values down
let contentView = ParentView()
            .environmentObject(theme)
            .environmentObject(PartialSheetManager())
            .environmentObject(DialogManager())

// Get values in any view down in hierarchy
struct AnyChildView: View {
    @EnvironmentObject var theme: Theme
    @EnvironmentObject var partialSheet: PartialSheetManager

    …
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When I then started to code with SwiftUI on my own, it seemed to be quite easy. With less code required, UI development was super-fast and very intuitive. There is also a live preview feature that, most of the time, eliminates the need to run the application in a simulator. As a result, implementation time is significantly reduced, and it feels almost like magic! For example, a shape in the following figure can be implemented with just 20 lines of code! Plus, it scales, and you can set any background or border you want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struct ProgressBarWithEndBubble: Shape {
    let scaleCircle: CGFloat = 0.5
    let scalePath: CGFloat = 12/32
    let startAngleCircle: Double = 202
    let endAngleCircle: Double = 158
    let startAnglePath: Double = 90
    let endAnglePath: Double = 270

    func path(in rect: CGRect) -&amp;gt; Path {
        let circleRadius = rect.height * scaleCircle
        let pathRadius = circleRadius * scalePath
        return Path { path in
            path.move(to: .init(x: pathRadius, y: rect.midY - pathRadius))
            path.addArc(center: .init(x: rect.maxX - circleRadius, y: rect.midY),
                        radius: circleRadius,
                        startAngle: .init(degrees: startAngleCircle),
                        endAngle: .init(degrees: endAngleCircle),
                        clockwise: false)
            path.addArc(center: .init(x: rect.minX + pathRadius, y: rect.midY),
                        radius: pathRadius,
                        startAngle: .init(degrees: startAnglePath),
                        endAngle: .init(degrees: endAnglePath),
                        clockwise: false)
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frzm6m0jyjhzlthjqe4tc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frzm6m0jyjhzlthjqe4tc.png" alt="Custom shape for progress bar" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Coming from an UIKit background, the most difficult part for me was getting used to the fact that I was no longer in control of the view hierarchy. As SwiftUI is a declarative framework, its main concept is that you define “what” should be displayed instead of “how” it should be implemented. As explained in &lt;em&gt;Demystify SwiftUI&lt;/em&gt; [3], you still need to follow some rules in order to achieve the animations you desire. Your code is then transformed (and optimised) to the view hierarchy on your behalf. There is a downside - you will no longer get much benefit from the view hierarchy debugger.&lt;/p&gt;

&lt;p&gt;I also struggled a bit with atomic design principles. Even though these are not directly involved in the SwiftUI framework, it helps to keep your code clean. Atomic design is a methodology that defines 5 levels of UI - atom, molecule, organism, template, screen - where each builds on lower-level components (e.g., molecules consist of atoms, etc.). In UIKit, every new UIView (the base class for viewable content) in a hierarchy could result in potential performance issue. This doesn’t apply for SwiftUI. On the contrary, you are encouraged to decompose your UI into smaller components with zero to little performance impact. This also results in improved code readability. Here is an example of such a component (two horizontally aligned buttons), that is both easy to reuse and to read:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;struct AppLandingActionView: View {
    let onLogIn: Callback
    let onSignUp: Callback

    var body: some View {
        HStack(spacing: Theme.spaces.s4) {
            RoundedButton(“Log In”, .quaternary, action: onLogIn)
            RoundedButton(“Sign Up”, .primary, action: onSignUp)
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Let’s be a little negative
&lt;/h2&gt;

&lt;p&gt;To be honest, there is still some functionality missing from SwiftUI. This is particularly obvious if you know that something missing was available in UIKit. For example, in SwiftUI, List (equivalent to UITableView) is still quite limited, as there is no way to react to scroll events and, until recently, it was not even possible to customise separators (introduced with iOS 15 in September 2021). You also need to be cautious when it comes to GeometryReader as extensive use might result in performance issues. And even as basic a component as text inputs can give you hard times in some cases - there’s more about that in &lt;em&gt;SwiftUI in production&lt;/em&gt; [4]. Luckily, SwiftUI and UIKit are interoperable with each other, so if you find something that really can’t be done in SwiftUI, you can always switch back to UIKit as your last option. The following figure contains such an example of using UITextField in SwiftUI, including reacting to SwiftUI environment values and using new property wrappers, which makes final usage really SwiftUI-like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// SwiftUI wrapper for UIKit text field view
struct DynamicTextField: UIViewRepresentable {
    @Binding var text: String
    let placeholder: String
    let textField = InsetTextField()    // custom UITextField subclass

    private var textInsets: EdgeInsets = .init()
    private var isSecure: Bool
    private var onCommit: (() -&amp;gt; Void)? = nil

    init(text: Binding&amp;lt;String&amp;gt;, placeholder: String = "", isSecure: Bool = false) {
        self._text = text
        self.placeholder = placeholder
        self.isSecure = isSecure
    }

    func makeCoordinator() -&amp;gt; Coordinator {
        Coordinator(parent: self)
    }

    func makeUIView(context: Context) -&amp;gt; InsetTextField {
        textField.placeholder = placeholder
        textField.autocapitalizationType = .none
        textField.delegate = context.coordinator
        return textField
    }

    func updateUIView(_ uiView: InsetTextField, context: Context) {
        uiView.text = text
        uiView.textInsets = textInsets.uiInsets
        uiView.isSecureTextEntry = isSecure
        if context.environment.disableAutocorrection == true {
            uiView.autocorrectionType = .yes
        }
    }

    class Coordinator: NSObject, UITextFieldDelegate {
        var parent: DynamicTextField

        init(parent: DynamicTextField) {
            self.parent = parent
            super.init()
            parent.textField.addTarget(self, action: #selector(editingChanged(_:)), for: .editingChanged)
        }

        @objc func editingChanged(_ textField: UITextField) {
            parent.text = textField.text ?? ""
        }

        // MARK: - UITextFieldDelegate
        func textFieldShouldReturn(_ textField: UITextField) -&amp;gt; Bool {
            parent.onCommit?()
            return true
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;To sum things up, SwiftUI can be used for any type of application, and I believe that it is much more efficient, readable, and fun, which is a win-win for both developers and businesses. Additionally, Apple’s effort to push SwiftUI forward indicates that it may become the main UI framework in the near future. With 5 months of intense experience, I personally don’t see any reason for developers to hold back.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://www.bigmountainstudio.com/free-swiftui-book"&gt;SwiftUI Views - Quick Start [Big Mountain Studio]&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.hackingwithswift.com/quick-start/swiftui/all-swiftui-property-wrappers-explained-and-compared"&gt;All SwiftUI property wrappers explained and compared [Hacking with swift]&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.apple.com/videos/play/wwdc2021/10022/"&gt;Demystify SwiftUI [Apple]&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pspdfkit.com/blog/2021/swiftui-in-production"&gt;SwiftUI in production [PSPDFKit]&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>ios</category>
      <category>swift</category>
      <category>programming</category>
    </item>
    <item>
      <title>Farmer, a better way to manage Azure resources</title>
      <dc:creator>Jiří Landsman</dc:creator>
      <pubDate>Sat, 27 Nov 2021 17:34:34 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/farmer-a-better-way-to-manage-azure-resources-4kho</link>
      <guid>https://dev.to/ciklum_czsk/farmer-a-better-way-to-manage-azure-resources-4kho</guid>
      <description>&lt;p&gt;The usual way to manage Azure resources is to open the Azure portal and click everything. Do you want a new App Service? Click and it’s there. Need a place to store uploaded images? Click ‘add new Storage Account’ and there you go. You can start uploading images to new blob. And what if you need a new SQL Server DB for your data? Just click the button, wait five to ten minutes and you are all set up J. You have your new dev environment for your awesome project. Everything is great right?&lt;/p&gt;

&lt;p&gt;And then do the same for testing, QA, and production. And did you hear about the possibility of having a short-lived environment for each development branch? Suddenly, even this simple 3 service setup doesn’t look so cool. This is where Infrastructure as Code comes to save us. And I would like to show you one little project I particularly like – Farmer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But first things first.&lt;/strong&gt;&lt;br&gt;
To understand what Farmer is, first you need to have a basic understanding of the nature of Azure Resource Manager.&lt;/p&gt;

&lt;p&gt;Similar to AWS’s CloudFormation, Azure has its own Infrastructure as Code (IaC) framework named Azure Resource Manager (ARM).&lt;/p&gt;

&lt;p&gt;ARM templates use JSON to define Azure resources in a declarative way. Within a template, you can use special template expressions that extend the capabilities of JSON. These expressions use the Resource Manager’s functions such as parameters, variables, or even user-defined functions. The deployment process then converts the template to a series of REST API calls to create final resources.&lt;/p&gt;

&lt;p&gt;You can do everything with it on Azure, but it also has a few disadvantages.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx7bzqthrkw1c0w5xx3t9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fx7bzqthrkw1c0w5xx3t9.png" alt="Image description" width="800" height="383"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s incredibly verbose. The example above is maybe as simple as possible, and it still takes over ten lines of code to define. When you start combining multiple resources, setting parameters, and so on, it rapidly gets enormous.&lt;/p&gt;

&lt;p&gt;Another strong argument against useing ARM directly is that it is not statically checked, compiled, and contains many magic strings you need to use, like values of “type” and “location” properties in an example.&lt;/p&gt;

&lt;p&gt;For that reason, I think it’s better to look for some solution that uses your programming language of choice. For me, that language is F#, and thankfully there is one library that is just perfect for the job.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to makes repeatable Azure deployments easy.&lt;/strong&gt;&lt;br&gt;
Created by Compositional IT, Farmer utilises the power of F# and its computation expressions to define your Azure resources and generate ARM templates.&lt;/p&gt;

&lt;p&gt;A template defined using Farmer is just normal F# code and can be run as an application or inside a F# script. That means that you can create complex structure of functions to generate your desired infrastructure. Names of the services, and as a matter of fact every service parameter, can be injected as parameters from a configuration. Thanks to this it is easy to create a copy of the infrastructure for the QA/production environments.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3hgkxw2wcil3p37sk797.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3hgkxw2wcil3p37sk797.png" alt="Image description" width="800" height="192"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the same example as before but created using Farmer. Much simpler, isn’t it?&lt;/p&gt;

&lt;p&gt;F# is a succinct language, so even the most complex infrastructure definition will most likely fit in a single file. This can be a big benefit when you are onboarding new team members, since they will be able to understand it quickly. Even our customers can read this kind of code and we can discuss the changes using a single document.&lt;/p&gt;

&lt;p&gt;Because everything is just a F# code every value is strongly typed. The only string in the example is the name of the service. The result of such an expression is an instance of an object and when you want to define relationships and dependencies between the resources it is as easy as assigning a value to a field.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ok you got me, but I have an existing environment. Is it a problem to integrate Farmer?&lt;/strong&gt;&lt;br&gt;
No, not at all. Just do it J. If you already have some infrastructure defined some other way there is no need to throw it all away and start over with Farmer.&lt;/p&gt;

&lt;p&gt;In the end the result of a Farmer program is an ARM template file so you can just integrate that into you existing pipeline. And if you don’t have a pipeline at all you can create one. It’s a better way to do things anyway J&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;But there must be some buts, right?&lt;/strong&gt;&lt;br&gt;
Nothing is just rainbows and butterflies. Even a project as awesome as Farmer has some.&lt;/p&gt;

&lt;p&gt;For me the main one is that it does not support all the services in Azure. But they are trying. Did I mention that the whole project is open source? So, if you are missing some service support or just some configuration value, nothing is stopping you from creating a pull request. They are fast with feedback. If pull requests are not your cup of tea, Compositional IT even provide commercial support.&lt;/p&gt;

&lt;p&gt;The second issue is that Farmer does not support ARM parameters and variables. They have their own reasoning about that. But because the whole ARM template is just a F# program anyway it is easy to work around that and have such logic implemented outside of an ARM template.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;To conclude all of this…&lt;/strong&gt;&lt;br&gt;
Even if there are much larger alternatives such as Pulumi or Terraform, there is still place for project like Farmer. It doesn’t have all the bells and whistles of its competitors. It does not support multiple cloud providers or programming languages. It’s simple, and straightforward. It does one thing and does it great. If you are just starting to experiment with Infrastructure as Code frameworks, I think Farmer is a great first step. If you are an experienced developer in this field, it is a good tool to have in your toolbelt.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Asynchronous Streams in C#</title>
      <dc:creator>Josef Matějka</dc:creator>
      <pubDate>Sat, 31 Jul 2021 08:16:55 +0000</pubDate>
      <link>https://dev.to/ciklum_czsk/asynchronous-streams-in-c-3479</link>
      <guid>https://dev.to/ciklum_czsk/asynchronous-streams-in-c-3479</guid>
      <description>&lt;h1&gt;
  
  
  C# Asynchronous streams
&lt;/h1&gt;

&lt;p&gt;I think everyone will agree that collections and data enumeration is usually bread and butter of C# programming. As a programmers we have at our disposal great tools for synchronous enumeration, we have IEnumerable and its generic variant, which can be combined with &lt;code&gt;foreach&lt;/code&gt; expression and/or with LINQ. But until C# 8.0 the options for asynchronous enumeration were limited. Iterators were strictly synchronous, thus programmers had to come up with their own solutions - the usual aproach was to create a method returning type &lt;code&gt;Task&amp;lt;IEnumerable&amp;lt;T&amp;gt;&amp;gt;&lt;/code&gt;. A task that will asynchronously get a part of the collection and then synchronously enumerate it, when the task succesfully finished. In this article we will explore &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; which provides an fast and elegant solution to asynchronous enumeration.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;As I said in some cases it is necesarry to load data asynchronously because&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;they are behind a blocking call (files, data send through the network),&lt;/li&gt;
&lt;li&gt;or we have to wait before data are generated (like in case of &lt;code&gt;Channel&amp;lt;T&amp;gt;&lt;/code&gt;),
and we don't want to block a thread by waiting for the result. Obtaining part of data asynchronously and then enumerating the result works good from the perfomance perspective, but syntactically it can be a bit awkward and over-complicated considering how elegant does the enumeration look in case of synchronous code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  IAsyncEnumerable and IAsycnEnumerator
&lt;/h2&gt;

&lt;p&gt;I assume the reader is already familiar with &lt;code&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; and &lt;code&gt;IEnumerator&amp;lt;T&amp;gt;&lt;/code&gt;, the asynchronous variant closesly mirrors the synchronous version, but there are few differences.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GetAsyncEnumerator (counterpart of GetEnumerator) accepts a CancellationToken,&lt;/li&gt;
&lt;li&gt;MoveNextAsync (counterpart of MoveNext) returns &lt;code&gt;ValueTask&amp;lt;T&amp;gt;&lt;/code&gt; instead of T,&lt;/li&gt;
&lt;li&gt;and disposing is done via DisposeAsync instead of Dispose.&lt;/li&gt;
&lt;li&gt;Reset method is missing (but for synchronous part it is usually not implemented).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As in the case of &lt;code&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; and &lt;code&gt;IEnumerator&amp;lt;T&amp;gt;&lt;/code&gt; programmers usually does not have to implement explicitly, but they can use iterators which will generate it. Since C# 8.0 can also generate &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; and &lt;code&gt;IAsyncEnumerator&amp;lt;T&amp;gt;&lt;/code&gt; via asynchronous iterators and C# provides direct support which allows you to use asynchronous stream in similar way as their synchronous counterpart. Which is why they should feel familiar, therefore it should not be problem to embrace them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating asynchronous iterator block
&lt;/h2&gt;

&lt;p&gt;Rules for the creating a asynchronous iterator with &lt;code&gt;yield return&lt;/code&gt; or &lt;code&gt;yield break&lt;/code&gt; are again analogous to the synchronous version. Your function must be of a return type &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; or &lt;code&gt;IAsyncEnumerator&amp;lt;T&amp;gt;&lt;/code&gt; it also must be &lt;code&gt;async&lt;/code&gt; function. That means no parameter can be &lt;code&gt;ref&lt;/code&gt; or &lt;code&gt;out&lt;/code&gt; and it should contain an &lt;code&gt;await&lt;/code&gt; expression. For example, consider this function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;IAsyncEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;FibonacciAsync&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;EnumeratorCancellation&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;CancellationToken&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;f0&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;f1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;f0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f0&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="k"&gt;break&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Delay&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TimeSpan&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromSeconds&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;ConfigureAwait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;f0&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;f1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;f1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This function returns a Fibonacci sequence of all numbers that fit into an &lt;code&gt;int&lt;/code&gt;, overflow is check by this condition &lt;code&gt;if (fn &amp;lt; 1)&lt;/code&gt;, we use &lt;code&gt;Task.Delay&lt;/code&gt; for simulation of asynchronous execution, in reality the asynchronous part would be for example an database fetch or any other similar blocking operation.&lt;/p&gt;

&lt;p&gt;Since we are talking about asynchronous execution, we have to ponder a bit about cancellation of execution. If we look at &lt;code&gt;GetAsyncEnumerator&lt;/code&gt; it accepts an optional &lt;code&gt;CancellationToken&lt;/code&gt;. But in our case the &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; is generated by compiler, how can we work with a token passed to &lt;code&gt;GetAsyncEnumerator&lt;/code&gt;? If you put attribute &lt;code&gt;EnumeratorCancellation&lt;/code&gt; in front of an &lt;code&gt;CancellationToken&lt;/code&gt; argument and compiler knows that for the enumerator cancellation serves said argument.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enumerating throught asynchronous stream
&lt;/h2&gt;

&lt;p&gt;Let's continue by enumeration of first 5 Fibonacci's numbers. Seasoned C# programmer would immediatelly use &lt;code&gt;Take&lt;/code&gt; from &lt;code&gt;System.Linq&lt;/code&gt;. Sadly for asynchronous enumerable it is necessary to download nuget package &lt;code&gt;System.Linq.Async&lt;/code&gt; first. It contains overloads of classic extension methods for &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt;. We expect that in future version of C# you will not have to download this nuget package, the methods will be automatically incorporated in base framework and no additional packages will be requiered.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;Main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;source&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;CancellationTokenSource&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;foreach&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nf"&gt;FibonacciAsync&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;Take&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;WithCancellation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Token&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;ConfigureAwait&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, C# supports asynchronous version of &lt;code&gt;foreach&lt;/code&gt; with &lt;code&gt;await&lt;/code&gt; word in front of it, the difference is that the underneath &lt;code&gt;MoveNextAsync&lt;/code&gt; calls are awaited and after finishing the enumerator is disposed asynchronously. If you need to pass a &lt;code&gt;CancellationToken&lt;/code&gt; you can do that via extension method &lt;code&gt;WithCancellation&lt;/code&gt;, which distributes the token to each internal &lt;code&gt;MoveNextAsync&lt;/code&gt; call. This token we get in our &lt;code&gt;FibonacciAsync&lt;/code&gt;, because we decorated our token argument with &lt;code&gt;EnumeratorCancellation&lt;/code&gt; attribute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance concerns
&lt;/h2&gt;

&lt;p&gt;Like in syncrhonous case, using an async iterator means, that a state machine is generated. It is represented by a hidden class implementing these interfaces: &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt;, &lt;code&gt;IAsyncEnumerator&amp;lt;T&amp;gt;&lt;/code&gt;, &lt;code&gt;IAsyncStateMachine&lt;/code&gt;, &lt;code&gt;IValueTaskSource&amp;lt;bool&amp;gt;&lt;/code&gt;, and &lt;code&gt;IValueTaskSource&lt;/code&gt;. The reason why one class implements both &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; and &lt;code&gt;IAsyncEnumerator&amp;lt;T&amp;gt;&lt;/code&gt; is to avoid unnecessary allocations. If you have a class implementing &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; and another one implementing &lt;code&gt;IAsyncEnumerator&amp;lt;T&amp;gt;&lt;/code&gt; you need to create a new instance of enumerator each enumeration. That can be avoided if one class implement both interfaces. If no one is using the object, it can be reused as an enumerator (the same principle also goes for synchronous iterators).&lt;/p&gt;

&lt;p&gt;The main trick to keep the allocation low is to use &lt;code&gt;ValueTask&amp;lt;T&amp;gt;&lt;/code&gt; over a &lt;code&gt;Task&lt;/code&gt; and implementing &lt;code&gt;IValueTaskSource&amp;lt;bool&amp;gt;&lt;/code&gt; and &lt;code&gt;IValueTaskSource&lt;/code&gt;. As the name suggest, the &lt;code&gt;ValueTask&amp;lt;T&amp;gt;&lt;/code&gt; has value semantics (whereas classic &lt;code&gt;Task&amp;lt;T&amp;gt;&lt;/code&gt; is a reference type). This is important in cases when the &lt;code&gt;MoveNextAsync&lt;/code&gt; call runs synchronously, because in that case the &lt;code&gt;ValueTask&amp;lt;T&amp;gt;&lt;/code&gt; can be put on the stack and we can avoid heap allocation and garbage collection of this task - which hleps performance-wise. So it is expected to use async enumeration with some kind of buffering, when in asynchronous call some data are loaded and then they're returned synchronously. If you are interested in the &lt;code&gt;ValueTask&amp;lt;T&amp;gt;&lt;/code&gt; more, I recommend reading this blog post: &lt;a href="https://devblogs.microsoft.com/dotnet/understanding-the-whys-whats-and-whens-of-valuetask/"&gt;Understanding the Whys, Whats, and Whens of ValueTask&lt;/a&gt;, which explains this type and its usage in depth.&lt;/p&gt;

&lt;p&gt;Last interface &lt;code&gt;IAsyncStateMachine&lt;/code&gt; is only intended for compiler, the runtime and internal APIs uses this interface to perform awaits.&lt;/p&gt;

&lt;p&gt;The number of unecessary allocations is low, the microsoft itself states this: "The compiler implementation has been designed to keep allocations incredibly low; in fact, no matter how many times an async iterator yields, the most common case is that it incurs at most two allocations of overhead."&lt;/p&gt;

&lt;h2&gt;
  
  
  Thread safety warning
&lt;/h2&gt;

&lt;p&gt;This may be surprising to some, but in general &lt;code&gt;MoveNextAsync&lt;/code&gt; is not thread-safe. On a given enumerator each call to &lt;code&gt;MoveNextAsync&lt;/code&gt; must happen after the last &lt;code&gt;MoveNextAsync&lt;/code&gt; has finished, therefore you cannot invoke enumeration concurrently. It is not a problem for a &lt;code&gt;MoveNextAsync&lt;/code&gt; to be called from a different thread, but you must not call this function from multiple threads at the same time. The main problem is, that anything can happen. It can seem to be running correctly in some cases, in some cases an exception could be emitted. So if you want to save yourself some debugging time, stay away from enumerating &lt;code&gt;IAsyncEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; concurrently.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Newly added asynchronous iterators provide a great tool for dealing with reading data collections asynchronously, this can be useful when loading data from database, files, internet or it can be usefull for in-memory collections too, like in case of Channel data structure. Plus side is, there's very small performance overhead and they closely mirror their synchronous counterpart, which makes them easier to use, because most programmers have already dealt with enumerables.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>dotnet</category>
    </item>
  </channel>
</rss>
