<?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: Divyajyoti Ukirde</title>
    <description>The latest articles on DEV Community by Divyajyoti Ukirde (@divyajyotiuk).</description>
    <link>https://dev.to/divyajyotiuk</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%2F383310%2Fc273b2be-b09e-4824-8370-f30ea603330c.jpg</url>
      <title>DEV Community: Divyajyoti Ukirde</title>
      <link>https://dev.to/divyajyotiuk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/divyajyotiuk"/>
    <language>en</language>
    <item>
      <title>I couldn't be a Competitive Coder, but it still worked out!</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Mon, 11 Jan 2021 05:06:06 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/i-couldn-t-be-a-competitive-coder-but-it-still-worked-out-1gb6</link>
      <guid>https://dev.to/divyajyotiuk/i-couldn-t-be-a-competitive-coder-but-it-still-worked-out-1gb6</guid>
      <description>&lt;p&gt;When I was in college, there was this fad of &lt;strong&gt;Competitive Coding&lt;/strong&gt;. Competitive Programming is like a sport where participants have to solve certain programming problems with constraints, timed or untimed.&lt;/p&gt;

&lt;p&gt;As a first year student in my undergraduate program, I literally had no idea what is coding. We were introduced to &lt;strong&gt;C language&lt;/strong&gt; (at least I was) for the first time and I had failed pretty badly in the first exam (yeah, 32%).&lt;/p&gt;

&lt;p&gt;I could write a good simple program in a couple of months. After I got a laptop, I did start practicing quite a lot at the end of first year. It wasn't easy, with no knowledge of data structures and only handful of looping and conditional constructs did not help much. I barely could solve problems that were grouped easy on &lt;a href="https://codeforces.com/"&gt;Codeforces&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I turned back to focusing on academics and got very good grades in the first year. I stepped into second year with imposter syndrome. I could see everyone doing great around me. I could not even formulate a pseudo-code for half of the year. I again focused on &lt;em&gt;implementing Data Structures&lt;/em&gt; in Practicals and got a hands-on them. &lt;strong&gt;C++&lt;/strong&gt; kind of made coding easier, I could write any code at the end of the year. Again, my focus was only on academics and academic projects. I loved tweaking with Linux and tried lots of stuff on &lt;strong&gt;Ubuntu&lt;/strong&gt;.  Soon, I was a go to person among my friends (also friends of friends) in fixing stuff that went wrong on their Linux systems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SsLatC0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1609826047670/iXNioo9Kh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SsLatC0O--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1609826047670/iXNioo9Kh.png" alt="Screenshot 2021-01-04 at 12.31.23 PM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I joined some coding groups but being an introverted (no programmer friends) and with a mindset that everyone around me had gone far ahead, I soon became demotivated. I left the coding group in a few days and went on to explore something else. My college had a very &lt;em&gt;competitive environment&lt;/em&gt; and it was tough to find the right person that would really help out. In the beginning of &lt;em&gt;Third Year&lt;/em&gt;, I found literally every single person I would talk was doing &lt;strong&gt;Machine Learning&lt;/strong&gt;. I was interested in security and chose &lt;strong&gt;Blockchain&lt;/strong&gt; as a specialisation. It was also a hype with a very few people into it.&lt;/p&gt;

&lt;p&gt;Internship drives had started and I kind of ignored them. I did practice problem solving on &lt;a href="https://www.hackerrank.com/"&gt;Hackerrank&lt;/a&gt;. But I never came out of the comfort zone of solving more than easy problems. I would retake the problem solving tests with different usernames to score good. Even though I knew the solution, I couldn't handle the timer ticking to zero. Timers always got me panicking and they still do. Due to my other development skills I landed a fellowship the same year. I learned a new language in each semester in college. Built skills around &lt;em&gt;simple web development&lt;/em&gt;, &lt;em&gt;android app development&lt;/em&gt; and later picked &lt;em&gt;react&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;During recruitment days at college, I failed to secure interviews for around &lt;strong&gt;25 companies&lt;/strong&gt; due to their assessment techniques which consisted of coding and quantitative aptitude. There was no consideration for skills, no companies checked our resumes for shortlisting. There were many students who had spent their time "leetcoding", solving various problems, memorising the code. I couldn't make myself invest time to solve the problems on coding platforms. I wasn't good at syntax because I never learnt a language to write it correctly but to build something out of it. I never memorised all algorithms because they were already there on the internet except those that were for academics. Algorithms weren't the &lt;em&gt;problems&lt;/em&gt;, they were the solution to other problems we were trying to solve. Sadly, the process wasn't project focused and I couldn't interview some big companies.&lt;/p&gt;

&lt;p&gt;But I got selected for internship and later got the job without a coding test or giving aptitude tests. I did make it through the technical interview because my concepts were clear. I could explain what I could build or had built. I am &lt;strong&gt;not encouraging&lt;/strong&gt; you to stop coding. I do code sometimes, just for fun and increasing my logical thinking. I just couldn't invest my whole time into it and compromise or ignore other stuff. During my college time, some good coders ignored academics, are rank holders in competitive coding and are also part of FAANG. Some people could balance all of these and were great at everything. It depends person to person.&lt;/p&gt;

&lt;p&gt;I tried a lot but I still feel competitive coding is not cut out for me. Also, this doesn't mean I am going to stop here. I still practice coding and will keep doing because I like to put my brain to use. I may not be a great coder but everything is still working fine for me. I don't solve those kinds of problems at my job or in my projects, that is partly why I have accepted it. &lt;strong&gt;It is okay to NOT be a rankholder competitive programmer.&lt;/strong&gt; There are other things too in Computer Science. But, this doesn't stop me from going back to solving coding problems. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;I love challenges and I'll take my time to write optimised code for all sorts of problems.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>Exporting your Twitter bookmarks in markdown file</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Sun, 01 Nov 2020 11:39:22 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/exporting-your-twitter-bookmarks-in-markdown-file-19bj</link>
      <guid>https://dev.to/divyajyotiuk/exporting-your-twitter-bookmarks-in-markdown-file-19bj</guid>
      <description>&lt;p&gt;People used to bookmark tweets using the like feature on Twitter. Later, they introduced Bookmarks feature that helps you save the tweets privately. And now, you have saved thousands of tweets and you can't afford to clear them.&lt;/p&gt;

&lt;p&gt;How about we export those bookmarks safely in a file. You can use it as you like - in a web application maybe. It should be noted that Twitter &lt;strong&gt;DOES NOT&lt;/strong&gt; provide an API to access the bookmarks. So, we might have to do some stuff manually here.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I am going to show you how to extract links to the bookmark as well in few lines of python code.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Store the Twitter payload in JSON file
&lt;/h3&gt;

&lt;p&gt;An alternative of this step is using the &lt;strong&gt;Postman Client&lt;/strong&gt;. You might want to try it out first, here is the &lt;a href="https://apievangelist.com/2019/12/30/pulling-your-twitter-bookmarks-via-the-twitter-api/" rel="noopener noreferrer"&gt;link&lt;/a&gt; to a blogpost that allows you to send the request and it's download feature enables you to download the response in a click.&lt;/p&gt;

&lt;p&gt;If you don't have the setup, we can get back to copy pasting the response from our good old browser DevTools.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Twitter web and go to the Bookmarks page&lt;/li&gt;
&lt;li&gt;Open Dev tools and go to Network tab&lt;/li&gt;
&lt;li&gt;Clear the network logs and select XHR&lt;/li&gt;
&lt;li&gt;Apply filter as &lt;strong&gt;"bookmark"&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Refresh the twitter bookmarks page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You would see some API calls are made as &lt;code&gt;bookmark.json&lt;/code&gt; like below image. The API call is subject to change.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Currently, &lt;code&gt;/Bookmarks&lt;/code&gt; is used. Twitter has recently started using GraphQL to fetch bookmarks.&lt;/p&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1604225132382%2FTw16tYOd1.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1604225132382%2FTw16tYOd1.png" alt="Screenshot 2020-11-01 at 3.22.19 PM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you have tons of bookmarks, you might have to scroll till the end to get all pagination requests.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After reaching the end. Select each request and copy paste the response received from the Response tab as shown in the image above.&lt;/li&gt;
&lt;li&gt;Save each response object with &lt;strong&gt;.json&lt;/strong&gt; extension.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 2
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Getting text and link of bookmarked tweets
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Once you have saved the JSON files, put them in a folder. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now we just have to write a &lt;strong&gt;python script&lt;/strong&gt; that would get us the links to the Bookmarks and text of the tweet!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reading JSON files from folder
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;

&lt;span class="c1"&gt;# using glob to read all files in the folder
&lt;/span&gt;&lt;span class="n"&gt;files&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt; &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;glob&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;JSONBookmarks/*&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;     
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;file_name&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;files&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;bk&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bk&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;        &lt;span class="c1"&gt;# reads json data
&lt;/span&gt;    &lt;span class="n"&gt;all_bookmarks&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;JSONBookmarks&lt;/code&gt; is the folder name. &lt;code&gt;glob()&lt;/code&gt; takes the path of the folder to read files from. &lt;code&gt;/*&lt;/code&gt; means all files.&lt;/p&gt;

&lt;p&gt;The twitter payload explicitly doesn't have the link to the bookmarked tweets.&lt;/p&gt;

&lt;p&gt;It provides two primary objects of our use with keys: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;tweets&lt;/li&gt;
&lt;li&gt;users&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will have to use this data in the payload to construct the url to the tweet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Function to construct bookmarked tweet url
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;constructUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tweet_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;https://twitter.com/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/status/&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;tweet_id&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have used a &lt;code&gt;deep_get&lt;/code&gt; method to get the nested objects.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Method to get value of nested dictionary
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;deep_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;dictionary&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;None&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;functools&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nf"&gt;isinstance&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;dict&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="n"&gt;default&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;dictionary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now the final code that loops through all the tweets to get the data and writes in the markdown. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; This logic is subject to change as per Twitter's bookmarks API response!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# saving in markdown file, if no file exists  using '+' creates one
&lt;/span&gt;&lt;span class="n"&gt;md_file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;bookmarks.md&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;w+&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;# Run a loop through all_bookmarks
&lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;all_bookmarks&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;instructions_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deep_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;data.bookmark_timeline.timeline.instructions&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tweet_entries_list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deep_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;instructions_list&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;entries&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;tweet_entry&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tweet_entries_list&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deep_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tweet_entry&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;content.itemContent.tweet_results.result&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deep_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;core.user.legacy.screen_name&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deep_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;legacy.full_text&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;tweet_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;deep_get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;rest_id&lt;/span&gt;&lt;span class="sh"&gt;"&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;tweet_id&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;continue&lt;/span&gt;
        &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;formatText&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;constructUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tweet_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;username&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="n"&gt;bookmarked_tweet&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;- &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\t&lt;/span&gt;&lt;span class="s"&gt; - &lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;
        &lt;span class="n"&gt;md_file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bookmarked_tweet&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The final output would look like this: &lt;/p&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1604229364586%2F6w4P76SIm.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1604229364586%2F6w4P76SIm.png" alt="Screenshot 2020-11-01 at 4.15.56 PM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have formatted it as I wanted, you can do something else too. Here is the whole code for you to refer in this &lt;a href="https://gist.github.com/divyajyotiuk/9fb29c046e1dfcc8d5683684d7068efe" rel="noopener noreferrer"&gt;gist&lt;/a&gt;. The gist will be updated with new logic if any changes from Twitter API are observed.&lt;/p&gt;

</description>
      <category>twitter</category>
      <category>python</category>
      <category>markdown</category>
      <category>json</category>
    </item>
    <item>
      <title>How to create React App with Flask backend?</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Sun, 27 Sep 2020 16:13:25 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/how-to-create-react-app-with-flask-backend-2nf7</link>
      <guid>https://dev.to/divyajyotiuk/how-to-create-react-app-with-flask-backend-2nf7</guid>
      <description>&lt;p&gt;Do you want use Python as backend for your React project? You can write the frontend logic in Javascript and use Python for the backend. Flask makes this integration into one single project really easy.&lt;/p&gt;

&lt;p&gt;We'll be covering,&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Creating Flask API&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Creating React App&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Integration&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Creating Flask API
&lt;/h2&gt;

&lt;p&gt;First we start by creating a Flask project. I would recommend to make a separate folder to run the backend server code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ mkdir flask-api
$ cd flask-api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I always setup a virtual environment. A virtual environment manages dependencies of the project and remain particular for the single project. It does not affect the system packages. The following commands are for Unix-based systems. They create virtual environment and activates it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ python3 -m venv venv
$ source venv/bin/activate
(venv) $ 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Python versions &lt;code&gt;&amp;lt;3.4&lt;/code&gt; do not have virtual environments inbuilt. You need to install a third-party package &lt;code&gt;virtualenv&lt;/code&gt;  and run &lt;code&gt;virtualenv venv&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now you start installing flask and python's dotenv package. And flask-cors for handling Cross Origin Resource Sharing for making cross-origin http calls.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(venv) $ pip install flask python-dotenv
(venv) $ pip install -U flask-cors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a file &lt;code&gt;app.py&lt;/code&gt; in the &lt;code&gt;flask-api&lt;/code&gt; directory and initialise the flask environment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_cors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CORS&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nc"&gt;CORS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next step is to create a &lt;code&gt;.env&lt;/code&gt; file which contains the following data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FLASK_APP=app.py
FLASK_ENV=development
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Flask automatically imports the project from the &lt;code&gt;FLASK_APP&lt;/code&gt; environment variable. And reads the environment from &lt;code&gt;FLASK_ENV&lt;/code&gt; variable.&lt;/p&gt;

&lt;p&gt;Let's start with writing a simple API that responds with  &lt;strong&gt;"Hello World"&lt;/strong&gt;. In recent versions, Flask supports returning dictionary rather than calling &lt;code&gt;jsonify()&lt;/code&gt; as Flask implicitly JSONifies the dictionary.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Flask&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask_cors&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CORS&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nc"&gt;CORS&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app.route&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;/hello&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;say_hello_world&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="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;result&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Hello World&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Start the Flask server using &lt;code&gt;flask run&lt;/code&gt;. You should see something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* Serving Flask app "app.py" (lazy loading)
* Environment: development
* Debug mode: on
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
* Restarting with fsevents reloader
* Debugger is active!
* Debugger PIN: 306-333-596
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Creating React App
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx create-react-app react-flask-app
$ cd react-flask-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;package.json&lt;/code&gt;, add this particular line. It tells the development server to proxy the request to API server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"proxy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:5000"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Integration
&lt;/h2&gt;

&lt;p&gt;In React's &lt;code&gt;App.js&lt;/code&gt; file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;logo&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./logo.svg&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./App.css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setPlaceholder&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/hello&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;()).&lt;/span&gt;&lt;span class="nf"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nf"&gt;setPlaceholder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;header&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App-header&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;img&lt;/span&gt; &lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;logo&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App-logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="nx"&gt;alt&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;logo&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Edit&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;code&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;src&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;js&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/code&amp;gt; and save to reload&lt;/span&gt;&lt;span class="err"&gt;.
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;
          &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;App-link&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://reactjs.org&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;_blank&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
          &lt;span class="nx"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;noopener noreferrer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
        &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nx"&gt;Learn&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/a&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;        &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Flask&lt;/span&gt; &lt;span class="nx"&gt;says&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/p&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/header&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;  &lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1601217268600%2FYXIVXq_eR.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%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1601217268600%2FYXIVXq_eR.png" alt="Screenshot 2020-09-27 at 8.04.04 PM.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hurrah! We did it! It automatically makes a request to Flask backend and updates the DOM. There is no language barrier for client server communication.&lt;/p&gt;

</description>
      <category>react</category>
      <category>python</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Clojure and Leiningen to manage Clojure projects</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Mon, 07 Sep 2020 09:53:21 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/clojure-and-leiningen-to-manage-clojure-projects-19io</link>
      <guid>https://dev.to/divyajyotiuk/clojure-and-leiningen-to-manage-clojure-projects-19io</guid>
      <description>&lt;p&gt;I would like to introduce you to Clojure. I am fascinated by how it works and it is also known to sharpen your thinking as a programmer. In this article, we'll do a basic setup and start programming in Clojure!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Clojure ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Daniel Higginbotham&lt;/strong&gt; in his book &lt;em&gt;Clojure for the Brave and True&lt;/em&gt; has humorously defined Clojure as &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;an alloy of Lisp, functional programming and a lock of Rich Hickey's own epic hair&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It combines Lisp dialect, powerful and expressive features of functional programming. Clojure is a &lt;em&gt;hosted language&lt;/em&gt; meaning Clojure programs run on platforms like Java, Javascript and .NET and use their underlying features.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Leiningen
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Leiningen&lt;/code&gt; is a useful tool to automate and manage your Clojure projects. Leiningen and Clojure require Java. Since, we are focusing on the JVM implementation of Clojure, OpenJDK will be required. You must have &lt;code&gt;&amp;gt; 1.6&lt;/code&gt; java version installed.&lt;/p&gt;

&lt;p&gt;Follow the steps on &lt;a href="https://leiningen.org/"&gt;https://leiningen.org/&lt;/a&gt; to download Leiningen. It will automatically download Clojure compiler, &lt;code&gt;clojure.jar&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a new project
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lein new app clojure-project
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After installing you would find the following files in the directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;project.clj&lt;/code&gt; (like package.json of npm) contains project dependencies. &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;resources&lt;/code&gt; folder to save assets (like images). &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;src/clojure-project/core.clj&lt;/code&gt; will be where you write your code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Running the project
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;(ns clojure-project.core
  (:gen-class))

(defn -main
  "I don't do a whole lot...yet."
  [&amp;amp; args]
    (println "Hello, World!"))
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This code will be already present in the &lt;code&gt;src/clojure-project/core.clj&lt;/code&gt; file. If you have ever used C, C++ you would know namespace and the main function. Well, the &lt;code&gt;defn -main&lt;/code&gt; is the starting point of your program. &lt;/p&gt;

&lt;p&gt;To run, &lt;code&gt;cd&lt;/code&gt; into the clojure-project and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lein run
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should see &lt;code&gt;Hello, World!&lt;/code&gt; as the output!&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the project
&lt;/h2&gt;

&lt;p&gt;Clojure works even with environment change. It is not necessary that Leiningen is required to run the project elsewhere. To allow code shareability, we can create a stand-alone file that works where Java is installed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lein uberjar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;After running this command a stand-alone file would be created in a &lt;em&gt;target/uberjar/&lt;/em&gt; folder (same directory level as src). This jar file can be distributed on any platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Using REPL
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;REPL&lt;/strong&gt; - &lt;strong&gt;r&lt;/strong&gt;ead, &lt;strong&gt;e&lt;/strong&gt;valuate and &lt;strong&gt;p&lt;/strong&gt;rint &lt;strong&gt;l&lt;/strong&gt;oop. It is a tool that takes single line and executes the code as soon as it evaluates (just like Console in web developer tools or python prompt). &lt;/p&gt;

&lt;p&gt;To start Clojure repl&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;lein repl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The prompt would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nREPL server started on port 56969 on host 127.0.0.1 - nrepl://127.0.0.1:56969
REPL-y 0.4.4, nREPL 0.7.0
Clojure 1.10.1
OpenJDK 64-Bit Server VM 1.8.0_242-b08
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

clojure-project.core=&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Clojure follows prefix notation and everything resides in matching parentheses. &lt;/p&gt;

&lt;p&gt;Samples to try out: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;(+ 1 2 3 4 5)&lt;/code&gt; should add up all numbers and return 15&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;( str "hello world" )&lt;/code&gt; should print &lt;code&gt;"hello world"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;( str "Hi! " "John " "Doe" )&lt;/code&gt; should concatenate all the strings&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;( * 1 2 3 4 5 )&lt;/code&gt; should return multiplied value 120&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>clojure</category>
      <category>functional</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Twitter: Automate updating follower count in your name</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Sun, 30 Aug 2020 13:38:38 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/twitter-automate-updating-follower-count-in-your-name-4gng</link>
      <guid>https://dev.to/divyajyotiuk/twitter-automate-updating-follower-count-in-your-name-4gng</guid>
      <description>&lt;p&gt;I wanted something fun to do in the weekend! Since, many people on dev twitter are building bots, I started this as a starting point. &lt;/p&gt;

&lt;p&gt;This is how it looks - my name with follower count:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1bH4IWkx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ujpi8or1qya7ganvssrf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1bH4IWkx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ujpi8or1qya7ganvssrf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this blogpost, I have listed one way of doing this. You'll find many other ways too!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tech stack for this pet project&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.npmjs.com/package/twitter-lite"&gt;twitter-lite&lt;/a&gt; (npm package)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://vercel.com/"&gt;Vercel&lt;/a&gt; (for hosting)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://console.cron-job.org/"&gt;cron-job&lt;/a&gt; (free cron service to automate the update)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Pre-requisites&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You must have an &lt;a href="https://developer.twitter.com/en/apply-for-access"&gt;approved twitter developer account&lt;/a&gt;, and have activated the &lt;a href="https://developer.twitter.com/en/portal/dashboard"&gt;developer portal&lt;/a&gt; where you can create new app. &lt;/li&gt;
&lt;li&gt;You get all your access tokens and API keys here and also a bearer token.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;To write the code first.&lt;/p&gt;

&lt;p&gt;We will be using twitter-lite, there are other packages as well that wrap the twitter API. First step is to create a twitter client that would fetch and send twitter data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Twitter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;twitter-lite&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;twitterClient&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Twitter&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;subdomain&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;api&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// we are using twitter api&lt;/span&gt;
    &lt;span class="na"&gt;version&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;1.1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// twitter api version 1.1&lt;/span&gt;
    &lt;span class="na"&gt;consumer_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;consumer_secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;API_SECRET&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;access_token_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ACCESS_TOKEN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="na"&gt;access_token_secret&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;ACCESS_TOKEN_SECRET&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

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



&lt;p&gt;Don't forget to add these environment variable when deploying on vercel.&lt;/p&gt;

&lt;p&gt;The logic comes here:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Divyajyoti👩‍💻JS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;httpResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;twitterClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;account/verify_credentials&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
                    &lt;span class="nx"&gt;httpResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Error fetching Twitter Client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="p"&gt;}&lt;/span&gt;

                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;followerCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;followers_count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;|&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;followerCount&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;userName&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;user_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;twitterClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;account/update_profile&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user_name&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

                &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&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="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
                        &lt;span class="nx"&gt;httpResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Update error&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
                        &lt;span class="nx"&gt;httpResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Update &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;user_name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; Success!`&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                    &lt;span class="p"&gt;}&lt;/span&gt;
                &lt;span class="p"&gt;})&lt;/span&gt;
                &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&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;httpResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="p"&gt;})&lt;/span&gt;
            &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&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;httpResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;It's my habit to add all these checks, you can avoid if you want but it helps in debugging. &lt;/p&gt;

&lt;p&gt;If you want the number emojis as well, just create an object mapping and append.&lt;/p&gt;

&lt;p&gt;The reason I used&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;is because &lt;a href="https://vercel.com/docs/serverless-functions/introduction"&gt;Vercel Serverless functions&lt;/a&gt; demand it. Keep the file in &lt;code&gt;/api&lt;/code&gt; folder, for vercel to identify it as lambda function. &lt;/p&gt;

&lt;p&gt;So, it would look like we have created an API endpoint that will do the dynamic updating.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you have done this correctly, rest all is easy job. I would suggest uploading your project on Github. Vercel is easy to use if you have Git integration. &lt;/p&gt;

&lt;p&gt;Import the project using github repo url, add the environment vars and deploy it! &lt;/p&gt;

&lt;p&gt;Open the url provided by vercel. If /api is not formed add /api/ if not index.js&lt;/p&gt;

&lt;p&gt;Now go to Function logs and select the your function from dropdown. You'll see your api logs here. &lt;/p&gt;

&lt;p&gt;Visit the url and see what message comes in the body. If it's successful, you'll see the change in your twitter account as well.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now to update it with cron service. You don't need to manually hit the api to update change, cron will do the job for you. &lt;/p&gt;

&lt;p&gt;Go to &lt;a href="https://console.cron-job.org/"&gt;cron-job&lt;/a&gt; and create an account. &lt;br&gt;
Create your first cron job, give your Vercel api url, specify the time interval to make your requests that will automatically run the function and update your twitter name.&lt;/p&gt;

&lt;p&gt;Your job is done here! &lt;/p&gt;

&lt;p&gt;You can comment if you get stuck or have any questions!&lt;/p&gt;

&lt;p&gt;I referred these articles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dev.to/code_rams/twitter-dynamic-name-generator-3ka2"&gt;https://dev.to/code_rams/twitter-dynamic-name-generator-3ka2&lt;/a&gt; by &lt;a href="https://twitter.com/code_rams"&gt;@code_rams&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/radnerus/twitter-api-is-followers-count-mda"&gt;https://dev.to/radnerus/twitter-api-is-followers-count-mda&lt;/a&gt; by &lt;a href="https://twitter.com/radnerus93"&gt;@radnerus93&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>showdev</category>
      <category>javascript</category>
      <category>node</category>
      <category>twitterapi</category>
    </item>
    <item>
      <title>Header tags and how they boost SEO</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Wed, 19 Aug 2020 14:02:52 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/header-tags-and-seo-354</link>
      <guid>https://dev.to/divyajyotiuk/header-tags-and-seo-354</guid>
      <description>&lt;p&gt;&lt;strong&gt;What is SEO?&lt;/strong&gt;&lt;br&gt;
SEO refers to &lt;strong&gt;S&lt;/strong&gt;earch &lt;strong&gt;E&lt;/strong&gt;ngine &lt;strong&gt;O&lt;/strong&gt;ptimisation. It is a process of increasing the &lt;code&gt;website&lt;/code&gt; or &lt;code&gt;webpage&lt;/code&gt; visibility when people search using certain keywords that are related to or rather used in the website. So, a lot of websites use this as a marketing strategy to increase their website traffic and rank higher in searches. &lt;/p&gt;

&lt;p&gt;There are a lot factors that affect SEO when building a site. But how do HTML header tags come into picture? &lt;/p&gt;

&lt;p&gt;Header tags play an important role in on-page SEO. They tell what your website is about, the overall context of the website or the webpage. Search engines give the header tags more importance than the rest. When search engines crawl your website, they read the header tags. So keep your header tags small and specific so that search engines can pickup the accurate keywords. &lt;/p&gt;

&lt;p&gt;The first 3 header tags- &lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;h2&lt;/code&gt; and &lt;code&gt;h3&lt;/code&gt; carry more SEO value than the rest(h4, h5, h6). Choose your title carefully when giving values in these tags. Give importance hierarchically, meaning put more essence to h1, then the subheading h2, and then h3. Keep the context same, as it will be easy for the crawlers to recognise correct keywords. &lt;/p&gt;

&lt;p&gt;Below is a basic example showing how you may use your header tags:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Header tags and SEO&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;What is SEO and importance of header tags in SEO&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;h3&amp;gt;&lt;/span&gt;How should you use header tags effectively?&lt;span class="nt"&gt;&amp;lt;/h3&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This example fairly shows certain keywords that might be easily extracted. Well, the game doesn't end here. You may get a lot of competition, only using header tags isn't going to help but is a great factor in deciding the rank of a website.&lt;/p&gt;

</description>
      <category>html</category>
      <category>webdev</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>What is Shadow DOM??</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Tue, 04 Aug 2020 14:23:30 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/what-is-shadow-dom-1036</link>
      <guid>https://dev.to/divyajyotiuk/what-is-shadow-dom-1036</guid>
      <description>&lt;p&gt;Shadow DOM is basically a sub-tree of DOM elements, which is included during rendering of the document but not included in the main document DOM. In other words, the content of a Shadow DOM is a different document, which is merged with the main document to create the overall rendered output.&lt;/p&gt;

&lt;p&gt;Take an example of slider:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"foo"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"range"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



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

&lt;p&gt;The thumb on the slider moves, when you have not written any css or javascript. &lt;/p&gt;

&lt;p&gt;If you do inspect element on the slider you might see something like this: &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jf3Asm_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gmmus3dhd88xf69145z8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jf3Asm_4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gmmus3dhd88xf69145z8.png" alt="inspect slider"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, to enable Shadow Root you need to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;inspect element&lt;/li&gt;
&lt;li&gt;click on the gear icon in the top right corner&lt;/li&gt;
&lt;li&gt;Go to Elements&lt;/li&gt;
&lt;li&gt;enable &lt;code&gt;Show user agent shadow DOM&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, try inspecting element again. &lt;br&gt;
Do you see this?&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--xJIlgX9g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bo034tu6ouy8u3f3ighg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--xJIlgX9g--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/bo034tu6ouy8u3f3ighg.png" alt="shadow-root"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can override the default styles and tweak some beautiful features!&lt;/p&gt;

&lt;p&gt;You could try it for &lt;code&gt;&amp;lt;audio&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; HTML5 tags.&lt;/p&gt;

&lt;p&gt;This is the link, I referred to understand. &lt;br&gt;
&lt;a href="https://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/"&gt;https://glazkov.com/2011/01/14/what-the-heck-is-shadow-dom/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>Get HTTPS support in just one line</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Fri, 31 Jul 2020 10:50:44 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/get-https-support-in-just-one-line-54fo</link>
      <guid>https://dev.to/divyajyotiuk/get-https-support-in-just-one-line-54fo</guid>
      <description>&lt;p&gt;In your &lt;strong&gt;react web app&lt;/strong&gt;, if you need &lt;code&gt;HTTPS&lt;/code&gt; support while running on your localhost, just add this in your start script in your &lt;code&gt;package.json&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"start"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"HTTPS=true react-scripts start"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then just run &lt;code&gt;npm start&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You'll see something like this:&lt;br&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%2Fi%2Ffqzwrbx8b6zg3r6hfnz9.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%2Fi%2Ffqzwrbx8b6zg3r6hfnz9.png" alt="Not secured"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But that's acceptable, till your site is getting served over HTTPS. &lt;/p&gt;

&lt;p&gt;Bingo! &lt;br&gt;
No need to take efforts of creating an SSL certificate! &lt;/p&gt;

</description>
      <category>todayilearned</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>Thwaites Conjecture - graphically</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Sat, 18 Jul 2020 09:43:43 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/thwaites-conjecture-graphically-2cgg</link>
      <guid>https://dev.to/divyajyotiuk/thwaites-conjecture-graphically-2cgg</guid>
      <description>&lt;p&gt;What are &lt;strong&gt;conjectures&lt;/strong&gt;? &lt;/p&gt;

&lt;p&gt;Wikipedia says &lt;em&gt;"In mathematics, a conjecture is a conclusion or a proposition which is suspected to be true due to preliminary supporting evidence, but for which no proof or disproof has yet been found".&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;So, from one of these conjectures, I came across was the &lt;strong&gt;Thwaites Conjecture&lt;/strong&gt;. &lt;br&gt;
The algorithm proceeds as below:&lt;br&gt;
Think of a positive whole number,&lt;br&gt;
if the number is odd, multiply by 3 and add 1,&lt;br&gt;
if the number is even, just half it. &lt;br&gt;
Keep repeating this procedure, you'll eventually reach 1. &lt;/p&gt;

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

&lt;p&gt;So, to see why this is true, I thought of plotting every step on the graph to see if there is any pattern. You can go ahead and comment your observations. Unfortunately, I couldn't find any pattern but I understood how &lt;code&gt;canvas&lt;/code&gt; was used. &lt;/p&gt;

&lt;p&gt;I am currently in the process of improving this project. &lt;br&gt;
The height and width need to be scaled properly to make all the points visible.&lt;/p&gt;

&lt;p&gt;Any suggestions are welcome. &lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>showdev</category>
      <category>codepen</category>
      <category>todayilearned</category>
    </item>
    <item>
      <title>Easy peasy formatting list of names</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Tue, 14 Jul 2020 10:34:12 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/easy-peasy-formatting-list-of-names-4a0e</link>
      <guid>https://dev.to/divyajyotiuk/easy-peasy-formatting-list-of-names-4a0e</guid>
      <description>&lt;p&gt;Given an array containing hashes of names.&lt;br&gt;
You have to return a string formatted as a list of names separated by commas except for the last two names, which should be separated by &lt;code&gt;&amp;amp;&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;formatList([ {name: 'Dave'}, {name: 'Alex'}, {name: 'Marge'} ])
// returns 'Dave, Alex &amp;amp; Marge'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's a single line solution, &lt;code&gt;regex&lt;/code&gt; peeps&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;formatList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;, &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;.*&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;,&lt;/span&gt;&lt;span class="se"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;.*&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;$1 &amp;amp;$2&lt;/span&gt;&lt;span class="dl"&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 this is the most clever solution, I could never think of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;formatList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;obj&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pop&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;a&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="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;, &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt; &amp;amp; &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I could think of using &lt;code&gt;reduce&lt;/code&gt;, &lt;code&gt;forEach&lt;/code&gt; and other looping methods using if else. &lt;code&gt;reduce&lt;/code&gt; does a pretty great job itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;formatList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;names&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&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;names&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;prev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&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;prev&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;curr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;, &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &amp;amp; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>todayilearned</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Easy peasy reverse words</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Sun, 12 Jul 2020 10:48:48 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/easy-peasy-reverse-words-4in0</link>
      <guid>https://dev.to/divyajyotiuk/easy-peasy-reverse-words-4in0</guid>
      <description>&lt;p&gt;Return string with &lt;strong&gt;&lt;code&gt;n&lt;/code&gt; or more lettered&lt;/strong&gt; words reversed, given that string consists of letters and spaces only. (i.e. n is the word length) &lt;/p&gt;

&lt;p&gt;A single line clever solution would be by using &lt;code&gt;regex&lt;/code&gt;.&lt;br&gt;
If &lt;code&gt;n&lt;/code&gt; is predetermined, like &lt;code&gt;n = 5&lt;/code&gt;,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;revWords&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&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;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\w{5,}&lt;/span&gt;&lt;span class="sr"&gt;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;w&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="nx"&gt;w&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But not all clever solutions are good to go on production. It does fit this problem but difficult to mutate or reuse the technique if problem changes. The next one's better.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;revWords&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;str&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&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;str&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&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="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; 
    &lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;word&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>todayilearned</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>setTimeout() - any drawback?</title>
      <dc:creator>Divyajyoti Ukirde</dc:creator>
      <pubDate>Tue, 07 Jul 2020 07:46:39 +0000</pubDate>
      <link>https://dev.to/divyajyotiuk/settimeout-any-drawback-47ed</link>
      <guid>https://dev.to/divyajyotiuk/settimeout-any-drawback-47ed</guid>
      <description>&lt;p&gt;Recently, I had come across a bug that needed auto-refresh after a certain point of time. And &lt;code&gt;setTimeout()&lt;/code&gt; had been used to count down to the time and reload the page. Little did I know that &lt;code&gt;setTimeout()&lt;/code&gt; came with a price. &lt;/p&gt;

&lt;p&gt;As quoted on MDN Web Docs at the very &lt;em&gt;bottom&lt;/em&gt;, &lt;strong&gt;"Browsers including Internet Explorer, Chrome, Safari, and Firefox store the delay as a 32-bit signed integer internally. This causes an integer overflow when using delays larger than 2,147,483,647 ms (about 24.8 days), resulting in the timeout being executed immediately."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, you'll understand what kept happening to the page! (The page kept reloading...)&lt;/p&gt;

&lt;p&gt;It is very much true that there is hardly any process that would require this big a delay. You have other options, like reseting timer after certain duration or using &lt;code&gt;setInterval()&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;I would prefer &lt;code&gt;setInterval()&lt;/code&gt;, when there are simple operations in the callback function and when you know what is the maximum time that function is going to take to execute. If you aren't aware of the maximum time, the event queue will keep piling up forever as your code's activity lags behind the actual system time. &lt;/p&gt;

&lt;p&gt;Choose wise! Don't forget to clear the timers when your job is done!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>todayilearned</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
