<?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: DiniFarb</title>
    <description>The latest articles on DEV Community by DiniFarb (@dinifarb).</description>
    <link>https://dev.to/dinifarb</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%2F645006%2F54ea0ff1-9001-48a4-8ff9-57b90f5b09c4.jpg</url>
      <title>DEV Community: DiniFarb</title>
      <link>https://dev.to/dinifarb</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dinifarb"/>
    <language>en</language>
    <item>
      <title>Bitwise operations for IPv4 calculations</title>
      <dc:creator>DiniFarb</dc:creator>
      <pubDate>Wed, 04 May 2022 11:02:58 +0000</pubDate>
      <link>https://dev.to/dinifarb/bitwise-operations-for-ipv4-calculations-5cle</link>
      <guid>https://dev.to/dinifarb/bitwise-operations-for-ipv4-calculations-5cle</guid>
      <description>&lt;p&gt;When I read/hear about bitwise operations, It is often said; Yeah, that's good to know but in your day to day job as software engineer you don't have to deal with that very often. Especially when you work in higher level apps. That might be true but there is one use case for bitwise operations which is in my opinion very useful and that's when it comes down to validate if a ip address is in a given subnet or not. To make that work you basically use the bits of the subnet mask and start address to validate the bits of the ip address with bitwise &lt;code&gt;&amp;amp;&lt;/code&gt; operations. Confused? Well me to 😅 it is always better to draw such things out step by step which I'am going to try now and explain it a bit further: &lt;/p&gt;

&lt;p&gt;Let's assume we have a very small network with a subnet mask of &lt;code&gt;255.255.255.192&lt;/code&gt; and a start address with &lt;code&gt;192.168.50.65&lt;/code&gt;. Next let's take two ip addresses &lt;code&gt;192.168.50.20&lt;/code&gt; and &lt;code&gt;192.168.50.80&lt;/code&gt;. &lt;br&gt;
Yeah I know it is pretty obvious to see by eye which address is in the network and which not but for the example and simplicity it will do 🙂 And of course we wan't to do that in code and not just by eye 😅&lt;/p&gt;

&lt;p&gt;So first we have a look on our example addresses and what they look like if we represent them as bits:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F611ljst33omtnmgr6hi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F611ljst33omtnmgr6hi0.png" alt="IP's as bits" width="800" height="694"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, as you can see the subnet mask has always a &lt;code&gt;1&lt;/code&gt; bit in the network ID section and a &lt;code&gt;0&lt;/code&gt; bit in the host ID section. This bit arrangement applies for all possible subnet masks out there and exactly this behaviour can we use to reach our goal.&lt;/p&gt;

&lt;p&gt;If you are confused about what Network ID and what Host ID is, then let me just say to that:&lt;/p&gt;
&lt;h3&gt;
  
  
  Network ID
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;A network ID or NetID is the fragment of IP address &lt;br&gt;
that classifies the network for a specified host i.e., &lt;br&gt;
it tells us which network the host belongs to.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3&gt;
  
  
  Host ID
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;It is the fragment of an IP address that uniquely &lt;br&gt;
classifies a host on a specified TCP/IP network.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Source of this quotes and more details you can find &lt;a href="https://www.geeksforgeeks.org/what-is-network-id-and-host-id-in-ip-addresses/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Back to our task, lets use now the bits of our subnet mask and start address to create some sort of validation bits with a bitwise &lt;code&gt;&amp;amp;&lt;/code&gt; operation:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3h64ptc2acrun851hnzh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3h64ptc2acrun851hnzh.png" alt="Validation bits" width="800" height="287"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In case you have forgotten how bitwise &lt;code&gt;&amp;amp;&lt;/code&gt; works you can look it up &lt;a href="https://en.wikipedia.org/wiki/Bitwise_operation#AND" rel="noopener noreferrer"&gt;here&lt;/a&gt;. Or just keep in mind &lt;code&gt;1 &amp;amp; 1 = 1&lt;/code&gt; and all other possibilities &lt;code&gt;= 0&lt;/code&gt; 😉&lt;/p&gt;

&lt;p&gt;And now we can do the same for our two ip addresses and compare the result to our validation bits and if they match you can tell that the ip is in the given network.&lt;/p&gt;

&lt;p&gt;Starting with the first ip &lt;code&gt;192.168.50.20&lt;/code&gt;:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2rzwtmspy42hs7jzmcm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff2rzwtmspy42hs7jzmcm.png" alt="IP 1 validation" width="800" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see that the validation bits not match with the result where i marked it red. So this ip is not in our network. If we do the same now for our second address:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnxpk9z5w7q3vfqf0us12.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnxpk9z5w7q3vfqf0us12.png" alt="IP 2 validation" width="800" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's a match 🎉&lt;/p&gt;

&lt;p&gt;Now before I go on with a code example to actually implement that. If you want do try it by your own you can practise the implementation in a codewars kata which I have created &lt;a href="https://www.codewars.com/kata/62642f000fe6db42eda65052" rel="noopener noreferrer"&gt;here&lt;/a&gt;. It is still in beta though but c#, js and golang are ready to use 😊&lt;/p&gt;

&lt;p&gt;In my example I am going to us golang, which is the language I'am learning at the moment and where I can use some practise 😅&lt;/p&gt;

&lt;p&gt;First of all, we can not really compare bits directly in our code. Therefore we need to parse our bits to a &lt;code&gt;int&lt;/code&gt; value or more precisely &lt;code&gt;uint&lt;/code&gt; since ip's have no negative values.&lt;/p&gt;

&lt;p&gt;This is actually pretty easy and ready to copy from golang playground &lt;a href="https://go.dev/play/p/T5B-6RExlj" rel="noopener noreferrer"&gt;here&lt;/a&gt;. For simplicity in our example we don't return a error at this function and just do a &lt;code&gt;panic&lt;/code&gt; directly if a wrong ip string is inserted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ipAddr&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;uint32&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ParseIP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ipAddr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;panic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"wrong ipAddr format"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;To4&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;binary&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BigEndian&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uint32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&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 need our comparing or validation function which just returns a bool value whether the ip is &lt;code&gt;in&lt;/code&gt; or &lt;code&gt;not in&lt;/code&gt; the given network. The bitwise &lt;code&gt;&amp;amp;&lt;/code&gt; operation is done in the &lt;code&gt;return&lt;/code&gt; where you can see that we use for both, ip and start address, the subnet mask to create our validation bits (as uint) and then compare it against each other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;IsInSubnet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;startAddress&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;uIntIp&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt;  &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;uIntStartAdress&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;startAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;uIntMask&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uIntIp&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;uIntMask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uIntStartAdress&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;uIntMask&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;Putting all together which you can use to play around:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"encoding/binary"&lt;/span&gt;
    &lt;span class="s"&gt;"fmt"&lt;/span&gt;
    &lt;span class="s"&gt;"net"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"255.255.255.192"&lt;/span&gt;
    &lt;span class="n"&gt;startAddress&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"192.168.50.65"&lt;/span&gt;
    &lt;span class="n"&gt;ip1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"192.168.50.20"&lt;/span&gt;
    &lt;span class="n"&gt;ip2&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"192.168.50.80"&lt;/span&gt;

    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IP1 Result: "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IsInSubnet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;startAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"IP2 Result: "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IsInSubnet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;startAddress&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;IsInSubnet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;startAddress&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mask&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;uIntIp&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;uIntStartAdress&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;startAddress&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;uIntMask&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uIntIp&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;uIntMask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uIntStartAdress&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;uIntMask&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;Ip2long&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ipAddr&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;uint32&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;net&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ParseIP&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ipAddr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nb"&gt;panic&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"wrong ipAddr format"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;ip&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;ip&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;To4&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;binary&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BigEndian&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Uint32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip&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;Have fun and a nice day 🙂!&lt;/p&gt;

</description>
      <category>bitwise</category>
      <category>programming</category>
      <category>go</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Display codewars stats at your github profile 🚀</title>
      <dc:creator>DiniFarb</dc:creator>
      <pubDate>Tue, 23 Nov 2021 18:27:49 +0000</pubDate>
      <link>https://dev.to/dinifarb/display-codewars-stats-at-your-github-profile-492b</link>
      <guid>https://dev.to/dinifarb/display-codewars-stats-at-your-github-profile-492b</guid>
      <description>&lt;p&gt;Hello 👋 I just wantet to share a update on the &lt;a href="https://github.com/andreasvogt89/codewars_readme_stats" rel="noopener noreferrer"&gt;codewars_readme_stats&lt;/a&gt; repo which lets you display a codewars stats card at a github readme.&lt;/p&gt;

&lt;p&gt;It is now possible to add a boarder around the card in the color of your choice. Just add the param &lt;code&gt;stroke={color of your choice}&lt;/code&gt; to the GET request along with the existing params. Here a quick example: (find the full instructions &lt;a href="https://github.com/andreasvogt89/codewars_readme_stats/blob/master/README.md#codewars-readme-stats" rel="noopener noreferrer"&gt;here&lt;/a&gt;)   &lt;/p&gt;

&lt;p&gt;Replace &lt;code&gt;USERNAME&lt;/code&gt; in the string below by your codewars username and the &lt;code&gt;COLOR&lt;/code&gt; with a color of your choice, then copy-paste it in your github profile readme&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;

&lt;span class="p"&gt;![&lt;/span&gt;&lt;span class="nv"&gt;Codewars&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://github.r2v.ch/codewars?user=USERNAME&amp;amp;stroke=COLOR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="sb"&gt;


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

&lt;/div&gt;

&lt;p&gt;For the &lt;code&gt;COLOR&lt;/code&gt; u can use either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;colorstring eg. &lt;code&gt;blue&lt;/code&gt;, &lt;/li&gt;
&lt;li&gt;RGB eg. &lt;code&gt;rgb(0,0,0)&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;HEX &lt;code&gt;%23BB432C&lt;/code&gt; =&amp;gt; If u use HEX make sure to pass in the &lt;code&gt;#&lt;/code&gt; as &lt;code&gt;%23&lt;/code&gt; because of the &lt;a href="https://www.w3schools.com/tags/ref_urlencode.asp" rel="noopener noreferrer"&gt;url encoding&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Full working example with my account:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;

&lt;span class="p"&gt;![&lt;/span&gt;&lt;span class="nv"&gt;Codewars&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://github.r2v.ch/codewars?user=andreasvogt89&amp;amp;stroke=%23BB432C&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="sb"&gt;


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

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://github.com/andreasvogt89/codewars_readme_stats" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnbsedqy5mmr9w5v5lr9u.png" alt="Codewars"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cheers 🍻&lt;/p&gt;

</description>
      <category>github</category>
      <category>stats</category>
      <category>readme</category>
    </item>
    <item>
      <title>Display your codewars stats on your github profile 👾</title>
      <dc:creator>DiniFarb</dc:creator>
      <pubDate>Thu, 01 Jul 2021 19:59:54 +0000</pubDate>
      <link>https://dev.to/dinifarb/display-your-codewars-stats-on-github-34b2</link>
      <guid>https://dev.to/dinifarb/display-your-codewars-stats-on-github-34b2</guid>
      <description>&lt;p&gt;I'm sure you already have an awesome github profile on which you display your stats, languages usage and all that other hot stuff 😎  &lt;/p&gt;

&lt;p&gt;If not, defenitly checkout &lt;a href="https://github.com/anuraghazra/github-readme-stats"&gt;https://github.com/anuraghazra/github-readme-stats&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;there are many other possibilities 😉 And now there is one more:&lt;/p&gt;

&lt;p&gt;If you are a passionet codewars player like me and want to let all your github visitors know that you play a lot, well then I have something for you. I have started a new small project which lets you display a nice codewars card with your stats on your github readme 🚀 &lt;/p&gt;

&lt;p&gt;I have just started a few days ago and I am happy to share that it is already possible to use. For sure it is still an early bird but I'll keep enhance it and I am happy to take any feedback or costribution in any way 😊  &lt;/p&gt;

&lt;p&gt;You can find it here:&lt;br&gt;
&lt;a href="https://github.com/andreasvogt89/codewars_readme_stats"&gt;https://github.com/andreasvogt89/codewars_readme_stats&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%2Faxtz4r7739v9lcoqwyfz.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%2Faxtz4r7739v9lcoqwyfz.PNG" alt="Alt Text" width="800" height="341"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A few weeks ago I added the possibility to add icons of your top trained languages. &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%2F5oz9b1nyp4zswk8wsxvr.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%2F5oz9b1nyp4zswk8wsxvr.png" alt="image" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>opensource</category>
      <category>markdown</category>
    </item>
  </channel>
</rss>
