<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Divyanshu Raj on Medium]]></title>
        <description><![CDATA[Stories by Divyanshu Raj on Medium]]></description>
        <link>https://medium.com/@divyanshuraj_39877?source=rss-356feeec5ce0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*f_jn8tvcT2x87BgCq6zd0Q.jpeg</url>
            <title>Stories by Divyanshu Raj on Medium</title>
            <link>https://medium.com/@divyanshuraj_39877?source=rss-356feeec5ce0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 21:33:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@divyanshuraj_39877/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A personal RAG — Glaze]]></title>
            <link>https://medium.com/@divyanshuraj_39877/a-personal-rag-glaze-07229ed97d2c?source=rss-356feeec5ce0------2</link>
            <guid isPermaLink="false">https://medium.com/p/07229ed97d2c</guid>
            <category><![CDATA[vector-database]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[openai]]></category>
            <category><![CDATA[agentic-rag]]></category>
            <dc:creator><![CDATA[Divyanshu Raj]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 20:36:34 GMT</pubDate>
            <atom:updated>2026-01-27T17:40:51.951Z</atom:updated>
            <content:encoded><![CDATA[<h3>A personal RAG — Glaze</h3><p>For long I wanted to build something in AI, I have always liked building end usable product over demos, i discovered that every small company or business needs RAG based chat apps to chat with their personal data like bank balance sheets, personal pdf, etc, they dont want their personal data to be used for training, so naturally RAG chat apps is the best answer to this.</p><p>I wanted to build fully open sourced app so that i dont have to pay to openai ( haha ) for this side project.</p><p>RAG is fairly simple starting point of building something in AI, RAG stands of Retrieval Augmented Generation, to understand this assume you have 10 pages of Bank balance sheet stored in pdf, and you want to know which vendor i pay most frequently or what is the maximum amount i have paid etc, practically you are expecting a well informed answer like “ you have spent $100 on starbucks and $90 on amazon prime in januray 2026, but it has gradually come down from december 2025” , this is gives fair understanding of data and trends not just numbers.</p><p>How RAG works is, it first <strong>chunks</strong> your 10 pages pdf into smaller sized document maybe divide it into 50 small parts, there are then <strong>vectorized</strong>, i.e these texts of each parts is converted into mathetical numbers which <strong>has meanings</strong>, and then stored into a special kind of database called vector database which are efficient in finding similar vectors. when you search for a term like “maximum amount i have paid” a RAG app will first query a vector database for eg. pinecone and <strong>retrieves</strong> top 3 chunks from the 50 small chunks it stored earlier, these vector database are build to find similar vectors, so ““maximum amount i have paid”” is converted into a vector [10, 20,30] for example and then from its stores it tries to find top k chunks which are near to this vector. The process of vectorization is done by a ML model like sentence transformers ( built on <strong>BERT</strong> or <strong>oBERTa ).</strong></p><p>Every vector retrieved from Pinecone ( vector DB ) also has the texts inserted into it, now once we have 3 very similar chunks, we pass the text data from chunks to LLM, for this project i used ollama, llama3.1 model totally open source and running on my macbook AIR M4, we could have sent whole pdf to the LLM actually but that is inefficient and it will take lot of time for llm to process, hence we are using vector database to ease the process.</p><p>We guide LLM with system-prompt of somethin like “ you are personal RAG assistant, you job is to answer the users question ONLY AND ONLY From the context provided and not from any other online or external knowledge base. IMPORTATNT : do not use any extra knowledge apart from context provided. IMPORTANT : do not leak any internal working or execution steps to the users” and pass user-prompt as “maximum amount i have paid” + knowledge base as “chunk1 text \n + chunk2 text \n + chunk3 text”, then show the LLM output to the end user.</p><p>This is very simple RAG system you can build, but what if you build a descision tree in the app, for eg. if user asks to check online then use google search to get internet data, or most important how do you validate that the output given by LLM is not hallucinated ones.</p><p>Now to actually have more controll over these things, we use openSource tool LangGraph, where we build our graph nodes just like we make if/else statement in normal coding. But here each node can be independent LLM deciding the true/false of a condition.</p><p>For eg to reduce hallucninations we build the graph like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/1*EAj4sBGiDBhiPD__dARohw.png" /></figure><p>Deployed App : <a href="https://glaze.agenticweb.co.in/">https://glaze.agenticweb.co.in/</a></p><p>Source code : <a href="https://github.com/endurance21/glaze">https://github.com/endurance21/glaz</a>e</p><p>I will covering RAG in more technical details in later posts.</p><p>Thanks !</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=07229ed97d2c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[extras for react reconciliation blog]]></title>
            <link>https://medium.com/@divyanshuraj_39877/extras-for-react-reconciliation-blog-988070189747?source=rss-356feeec5ce0------2</link>
            <guid isPermaLink="false">https://medium.com/p/988070189747</guid>
            <dc:creator><![CDATA[Divyanshu Raj]]></dc:creator>
            <pubDate>Thu, 19 Jan 2023 19:41:07 GMT</pubDate>
            <atom:updated>2023-01-19T19:45:11.697Z</atom:updated>
            <content:encoded><![CDATA[<p>if you have not been redirected here from the original my <a href="https://medium.com/@divyanshuraj_39877/react-reconcillation-algo-and-key-prop-in-progress-8bef74e3d23a">react reconciliation blog</a>, please go back to the original post for the <a href="https://medium.com/@divyanshuraj_39877/react-reconcillation-algo-and-key-prop-in-progress-8bef74e3d23a">actual story.</a></p><p>If you have already read the previous blog, let&#39;s get started…</p><p>you can make the input uncontrolled and perform those experiments and see how mutations change.</p><p>for eg., if you remove the state from the Task component and make it uncontrolled, there will be one more mutation of type “attributes” as the value attribute gets changed for one input.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HtRlyiO8-sSJnEBAlGDjzQ.png" /><figcaption>un controlled Task</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z971Can_uF_JMgV4j7ndBQ.png" /><figcaption>when input is uncontrolled</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ofYJF8VYNyIxGdHVWIAAQ.png" /><figcaption>two extra mutations of type attribute can be seen here.</figcaption></figure><blockquote>Always go one extra mile, it’s never crowded</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=988070189747" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Reconciliation, you did not know!]]></title>
            <link>https://medium.com/@divyanshuraj_39877/react-reconcillation-algo-and-key-prop-in-progress-8bef74e3d23a?source=rss-356feeec5ce0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bef74e3d23a</guid>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[reconciliation]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[news]]></category>
            <dc:creator><![CDATA[Divyanshu Raj]]></dc:creator>
            <pubDate>Wed, 18 Jan 2023 03:28:27 GMT</pubDate>
            <atom:updated>2023-01-25T19:49:36.409Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>React Reconciliation, you did not know!</strong></p><p>Hello everyone, if you are here you probably already know about the <a href="https://reactjs.org/">react.js</a> library, in this article we will deep dive into some famous topics of this library. This is going to be informative at the start and interactive at the end, this is <strong>not going to be some normal blog</strong> only explaining those topics, you would find some unique experiments to visualize how under the hood things are working in react.js</p><p>Let’s start with Virtual Dom.</p><p>Simply put, <a href="https://en.wikipedia.org/wiki/Virtual_DOM"><em>Virtual Dom</em></a><em> (V-DOM) </em>is a technique to store a copy representation of the actual <a href="https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model/Introduction">browser DOM</a> tree. Any update that we intend to make on the webpage will at first be made to this V-DOM, as making changes to virtual doms are computationally cheap so unnecessary changes could also be made, this is better than directly making expensive updates to the actual DOM tree.</p><p>Every render method call returns a new V-DOM tree, react saves the previous V-DOM, then diff between the previous V-DOM (V-DOM-initial) and the current V-DOM(V-DOM-new) is calculated using a <strong>diffing algorithm</strong>, and based on the diff, it makes changes to the actual browser DOM smartly, this process is called <strong>Reconciliation.</strong></p><p>The following illustration intends to depict the same :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHjk5cwv1-XvzA9FvzbnVA.png" /></figure><h3>The Mechanism</h3><p>Diffing algorithm compares nodes from both V-DOM, calculates diff between them, and generates smart mutations that are to be made to the actual dom. let us say the name of a node in V-DOM-INITIAL is <strong>root1</strong> and that of a node in V-DOM-NEW is <strong>root2.</strong></p><p>There are two scenarios that occur while comparing root1 and root2.</p><ul><li>if the element type of root1 and root2 <strong>are not the same</strong>, for example, root1 is &lt;input/&gt; and root2 is &lt;image/&gt;, then the whole subtree rooted at root2 roots are marked as a new whole subtree, in actual DOM, subtree with root1 is <strong>torn down</strong> and whole new subtree with root as root2 <strong>is added.</strong></li><li>if elements the type of root1 and root2 <strong>are the same, </strong>react does not simply replace that element in the browser DOM, instead, it applies mutations very smartly, for example, if necessary it will only update attributes, innerHTML, innerText, etc.</li></ul><h3>Rendering of lists of similar elements</h3><p>Consider the following scenario, initially, there are only two <em>&lt;li/&gt;</em> elements. Then a third <em>&lt;/li&gt;</em> is added to the list <strong>at the last,</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_FzJFJSfLGQRtezUhzGjIg.png" /></figure><p>here it&#39;s easy for react to conclude that the first and second elements are the same in both V-DOM and a new element(<em>&lt;li&gt;third &lt;/li&gt;)</em> has been added, so the diff says to add one extra <em>&lt;li&gt;third&lt;/li&gt;</em> to the actual DOM rather than simply adding all-new 3 nodes to the browser DOM.</p><p>However, for the following situation, it&#39;s challenging to figure out which element is the same across both trees.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cL3bJsVyaaTdr_Q191e8fw.png" /></figure><p>here new element is added at the start, and there can number of other combinations in which this new element could be inserted, which is confusing and makes it hard to recognize which elements are the same across the render.</p><p>To rescue this scenario, developers provide a <strong>key prop</strong> to the elements to hint react that these two elements are the same, it&#39;s upon the developers what key prop they choose for these elements. Broadly they could either set a <strong>constant value </strong>or<strong> variable value</strong> for each child element. we will demonstrate which one is <strong>safer and better</strong> and which one can <strong>negatively / positively </strong>affect your react application.</p><p>I have made code <strong>snippets</strong> so that you can try them yourselves and conclude better.</p><p>Both snippets have the common functionality of a simple TODO app with the only difference being how the key is set in these two snippet.</p><p>A unit task has the following properties :</p><ul><li>id</li><li>task</li><li>createdAt</li></ul><p>further, the TODO app has the following functionalities :</p><ul><li>Add Task to start of the list</li><li>Add Task to end of the list</li><li>Clear tasks</li></ul><p>and I hope those buttons and fields are self-explanatory, initially, there are two tasks in the tasks array and the id of the tasks starts as 1, 2…..</p><p>here is the initial view of one of the snippets of one of the cases :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYgAXErC_jFyIKM71w8VsQ.png" /><figcaption>sample initial view of snippet</figcaption></figure><p>To view/analyze better what is react doing under the hood, I took help from our new guest here<a href="https://javascript.info/mutation-observer"> Mutation Observer</a>, it is a Web API that facilitates us to view any changes made to any subtree in the <strong>actual DOM tree. </strong>you just have to <strong>see the console </strong>after making any changes to a snippet, the console shows the <a href="https://dom.spec.whatwg.org/#mutationrecord">Mutation Record</a> of the <strong>actual DOM tree</strong>, when an element is removed/added or just text gets changed, it gets reflected in this record.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sr-WvdQEh2ICd5-WL1aeCQ.png" /><figcaption>sample console view</figcaption></figure><p>gear yourself up for this Interesting, Interactive journey!</p><h4>CASE 1: variable key ( index of the array)</h4><p>while rendering a list of elements, developers use the <strong>index </strong>of elements in the <strong>array </strong>as their <strong>key prop</strong> but that is not constant, suppose the array is modified later in the runtime, the index of each element gets changed, and hence key would also change.</p><blockquote><a href="https://codesandbox.io/s/index-as-key-final-feytmg"><strong>Use this sandbox link for case 1</strong></a></blockquote><p>The initial screen would look like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYgAXErC_jFyIKM71w8VsQ.png" /></figure><p>Now click on the button to add a task to the <strong>end of the list.</strong></p><p>as a result, you would see something like this :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VMnhq7kYDIu3Fydlm7-4DQ.png" /></figure><p>when you have a look at the mutation record in the console, you will see there is only one mutation record.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1sFlr5cehyHXxFEKNf2KA.png" /><figcaption>console view</figcaption></figure><p>This record of type “<strong>childList” </strong>indicates a child has been added or deleted from the list and evidently “<strong>addedNodes”</strong> field shows one node has been added to the subtree in the real browser DOM tree, which is expected behavior as if we have added an element in the react application then only one element should be added to the actual DOM, here react optimizations is working fine.</p><p>okay, that was simple! no harm, no anomalies 😇.</p><blockquote><strong>click on clear tasks button for next step</strong></blockquote><p>Now click on the button to add a task to the <strong>start of the list, </strong>do you see any weird behavior? 😵‍💫😵‍💫😵‍💫😵‍💫😵‍💫</p><p>if you followed the tutorial just right, something like the following would be there on your screen</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eHB8xTmEa-Sfs5cP-WFdSA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sr-WvdQEh2ICd5-WL1aeCQ.png" /><figcaption>console view</figcaption></figure><p>😱😱 😱😱😱😱 !<br> can you find the following anomalies here? :</p><ul><li>why is task 3 showing “task1” in its input?</li><li>why is task 1 showing “task2&quot; in its input?</li><li>why are there 4 mutation records in the console, should not be only one as before?</li></ul><p>well, let me answer that for you!</p><p>initially, there was an array (something like [task1, task2]), as the index has been set as the key prop for elements, task1 has an index of “0” so “0” becomes its key, and task2 has an index of “1” so “1” becomes its key too.</p><p>well, you clicked the “add a task to start” button a new task with id equal to 3 was added at the start of the tasks in the new V-DOM, the index of present nodes got increased by 1, and hence the key of existing nodes got mismatched. key of task 1 got changed to “1” from “0” and so on, the key for task 2 got changed to “2” from “1” and the key of newly added task 3 is “0” in a new <strong>updated version of V-DOM.</strong></p><p><strong>task 3 </strong>in the new V-DOM is considered as just a new version of <strong>task 1 </strong>in the initial V-DOM<strong> </strong>as the key of both tasks is the same equal to “0”, react will perform a diff and make only necessary changes to the <strong>actual DOM.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s_oU1bqpPux4y_MHlhg3vA.png" /></figure><p><strong>task 1 in actual dom</strong> will be updated to look like task 3 as the new V-DOM, its id becomes 3, and createdAt becomes date2, however, if you notice carefully <strong>text field does not change</strong>, and that is <strong>very interesting to see</strong>, actually, the input element here is the <a href="https://reactjs.org/docs/forms.html#controlled-components">Controlled Component</a>, and the “value” attribute of the input element in the Task component is managed by javascript and not left for HTML to decide ( that happens in case of <a href="https://reactjs.org/docs/uncontrolled-components.html">Uncontrolled Component</a>).</p><p>the total mutation made here = 1 ( for id ) + 1(createdAt) + 0(input) = 2</p><p>in the new V-DOM, the key of task 1 becomes “1” as its index changed to “1” which was the key for <strong>task 2</strong> earlier in the initial V-DOM, so again task 1 in the updated V-DOM was misunderstood as a new version of task 2 of the initial V-DOM. React will calculate diff and make the necessary update to task 2 in the real dom, this action can be seen in the below demonstration :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eGAkNv0pNjmq2W_lcMbvjw.png" /></figure><p>final id becomes 1, as createdAt field was initially the same for both tasks hence there was no change and as explained above the value of the text field remained “task2&quot; because that is a controlled component.</p><p>the total mutation made here = 1 ( for id ) + 0(createdAt) + 0(input)= 1</p><p><strong>for task 2 </strong>in the new V-DOM, which is the last element of the new task and hence has a key prop equal to “2”, this key is entirely new for react and hence this task 2 will be created entirely new and added to the child list.</p><p>the total mutation made here = 1(for creation) = 1</p><p>the Net total mutation = 2+1+1 = 4. which is evident from the console too, 3 mutations of type “characterData” and 1 of type “childList”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cyLs7gQRQHIvxvDtCTxSoQ.png" /></figure><p>restore the original snippet for further steps</p><h4>CASE 2 : constant key ( id of the task)</h4><blockquote><a href="https://codesandbox.io/s/id-as-key-final-xvhd9m"><strong>Use this sandbox link for case 2</strong></a></blockquote><p>The initial view of the snippet :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ctw5s0NBkyiKdUB1KFRojg.png" /></figure><p>Go on and try adding a task either at the start or at the end of the list, you will only see one mutation record each time, and I hope you can self-explain the reason. which is, the keys of old tasks were left unchanged, and also there was no change in those tasks so the diff was zero for them, and the respective addition of new tasks costs one mutation to the real DOM tree each time.</p><p>Conclusion :</p><p>while rendering lists, if the key prop is not set correctly the optimization mechanism performed by react can backfire, negatively impact performance and even break the application.</p><blockquote>A perfect key prop should be constant across the application lifecycle.</blockquote><p>Hope you like the post and feel free to shoot questions in the comments in case you have doubts.</p><p><a href="https://medium.com/@divyanshuraj_39877/react-reconcillation-algo-and-key-prop-in-progress-8bef74e3d23a">Also, here is something as extras</a> 😉</p><p>Thanks and Happy 2023!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bef74e3d23a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Spring Boot Application on HEROKU]]></title>
            <link>https://medium.com/@divyanshuraj_39877/deploying-spring-boot-application-on-heroku-bdbf3fe3794b?source=rss-356feeec5ce0------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdbf3fe3794b</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Divyanshu Raj]]></dc:creator>
            <pubDate>Fri, 26 Aug 2022 22:08:17 GMT</pubDate>
            <atom:updated>2022-08-28T09:05:56.674Z</atom:updated>
            <content:encoded><![CDATA[<p>Hmmm… so you are one of the people who have either built their application on spring boot and now looking for methods to deploy their application to the cloud, no doubt Heroku sounds to be the simplest and fast-to-implement solution, let’s try to do so!</p><p><strong>What’s different here in this blog than others?</strong></p><p>I have also tried many blogs out there to do so but very few of them talked about the error encountered while deploying the application straightforwardly. I have tried to cater to that problem and solve it in a very beginner-friendly manner.</p><p>We will begin setting up a demo project from scratch using spring-boot-initializer and then we will deploy that application on Heroku <strong>most importantly we will solve some problems related in between.</strong></p><h3><strong>BUILD A SPRING BOOT PROJECT</strong></h3><ul><li>Go to <a href="https://start.spring.io/">https://start.spring.io/ </a>and select parameters like java versions, build system, spring boot version ….</li></ul><p>I prefer Gradle over XML-based maven, here are all parameters I chose :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*peOFxkqNU6SI-vMA0FuvQg.png" /></figure><ul><li>Add dependencies</li></ul><p>I have only added <strong>spring-web, </strong>just to build a REST-API and serve it from the deployed server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*rDhVCgVefXcs5OW0ElTy9g.png" /></figure><ul><li>Download the zip file, unzip it, and open the project in your favorite IDE( mine is IntelliJ ).</li><li>Add the following code to the <em>demo/src/main/java/com/example/&lt;your-user-name&gt;/demo/DemoApplication.java </em>file and it should look something like this.</li></ul><pre>package com.example.demo.demo;</pre><pre>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.RestController;</pre><pre><a href="http://twitter.com/SpringBootApplicatio">@SpringBootApplicatio</a>n<br>public class DemoApplication {</pre><pre>public static void main(String[] args) {<br>  SpringApplication.run(DemoApplication.class, args);<br> }</pre><pre>}</pre><pre><a href="http://twitter.com/RestController">@RestController</a></pre><pre>class Controller{</pre><pre><a href="http://twitter.com/GetMapping">@GetMapping</a>(&quot;/&quot;)<br> public String handle(){<br>  return &quot;Hey, Have a Nice Day&quot; ;<br> }<br>}</pre><ul><li>Let&#39;s build and run the application using</li></ul><pre>&gt; ./gradlew build<br>&gt; ./gradlew bootRun ( or you can use &quot;java -jar &lt;jar_file&gt;&quot; ) </pre><ul><li>you should see something like this on the browser</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*euAZSA7PIp6kigYlAIJVog.png" /></figure><ul><li>Move to your project folder using terminal and Initialize your project as a git repository using</li></ul><pre>&gt; cd /path_to_your_project<br>&gt; git init </pre><h3>DEPLOY ON HEROKU</h3><ul><li>Go to <a href="https://www.heroku.com/">https://www.heroku.com/</a> and signup.</li><li>Download Heroku CLI from <a href="https://devcenter.heroku.com/articles/heroku-cli">here</a>.</li><li>Go to terminal and move to project folder using</li></ul><pre>&gt; <em>cd /path_to_your_project </em></pre><ul><li>Login to Heroku using</li></ul><pre>&gt; heroku login</pre><p>output</p><pre>heroku: Press any key to open up the browser to login or q to exit<br> ›   Warning: If browser does not open, visit<br> ›   https://cli-auth.heroku.com/auth/browser/***<br>heroku: Waiting for login...<br>Logging in... done<br>Logged in as me@example.com</pre><ul><li>Create an application on Heroku using</li></ul><pre>&gt; heroku create</pre><p>output</p><pre>Creating app... done, ⬢<strong> calm-caverns-03103</strong><br><a href="https://calm-caverns-03103.herokuapp.com/">https://calm-caverns-03103.herokuapp.com/</a> | <a href="https://git.heroku.com/calm-caverns-03103.git">https://git.heroku.com/calm-caverns-03103.git</a></pre><ul><li>Great ! so our Heroku app name is <strong>calm-caverns-03103.</strong></li><li>Make a commit and push the changes to Heroku using git.</li></ul><pre>&gt; git add . <br>&gt; git commit -m &quot;initial commit&quot;<br>&gt; git push heroku master </pre><p><strong>heroku</strong> has been added as one of the remotes already when you perform<strong> heroku create, </strong>you can verify that using <strong>git remote -v.</strong></p><p>output</p><pre>.....<br>remote: <br>remote: -----&gt; Compressing...<br>remote:        Done: 69.9M<br>remote: -----&gt; Launching...<br>remote:        Released v3<br>remote:        <a href="https://calm-caverns-03103.herokuapp.com/">https://calm-caverns-03103.herokuapp.com/</a> deployed to Heroku<br>.....</pre><ul><li>Looks like our application has been hosted on<strong> </strong><a href="https://calm-caverns-03103.herokuapp.com/"><strong>https://calm-caverns-03103.herokuapp.com/</strong></a>, what do you say? let&#39;s see how it looks.</li><li>oh no! it’s show something like this 💔😢</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bms5hZ08lM4lQdV8zPFSCw.png" /></figure><ul><li>Let&#39;s DEBUG What went wrong ( t<strong>hat’s real crux </strong>😈 ).</li></ul><h3>DEBUGGING</h3><ul><li>let&#39;s see the logs of our application on Heroku to get some idea</li></ul><pre>&gt; heroku logs --tail</pre><ul><li>It looks something like this …</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PQBb_gom0Xy6otvlUjg_aA.png" /></figure><ul><li>What happens is Heroku identifies what type of project it is on every push to the master branch and performs a build on the application, in our case, it used the<strong> ./gradlew build </strong>command,<strong> </strong>and then runs the application using a specific command, In our Case, It says <strong>Starting process</strong> with the command <strong>`java -Dserver.port=4512 $JAVA_OPTS -jar build/libs/*.jar`</strong></li></ul><p>Let&#39;s understand this -</p><ul><li><strong>-Dserver. port = 4512</strong>, is to tell the application to start the tomcat server at 4512, this is called port binding and it is very important as you are not allowed to run your tomcat server at 8080 all the time as that port might not be available on Heroku system, that&#39;s why Heroku passes <strong>$PORT</strong> env variable and that should bind to the port on which tomcat server shall run, also it changes time to time so the value 4512 is not constant, essentially on the runtime it was the value of $PORT env variable.</li><li><strong>$JAVA_OPTS </strong>are other runtime java-specific options, which for our purpose are not necessary</li><li><strong>-jar build/libs/*.jar</strong> tells JVM to run the application as jar at the location build/libs/*.jar</li></ul><p><strong>What might be the error? </strong>🤔🤔🤔🤔🤔</p><ul><li>we can think that Heroku would also be using some sort of unix-based environment to run our apps, can we access that system?</li><li>Luckily we can do so using</li></ul><pre>&gt; heroku run bash </pre><ul><li>Now you are logged in to the terminal of the deployed computer, it is similar to what we have on our system ( Linux ).</li><li>Now try to run the same command in order to run the project i.e</li></ul><pre>&gt; <strong>java -jar -Dserver.port=$PORT  $JAVA_OPTS build/libs/*.jar</strong></pre><ul><li>we used <strong>$PORT </strong>instead of 4512 as we don&#39;t know if 4512 would be available on the Heroku system or not.</li></ul><p>output :</p><pre>&gt; no main manifest attribute, in build/libs/demo-0.0.1-SNAPSHOT-plain.jar</pre><ul><li>hmmmmm….. so demo-0.0.1-SNAPSHOT-plain.jar does not seem to be an executable jar file Gradle on build produces two jar files, one is executable which contains the manifest file within and the other is a plain jar which is non-executable explicitly.</li><li><strong>build/libs/</strong> folder contains two jar files one is <strong>demo-0.0.1-SNAPSHOT.jar</strong> and the other is<strong> demo-0.0.1-SNAPSHOT-plain.jar, </strong>The <strong>problem</strong> is with the expression<strong> build/libs/*.jar </strong>expression<strong>, </strong>it matches to the non-executable jar.</li></ul><h3>That‘s the problem 😶 !</h3><h3>SOLUTION</h3><ul><li>we can either change the run command to choose the executable jar or we can configure Gradle to produce the executable jar only.</li><li>I would choose to change the run command because, in my view, your project should be as minimum tweaked as minimum possible according to deployment strategies.</li><li>We will add a Procfile that will look like this</li></ul><pre>web: java -jar -Dserver.port=$PORT build/libs/demo-0.0.1.jar </pre><ul><li>let&#39;s commit these changes and push it to the Heroku remote!</li></ul><pre>&gt; git add . <br>&gt; git commit -m &quot;add procfile&quot;<br>&gt; git push heroku master</pre><ul><li>See the result now</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*oL9a_KOUUV5yYs-KFvRwmg.png" /></figure><h3>YAY 🥳️😍</h3><p>you can find the source code <a href="https://github.com/endurance21/SPRING-BOOT-GRADLE-HEROKU">here</a></p><p>Happy to hear feedback and if you liked it, hit the clap button 🤗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdbf3fe3794b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Let’s talk about self control.]]></title>
            <link>https://medium.com/@divyanshuraj_39877/lets-talk-about-self-control-c9622aeee94a?source=rss-356feeec5ce0------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9622aeee94a</guid>
            <dc:creator><![CDATA[Divyanshu Raj]]></dc:creator>
            <pubDate>Tue, 12 Oct 2021 18:15:27 GMT</pubDate>
            <atom:updated>2021-10-13T07:07:39.044Z</atom:updated>
            <content:encoded><![CDATA[<p>While reading the amazing book Atomic Habits written by James Clear, I came across this topic and would like to present a summary of my understanding ☺.</p><p>Most of us struggle in breaking our bad habits, the key strategy we use and have learnt is &quot;self-control&quot;.</p><p>It has been deeply embedded in our culture that little bit of discipline would solve all our problems.</p><p>But we may mis-conclude disciplines with self control 🧐.</p><p>while practising self-control we tend to resist our temptations by changing our current behaviour, which in short run can help but can backfire in long term.</p><p>If we observe , we live in a world full of temptations , infact far more than our ancestors have experienced, We may easily slide back to our previous version due large tempting forces no matter how hard we try to resist, which is why, simply resisting temptations would be an ineffective strategy</p><p>what could be the more effective way then ?🤔</p><p>Creating a more <strong>disciplined environment</strong>, <br>which means leave no space for any temptations, infact The people with best self control are typically the ones who need to use it the least, which means they are wise enough and know that self control is not the main weapon.</p><p>Let’s understand this through a case study.</p><p>During the Vietnam war, A Number of American soldiers who were sent to Vietnam were found to be heroine addict. The reason being, they spent a lot of time with their fellow soldiers there who already were addicts and the environment was tempting of the same.</p><p>The Special Action office of Drug Abuse Prevention ( which was founded same year for this purpose ) , regulated the rehabilitation and prevention acts to controll the situation.</p><p>Surprisingly, It was estimated that approximately 9 out of 10 soldiers who were addicted to heroin eliminated their addiction in a very short span of time.</p><p>Compared to typical treatment of drug addicts, 90% of people are highly probable to become re-addicted once they return from the rehab centers.</p><p>The American soldiers never got a chance to visit the Vietnam again , They remained in <strong>disciplined environment, </strong>that was the reason to witness surprising positive result in their rehabilitation.</p><p>Wrap-Up:</p><p>Breaking Bad-Habits is one of most challenging process we encounter in our lives, and primarily we use self-control to do so but self-Control has been proven to be ineffective way, just like treating a symptom of disease won’t make the disease go away. The key idea is to bring in Disciplined Environment, leave no space for any kind of temptations, which is the main weapon and ofcourse keeping a shot gun with the main weapon won’t do a harm so self-control shall be used like a shot gun.</p><p>Thank your for reading this ☺</p><p>#habits <br>#atomichabits</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9622aeee94a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How i made firefly-react]]></title>
            <link>https://medium.com/@divyanshuraj_39877/how-i-made-firefly-react-cce580667fe?source=rss-356feeec5ce0------2</link>
            <guid isPermaLink="false">https://medium.com/p/cce580667fe</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[original]]></category>
            <dc:creator><![CDATA[Divyanshu Raj]]></dc:creator>
            <pubDate>Sat, 31 Jul 2021 16:46:39 GMT</pubDate>
            <atom:updated>2021-08-01T07:33:12.205Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why/How i made firefly-react</h3><p>Well, let’s start the story and I will be explaning what is firefly-react and how it came into existence.</p><p>Let me break down the words , here<strong> firefly</strong> means … well you guessed it right, those tiny, glittery, blinking flies that we see during night in the sky , looking at them is not less than a startgazing in itself.</p><p>what if i tell you, you can bring it the websites ? 🤔</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*26BdYhDHm9A_uVyMvceUKw.gif" /><figcaption>something like this ?</figcaption></figure><p>It so happened, I was working with a team to develop a website for THOMSO in 2019 ( in case you dont know, THOMSO is the cultural festival at IIT ROORKEE organized by students ) , I was wondering to add some good user engaging stuff on the website, and i got some references online and gamification of website seemed like amusing feature to be added. I used javascript , Object Oriented Paradigm, and HTML CANVAS to simulate a firefly looking shape on the website .</p><p>Well how that is Gamification ?</p><p>The firefly that i am talking about has a<strong> life time</strong> ( not the real one xd ) , it gets its <strong>birth</strong> when user moves their mouse on screen and <strong>disappears</strong> after some time ,it goes wherever your mouse goes ( yeah fun ! ) , it <strong>walks</strong> in a random direction ( like a real firefly would walk) , it <strong>blinks</strong> like a real firefly would do.</p><p>okay ! was the job done ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DgXPefnFp6CxKq-pTjfqfw.gif" /><figcaption>you can experience it live here-<a href="https://www.thomso.in/">https://www.thomso.in/</a> 😎</figcaption></figure><p>Well pretty much yes, we used <a href="https://www.hotjar.com/?utm_campaign=HJ-MicrosoftAds-India-Branded&amp;utm_source=MicrosoftAds&amp;utm_medium=cpc&amp;ads_adid=1147890919472938&amp;ads_targetid=kwd-71743750411465:aud-809010884:loc-90&amp;utm_term=hotjar&amp;keyword=hotjar&amp;matchtype=e&amp;geo=90&amp;ads_creative=&amp;ads_network=o&amp;device=c&amp;adpos=&amp;msclkid=a2e7cd474839193a3548ac422309d3b8">hotjar</a>( a website session recorder that records how a user is interacting with website) , we were amused to see that users liked playing around with that thing 🤩, they spent more time than usual.</p><p>Well that’s it !</p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p>NO ?</p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p>.</p><p>okay okay 😅 !</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*-fwRom1VHsY5npiHmAOUpw.png" /></figure><p>So almost after a year, one of my senior contacted me and aksed me how i made it and maybe if i could share the code. As my code was cohesively attached to the codebase of whole big website,it was very difficult to resuse that code and also it would really be a time taking thing to explain the working and uses of code to other people.</p><p>I decided to make something like a plugin that could be easily facilated into the websites without much effort.</p><p>As i had a good experience in <a href="https://reactjs.org/">react.js</a> with typescript also most of the websites today are using react so it was good option to go with , well that explains from where <strong>react</strong> came into picture in firefly-react.</p><p>Now, lets break the patience and define it properly :-</p><blockquote><strong>It is a react package / plugin that does that firefly simulation job in less than 4–5 lines of codes . you can download and integrate it into your react websites.</strong></blockquote><p>I was pretty excited about my first ORIGINAL product, and i posted it on reddit community , it was really overwhelming to see the responses. It crossed more than <strong>220 downloads per week </strong>on npm<strong> </strong>, I know this may not sound such a good number but i do feel good about how it came up !</p><p>link for npm package- <a href="https://www.npmjs.com/package/firefly-react">https://www.npmjs.com/package/firefly-react</a></p><p>link for codebase-<a href="https://github.com/endurance21/firefly-react">https://github.com/endurance21/firefly-react</a></p><p>Go and try it😄, Installation process is explained in the repository and npm itself.</p><p>Any suggestion / contribution is warmly welcome.</p><p>I would like to thank my friend <a href="https://github.com/Adi-11">Aditya </a>, who helped me out a lot while writing the codebase from scratch.</p><p>Thank you for your patience, Do follow and hit the clap button if you liked the post 😀!</p><p>Have a good day :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cce580667fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>