<?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: Snehendu Roy</title>
    <description>The latest articles on DEV Community by Snehendu Roy (@snehendu_roy_).</description>
    <link>https://dev.to/snehendu_roy_</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%2F743616%2Ffbbfd44c-21fd-45e9-b80e-4636c064ed2c.jpg</url>
      <title>DEV Community: Snehendu Roy</title>
      <link>https://dev.to/snehendu_roy_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/snehendu_roy_"/>
    <language>en</language>
    <item>
      <title>Space Complexity | Measure your code performance: DSA 002</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Mon, 22 Aug 2022 01:46:00 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/space-complexity-measure-your-code-performance-dsa-002-4oin</link>
      <guid>https://dev.to/snehendu_roy_/space-complexity-measure-your-code-performance-dsa-002-4oin</guid>
      <description>&lt;p&gt;In my &lt;a href="https://dev.to/snehendu_roy_/time-complexity-dsa-001-2oeh"&gt;previous article&lt;/a&gt; I wrote about time complexity. A way to measure code with respect to growing size of inputs.&lt;/p&gt;

&lt;p&gt;Time complexity is basically the relation between input size and running time&lt;/p&gt;

&lt;h2&gt;
  
  
  Think About It
&lt;/h2&gt;

&lt;p&gt;You obviously have apps in your phone. You are most likely to prefer the ones which takes less time to load the data and consumes less space. The factor which is used to measure the time is related to time complexity. But what about the space? How do we measure the space used by a code?&lt;/p&gt;

&lt;h2&gt;
  
  
  Space Complexity
&lt;/h2&gt;

&lt;p&gt;The relation between the input size and memory consumed in your system.&lt;/p&gt;

&lt;p&gt;If you want your code to be optimized, it should take less time and less space too. So, here's where space complexity comes in place cause this is the way to measure how much space your code will take&lt;/p&gt;

&lt;h2&gt;
  
  
  Calculating Space Complexity
&lt;/h2&gt;

&lt;p&gt;The space used by a code depends on how many variables are used. The more variables, the more space used.&lt;/p&gt;

&lt;p&gt;How much memory consumed by a code is directly proportional to how many variables assigned&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sum = 0
i = 0
while (i &amp;lt; 24):
    sum += i
    i += 1
print(sum)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, there are 2 variables which we are assigning to the memory that is &lt;code&gt;i&lt;/code&gt; and &lt;code&gt;sum&lt;/code&gt;. Now, no matter the the value of sum increases the memory used by that one variable would be the same. So, the space complexity for this code will be O(1)&lt;/p&gt;

&lt;p&gt;Now, let's take the example of arrays. It is basically a data structure which stores a list of elements. We will talk about arrays deeply later&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def create_array(n):
    a = []
    for i in range(n):
        a.append(i)
    return a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this function, we take integer &lt;code&gt;n&lt;/code&gt; as an input. Then we create an array. Using  the loop we store the numbers 0 to n-1 in the array. Then we return it. So, basically what we are doing is, we are generating a series of numbers and storing it in an array. Here, with the increasing size of input, the space used by the code also increases. So, the space complexity for this code is O(n)&lt;/p&gt;

&lt;p&gt;You can check the size here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D6ZY3_e0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1gqxlz9p8s9xiy80z54.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D6ZY3_e0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1gqxlz9p8s9xiy80z54.png" alt="Image description" width="880" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;sys.getsizeof()&lt;/code&gt; gives out the size of a particular function, class, variable etc. in python&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I really hope you understood, if you didn't then feel free to criticize in the comment section. It's okay to criticize if I have wasted your valuable time. Also if you have any doubts, feel free to put it up in the comments section&lt;/strong&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Time Complexity | DSA 001</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Fri, 19 Aug 2022 01:30:40 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/time-complexity-dsa-001-2oeh</link>
      <guid>https://dev.to/snehendu_roy_/time-complexity-dsa-001-2oeh</guid>
      <description>&lt;h2&gt;
  
  
  Ways to calculate code performance
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Approach 1: Time based approach
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;calculateTime()
function fancyName(){
   do something
}
calculateTimeDifference()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this approach of judging code, before running a chunk of code, the initial time is taken and after running that code, the final time is taken. Then when the final time is subtracted from initial time, we get the how much time was required for processing of the code. &lt;/p&gt;

&lt;p&gt;This method of calculating code performance is rated as average but still this approach is used hugely to judge code&lt;/p&gt;

&lt;h4&gt;
  
  
  Problems in Approach 1:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It is based on machine: Depends from processor to processor&lt;/li&gt;
&lt;li&gt;It is based on processing: Depends on the processing power of your PC&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Approach 2:
&lt;/h3&gt;

&lt;p&gt;Counting the number of operations in a code. Technically, this literally means that we are going to count the number of operations in a code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Count Operation in the code below&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;a = a + 1&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you said there is one operation, you are wrong my friend. There are actually 2 operator: "=" and "+"&lt;/p&gt;

&lt;p&gt;Now, count the operation in this code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sum = 0
winner = 1
for (i = 1; i &amp;lt; n; i++){
  sum = sum+1
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice closely, that there are several operators. In total, there is 3 "="s, 1 "&amp;lt;", then in &lt;code&gt;i++&lt;/code&gt;, there are actually 2 operators which are responsible to increment the value of i, &lt;code&gt;i++&lt;/code&gt; can be written as &lt;code&gt;i = i+1&lt;/code&gt;, so in &lt;code&gt;i++&lt;/code&gt; there are 2 operators. Then inside the loop there are 2 operators: "=" and "+"&lt;/p&gt;

&lt;p&gt;But, in this code, apart from &lt;code&gt;sum = 0&lt;/code&gt;, &lt;code&gt;winner = 1&lt;/code&gt;, &lt;code&gt;i=1&lt;/code&gt;, all the other operators are dependent on the variable &lt;code&gt;n&lt;/code&gt;. So, there are 3 constant operators, and 5 operators which varies with the value of &lt;code&gt;n&lt;/code&gt;. Thus there are 3+5n operators&lt;/p&gt;

&lt;h2&gt;
  
  
  Big O
&lt;/h2&gt;

&lt;p&gt;The whole way of measuring code with number of operators is known as Big O. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code 1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sum = 0
i = 0
while (i &amp;lt; n):
    sum += i
    i += 1
print(sum)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this given code, there are 5n+2 operators. &lt;/p&gt;

&lt;p&gt;Now, coming to the complexity of the code: To measure the complexity of the code, the constants are to be ignored. &lt;/p&gt;

&lt;p&gt;So O(n) [Said as O of n] is the complexity&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code 2&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (------):
  ---------
  ---------
for (------):
  ---------
  ---------
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might think that the complexity of the above code is 2O(n) and that's completely correct. But since the constants are to be ignored, so the complexity will be O(n).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Code 3&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;for (let i = 0; i &amp;lt; N; i++) {
  for (let j = 0; j &amp;lt; N; j++) {
    sum+=j
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above code, O(n) is inside another O(n). Thus, the complexity of the code becomes O(n^2). If the nested loop would run on a constant and not on N, the complexity would not be O(n^2). &lt;/p&gt;

&lt;h3&gt;
  
  
  Complexity Notation
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Code Complexity&lt;/th&gt;
&lt;th&gt;Notation&lt;/th&gt;
&lt;th&gt;Note&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;O(10), O(1000) O(k), 3O(k) kO(k)&lt;/td&gt;
&lt;td&gt;O(1)&lt;/td&gt;
&lt;td&gt;"k" is some constant&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;O(3n), O(4n+100000)&lt;/td&gt;
&lt;td&gt;O(n)&lt;/td&gt;
&lt;td&gt;Constants are to be ignored&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;O(3n^2), O(4n^2+100000)&lt;/td&gt;
&lt;td&gt;O(n^2)&lt;/td&gt;
&lt;td&gt;Constants are to be ignored&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;O(3n^2), O(4n^2 + 3n + 4)&lt;/td&gt;
&lt;td&gt;O(n^2)&lt;/td&gt;
&lt;td&gt;Since with increasing value of n, the value of n^2 will become much higher than theat of n, so n can be ignored, incase of cubic equations,the complexity will be O(n^3) and so on&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1iLgTvwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AyiyfZodqXNwMouC0-B0Wlg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1iLgTvwz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AyiyfZodqXNwMouC0-B0Wlg.png" alt="Complexity time graph" width="880" height="761"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This graph shows the time for complexity of code with increasing input.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Introduction to Data Structures and Algorithms | 000</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Wed, 17 Aug 2022 00:49:00 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/introduction-to-data-structures-and-algorithms-000-3hk6</link>
      <guid>https://dev.to/snehendu_roy_/introduction-to-data-structures-and-algorithms-000-3hk6</guid>
      <description>&lt;p&gt;&lt;strong&gt;I am going to call Data Structures and Algorithms as DSA&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Code written is in Python&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Why DSA?
&lt;/h2&gt;

&lt;p&gt;The main moto to learn DSA is to know how to write optimized code. In this age of &lt;em&gt;Cloud Functions&lt;/em&gt;, the optimized code requires less money as less computation and memory is used in the servers. On the other hand if you don't write optimized code, you will have to pay more money and also the results from the cloud servers would be very slow.&lt;/p&gt;
&lt;h2&gt;
  
  
  Judging code
&lt;/h2&gt;

&lt;p&gt;Now you know that writing optimized code would save your time. But how will you judge if a code is optimized or not? &lt;br&gt;
Many people say that the less number of lines means the more optimized code. But this is a true lie. Optimized code can't be judged by the number of lines but the parameters involved in the code. Judge this case:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;: Generate a series of number from 1 to n and store it in a variable or function so that it can be accessed later&lt;/p&gt;

&lt;p&gt;Code 1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def gen_series():
    a = []
    n = int(input("What's n? "))
    for i in range(1, n+1):
        a.append(i)
    return a

def print_series():
    a = gen_series()
    for i in a:
        print(i)

if __name__ == "__main__":
    print_series()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Code 2:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def gen_series():
    n = int(input("What's n? "))
    a = series(n)
    print(a)
    return a

def print_series():
    a = gen_series()
    for i in a:
        print(i)

def series(n):
    d = 11
    for i in range(1, n+1):
        yield i + d
        d += 11

if __name__ == "__main__":
    print_series()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you count the number of lines, you would say Code 1 is more optimized but is it?&lt;/p&gt;

&lt;p&gt;In both the cases the series is generated and stored inside the function named &lt;code&gt;gen_series()&lt;/code&gt;. If you know about the &lt;code&gt;sys.getsizeof()&lt;/code&gt; method in python, you will know that it gives out the memory used inside a variable, function. If you write this in your code editor, run the program, and enter 200 as the input of &lt;code&gt;What's n?&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;import sys


def gen_series():
    a = []
    n = int(input("What's n? "))
    for i in range(1, n+1):
        a.append(i)
    return a


def print_series():
    a = gen_series()
    for i in a:
        print(i)


if __name__ == "__main__":
    print(sys.getsizeof(gen_series()))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get the memory used in bytes. And surprisingly, you will notice that the 2nd code consumes less memory.&lt;/p&gt;

&lt;p&gt;So, we can come to a conclusion that less code always doesn't mean optimized code. For a code to be judged, the parameters are important.&lt;/p&gt;

&lt;h2&gt;
  
  
  Programming Language
&lt;/h2&gt;

&lt;p&gt;DSA is mostly independent of programming language the main things which matter are the concepts. I'll be using python in the next articles regarding DSA&lt;/p&gt;

</description>
      <category>python</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Generators in Python</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Mon, 15 Aug 2022 04:01:25 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/generators-in-python-1lal</link>
      <guid>https://dev.to/snehendu_roy_/generators-in-python-1lal</guid>
      <description>&lt;h1&gt;
  
  
  Starting Note
&lt;/h1&gt;

&lt;p&gt;Before reading this blog, I want to make a clear statement that this blog is written completely based on my understanding about how generators work in python. To move forward, you must be an intermediate in python.&lt;/p&gt;

&lt;h1&gt;
  
  
  Iterators
&lt;/h1&gt;

&lt;p&gt;An object that contains countable number of values. The next value can be accessed with the &lt;code&gt;next(object_name)&lt;/code&gt; parameter&lt;/p&gt;

&lt;p&gt;You can know more about iterators here: &lt;a href="https://www.w3schools.com/python/python_iterators.asp"&gt;Iterators by W3 Schools&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Case
&lt;/h1&gt;

&lt;p&gt;Let's say you are working in a company and your company gives you a task to write a program to find a series of numbers. Each number having a difference of 12 from the previous. So the series is like: [12,24,36,48.....]&lt;/p&gt;

&lt;p&gt;You have to find the series till a number given by the user and store the results somewhere so that others get those values using a loop. &lt;/p&gt;

&lt;p&gt;So, if the user enters 10, the program will return a series like: &lt;strong&gt;12,24,36,........,120&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You will be like: &lt;em&gt;Okay that's easy&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def gen_series():
    n = int(input("What's n? "))
    a = []
    d = 11
    for i in range(1, n+1):
        a.append(i + d)
        d += 11
    return a

if __name__ == "__main__":
    print(gen_series())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, your program works nicely if the user inputs numbers like 12, 23, 89, 74.&lt;/p&gt;

&lt;p&gt;If you test this code yourself and you enter a number like 1000000000000000 then what happens?&lt;br&gt;
Your code starts to hang, the program doesn't work smoothly. So, this is not the best approach to get a series of numbers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let's refactor this code a bit&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def gen_series():
    n = int(input("What's n? "))
    a = series(n)
    print(a)

def series(n):
    a = []
    d = 11
    for i in range(1, n+1):
        a.append(i + d)
        d += 11
    return a

if __name__ == "__main__":
    gen_series()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, the program runs the same but our problem is not yet solved. We want to generate a series of numbers with each number having a difference of 12 from the previous and we want our program to generate as much numbers as we want.&lt;/p&gt;

&lt;p&gt;Try to run this code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def gen_series():
    n = int(input("What's n? "))
    a = series(n)
    print(a)


def series(n):
    d = 11
    for i in range(1, n+1):
        yield i + d
        d += 11


if __name__ == "__main__":
    gen_series()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you run this code and input a number as 20, you will see the output as &lt;code&gt;&amp;lt;generator object series at 0x0000020B20684350&amp;gt;&lt;/code&gt;. Now, if you run again, and input a big number such as 1000000000000000, you will notice that your program doesn't lag. It works perfectly fine and you get the output.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;yield&lt;/code&gt; keyword is responsible to make this function a generator.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;series&lt;/code&gt; function is now a generator function which generates an iterator. If you have read the article of &lt;a href="https://www.w3schools.com/python/python_iterators.asp"&gt;W3 Schools&lt;/a&gt;, you will certainly know that we can easily access the values from an iterator using a loop. &lt;/p&gt;

&lt;p&gt;So, here's the definition of generators&lt;/p&gt;

&lt;h3&gt;
  
  
  Generators
&lt;/h3&gt;

&lt;p&gt;Generators are those kind of functions that return an iterator.&lt;/p&gt;

&lt;h1&gt;
  
  
  Back to program
&lt;/h1&gt;

&lt;p&gt;Now to print the values of the series we can use another function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def print_series():
    a = gen_series()
    for i in a:
        print(i)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The complete code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def gen_series():
    n = int(input("What's n? "))
    a = series(n)
    print(a)
    return a


def print_series():
    a = gen_series()
    for i in a:
        print(i)


def series(n):
    d = 11
    for i in range(1, n+1):
        yield i + d
        d += 11


if __name__ == "__main__":
    print_series()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Generators are functions that return an iterator&lt;/li&gt;
&lt;li&gt;We can turn a normal function to generator by using the &lt;code&gt;yield&lt;/code&gt; keyword&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;If you didn't understand then don't forget to criticize me in the comments. That will help me to come up with a better explanation. It is okay to criticize me if I have wasted your time. Also if you have any questions, please ask me in the comments&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Solana</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Tue, 29 Mar 2022 08:44:21 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/solana-4kmd</link>
      <guid>https://dev.to/snehendu_roy_/solana-4kmd</guid>
      <description>&lt;h1&gt;
  
  
  What is Solana?
&lt;/h1&gt;

&lt;p&gt;It is an open source project which aims to make a fast, high-performance, permission-less blockchain.&lt;/p&gt;

&lt;h1&gt;
  
  
  Why Solana?
&lt;/h1&gt;

&lt;p&gt;It is possible for a centralised database to handle 710,000 transactions per second on a standard network if the transaction size is not more than 176 byes. A centralised database can also replicate itself and maintain itself highly without significantly compromising that transaction rate using the distributed system technique known as Optimistic Concurrency Control. Solana aims to achieve these theoretical limitations in its blockchain network.&lt;/p&gt;

&lt;h3&gt;
  
  
  Optimistic Concurrency Control
&lt;/h3&gt;

&lt;p&gt;It is a method of generating correct results of concurrent operations which are applied to systems which record transactions.&lt;/p&gt;

&lt;h1&gt;
  
  
  How does it achieve
&lt;/h1&gt;

&lt;p&gt;It is by a new mechanism called as &lt;strong&gt;proof of history.&lt;/strong&gt; In normal blockchain transactions, nodes have to interact with each other to verify a transaction. Through proof of history, there is a standardised clock in every block of the network. In other networks, there is no standardised clock&lt;/p&gt;

&lt;p&gt;The lack of a trusted source of time (i.e., a standardized clock) meant that when a message timestamp was used to accept or reject a message, there was no guarantee that every other participant in the network would make the exact same choice. Proof of History gets past this hurdle, with every node in the network able to rely on the recorded passage of time in the ledger on the trustless basis that is key to blockchain functioning&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>solana</category>
      <category>programming</category>
    </item>
    <item>
      <title>Fallback true returns error while deployment</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Tue, 29 Mar 2022 08:42:25 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/fallback-true-returns-error-while-deployment-53og</link>
      <guid>https://dev.to/snehendu_roy_/fallback-true-returns-error-while-deployment-53og</guid>
      <description>&lt;p&gt;Next Js by itself is a super power over react. With its functions like &lt;code&gt;getStaticPaths()&lt;/code&gt; and &lt;code&gt;getDtaticProps()&lt;/code&gt;, dynamic page generation becomes truly easy.&lt;/p&gt;

&lt;p&gt;But in most cases, &lt;strong&gt;fallback true returns error during deployment&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function getStaticPaths() {
   returns {
     paths: paths, 
     fallback: true // returns erroe
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To solve this, you must handle the data coming from &lt;code&gt;getStaticProps()&lt;/code&gt; in your component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function App({data}) {
  if (!data) return null;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple one liner, at the top of your component page where &lt;code&gt;getStaticPaths()&lt;/code&gt;is used, can fix all the problems regarding this during deployment.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
      <category>vercel</category>
    </item>
    <item>
      <title>Fallback true returns error while deployment </title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Tue, 01 Mar 2022 10:35:04 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/fallback-true-returns-error-while-deployment-4pnb</link>
      <guid>https://dev.to/snehendu_roy_/fallback-true-returns-error-while-deployment-4pnb</guid>
      <description>&lt;p&gt;Next Js by itself is a super power over react. With its functions like &lt;code&gt;getStaticPaths()&lt;/code&gt; and &lt;code&gt;getDtaticProps()&lt;/code&gt;, dynamic page generation becomes truly easy.&lt;/p&gt;

&lt;p&gt;But in most cases, &lt;strong&gt;fallback true returns error during deployment&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export async function getStaticPaths() {
   returns {
     paths: paths, 
     fallback: true // returns error
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To solve this, you must handle the data coming from &lt;code&gt;getStaticProps()&lt;/code&gt; in your component&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function App({data}) {
  if (!data) return null;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple one liner, at the top of your component page where &lt;code&gt;getStaticPaths()&lt;/code&gt;is used, can fix all the problems regarding this during deployment.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>nextjs</category>
      <category>vercel</category>
    </item>
    <item>
      <title>Crypto Arbitrage: This can make you millions</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Tue, 22 Feb 2022 03:12:14 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/crypto-arbitrage-this-can-make-you-millions-4ch2</link>
      <guid>https://dev.to/snehendu_roy_/crypto-arbitrage-this-can-make-you-millions-4ch2</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Crypto Arbitrage is a process through which you can make much money by swapping crypto coins&lt;br&gt;
&lt;em&gt;Let that blow your mind for a while&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Swapping
&lt;/h2&gt;

&lt;p&gt;There are crypto exchange platforms like &lt;strong&gt;Uniswap&lt;/strong&gt;, &lt;strong&gt;Sushiswap&lt;/strong&gt; where you can swap cryptos. Let's say you have a METAMASK account with 1 ETH in it. Now, if you swap 1ETH with Dai you might get 2200 DAI. So this is what swapping is, exchange of tokens.&lt;/p&gt;

&lt;h2&gt;
  
  
  How is it related to profit
&lt;/h2&gt;

&lt;p&gt;The amount of DAI you get for 1 ETH is different for each platforms. For example if you get 2200 DAI for 1 ETH in Uniswap, then 1 ETH might be equivalent to 2000 DAI in Sushiswap.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Profit
&lt;/h3&gt;

&lt;p&gt;Now, you have 1 ETH in your account, you go to Uniswap where 1ETH is equivalent to 2200 DAI. So, you have 2200 DAI in your account now.&lt;/p&gt;

&lt;p&gt;Then you go to SushiSwap where 1 ETH is equivalent to 2000 DAI. You exchange 2000 DAI from your account for 1 ETH and still you are left with 200 DAI. That's your free profit.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do you need
&lt;/h2&gt;

&lt;p&gt;To start this arbitrage and earn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Capital: You need some tokes in your wallet to do this&lt;/li&gt;
&lt;li&gt;Knowledge: You need to know how much you are getting for the tokens in you have in different websites
## Automation
Now there is a way to do this arbitrage automatically even if you don't have any capital.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can make a &lt;code&gt;smart contract&lt;/code&gt; and a &lt;code&gt;node server&lt;/code&gt; to do this. Here's how it will work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Smart Contract&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Take a flash loan&lt;/li&gt;
&lt;li&gt;Swap the flash loans in one Exchange where you get more of you preferred tokens&lt;/li&gt;
&lt;li&gt;Again swap the tokens in other exchange where its price is low&lt;/li&gt;
&lt;li&gt;Send the tokens widrawn from the Flash Loan and keep the rest&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Node Server&lt;/strong&gt;&lt;br&gt;
Check the price of tokens in exchanges and according to that execute smart contract events.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>programming</category>
      <category>web3</category>
    </item>
    <item>
      <title>Features of Blockchain which makes it useful</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Wed, 05 Jan 2022 01:08:16 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/features-of-blockchain-which-makes-it-useful-ank</link>
      <guid>https://dev.to/snehendu_roy_/features-of-blockchain-which-makes-it-useful-ank</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Blockchain contains 2 words in itself one is block and the other is chain. The block represents the data which are stored in variety of computers and chain makes the network. So the blockchain is a record of data stored in networks of computers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are 3 features of blocchain which makes it useful:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Decentralization&lt;/li&gt;
&lt;li&gt;Immutability&lt;/li&gt;
&lt;li&gt;Transparency&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Decentralization:
&lt;/h3&gt;

&lt;p&gt;Once a data is being created, it gets divided among the network of computers and no particular authority has a hold on it. So, no centralized authority is present in a blockchain platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  Immutability
&lt;/h3&gt;

&lt;p&gt;Once a data is being put up in the blockchain network, it cannot be altered or forged. This happens due to advanced cryptography hashing concepts. &lt;/p&gt;

&lt;h3&gt;
  
  
  Transparency
&lt;/h3&gt;

&lt;p&gt;In a blockchain network every action is stored as a transaction and once a transaction is made, the data becomes available to all. Since no central authority remains and the data is also immutable, the data is kept forever and everyone can see  it making it a transparent and trustable system for everyone.&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>crypto</category>
    </item>
    <item>
      <title>Linux Commands that you need to know </title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Wed, 01 Dec 2021 20:21:16 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/linux-commands-that-you-need-to-know-70m</link>
      <guid>https://dev.to/snehendu_roy_/linux-commands-that-you-need-to-know-70m</guid>
      <description>&lt;p&gt;&lt;code&gt;ls&lt;/code&gt;&lt;br&gt;
Helps you to list the directories&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pwd&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Helps to know the exact directory you are in&lt;/p&gt;

&lt;p&gt;&lt;code&gt;alias&lt;/code&gt;&lt;br&gt;
This helps you to create your own shortcuts of commands.&lt;br&gt;
&lt;em&gt;Example:&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;alias cls=clear&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;One tip: Install tmux in linux. If you want me to make a detailed post then make sure to comment down below&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>linux</category>
      <category>programming</category>
      <category>terminal</category>
    </item>
    <item>
      <title>GHOST CMS. Is it a superpower for making blog-applications</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Tue, 23 Nov 2021 20:56:42 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/ghost-cms-is-it-a-superpower-for-making-blog-applications-251i</link>
      <guid>https://dev.to/snehendu_roy_/ghost-cms-is-it-a-superpower-for-making-blog-applications-251i</guid>
      <description>&lt;h2&gt;
  
  
  INTRODUCTION
&lt;/h2&gt;

&lt;p&gt;Ghost CMS can be a lifesaver and a timesaver if you want to make a fulstack blog app.&lt;/p&gt;

&lt;h2&gt;
  
  
  DETAILS
&lt;/h2&gt;

&lt;p&gt;Ghost CMS provides you a prebuilt admin dashboard which makes 70% of your works easier. You can directly publish a blog post through that admin panel. &lt;/p&gt;

&lt;p&gt;It will provide you with a REST API with a bunch of endpoints and you can use those in your next blog application. &lt;/p&gt;

&lt;p&gt;Visit: &lt;a href="https://ghost.org/docs/content-api/"&gt;GHOST&lt;/a&gt; for reference&lt;/p&gt;

&lt;p&gt;&lt;em&gt;In short you can say that if you get into any error in the backend portion for making your next node.js app, then you can use ghost CMS as your REST API. Rather than that, it also provides you support like WordPress&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Redux the easiest way [Part 2]</title>
      <dc:creator>Snehendu Roy</dc:creator>
      <pubDate>Fri, 05 Nov 2021 19:49:53 +0000</pubDate>
      <link>https://dev.to/snehendu_roy_/redux-the-easiest-way-part-2-2kg4</link>
      <guid>https://dev.to/snehendu_roy_/redux-the-easiest-way-part-2-2kg4</guid>
      <description>&lt;p&gt;So in the 1st part we saw a story for understanding about redux. So what redux basically does is that it takes the data from other screens and those data can afterwards be rendered in other screens without any sort of prop drilling. So, it basically puts up the state to the steroid form. &lt;/p&gt;

&lt;h3&gt;
  
  
  Redux: Three Principles
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Store: The global state of your application is stored in a store from where the data flows through different screens and  you can have access to them.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Actions: The only way to change the state is to emit an action. In the example story of part 1, we saw that, your sister tells Clark to give the pizza then only Clark gives it to her. This 'call for pizza' is actually an action.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reducer: This is basically the function which is fired once an action is emmited. In the story, when your sister calls for the pizza, Clark checks the box and if there is a pizza for her he returns it. This whole thing that Clark is doing is an example of a reducer. This is kind of the brain of the redux. &lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>react</category>
      <category>redux</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
