<?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: Zalán</title>
    <description>The latest articles on DEV Community by Zalán (@tothzalan).</description>
    <link>https://dev.to/tothzalan</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%2Fuser%2Fprofile_image%2F332528%2Fadbe5e2a-d1a0-4a8a-9227-a2b9aa29b7e9.png</url>
      <title>DEV Community: Zalán</title>
      <link>https://dev.to/tothzalan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tothzalan"/>
    <language>en</language>
    <item>
      <title>TypeScript generics</title>
      <dc:creator>Zalán</dc:creator>
      <pubDate>Tue, 21 Jul 2020 15:39:19 +0000</pubDate>
      <link>https://dev.to/tothzalan/typescript-generics-11ie</link>
      <guid>https://dev.to/tothzalan/typescript-generics-11ie</guid>
      <description>&lt;p&gt;One of the most essential aspects of software development is writing reusable code. Your code must work with variable X and even with variable Y.&lt;br&gt;
One of the most common ways you might know is writing methods. A well-written method without generics will only work with one specified type. For example this piece of code only works with integers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;isEven&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;num&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;boolean&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="nx"&gt;num&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&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;But what if we want to use more types for the same method? That's what generics are used for. During our journey of learning TypeScript, you might have come across snippets like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This Array type is using generics to only accept a certain type selected by you&lt;/p&gt;

&lt;h3&gt;
  
  
  But what is this &lt;strong&gt;&amp;lt; &amp;gt;&lt;/strong&gt; thing?
&lt;/h3&gt;

&lt;p&gt;We can use this syntax to give types to generics.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can I create generic methods or classes?
&lt;/h3&gt;

&lt;p&gt;We need a way of capturing the type of the argument in such a way that we can also use it to denote what is being returned. Here, we will use a type variable, a special kind of variable that works on types rather than values (we mostly call this variable "T").&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getRandomItem&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="p"&gt;[]):&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;random&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&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;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;[Easy]&lt;/strong&gt;: Write a generic method that swaps two values&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;[Medium]&lt;/strong&gt;: Write a generic method to count the number of elements in a collection that have a specific property (for example: odd integers, prime numbers, etc..).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;[Hard]&lt;/strong&gt;: Write a linked list implementation with generics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  If you want more write a comment and follow me, thanks!
&lt;/h4&gt;

&lt;h4&gt;
  
  
  Follow me on &lt;a href="https://twitter.com/tzalan15"&gt;twitter&lt;/a&gt;
&lt;/h4&gt;

</description>
      <category>typescript</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>What would you like to see?</title>
      <dc:creator>Zalán</dc:creator>
      <pubDate>Fri, 03 Jul 2020 19:20:41 +0000</pubDate>
      <link>https://dev.to/tothzalan/what-would-you-like-to-see-10an</link>
      <guid>https://dev.to/tothzalan/what-would-you-like-to-see-10an</guid>
      <description>&lt;p&gt;What content would you like to read more about on this website?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A month-long challenge for building Linux sysadmin skills</title>
      <dc:creator>Zalán</dc:creator>
      <pubDate>Wed, 24 Jun 2020 16:39:29 +0000</pubDate>
      <link>https://dev.to/tothzalan/a-month-long-challenge-for-building-linux-sysadmin-skills-3eb0</link>
      <guid>https://dev.to/tothzalan/a-month-long-challenge-for-building-linux-sysadmin-skills-3eb0</guid>
      <description>&lt;h3&gt;
  
  
  Are you interested in learning more about Linux? 🐧
&lt;/h3&gt;

&lt;p&gt;If you are interested than I got some good news for you. The &lt;a href="http://linuxupskillchallenge.com"&gt;http://linuxupskillchallenge.com&lt;/a&gt; Linux command-line / sysadmin "challenge" course will start on Monday.&lt;/p&gt;

&lt;h4&gt;
  
  
  But what is this challenge? 🤔
&lt;/h4&gt;

&lt;p&gt;It is a fully free and open-source course (it costs nothing but your time) where you can start learning about Linux or deepen your knowledge.&lt;/p&gt;

&lt;h4&gt;
  
  
  How is this structured?
&lt;/h4&gt;

&lt;p&gt;Daily lessons will appear in the subreddit called r/linuxupskillchallenge from this coming Monday - which will also be used for support/discussion. Furthermore, it is a "rolling" course, which restarts every month.&lt;/p&gt;

&lt;h4&gt;
  
  
  What do I need to start? 💪
&lt;/h4&gt;

&lt;p&gt;As I have mentioned above, the course is free, but it does require some commitment - but if gaining/growing these skills is important to you, then you now have no excuse.&lt;/p&gt;

&lt;p&gt;I hope you will have fun while doing the challenge   🔥 🔥&lt;/p&gt;

&lt;h5&gt;
  
  
  If you want more write a comment and follow me, thanks!
&lt;/h5&gt;

</description>
      <category>linux</category>
      <category>beginners</category>
      <category>opensource</category>
      <category>challenge</category>
    </item>
    <item>
      <title>Getting started with Regex</title>
      <dc:creator>Zalán</dc:creator>
      <pubDate>Thu, 18 Jun 2020 18:41:09 +0000</pubDate>
      <link>https://dev.to/tothzalan/getting-started-with-regex-1884</link>
      <guid>https://dev.to/tothzalan/getting-started-with-regex-1884</guid>
      <description>&lt;h1&gt;
  
  
  What is Regex?
&lt;/h1&gt;

&lt;p&gt;Regex or Regular Expression is a sequence of characters defining a search pattern. Mostly we use Regex to find and or replace text. Most of the programming languages (for example JavaScript or Python) has support for it, making it an important part of the programmers' life.&lt;/p&gt;

&lt;h2&gt;
  
  
  Regex must be really hard!!! Just look at it…
&lt;/h2&gt;

&lt;p&gt;For the first sight, regular expressions might look a bit confusing but after understanding the basics it is fairly easy to understand and master.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let’s look into regular expressions!
&lt;/h2&gt;

&lt;p&gt;For this article, I will be using the tool called “grep” (globally search for a regular expression and print matching lines) which is a command-line utility for searching plain-text data for lines that match a given regular expression. Grep comes built-in on Unix based systems. If you are using Windows, you can download it from here: &lt;a href="http://gnuwin32.sourceforge.net/packages/grep.htm"&gt;http://gnuwin32.sourceforge.net/packages/grep.htm&lt;/a&gt;. After getting grep we can start learning the most important things. I have created a file called “test.txt” which contains the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello World
Test test
is this working?
i think so...
random test
what else should I add?
tttttttttttest
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h4&gt;
  
  
  My first Regex
&lt;/h4&gt;

&lt;p&gt;With regex you can just search for a text:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep "test" test.txt&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;this will return:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BbnmfHwi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c10oa5gev53somsupgup.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BbnmfHwi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/c10oa5gev53somsupgup.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
You can see that it matched everything case-sensitively.&lt;/p&gt;
&lt;h3&gt;
  
  
  What are the most important things a beginner should learn?
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Any character: "."
&lt;/h4&gt;

&lt;p&gt;You can match any character with writing a "."&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep ".est" test.txt&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H9juxBUA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yx3hjttdoy8eh62dbejz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H9juxBUA--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yx3hjttdoy8eh62dbejz.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Match any number of previous "*":
&lt;/h4&gt;

&lt;p&gt;You can use it to match any number of the previous (including 0) with "*"&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep "t*est" test.txt&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hp2qDDPe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zm2ivw2j54u0qcyhcicj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hp2qDDPe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/zm2ivw2j54u0qcyhcicj.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  End of the line: "$":
&lt;/h4&gt;

&lt;p&gt;You can match the end of the line with "$"&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep "t$" test.txt&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hF-ZoOnI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/35wg7g66nbmtxwecwgsa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hF-ZoOnI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/35wg7g66nbmtxwecwgsa.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Something is optional: "?":
&lt;/h4&gt;

&lt;p&gt;You can make something optional by using "?"&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;grep "t\?test" test.txt&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dp71xgW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/th9363y9lbzqm9vnml5b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dp71xgW8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/th9363y9lbzqm9vnml5b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Other helpful things:
&lt;/h4&gt;

&lt;h5&gt;
  
  
  Escape character: "\"
&lt;/h5&gt;

&lt;h5&gt;
  
  
  Beginning of the line: "^"
&lt;/h5&gt;

&lt;h5&gt;
  
  
  Any lowercase letter: [a-z]
&lt;/h5&gt;

&lt;h5&gt;
  
  
  Any uppercase letter: [A-Z]
&lt;/h5&gt;

&lt;h5&gt;
  
  
  Any letter: [A-Za-z]
&lt;/h5&gt;

&lt;h3&gt;
  
  
  One final challenge:
&lt;/h3&gt;

&lt;p&gt;After reading everything I would like to challenge your knowledge with a simple exercise. Write a pattern that matches HTML tags. Have fun.&lt;/p&gt;

&lt;h3&gt;
  
  
  Now I understand these, how can I learn more about Regex?
&lt;/h3&gt;

&lt;p&gt;Congratulations, you have started your journey of mastering Regex.There are a few sites which can help you learn more about Regex and create more complicated patterns.&lt;br&gt;
My favourite site is: &lt;a href="https://regexr.com/"&gt;https://regexr.com/&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  If you want more write a comment and follow me, thanks!
&lt;/h5&gt;

</description>
      <category>regex</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
