<?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 Kathiriya Niket on Medium]]></title>
        <description><![CDATA[Stories by Kathiriya Niket on Medium]]></description>
        <link>https://medium.com/@n-r-kathiriya?source=rss-2fcaea318e48------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nNVKUcK_bFWXeP6w5IHhvQ.jpeg</url>
            <title>Stories by Kathiriya Niket on Medium</title>
            <link>https://medium.com/@n-r-kathiriya?source=rss-2fcaea318e48------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 08:38:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@n-r-kathiriya/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[Dynamic Programming — Simplified]]></title>
            <link>https://medium.com/advanced-algorithms/dynamic-programming-simplified-6ac47a1bdae9?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ac47a1bdae9</guid>
            <category><![CDATA[dynamic-programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Sat, 10 Dec 2022 08:47:06 GMT</pubDate>
            <atom:updated>2022-12-10T08:47:06.734Z</atom:updated>
            <content:encoded><![CDATA[<h3>Dynamic Programming — Simplified</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TgUgpkpOmTPS8kZmeevftA.png" /><figcaption>Clearing out the prejudices against DP</figcaption></figure><p>To many programmers, dynamic programming seems like an enigma or a suffering that they have to go through when they are preparing for interviews. But, once you understand the core of it, the rest is just practice. This post hopes to clear the core idea behind dynamic programming and the step-by-step approach on how to identify and solve a dynamic programming problem.</p><p>Remember recursion? The neat little trick where we divided a problem into multiple sub-problems of similar structure and then assumed that we had the solution to sub-problems, we just needed a way to combine them to find the solution of original problem. (In case you are unfamiliar with recursion, here’s a resource that can help : <a href="https://www.geeksforgeeks.org/recursion/">https://www.geeksforgeeks.org/recursion/</a>. Note that recursion is the base of dynamic programming, so it is recommended to have some basic understanding of it.)</p><p>In some cases, while going through recursion, some of the sub-problems repeat multiple times before we get the final answer. Like in the famous Fibonacci-series problem, finding 5th number in the series requires us to find 3rd and 4th number and add them. Now, in the process of finding 4th number, we again need 3rd number, along with the 2nd number of the series.</p><p>This is where dynamic programming shines. While recursion calculates the solution to each sub-problems every time they occur, dynamic programming stores the answers to each sub-problem it solves in the main memory/RAM and re-uses the answer if and when any of them repeat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/165/1*sDxN0OfWRne1NXhGydkuPQ.png" /><figcaption>Reusing the answers</figcaption></figure><p>This repeating sub-problem scenario is known as overlapping sub-problems. So, <strong>dynamic programming is used when the sub-problems of typical divide-and-conquer strategy overlap. Just like any divide-and-conquer strategies, dynamic programming also solves a problem by combining the solutions to the sub-problems.</strong></p><p>Next time you see any problem that can be solved by same old recursion, check to see if there are overlapping sub-problems. If so, have a try at dynamic programming.</p><h4><strong>But how??</strong></h4><p>Well, now we know what is the main concept behind dynamic programming and when to use it. The remaining question is, “HOW?” and this is where most confusions arise. So we will look at 4-step process of solving a dynamic programming problem.</p><ul><li><strong>Step-1: Characterize the structure of an optimal solution.</strong></li></ul><p>Try to phrase the problem in a way that shows that the optimal solution of the given problem is dependent on the smaller sub-problems.</p><ul><li><strong>Step-2: Recursively define the value of an optimal solution.</strong></li></ul><p>Define the problem as an equation of recursion problem (i.e, recurrence). At this point, verify that dynamic programming is actually needed. If the sub-problems are not repeating, then there is no need to store the answers to them. In that case, its better to just use recursion.</p><ul><li><strong>Step-3: Compute the value of an optimal solution, in either bottom-up fashion (a.k.a. tabulation) or top-down fashion (a.k.a. memoization).</strong></li></ul><p>This is where we write the algorithm. It will be very much similar to the regular recursion algorithm. Only, every time the function is called, first we will check if we have already solved the problem (i.e, if a solution to the problem is there in our bag). If and only if we do not have the answer stored, we will calculate it. And after calculation, store it in the bag so that next time it can be reused.</p><ul><li><strong>Step-4: Construct an optimal solution from computed information.</strong></li></ul><p>This step is done in two parts. One, while writing algorithm in step-3, we make sure to store the information about our solution along with the answers to the problems. Second, afterwards, we use that information to retrace the steps that led to an optimal solution. E.g, in the T<a href="https://www.geeksforgeeks.org/travelling-salesman-problem-set-1/">ravelling Salesman problem</a>, step-3 just gives the optimal distance that needs to be travelled to visit all the cities. But what we need is the order in which to travel these cities. That order is retraced in the step 4.</p><p>And that’s about it for the core of Dynamic Programming. Short and Simple. Let me know your comments/reviews/suggestions.</p><p>Here are some resources that I would like to suggest:</p><ul><li><a href="https://www.interviewbit.com/courses/programming/topics/dynamic-programming/#:~:text=Dynamic%20Programming%20(commonly%20referred%20to,solution%20to%20it&#39;s%20individual%20subproblems.">Dynamic Programming | Practice Interview Questions - InterviewBit</a></li><li><a href="https://www.geeksforgeeks.org/dynamic-programming/?ref=lbp">Dynamic Programming - GeeksforGeeks</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FOQ5jsbhAv_M%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DOQ5jsbhAv_M&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FOQ5jsbhAv_M%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc85a136a051ed9d06c22a50d6dc8370/href">https://medium.com/media/cc85a136a051ed9d06c22a50d6dc8370/href</a></iframe><p>And of course, the text book: <a href="https://mitpress.mit.edu/books/introduction-algorithms-third-edition">Introduction to Algorithms, Third Edition | The MIT Press</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ac47a1bdae9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/advanced-algorithms/dynamic-programming-simplified-6ac47a1bdae9">Dynamic Programming — Simplified</a> was originally published in <a href="https://medium.com/advanced-algorithms">Advanced Algorithms</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Attitude is everything — 3 Takeaways of Part 3]]></title>
            <link>https://medium.com/way-to-wisdom/attitude-is-everything-3-takeaways-of-part-3-b97f64a3ca57?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/b97f64a3ca57</guid>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[success]]></category>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[book-summary]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Sun, 25 Apr 2021 15:14:08 GMT</pubDate>
            <atom:updated>2021-04-25T15:14:08.110Z</atom:updated>
            <content:encoded><![CDATA[<h3>Attitude is everything — 3 Takeaways of Part 3</h3><figure><img alt="Cover Photo" src="https://cdn-images-1.medium.com/max/313/1*vYfPWD1Rcr_Ik2FooKn-ig.jpeg" /><figcaption>Attitude is everything</figcaption></figure><p>“Attitude is everything” is a small and interesting book by Jeff Keller. The language used is simple and easy to understand. The strategies are effective.</p><p>The book is divided into 3 parts by the author himself.</p><ul><li><a href="https://n-r-kathiriya.medium.com/attitude-is-everything-7-key-ideas-from-its-part-1-5324c8eb1fb7"><em>Part 1: Success Begins in the Mind — </em>Focuses on the way of THINKING</a></li><li><a href="https://link.medium.com/OsTNtnQkKfb"><em>Part 2: Watch Your Words — </em>Focuses on what we SPEAK</a></li><li><em>Part 3: Heaven Helps Those Who Act — </em>Focuses on taking ACTIONS.</li></ul><p>Let’s look at some of the takeaway points of <strong>part 3 </strong>where the author is describing the actions that need to be taken.</p><h4>1. Choose your friends wisely!</h4><p>When you hear some ridiculous song on the radio, you will dislike it at first. Then, as the song moves up the charts, you can’t get away from it! The stations will keep on playing it and you will have to hear it several times over for a few days. Then, all of a sudden, you start humming that song or your brain can’t stop singing it in your free time. You may still be hating the damned thing, but it has made its place at the forefront of your consciousness. Slowly, as the popularity decreases and the song is played lesser on the radio, you will tend to think lesser about it.</p><p>There’s a lesson here. The mind tends to dwell upon what is repeated over and over. <strong>It doesn’t discriminate between messages that are good or bad for us. If we hear something often enough, we tend to believe it… and act upon it!</strong></p><p>This is why you must hang out with the right people. Your friends have the power to stretch your vision or even choke your dreams. In a way, we are like sponges. We “soak up” whatever people around us are saying. Be it positivity or negativity.</p><h4><strong>2. Evaluate your friendships</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/380/0*8fM59kvAJTFNmJO_" /><figcaption>Evaluate the attitude of the people around you</figcaption></figure><p>This one sounds a bit judgemental, doesn’t it?</p><p>“Evaluate your friends?” Why? Because, the people that occupy your time have a significant impact on your most priceless possession — your mind!</p><p>If you are surrounding yourself with negative people in your leisure time, eliminate or at least, <strong>reduce that time</strong>. Be that a friend, a co-worker, or a family member. I’m not saying to just cut them out of your life… but, keep the conversions limited. <strong>The closer they are, the more effect they have over our attitude,</strong> and keeping negative people with you most of the time will lead you to doom as well.</p><p>Now, you might be saying “This is wrong… I should try to help them…”. By all means, try to help them. But <strong>keep a fine watch</strong> over the results of your help. Even after helping, if the person still keeps a negative attitude and keeps on complaining, it is better to leave them be and focus on <strong>your own </strong>life. After all, these kinds of people <strong>don’t want to </strong>change. They just want someone to listen to their tails of woe. <strong>DO NOT BE THEIR CRYING PILLOW.</strong></p><h4>3. Facing failure?</h4><p>(<em>So much has already been said everywhere about this point, so I will keep this one short.</em>)</p><p>If you take your eyes off the goal and instead focus on how others may be viewing you, you are doing yourself a great disservice. To develop a new skill or reach a meaningful target, you must be committed to doing what it takes to get there, even if it means putting up with negative feedback or falling on your face now and then.</p><p>Successful people have learned to “fail” their way to success. While they may not particularly enjoy their “failures”, they recognize them as a necessary part of the road to victory.</p><blockquote>“If you keep trying, keep developing yourself and keep making adjustments along the way, you’re going to succeed.” — Jeff Keller</blockquote><p>That’s it for “Attitude is everything.” It is a good read, you can read the entire book if you liked the summary.</p><p><strong>Note: </strong>I have not included the networking chapter in this part 3 because that entire chapter is gold. Each line in that is packed with wisdom. I recommend that you read that chapter once every few weeks.</p><p>Do <strong>clap 👏 </strong>if you liked the post and write your comments below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b97f64a3ca57" width="1" height="1" alt=""><hr><p><a href="https://medium.com/way-to-wisdom/attitude-is-everything-3-takeaways-of-part-3-b97f64a3ca57">Attitude is everything — 3 Takeaways of Part 3</a> was originally published in <a href="https://medium.com/way-to-wisdom">Way to wisdom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Attitude is everything — Part 2 (Watch your words!)]]></title>
            <link>https://medium.com/way-to-wisdom/attitude-is-everything-part-2-watch-your-words-59772f547e07?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/59772f547e07</guid>
            <category><![CDATA[book-summary]]></category>
            <category><![CDATA[personality-development]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[success]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Sun, 25 Apr 2021 06:25:43 GMT</pubDate>
            <atom:updated>2021-04-25T06:25:43.908Z</atom:updated>
            <content:encoded><![CDATA[<h3>Attitude is everything — Part 2 (Watch your words!)</h3><figure><img alt="Book Cover" src="https://cdn-images-1.medium.com/max/313/1*vYfPWD1Rcr_Ik2FooKn-ig.jpeg" /><figcaption>Attitude is everything</figcaption></figure><p>“Attitude is everything” is a small and interesting book by Jeff Keller. The language used is simple and easy to understand. The strategies are effective.</p><p>The book is divided into 3 parts by the author himself.</p><ul><li><a href="https://n-r-kathiriya.medium.com/attitude-is-everything-7-key-ideas-from-its-part-1-5324c8eb1fb7"><em>Part 1: Success Begins in the Mind — </em>Focuses on the way of THINKING</a></li><li><em>Part 2: Watch Your Words — </em>Focuses on what we SPEAK</li><li><em>Part 3: Heaven Helps Those Who Act — </em>Focuses on taking ACTIONS.</li></ul><p>Let’s look at some of the key points of <strong>part 2 </strong>where the author is describing the power of words that we speak.</p><h4>1. Words encourage action.</h4><p>What we speak reinforces our belief and our belief creates our reality. Think of this process as a row of dominos that look like this:</p><figure><img alt="Thought -&gt; Words -&gt; Beliefs -&gt; Actions -&gt; Results" src="https://cdn-images-1.medium.com/max/806/1*655eR66AK2J_fS11FqdIKA.png" /><figcaption>The row of dominos leading from thought to result.</figcaption></figure><p>In my initial years of college, I used to think that I am not a social person. Every so often, I also kept talking about how I’m not very social or how I don’t like public gatherings and all. Now, looking back, it seems that I might have started saying that before I actually believed it, i.e, I was not actually introvert. But, because I kept saying that I am not a social person, it eventually became my belief. Slowly, I started avoiding celebrations, birthday parties, even hanging out in a group.</p><p>Now, because I was spending more and more time in my room binge-watching anime, my thoughts and belief of not being a social person became stronger, and the vicious chain continued. (similar to the <a href="https://medium.com/@sarvesha.chavan/the-feedback-loop-from-hell-85bc7f603c3b"><em>feedback loop from hell</em></a><em>!)</em></p><p>Next time you are talking about something negative that is related to your goal, remember, <strong>you are not helping yourself. Actually, you are hurting your chances of actually achieving success.</strong></p><h4>2. With whom to talk positively?</h4><p>These positive words <strong>can be talked out loud </strong>or <strong>told to yourself internally. </strong>There are no hard-and-fast rules about that part. But, beware, do not discuss your goals with negative people. They will only argue and point out the reasons why you can not succeed. Instead, have these talks with someone whose feedback includes solutions to the difficulties that may arise.</p><p>Moreover, make sure that the person giving you advice actually has expertise in that domain. You do not want a discussion about opening a business with someone who has only worked for others their entire life.</p><h4>3. “How are you?”</h4><p>“How are you?” or “How do you do?” are the questions that we get asked a lot of times in our day-to-day lives. Most of the time, we reply with: “fine”, “Okay I guess”, “Bored”, “Fu*ked”, “Terrible” and the very common one… “Don’t even ask.”; makes the other person regret ever asking. These replies have twofold effects:</p><ul><li>One, by speaking negative, or barely neutral terms, you are programming your mind to think in that direction which ultimately affects your attitude negatively.</li><li>Two, you are pushing people away. Think about it, would you like to hang out with someone who never has a good day? Chances are, you will also become a part of his bad day, making your day worse, too. Would you like to do business with someone who always sounds like he/she has not slept in 3 days?</li></ul><p>So, instead, whenever asked this question, speak positive response with energy. “Terrific”, “Awesome”, “Livin’ the dream”, etc. I’m sure, even reading these will leave a positive sensation inside you. As you speak these words, your physiology begins to correspond with your optimistic language. Your posture is more upright, other people are attracted to your vitality and energy (<em>after a few initial days of giving strange looks).</em> Your business and personal relationships improve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/434/1*MILI3P1OPbrHrA0xmjNRtQ.png" /></figure><p>Will your life’s problems magically disappear? <strong>NO, </strong>but you set in motion a very important principle: “We get what we expect in life.”</p><h4>4. No complaining</h4><p>Complaints work against you in three ways.</p><ul><li>First, no one wants to hear negative words about your illness and your problems.</li><li>Second, complaining reinforces your own pain and discomfort. So why keep replaying the painful, negative memories?</li><li>Third, complaining, by itself achieves nothing and diverts you from the constructive actions you could be taking to improve your situation.</li></ul><p>That’s it for part two. In the next part, we will focus on taking action.</p><p>Do <strong>clap 👏 </strong>if you liked the post and write your comments below.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=59772f547e07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/way-to-wisdom/attitude-is-everything-part-2-watch-your-words-59772f547e07">Attitude is everything — Part 2 (Watch your words!)</a> was originally published in <a href="https://medium.com/way-to-wisdom">Way to wisdom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Attitude is everything — 7 key ideas from it’s part 1]]></title>
            <link>https://medium.com/way-to-wisdom/attitude-is-everything-7-key-ideas-from-its-part-1-5324c8eb1fb7?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/5324c8eb1fb7</guid>
            <category><![CDATA[book-summary]]></category>
            <category><![CDATA[reading-books]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[success]]></category>
            <category><![CDATA[attitude-is-everything]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Tue, 13 Apr 2021 19:11:24 GMT</pubDate>
            <atom:updated>2021-04-13T19:11:24.269Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Cover Image" src="https://cdn-images-1.medium.com/max/313/1*vYfPWD1Rcr_Ik2FooKn-ig.jpeg" /><figcaption>Attitude is everything</figcaption></figure><p>“Attitude is everything” is a small and interesting book by Jeff Keller. The language used is simple and easy to understand. The strategies are effective.</p><p>The book is divided into 3 parts by the author himself.</p><ul><li><em>Part 1: Success Begins in the Mind — </em>Focuses on the way of THINKING</li><li><em>Part 2: Watch Your Words — </em>Focuses on what we SPEAK</li><li><em>Part 3: Heaven Helps Those Who Act — </em>Focuses on taking ACTIONS.</li></ul><p>Let’s look at some of the key points of <strong>part 1 </strong>where the author is describing the power of attitude and belief to shape our destiny.</p><h4>1. Clean your window regularly.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*0wjLq-p6Rm2q6zFR2Egwbw.png" /><figcaption>A negative attitude can invert the best of the opportunities</figcaption></figure><p>Consider our <strong>attitude as the window</strong> through which we “see” the world. Just like any physical window, the cleaner the window, the clearer the picture.</p><p>Think of a class full of students learning from the same professor or a bunch of employees working in the same field under the same manager or entrepreneurs building their business in the same open market of today. Though their domain is similar, there will always be some differences in their performance. Even after considering factors like talent, efforts, opportunities, etc. there will always be people who still don’t match the equation. Despite similar efforts (or even lesser sometimes), these people still give better performance and achieve better results.</p><p>The difference here is the attitude of the person. A positive attitude helps you see the opportunities from far away. By having clear thoughts of the goals that you want to achieve, your brain stays more focused on the “how?” part of it. Due to that, whenever the chance arrives, your brain will immediately take it while the negative attitude mind will still be clouded, thus, making a delayed judgment.</p><p>Now, everyone starts with a clean window, but, along the path of time, these “windows” get splattered by criticism, smudged by peers, smeared by rejection, soiled by disappointments, and clouded by doubt. Once in a while, all of us adults should take some self-reflection time to clean out our windows so that we can see the world better.</p><h4>2. Spot the negativity</h4><p>So how do you know if your window is clean or not? (i.e, attitude is positive or negative?)</p><p>Take a deep breath. Observe. While you are reading this, there is a voice in your head that is transcribing whatever you are reading. That <strong>inner voice</strong> is almost always rambling on. ALL THE TIME.</p><p>More often than not, that voice is leading you towards a negative attitude. “That is very tough, I can’t do that!”, “I don’t think I am worthy of it”, etc. Keeping that voice under check is how you <em>spot the negativity.</em> Be aware of what you feed your beliefs on a daily basis!</p><h4>3. Turn that frown, upside down.</h4><p>Once you are being observant of your negativity, the next step is to <strong>turn those thoughts around in a positive direction</strong>. Start with spending 15–20 minutes in the morning AND night reading some good books or listening to a motivational podcast or just meditate. While your commute, listen to some inspirational music.</p><p>Remember this, spending few minutes every day is just for starting the motion in a positive direction. That is not enough. You gotta keep the momentum going for as long as you can. Of course, overnight positivity is <strong>not </strong>an option. Easy come — easy go. You need <strong>patience and persistence</strong> to achieve any goal. Forget about success for a while, even positive thinking takes time. Monitoring your thoughts, trying to divert them in a positive direction takes time. So… <em>be patient</em>.</p><h4>4. First, you visualize, then you materialize.</h4><p>We all have some imagination (sort of like a movie) going on in our head in our free time (or when the lecture/meeting is “really 😆” boring). Usually, this movie is either about something that already happened or something that might happen. (Yes, we are <strong><em>not </em></strong>considering the movies where you save everyone from a terrorist attack). These movies play a significant role in our attitude, since “we ARE what we THINK we are”. Here’s how to handle the possible cases:</p><ul><li>Case 1- Remembering bad memory from the past: <strong>PAST</strong> is the keyword here. As in, it already happened. Now, this gives <strong>no control over action </strong>and <strong>full control over perspective. </strong>Try to imagine the same situation from a different perspective, understand what good came out of it and the situation will eventually be marked a positive memory.</li><li>Case 2- Imagining bad things about the future: The action has not happened yet. Thinking negatively will only attract negative outcomes. Instead, think about how you will conquer that situation. Think about what do you need to do to get the most out of it. This will result in higher confidence and a positive attitude.</li><li>Case 3- Thinking positively of the future or Remembering positive memories from the past: <em>because the post is already going to be too long, I’ll cut this one short. </em><strong>You got it, dude. Keep it up!</strong></li></ul><figure><img alt="Michelle from Full House, with her famous dialogue." src="https://cdn-images-1.medium.com/max/327/1*fcXzNwwi8BFd9fZS1oW6bg.png" /></figure><p>Remember one thing here, <strong>monitoring and altering these images will take time and conscious effort.</strong></p><h4>5. Commitment is the glue that bonds you to your goals.</h4><p>Once you visualize your success, you need to commit to the idea and work on it with persistence. Knowing “the entire plan” or “how to do that” from the get-go is not necessary. <strong>Commitment and persistence</strong> need to come first, and for the rest, your subconscious mind and the universe will adjust automatically.</p><blockquote>“Stay committed to your decisions but flexible in your approach.” -Tony Robbins</blockquote><p><em>Know that</em> it doesn’t mean you will get your success just like that! Obstacles and hardships <strong>WILL </strong>be there. But, that’s where persistence comes. You have to keep doing what needs to be done.</p><p>Putting a <strong>time limit on your goal</strong> might be a <em>good motivator</em>, but that does not mean you will get to succeed within that time. No one can predict what the future holds. So, even after that initial month/ year/ three years that you gave to your dream, if you are still not there, <strong>keep working for it</strong>.</p><h4>6. For the times that try your soul.</h4><p>The challenge now is to be strong in the face of adversity. The natural response to problems in our life is complaining. However, once that initial disappointment wears off, you have a choice to make — Either keep wallowing in your misery or try to find the benefit that the situation is offering.</p><p>Sometimes, you gotta get fired from the job to get the courage to start a business, your girlfriend/ boyfriend gotta dump you for you to meet your actual soulmate. you gotta fail that test for you to not enter in a rat race (<em>or maybe to realize that you need to study harder next time!).</em></p><p>Now, if you are like me, and you don’t believe in that “Everything happens for good” stuff, then consider this: <em>would you like the problem to keep repeating and even affect other areas of your life? or would you like to try and find a solution that can minimize the damage? </em>The choice is yours. Just remember that…</p><blockquote>“Every adversity carries with it the seed of an equivalent or greater benefit.” — Napoleon Hill</blockquote><h4>7. Positive thinking doesn’t solve problems.</h4><p>We all know this very well. Just like having a sharper axe <em>(or ‘ax’ as per Amerian English.)</em> will not cut the tree for you, the same way, having a positive attitude will not solve the problems.</p><p>But, just as a sharper axe can make the work required to cut the tree much lesser, similarly, like a useful tool, a positive attitude will help you a lot along the path to success.</p><p>That’s it for part one. In the next part, we will discuss the effect of what we speak on our attitude. Do write your comments below and <strong>hit the clap button</strong> if you liked the post (<em>or even a part of it!).</em></p><p>No…seriously….hit that clap button!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5324c8eb1fb7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/way-to-wisdom/attitude-is-everything-7-key-ideas-from-its-part-1-5324c8eb1fb7">Attitude is everything — 7 key ideas from it’s part 1</a> was originally published in <a href="https://medium.com/way-to-wisdom">Way to wisdom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Attitude is everything — Introduction (The 3 important takeaways)]]></title>
            <link>https://medium.com/way-to-wisdom/attitude-is-everything-introduction-the-3-important-takeaways-82c305a41abb?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/82c305a41abb</guid>
            <category><![CDATA[personality-development]]></category>
            <category><![CDATA[book-summary]]></category>
            <category><![CDATA[success]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[attitude-is-everything]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Sat, 10 Apr 2021 05:39:55 GMT</pubDate>
            <atom:updated>2021-04-11T16:04:39.651Z</atom:updated>
            <content:encoded><![CDATA[<h3>Attitude is everything — Introduction</h3><figure><img alt="Book Cover" src="https://cdn-images-1.medium.com/max/313/1*vYfPWD1Rcr_Ik2FooKn-ig.jpeg" /><figcaption>Attitude is everything</figcaption></figure><p>“Attitude is everything” is a small and interesting book by Jeff Keller. The language used is simple and easy to understand. The strategies are effective.</p><p>The book starts with an introduction about the author and how he changed his life</p><p>Since his early teenage years, Jeff was interested in becoming a lawyer. After years of formal education, he was finally a lawyer. Everything seemed to be going in his way. After a few years though, he realized that he wasn’t happy. There were parts of his job that Jeff loathed. Now, still, he continued. Of course! That is what the logical person would do! After all, he spent so much of his life achieving the position and expertise. And the result was that Jeff started to feel dreaded going to work.</p><p>One night, he was watching TV, all the while thinking — “There’s got to be more to my life than this.” and while channel surfing, he came upon an infomercial about a home-study course that was banking on the theory that everything we achieve in life is based upon our subconscious beliefs. The content was fascinating for Jeff, as this was the first time he learned how our thoughts determine our way of life. This program began a new chapter in Jeff’s life. He started seeking out other good reads and inspirational programs.</p><p>Now, still, he was the same lawyer. None of the content actually changed his outward circumstances. But, his outlook on life started getting more and more positive. One day, he received an offer to give seminars at a local high school with the pay of $30 for each class. He accepted it and the thrill he got from these seminars, pushed him towards getting better and better. Eventually, his speaking fees started getting larger and he decided to <strong>phase out</strong> his law career over the next few years.</p><p>Making sure that there was enough saving to live by, he started a gradual transition towards the personality development field — working four days a week as a lawyer, then three days a week, and so on. This decision did receive some resistance from his family, but he knew that these were a part of the issues you face when you take these kinds of decisions to leave high pay, career safety, and the prestige of the job for going after your intuition. Though, later everyone was supportive when he started making progress in the new field.</p><p>Currently, Jeffrey Keller, President of Attitude is Everything, Incorporated, works with organizations that want to develop achievers and with sales managers who want their people to be more positive. His articles have been published in national and international publications, including Selling Power, The Pryor Report Management Newsletter, The Toastmaster, and The Chamber of Commerce Pacesetter — and can also be found on the internet at the web site for Salesdoctors Magazine.</p><h4>Points that I found important (i.e, Moral of the story 😆)</h4><ol><li>It took 4 years of continuous learning for him to receive that first offer of $30. Still, he carried on. After that offer, he did not take the usual “$30 for 4 years of work? the hell with it!” path. Instead, he still carried on. — <strong>keep on working on it. Do not underestimate the long-term results based on short-term scenarios. Remember, it’s a journey.</strong> Check out the guitarist Ben Woods <a href="https://www.youtube.com/channel/UChMCY4mftnsVuy0ec9QTYvg">here</a>. When I first heard his “Malaguena”, I was thrilled and depressed at the same time. I had been trying to play this piece for a long time and I thought that my months of practice were wasted but then I came to know that he had been playing for years (more than a decade!). (BTW, Here’s the link to my current level of playing Malaguena: <a href="https://youtu.be/SQOHkUCCJaM">https://youtu.be/SQOHkUCCJaM</a>);</li><li>When Jeff decided to slowly leave law practice, that decision must have been one of the most difficult ones of his life since he was thinking of giving up on 7 years of education, 10 years of experience, and a potential $100,000 salary (in the 1990s! 😲) with job safety. — <strong>you have to take a chance on yourself. The past should not be a restraint on your future projection and money should not distract you from the path to your happiness and satisfaction.</strong> It’s like the <a href="https://thedecisionlab.com/biases/the-sunk-cost-fallacy/"><strong>sunk cost fallacy</strong>: </a>“You invest more of your time, effort, and money because you have already invested much of it in the past”. This stops you from jumping off the ship before it sinks.</li><li>Before actually phasing out of his law practice, he made sure that there were enough savings for the family to live by and the transition was fully gradual. He did not resign from his job immediately to “pursue his dreams”, instead, he chose the lengthy but practical path. — <strong>once you realize what you would like to do, do not make harsh decisions. Be rational. Be patient. Give the time that is needed for the process.</strong> Sometimes, the urge to leave the job that you dread is so strong that you get deluded into believing that the “hobby” of yours is your actual calling and you can make enough to live off of it. At this time, try to stay calm. Take a step back and calculate the situation. Ask yourself: “Am I running <strong>towards</strong> something or am I running <strong>from </strong>something?”. Some time spent in solitude and self-interrogation will help you make the smart choice here.</li></ol><p>That’s it for the introduction. We will dive into the book in the next post. Do write your comments below and let me know if you liked the post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82c305a41abb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/way-to-wisdom/attitude-is-everything-introduction-the-3-important-takeaways-82c305a41abb">Attitude is everything — Introduction (The 3 important takeaways)</a> was originally published in <a href="https://medium.com/way-to-wisdom">Way to wisdom</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JUnit: testing API with WebTestClient]]></title>
            <link>https://medium.com/reactive-programming-in-springboot-using-webflux/junit-testing-api-with-webtestclient-74479bf3491f?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/74479bf3491f</guid>
            <category><![CDATA[junit]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[reactor-project]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Fri, 11 Dec 2020 02:38:41 GMT</pubDate>
            <atom:updated>2020-12-11T02:38:41.815Z</atom:updated>
            <content:encoded><![CDATA[<p>For the sake of getting straight to the point, we will assume followings, so that we can look directly into testing.</p><ol><li>We have a RestController with two get mappings.</li><li>‘/flux’ returns Flux&lt;Integer&gt; in default media type — application/json.</li><li>‘/fluxStream’ returns Flux&lt;Long&gt; in — application/stream+json <strong>OR</strong> application/x-ndjson.</li><li>‘/flux’ is finite and will return (1,2,3,4).</li><li>/fluxStream’ is infinite and will return (1,2,3,4,5….).</li></ol><ul><li>Let’s look at few of the ways to test an API using WebTestClient.</li></ul><pre>@RunWith(SpringRunner.class)<br>@WebFluxTest<br>public class testDemo{<br>	@Autowired<br>	WebTestClient webTestClient;</pre><pre>	@Test<br>	public void flux_approach1(){<br>		Flux&lt;Integer&gt; integerFlux = webTestClient.get().uri(&quot;/flux&quot;)<br>			.accept(&quot;application/json&quot;)<br>			.exchange()<br>			.expectStatus().isOk()<br>			.returnResult(Integer.class)<br>			.getResponseBody();</pre><pre>		StepVerifier.create(integerFlux)<br>			.expectSubscription()<br>			.expectNext(1,2,3,4)<br>			.verifyComplete();<br>	}</pre><pre>	@Test<br>	public void flux_approach2(){<br>		Flux&lt;Integer&gt; integerFlux = webTestClient.get().uri(&quot;/flux&quot;)<br>			.accept(&quot;application/json&quot;)<br>			.exchange()<br>			.expectStatus().isOk()<br>			.expectHeader().contentType(&quot;application/json&quot;)<br>			.expectBodyList(Integer.class)<br>			.hasSize(4);<br>	}</pre><pre>	@Test<br>	public void flux_approach3(){<br>		List&lt;Integer&gt; expectedIntegerList = Arrays.asList(1,2,3,4);</pre><pre>		EntityExchangeResult&lt;List&lt;Integer&gt;&gt; eeResult = webTestClient.get().uri(&quot;/flux&quot;)<br>			.accept(&quot;application/json&quot;)<br>			.exchange()<br>			.expectStatus().isOk()<br>			.expectHeader().contentType(&quot;application/json&quot;)<br>			.expectBodyList(Integer.class)<br>			.returnResult();</pre><pre>		assertEquals(expectedIntegerList,eeResult.getResponseBody());<br>	}</pre><pre>	@Test<br>	public void flux_approach4(){<br>		List&lt;Integer&gt; expectedIntegerList = Arrays.asList(1,2,3,4);</pre><pre>		webTestClient.get().uri(&quot;/flux&quot;)<br>			.accept(&quot;application/json&quot;)<br>			.exchange()<br>			.expectStatus().isOk()<br>			.expectHeader().contentType(&quot;application/json&quot;)<br>			.expectBodyList(Integer.class)<br>			.consumeWith((eeResult) -&gt; {<br>				assertEquals(expectedIntegerList,eeResult.getResponseBody());<br>			});<br>	}<br>}</pre><ul><li><strong>@WebFluxTest will only instantiate RestControllers. </strong>If we are using any Components, Services or Repositories, then use <strong>@SpringBootTest</strong> with <strong>@AutoConfigureWebTestClient.</strong></li></ul><p><strong>What to do in case of infinite flux?</strong></p><pre>@Test<br>public void fluxStream(){<br>	Flux&lt;Long&gt; longStreamFlux = webTestClient.get().uri(&quot;/fluxStream&quot;)<br>			.accept(&quot;application/stream+json&quot;)<br>			.exchange()<br>			.expectStatus().isOk()<br>			.returnResult(Long.class)<br>			.getResponseBody();</pre><pre>		StepVerifier.create(integerFlux)<br>			.expectSubscription()<br>			.expectNext(1L,2L,3L)<br>			.thenCancel()<br>			.verify();<br>}</pre><ul><li>So, basically, in case of infinite flux, just test first few elements and then cancel the subscription.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=74479bf3491f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reactive-programming-in-springboot-using-webflux/junit-testing-api-with-webtestclient-74479bf3491f">JUnit: testing API with WebTestClient</a> was originally published in <a href="https://medium.com/reactive-programming-in-springboot-using-webflux">Reactive programming in Springboot using WebFlux/Reactor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hot vs Cold Reactive Streams]]></title>
            <link>https://medium.com/reactive-programming-in-springboot-using-webflux/hot-vs-cold-reactive-streams-2314ec983f5b?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/2314ec983f5b</guid>
            <category><![CDATA[reactor-project]]></category>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Fri, 11 Dec 2020 02:33:24 GMT</pubDate>
            <atom:updated>2020-12-11T02:33:24.556Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>Let’s suppose there is a producer that produces integers 1 to 10.</li><li>Now, a subscriber will subscribe and request for data.</li><li>The publisher starts sending data through onNext() event.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*Omk43zCFtVDcQOgrv8PG2g.png" /><figcaption>PubSub example for Hot/Cold streams</figcaption></figure><ul><li>When the publisher has sent 3 onNext() events, another subscriber (subscriber-2) will subscribe and request for data. This can lead to 2 possible scenarios.</li></ul><p><strong><em>Case 1:-</em></strong> The publisher sends data to the subscriber — 2 from the beginning (from 1) and keeps sending the data in continuing sequence to the running subscriber. This type of publisher is called Cold Publisher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*26UwGVsvb-0L658le3yQ2w.png" /><figcaption>Cold Publisher</figcaption></figure><blockquote><em>Cold Publisher: “For every subscriber, the items start from the beginning.”</em></blockquote><p><strong><em>Case 2:-</em></strong> The publisher sends the same data to subscriber — 2 that it is currently giving to the running subscriber. This type of publisher is called Hot Publisher.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*BLZRqqwrRSmYUzRvqJU3Yw.png" /><figcaption>Hot Publisher</figcaption></figure><blockquote><em>Hot Publisher: “Doesn’t publish from the beginning. Instead, the values keep on going independently. Any subscriber joining will get the same value that all others do.”</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2314ec983f5b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reactive-programming-in-springboot-using-webflux/hot-vs-cold-reactive-streams-2314ec983f5b">Hot vs Cold Reactive Streams</a> was originally published in <a href="https://medium.com/reactive-programming-in-springboot-using-webflux">Reactive programming in Springboot using WebFlux/Reactor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Error handling for Flux]]></title>
            <link>https://medium.com/reactive-programming-in-springboot-using-webflux/error-handling-for-flux-1f53701697c7?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f53701697c7</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[junit]]></category>
            <category><![CDATA[reactor-project]]></category>
            <category><![CDATA[flux]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Mon, 30 Nov 2020 14:42:20 GMT</pubDate>
            <atom:updated>2020-11-30T14:42:20.921Z</atom:updated>
            <content:encoded><![CDATA[<p>Earlier, we saw how to check/ verify errors in the stream.</p><pre>Flux&lt;String&gt; strFlux = Flux.just(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>			.concatWith(Flux.error(new RuntimeException(&quot;Exception Occured&quot;)))<br>			.concatWith(Flux.just(&quot;After Error&quot;));</pre><pre>StepVerifier.create(strFlux)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectError(RuntimeException.class)<br>	.verify();</pre><p>Now let’s see how to handle the error.</p><h3>Sending a default value in case of error</h3><ul><li>onErrorResume() method can be used to return a default Flux object if any error occurs. The consumer will not know at all that any error occurred.</li></ul><pre>Flux&lt;String&gt; strFlux = Flux.just(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>			.concatWith(Flux.error(new RuntimeException(&quot;Exception Occured&quot;)))<br>			.concatWith(Flux.just(&quot;After Error&quot;))<br>			.onErrorResume((e) -&gt; {<br>				System.out.println(&quot;Exception: &quot; + e);<br>				return Flux.just(&quot;default value&quot;,&quot;ek aur default value&quot;);<br>			});</pre><pre>StepVerifier.create(strFlux)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectNext(&quot;default value&quot;,&quot;ek aur default value&quot;)<br>	.verifyComplete();</pre><ul><li>onErrorReturn() method can be used to return a default value instead of the whole Flux.</li></ul><pre>Flux&lt;String&gt; strFlux = Flux.just(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>			.concatWith(Flux.error(new RuntimeException(&quot;Exception Occured&quot;)))<br>			.concatWith(Flux.just(&quot;After Error&quot;))<br>			.onErrorReturn(&quot;default&quot;);</pre><pre>StepVerifier.create(strFlux)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectNext(&quot;default&quot;)<br>	.verifyComplete();</pre><h3>Transforming an error</h3><ul><li>onErrorMap() method can be used to apply a transformation on the actual Exception object.</li></ul><pre>Flux&lt;String&gt; strFlux = Flux.just(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>			.concatWith(Flux.error(new RuntimeException(&quot;Exception Occured&quot;)))<br>			.concatWith(Flux.just(&quot;After Error&quot;))<br>			.onErrorMap((e) -&gt; new CustomException(e));</pre><pre>StepVerifier.create(strFlux)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectError(CustomException.class)<br>	.verify();</pre><ul><li>Notice here that the error is still being thrown. Just the object is transformed from RuntimeException to CustomException.</li></ul><h3>Retry</h3><ul><li>retry() method can be used if we wanted to try again in case of errors.</li></ul><pre>Flux&lt;String&gt; strFlux = Flux.just(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>			.concatWith(Flux.error(new RuntimeException(&quot;Exception Occured&quot;)))<br>			.concatWith(Flux.just(&quot;After Error&quot;))<br>			.onErrorMap((e) -&gt; new CustomException(e))<br>			.retry(2);</pre><pre>StepVerifier.create(strFlux)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectError(CustomException.class)<br>	.verify();</pre><ul><li>Notice here that the Consumer will only know of an error if the last try throws it. If 1st time or 2nd time error is thrown, the Flux will try again. As the retry count is 2, 3rd time will be the last. If 3rd time also error happens, it will be thrown to Consumer.</li><li>This can be useful in the case of API calls. If a connection error occurred due to any network problem, we can use the retry() method to try again 2–3 times before throwing an error.</li><li>In that case, we would ideally want to wait for a while before trying again.</li><li>retryBackoff() method can be used for that.</li></ul><pre>Flux&lt;String&gt; strFlux = Flux.just(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>			.concatWith(Flux.error(new RuntimeException(&quot;Exception Occured&quot;)))<br>			.concatWith(Flux.just(&quot;After Error&quot;))<br>			.onErrorMap((e) -&gt; new CustomException(e))<br>			.retryBackoff(2,Duration.ofSeconds(5));</pre><pre>StepVerifier.create(strFlux)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectNext(&quot;These&quot;,&quot;Strings&quot;,&quot;will&quot;,&quot;create&quot;,&quot;flux&quot;)<br>	.expectError(IllegalStateException.class)<br>	.verify();</pre><ul><li>This method, however, doesn’t throw the original error after all retries. It will throw an Illegal StateException.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f53701697c7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reactive-programming-in-springboot-using-webflux/error-handling-for-flux-1f53701697c7">Error handling for Flux</a> was originally published in <a href="https://medium.com/reactive-programming-in-springboot-using-webflux">Reactive programming in Springboot using WebFlux/Reactor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Operations on Reactive Streams]]></title>
            <link>https://medium.com/reactive-programming-in-springboot-using-webflux/operations-on-reactive-streams-eda9c3d20fa4?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/eda9c3d20fa4</guid>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[reactor-project]]></category>
            <category><![CDATA[mono]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Mon, 30 Nov 2020 14:36:50 GMT</pubDate>
            <atom:updated>2020-11-30T14:36:50.251Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s look at some of the operations that can be done on a Reactive Stream (Flux/ Mono) and play around with the stream.</p><h3>Filtering Reactive Stream</h3><ul><li>We can filter a stream based on a predicate (condition) provided as an argument with the <strong>filter() method</strong>.</li><li>If we wanted to filter a string stream and only return strings starting with ’n’ :</li></ul><pre>strFlux.filter(s-&gt;s.startsWith(&quot;n&quot;)).log();</pre><ul><li>If we wanted to filter an integer stream and only return values higher than some ‘x’ value:</li></ul><pre>intFlux.filter(n-&gt;n &gt; x).log();</pre><h3>Transforming Reactive Stream</h3><ul><li>Using the <strong>map() method</strong>, we can transform a stream.</li><li>If we wanted to convert string stream elements to uppercase.</li></ul><pre>strFlux.map(s-&gt;s.toUpperCase()).log();</pre><ul><li>If length of a string is greater than 4, then return it’s length as an element of the stream.</li></ul><pre>strFlux.filter(s -&gt; s.length() &gt; 4).map(s-&gt;s.length()).log(); //Now it will be a Flux&lt;Integer&gt;</pre><ul><li>The <strong>flatMap() method</strong> can be used in case a DB call or external API call is needed for each elements of the stream.</li><li>using <strong>window() method</strong> with flatMap makes the DB/API calls parallel.</li></ul><pre>strFlux.window(2).flatMap((s)-&gt;{<br>	s.map(<br>		//the DB or API call that takes some time and returns a new Flux<br>	).subScribeOn(parellel())<br> }).log();</pre><ul><li>This will disrupt the sequence. Parallel processing does not provide any fixed order in which elements will be emitted.</li><li>The <strong>flatMapSequential() method</strong> can be used in case we need the parallel operations <strong>and items in the same order as earlier.</strong></li></ul><pre>strFlux.window(2).flatMapSequential((s)-&gt;{<br>	s.map(<br>		//the DB or API call that takes some time and returns a new Flux<br>	).subScribeOn(parellel())<br> }).log();</pre><h3>Combining Reactive Streams</h3><ul><li><strong>merge() method</strong> can be used to merge two streams.</li></ul><pre>Flux&lt;String&gt; mergedFlux = Flux.merge(flux1,flux2);</pre><ul><li>The method does not wait until all elements from flux1 are over. It will take any element available from either of the fluxes.</li><li>It means that, in practical cases, we can’t predict the sequence, in which the mergedFlux will be publishing elements.</li><li>For fixed order ( first all elements of flux1 and then all elements of flux2), we can use the <strong>concat() method.</strong></li></ul><pre>Flux&lt;String&gt; mergedFlux_withOrderMaintained = Flux.concat(flux1,flux2);</pre><ul><li><strong>zip() method</strong> can also be used in case we want to create a Flux based on performing operations on two streams and combining them in a way that emits a single element with respect to one element from both streams.</li><li>Consider concatenating the strings inside each Flux.</li></ul><pre>Flux&lt;String&gt; mergedFlux = Flux.zip(flux1,flux2, (t1,t2) -&gt; {<br>	return t1.concat(t2);<br>});</pre><ul><li>What if we wanted to apply a mathematical linear function that takes two variables and returns one output. The variables, of course, come from two fluxes.</li></ul><pre>Flux&lt;Integer&gt; mergedFlux = Flux.zip(flux1,flux2, (t1,t2) -&gt; {<br>	return t1*5 + t2;<br>});</pre><h3>Infinite Flux</h3><ul><li><strong>interval() method</strong> can be used to create a flux that will emit numbers at a fixed interval.</li></ul><pre>Flux&lt;Long&gt; infiniteFlux = Flux.interval(Duration.ofMillis(500)).log();</pre><ul><li>Testing infinite Flux: well, we have to make it finite. It can be done using the <strong>take() method</strong>.</li></ul><pre>Flux&lt;Long&gt; finiteFlux = Flux.interval(Duration.ofMillis(1000)).take(3).log();<br>StepVerifier.create(finiteFlux).expectSubscription().expectNext(0L,1L,2L).verifyComplete();</pre><h3>More Operations</h3><p>For more on operations and choosing the right one for your need, check out the documentation:</p><p><a href="https://projectreactor.io/docs/core/release/reference/index.html#which-operator">https://projectreactor.io/docs/core/release/reference/index.html#which-operator</a></p><p>It provides the easiest possible way to find out the required operator.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eda9c3d20fa4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reactive-programming-in-springboot-using-webflux/operations-on-reactive-streams-eda9c3d20fa4">Operations on Reactive Streams</a> was originally published in <a href="https://medium.com/reactive-programming-in-springboot-using-webflux">Reactive programming in Springboot using WebFlux/Reactor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flux/Mono Factory Methods]]></title>
            <link>https://medium.com/reactive-programming-in-springboot-using-webflux/flux-mono-factory-methods-24905562e1a2?source=rss-2fcaea318e48------2</link>
            <guid isPermaLink="false">https://medium.com/p/24905562e1a2</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[flux]]></category>
            <category><![CDATA[reactor-project]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[mono]]></category>
            <dc:creator><![CDATA[Kathiriya Niket]]></dc:creator>
            <pubDate>Mon, 30 Nov 2020 04:02:37 GMT</pubDate>
            <atom:updated>2020-11-30T04:02:37.490Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, we will discuss different ways to create Flux/Mono.</p><h3>Flux</h3><ul><li>From List (or any other Iterable data type):</li></ul><pre>Flux&lt;String&gt; strFlux = Flux.fromIterable(strList);</pre><ul><li>From Array:</li></ul><pre>Flux&lt;String&gt; strFlux = Flux.fromArray(strArray);</pre><ul><li>From Stream:</li></ul><p>Stream is an API included in JDK from Java 8. It can be used to process collection from iterables.</p><p>Visit this page for more on Java 8 Streams: <a href="https://www.geeksforgeeks.org/stream-in-java/">https://www.geeksforgeeks.org/stream-in-java/</a></p><pre>Flux&lt;String&gt; strFlux = Flux.fromStream(strStream); </pre><ul><li>From Range:</li></ul><pre>Flux&lt;int&gt; intFlux = Flux.range(1,5);</pre><h3>Mono</h3><ul><li>With or without any data:</li></ul><pre>Mono&lt;String&gt; strMono = Mono.justOrEmpty(null);</pre><ul><li>From Supplier:</li></ul><p>This is a functional interface in java.util.function</p><pre>Supplier&lt;String&gt; stringSupplier = () =&gt; &quot;string in Supplier&quot;;<br>Mono&lt;String&gt; strMono = Mono.fromSupplier(stringSupplier);</pre><h3>Further reading:</h3><p>These methods are just the tip of the iceberg. There are other methods to create Mono and Flux, too.</p><p>Checkout below links to the documentation for more:</p><p>Flux — <a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html">https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html</a></p><p>Mono — <a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html">https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24905562e1a2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/reactive-programming-in-springboot-using-webflux/flux-mono-factory-methods-24905562e1a2">Flux/Mono Factory Methods</a> was originally published in <a href="https://medium.com/reactive-programming-in-springboot-using-webflux">Reactive programming in Springboot using WebFlux/Reactor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>