<?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>Forem: Chandra Prakash Tiwari</title>
    <description>The latest articles on Forem by Chandra Prakash Tiwari (@chandra).</description>
    <link>https://forem.com/chandra</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%2F254802%2Fc2b028a7-2753-4801-806d-9b8512a3e96e.jpg</url>
      <title>Forem: Chandra Prakash Tiwari</title>
      <link>https://forem.com/chandra</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/chandra"/>
    <language>en</language>
    <item>
      <title>How to integrate Free SSL into your website?</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Tue, 09 Feb 2021 09:53:23 +0000</pubDate>
      <link>https://forem.com/chandra/how-to-integrate-ssl-for-free-2ibc</link>
      <guid>https://forem.com/chandra/how-to-integrate-ssl-for-free-2ibc</guid>
      <description>&lt;p&gt;Adding an SSL certificate is really important for modern web applications or websites.&lt;/p&gt;

&lt;p&gt;So without taking too much time, let's dive directly into the free SSL implementations site.&lt;/p&gt;

&lt;p&gt;First login to &lt;a href="https://zerossl.com?fpr=coffeetobusiness"&gt;ZeroSSL&lt;/a&gt; website to generate SSL certificate.&lt;/p&gt;

&lt;p&gt;After sign up, you just click on the &lt;em&gt;New Certificate&lt;/em&gt; button to generate a new SSL certificate for your website. &lt;/p&gt;

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

&lt;p&gt;Then, add your domain name, and move to the next step.&lt;/p&gt;

&lt;p&gt;You have three options to verify your domain, choose any one of the options.&lt;/p&gt;

&lt;p&gt;After verification, you will have the certificate to install in your website server.&lt;/p&gt;

&lt;p&gt;For further details, you can go to their official documentation.&lt;br&gt;
&lt;a href="https://help.zerossl.com/hc/en-us/articles/360058295094-Before-Installation"&gt;https://help.zerossl.com/hc/en-us/articles/360058295094-Before-Installation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>security</category>
      <category>certificate</category>
      <category>ssl</category>
    </item>
    <item>
      <title>Manage Pabbly Payments in Node.js application</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Tue, 10 Nov 2020 10:57:02 +0000</pubDate>
      <link>https://forem.com/chandra/manage-pabbly-payments-in-node-js-application-ei8</link>
      <guid>https://forem.com/chandra/manage-pabbly-payments-in-node-js-application-ei8</guid>
      <description>&lt;p&gt;Hello everyone,&lt;br&gt;
Pabbly is an Indian Software to manage and automate stuff. Its one product called Pabbly subscription helps users to make payment pages and accept payments.&lt;/p&gt;

&lt;p&gt;I have created a simple code which can help you to create plans and handle payments.&lt;/p&gt;

&lt;p&gt;I have created a github gist for you. &lt;br&gt;
Please look at it.&lt;br&gt;
&lt;a href="https://gist.github.com/cptiwari20/28d79f4e13161b9c13cebfa5f5a6333b"&gt;https://gist.github.com/cptiwari20/28d79f4e13161b9c13cebfa5f5a6333b&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

</description>
      <category>node</category>
      <category>pabbly</category>
      <category>javascript</category>
      <category>integration</category>
    </item>
    <item>
      <title>Manage Thrivecart Payment using webhooks in Node.js</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Mon, 14 Sep 2020 17:07:07 +0000</pubDate>
      <link>https://forem.com/chandra/manage-thrivecart-payment-using-webhooks-in-node-js-3e4k</link>
      <guid>https://forem.com/chandra/manage-thrivecart-payment-using-webhooks-in-node-js-3e4k</guid>
      <description>&lt;p&gt;I really found it difficult to start with thrive cart integration for my marketing application.&lt;br&gt;
The lack of complete API reference makes it confusing to use.&lt;/p&gt;

&lt;p&gt;After some trial and errors, I have created the simplest approach to handle the thrivecart webhook events. &lt;/p&gt;

&lt;p&gt;Please visit this gist for more reference.&lt;br&gt;
&lt;a href="https://gist.github.com/cptiwari20/836e7875d38dd4965faeb14fb8f3a4ad"&gt;https://gist.github.com/cptiwari20/836e7875d38dd4965faeb14fb8f3a4ad&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you are new to thrivecart, Please use my promo code 'cptiwari20' to get 50% OFF on the premium plans.&lt;/p&gt;

</description>
      <category>thrivecart</category>
      <category>javascript</category>
      <category>node</category>
      <category>webhooks</category>
    </item>
    <item>
      <title>Node Vs Deno</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Fri, 22 May 2020 11:12:46 +0000</pubDate>
      <link>https://forem.com/chandra/node-vs-deno-pic</link>
      <guid>https://forem.com/chandra/node-vs-deno-pic</guid>
      <description>&lt;h2&gt;
  
  
  Node vs Deno
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Similarities
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Developed by a single person( Ryan Dahl)&lt;/li&gt;
&lt;li&gt;Both are JavaScript runtime&lt;/li&gt;
&lt;li&gt;Both help in developing applications&lt;/li&gt;
&lt;li&gt;Both support Typescript&lt;/li&gt;
&lt;li&gt;Both uses chrome v8 engine &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Differences
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Node is written in C++, deno is using Rust language.&lt;/li&gt;
&lt;li&gt;Node uses npm and imports libraries locally, deno uses urls for module usage&lt;/li&gt;
&lt;li&gt;Node doesn't have built Typescript support, deno has&lt;/li&gt;
&lt;li&gt;Node was launched in 2009 and Deno launched in 2020.&lt;/li&gt;
&lt;/ul&gt;

&lt;h1&gt;
  
  
  Funfact: “Deno” is actually an anagram for “Node”.
&lt;/h1&gt;

</description>
      <category>node</category>
      <category>deno</category>
      <category>javascript</category>
      <category>typescript</category>
    </item>
    <item>
      <title>What is Big-O Notation? Understand Time and Space Complexity in JavaScript.</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Fri, 10 Jan 2020 08:43:05 +0000</pubDate>
      <link>https://forem.com/chandra/what-is-big-o-notation-understand-time-and-space-complexity-in-javascript-4684</link>
      <guid>https://forem.com/chandra/what-is-big-o-notation-understand-time-and-space-complexity-in-javascript-4684</guid>
      <description>&lt;p&gt;As we know, there may be more than one solution to any problem. But it is hard to define, what is the best approach and method of solving that programming problem. &lt;br&gt;
Writing an algorithm that solves a definite problem gets more difficult when we need to handle a large amount of data. How we write each and every syntax in our code matters.&lt;/p&gt;

&lt;p&gt;There are two main complexities that can help us to choose the best practice of writing an efficient algorithm:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Time Complexity - Time taken to solve the algorithm
&lt;/h3&gt;

&lt;h3&gt;
  
  
  2. Space Complexity - The total space or memory taken by the system.
&lt;/h3&gt;

&lt;p&gt;When you write some algorithms, we give some instructions to our machine to do some tasks. And for every task completion machine needs some time. Yes, it is very low, but still, it takes some time. So here, is the question arises, does time really matters.&lt;/p&gt;

&lt;p&gt;Let's take an example, suppose you try to find something on google and it takes about 2 minutes to find that solution. Generally, it never happens, but if it happens what do you think what happens in the back-end. Developers at google understand the time complexity and they try to write smart algorithms so that it takes the least time to execute and give the result as faster as they can. &lt;/p&gt;

&lt;p&gt;So, here is a challenge that arises, how we can define the time complexity.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Time Complexity?:
&lt;/h2&gt;

&lt;p&gt;It quantifies the amount of taken by an algorithm. We can understand the difference in time complexity with an example.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Suppose you need to create a function that will take a number and returns a sum of that number upto that number.&lt;br&gt;
Eg. addUpto(10);&lt;br&gt;
it should return the sum of number 1 to 10 i.e. 1 + 2+ 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We can write it this way: &lt;br&gt;
&lt;code&gt;function addUpTo(n) {&lt;br&gt;
  let total = 0;&lt;br&gt;
  for (let i = 1; i &amp;lt;= n; i++) {&lt;br&gt;
    total += i;&lt;br&gt;
  }&lt;br&gt;
  return total;&lt;br&gt;
}&lt;br&gt;
addUpTo(5); // it will take less time&lt;br&gt;
addUpTo(1000) // it will take more time&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Now you can understand why the same function takes different time for different inputs. This happens because the loop inside the function will run according to the size of the input. If the parameter passed to input is 5 the loop will run five times, but if the input is 1000 or 10,000 the loop will run that many times. This makes some sense now. &lt;/p&gt;

&lt;p&gt;But there is a problem, different machines record different timestamp. As the processor in my machine is different from yours and same with multiple users. &lt;/p&gt;

&lt;h2&gt;
  
  
  So, how can we measure this time complexity?
&lt;/h2&gt;

&lt;p&gt;Here, Big-O-Notation helps us to solve this problem. According to Wikipedia, &lt;em&gt;Big O Notation is a mathematical notation that describes the limiting behavior of a function when the argument tends towards a particular value or infinity. The letter O is used because the growth rate of a function is also referred to as the &lt;br&gt;
order of the function.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;According to Big O notation, we can express time complexities like&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;If the complexity grows with input linearly, that mean its O(n). &lt;em&gt;'n' here is the number of operation that an algorithm have to perform.&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;If complexity grows with input constantly then, the Big O Notation will be O(1).&lt;/li&gt;
&lt;li&gt;If complexity grows with input quadratically, then the Big O Notation will be O(n^2). &lt;em&gt;you can pronounce it as O of n square&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;If the complexity grows with input with inverse of exponentiation, we can say. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="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%2F9rmumlwqacl6jdputjnk.png" class="article-body-image-wrapper"&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%2F9rmumlwqacl6jdputjnk.png" alt="log algorithm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can simplify these expressions like below. Basically while calculating the Big O Notation we try to ignore the lower values and try to focus on highest factor which can increase the time of the performance. So, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;instead of O(2n) prefer O(n);&lt;/li&gt;
&lt;li&gt;instead of O(5n^2) prefer O(n^2);&lt;/li&gt;
&lt;li&gt;instead of O(55log n) prefer O(log n);&lt;/li&gt;
&lt;li&gt;instead of O(12nlog n) prefer O(nlog n);&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fa3e1m9j7v9ipd8dmxzim.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fa3e1m9j7v9ipd8dmxzim.png" alt="Log Image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For better understanding, please have a look at some algorithms which we use daily that have O(n),O(n^2), and O(log n) complexities?&lt;/p&gt;

&lt;p&gt;In Quora, Mark Gitters said,&lt;br&gt;
``&lt;br&gt;
O(n): buying items from a grocery list by proceeding down the list one item at a time, where “n” is the length of the list&lt;/p&gt;

&lt;p&gt;O(n): buying items from a grocery list by walking down every aisle (now “n” is the length of the store), if we assume list-checking time is trivial compared to walking time&lt;/p&gt;

&lt;p&gt;O(n): adding two numbers in decimal representation, where n is the number of digits in the number.&lt;/p&gt;

&lt;p&gt;O(n^2): trying to find two puzzle pieces that fit together by trying all pairs of pieces exhaustively&lt;/p&gt;

&lt;p&gt;O(n^2): shaking hands with everybody in the room; but this is parallelized, so each person only does O(n) work.&lt;/p&gt;

&lt;p&gt;O(n^2): multiplying two numbers using the grade-school multiplication algorithm, where n is the number of digits.&lt;/p&gt;

&lt;p&gt;O( log n ): work done by each participant in a phone tree that reaches N people. Total work is obviously O( n ), though.&lt;/p&gt;

&lt;p&gt;O( log n ): finding where you left off in a book that your bookmark fell out of, by successively narrowing down the range&lt;br&gt;
``&lt;br&gt;
and Arav said,&lt;br&gt;
"&lt;br&gt;
If you meant algorithms that we use in our day to day lives when we aren't programming:&lt;/p&gt;

&lt;p&gt;O(log n): Looking for a page in a book/word in a dictionary.&lt;br&gt;
O(n): Looking for and deleting the spam emails (newsletters, promos) in unread emails.&lt;br&gt;
O(n ^ 2): Arranging icons on the desktop in an order of preference (insertion or selection sort depending on the person)."&lt;/p&gt;

&lt;p&gt;I hope you are now familiar with the complexities.&lt;br&gt;
I am not completing the topic in this article, I will make another in future. &lt;br&gt;
If you have any questions and suggestions please write down the comment or feel free to contact me.&lt;/p&gt;

&lt;p&gt;Thanks for giving your valuable time in reading this article.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>productivity</category>
      <category>bigonotation</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Set a callback to setState(useState) in React funtional Component</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Wed, 11 Dec 2019 07:06:02 +0000</pubDate>
      <link>https://forem.com/chandra/set-a-callback-to-setstate-usestate-in-react-funtional-component-g7p</link>
      <guid>https://forem.com/chandra/set-a-callback-to-setstate-usestate-in-react-funtional-component-g7p</guid>
      <description>&lt;p&gt;It is hard sometime to call something after updating the state using useState hook in functional component in React.&lt;/p&gt;

&lt;p&gt;Here is a simple trick: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define State using UseState
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [filterObj, setFilterObj] = useState({});
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Set State first
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // when props updates please update the state.
  useEffect(() =&amp;gt; {
      setFilterObj({ ...props.something});
  }, [props.something]);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;UseEffect to call the function which you want to call after the setState.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; // on state change call this event
  useEffect(() =&amp;gt; {
    fetchData(currentPage); // this is a fuction which calls api
  }, [filterObj]) 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>react</category>
      <category>functional</category>
      <category>javascript</category>
      <category>redux</category>
    </item>
    <item>
      <title>For Android and IOs development what would prefer?</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Sun, 10 Nov 2019 13:02:42 +0000</pubDate>
      <link>https://forem.com/chandra/for-android-and-ios-development-what-would-prefer-264j</link>
      <guid>https://forem.com/chandra/for-android-and-ios-development-what-would-prefer-264j</guid>
      <description>&lt;ol&gt;
&lt;li&gt;Java Android&lt;/li&gt;
&lt;li&gt;Swift IOS&lt;/li&gt;
&lt;li&gt;Kotlin&lt;/li&gt;
&lt;li&gt;React Native&lt;/li&gt;
&lt;li&gt;Flutter&lt;/li&gt;
&lt;li&gt;Ionic&lt;/li&gt;
&lt;li&gt;Xamerin&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Please let me know what's you'll prefer?&lt;/p&gt;

</description>
      <category>android</category>
      <category>ios</category>
      <category>reactnative</category>
      <category>flutter</category>
    </item>
    <item>
      <title>How to solve any programming problem?</title>
      <dc:creator>Chandra Prakash Tiwari</dc:creator>
      <pubDate>Wed, 30 Oct 2019 16:20:28 +0000</pubDate>
      <link>https://forem.com/chandra/how-to-solve-any-programming-problem-44io</link>
      <guid>https://forem.com/chandra/how-to-solve-any-programming-problem-44io</guid>
      <description>&lt;p&gt;Solving a problem in programming is not always easy. I was very confident after learning some great frameworks like node, express, react, react-native and much more and created some awesome apps with JavaScript, but one day someone asked me a simple question. And the question was, how can you check a number is palindrome or not(condition you can't convert it into string)?&lt;/p&gt;

&lt;p&gt;I tried and failed, again tried and failed. I became exhausted and started learning some basic concepts of programming.&lt;/p&gt;

&lt;p&gt;In this article I am going to share &lt;code&gt;5 steps to solve any problem&lt;/code&gt;. So lets start.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Understand the Problem:
&lt;/h2&gt;

&lt;p&gt;Before start writing the code you need to understand the problem. Understanding the exact problem can solve your problem more than 30%. You can ask some questions before start writing the code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Can I restate the problem in my own words?&lt;/li&gt;
&lt;li&gt;What will be the inputs in the problem?&lt;/li&gt;
&lt;li&gt;What would be the outputs should come from the solution?&lt;/li&gt;
&lt;li&gt;Would input determine the output?&lt;/li&gt;
&lt;li&gt;How should I label the important pieces of data that are part of the problem?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  2. Explore problem:
&lt;/h2&gt;

&lt;p&gt;After understanding the problem you need to explore the possibilities like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What if there is no input or invalid input?&lt;/li&gt;
&lt;li&gt;Is any limitations to the output?
Try to find the more options to better understand the problem.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. Break it down:
&lt;/h2&gt;

&lt;p&gt;This is a most important method to solve any problem. You can break down the code into small steps to solve it. Write down the comments in steps, this will help you to be in track of solving the problem without distracting. Suppose, there is time limitation for solving any specific problem, and you are unable to solve it completely, your comments can help to get the good marks in that. Examiner would be able to understand your approach and right approach is the way to solve any problem. &lt;/p&gt;

&lt;h2&gt;
  
  
  4. Solve and simplify:
&lt;/h2&gt;

&lt;p&gt;After writing the steps, start solving the problem. Try to solve simple steps first and then solve the complex one. &lt;/p&gt;

&lt;h2&gt;
  
  
  5. Look back and refactor:
&lt;/h2&gt;

&lt;p&gt;After solving the complete problem, look back to your code and try to refactor it. Make it concise and readable. Try to test it at least one time before submitting.&lt;/p&gt;

&lt;p&gt;I hope this will help you to get out of any problem easily. :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>productivity</category>
      <category>career</category>
      <category>todayilearned</category>
    </item>
  </channel>
</rss>
