<?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 Harshdeep Gupta on Medium]]></title>
        <description><![CDATA[Stories by Harshdeep Gupta on Medium]]></description>
        <link>https://medium.com/@harshdeepgupta?source=rss-8042864c52bf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5i2TRIvY7KPnUvemtukdwA.jpeg</url>
            <title>Stories by Harshdeep Gupta on Medium</title>
            <link>https://medium.com/@harshdeepgupta?source=rss-8042864c52bf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:12:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@harshdeepgupta/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[Should I make class member variables const or constexpr?]]></title>
            <link>https://medium.com/@harshdeepgupta/should-i-make-class-member-variables-const-or-constexpr-327cfdc0dd27?source=rss-8042864c52bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/327cfdc0dd27</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[cplusplus]]></category>
            <dc:creator><![CDATA[Harshdeep Gupta]]></dc:creator>
            <pubDate>Fri, 21 Jan 2022 23:06:01 GMT</pubDate>
            <atom:updated>2022-01-21T23:06:01.510Z</atom:updated>
            <content:encoded><![CDATA[<p>In this post, I present the answer I came up with finally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P0PBrqcn88HeNohn" /><figcaption>Photo by <a href="https://unsplash.com/@towfiqu999999?utm_source=medium&amp;utm_medium=referral">Towfiqu barbhuiya</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I recently found myself trying to find an answer to the above question, and after reading multiple SO posts and docs like this: <a href="https://docs.microsoft.com/en-us/cpp/cpp/constexpr-cpp?view=msvc-170">constexpr (C++) | Microsoft Docs</a>, I still didn’t have an answer. Here is what I found eventually:</p><ul><li>Use constexpr if the value of your variable is known at compile time</li><li>Use const in cases where the value is not known at compile time, or you can’t use constexpr with the type even though you know it at compile time</li><li>In C++17, constexpr is not available for all types such as string. String has no constructor which returns constexpr. In C++20, it is possible though</li></ul><p>The below example shows how to use constexpr for something like int or bool, and what to do in case of std::strings.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcarbon.now.sh%2Fembed%2FAhjcFrNtvGoblNW1HrE1%3F&amp;display_name=Carbon&amp;url=https%3A%2F%2Fcarbon.now.sh%2FAhjcFrNtvGoblNW1HrE1&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;scroll=auto&amp;schema=carbon" width="1024" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac3b5e9e7c045537542f383265d5efa3/href">https://medium.com/media/ac3b5e9e7c045537542f383265d5efa3/href</a></iframe><p>This link helped me find some of the answers: <a href="https://www.reddit.com/r/cpp_questions/comments/lq6x0f/member_variables_const_vs_static_constexpr/">Member variables: const vs static constexpr </a>.</p><p>Hope this helps save someone a lot of grunts and confusion.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=327cfdc0dd27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amor Fati. Memento Mori. Carpe Diem]]></title>
            <link>https://medium.com/the-ascent/amor-fati-memento-mori-carpe-diem-b40fcc46bd3e?source=rss-8042864c52bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/b40fcc46bd3e</guid>
            <category><![CDATA[philosophy]]></category>
            <category><![CDATA[stoicism]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[life-lessons]]></category>
            <dc:creator><![CDATA[Harshdeep Gupta]]></dc:creator>
            <pubDate>Sun, 13 Jan 2019 21:01:01 GMT</pubDate>
            <atom:updated>2019-01-14T19:59:51.186Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PG5IkYYh6KFMpE6w" /><figcaption>Photo by <a href="https://unsplash.com/@victorfreitas?utm_source=medium&amp;utm_medium=referral">Victor Freitas</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Stoicism, a school of philosophy, is as ancient as wisdom goes. You can think of it as an operating system for life, and use it to derive strength in times of your crisis, and also build strength in times of prosperity.</p><p>I was introduced to Stoicism through Tim Ferris’s podcast and through works of Ryan Holiday. As someone who prided himself in staying away from conventional big brand religions, Stoicism instantly hooked me. It was mostly because of its simplicity, practicality, and the type of people who associate themselves with it.</p><p>The previous year, I set myself up for some challenging projects. One of them was reading stoic philosophy every day and applying it in my daily life. These could be any articles I find online, some podcast I might listen to or read books such as <em>Ego is the Enemy</em> and <em>Obstacle is the Way</em>.</p><p>One of the books is <em>The Daily Stoic</em>, a page a day book, and I thoroughly enjoyed reading it over the course of the entire year. Even while traveling on long trips, the book went alongside me in my bag. The slow, repeated and constant exposure to Stoic wisdom eventually breakthroughs you, and helps you chisel away your faults/limitations one day at a time.</p><p>Though the book has nearly 365 pages worth of reading, below are excerpts of twelve ideas I found the most powerful in some way or the other. Whether unique to my experiences or whether they present the idea in a clean and simple way, the ideas here are what I try to remind myself every day.</p><h3>A. Control and Choice</h3><p>The first job of a philosopher is to separate things which he can control from which he can’t control. Aka, separating the wheat from the chaff. The recovery community (people who are recovering from drug addictions etc.) practices something called the Serenity Prayer: <em>“God, grant me the serenity to accept the things I cannot change, the courage to change the things I can, and the wisdom to know the difference.”</em></p><blockquote>We control our opinion, reasoned choice, desire, aversion, and, in a word, everything of our own doing. We don’t control our body, property, reputation, position, and, in a word, everything not of our own doing.</blockquote><p>In other words, all we have control over is our own mind. And our will.</p><h3>B. The Source of Your Anxiety</h3><blockquote>“When I see an anxious person, I ask myself, what do they want? For is a person wasn’t wanting something outside of their own control, why would they be stricken by anxiety?”</blockquote><p>As Epictetus says, it’s wanting something outside of our own control that causes our anxiety. It is as if we all belong to a religious cult that believes the gods of fate will only give us what we want if we sacrifice our peace of mind. Today, when you find yourself getting anxious, ask yourself: <em>Why are my insides twisted into knots? Am I in control here or is my anxiety? Is my anxiety doing me any good?</em></p><h3>C. When you lose control?</h3><p>So, you messed up a little, or you messed it up a lot this time. Now what?</p><p>That doesn’t change the philosophy you know. It’s not as if your reasoned choice has permanently abandoned you. Rather it was you who temporarily abandoned it. Stop. Regain your composure. It’s waiting for you.</p><h3>D. Carpe Diem</h3><p>You will only get one shot at today. You have only twenty-four hours with which to take it. And then it is gone and lost forever. As Seneca says:</p><blockquote>“Let us therefore set out whole-heartedly, leaving aside our many distractions and exert ourselves in this single purpose, before we realize too late the swift and unstoppable flight of time and are left behind. As each day arises, welcome it as the very best day of all, and make it your own possession. We must seize what flees.”</blockquote><h3>E. Guilt is worse than Jail</h3><blockquote>The greatest portion of peace of mind is doing nothing wrong.</blockquote><p>There are immense costs of doing wrong, not only to society but to the perpetrator. The guilt is almost worse than whatever society metes out. This is why so many petty criminals confess or voluntarily surrender. They want the peace of mind that comes with doing <em>right. </em>And so do you.</p><h3>F. Prepared and Active</h3><blockquote>Let Fate find us prepared and active. Here is the great soul: the one who surrenders to Fate. The opposite is the weak and degenerate one, who struggles with and has a poor regard for the order of the world, and seeks to correct the faults of the gods rather than their own.</blockquote><p>Whatever happens today, let it find us prepared and active: ready for problems, ready for difficulties, ready for people to behave in disappointing or confusing ways, ready to accept and make it work for us. Let’s not wish we could turn back time or remake the universe according to our preference. Not when it would be far better and far easier to remake ourselves.</p><h3>G. No Self Flagellation Needed</h3><p>Marcus’s meditations are filled with self-criticism and so are the writings of other Stoics. It’s important to remember, however, that that&#39;s as far as it goes. There was no paying penance, no self-esteem issues from guilt or self-loathing. You never hear call themselves a worthless piece of crap, nor do they ever starve themselves as punishment. Their self-criticism is constructive.</p><p>There is no need to be too hard on yourself. Hold yourself to a higher standard but not an impossible one. And forgive yourself if and when you slip up.</p><h3>H. Make the words your own</h3><p>One of the criticisms of Stoicisms by modern translators is the amount of repetition. Marcus Aurelius, for example, has been dismissed by academics as not being original. This criticism misses the point. That’s because real philosophers weren’t concerned with authorship, only what worked. You are welcome to take all the words of the great philosophers and use them to your own liking.</p><p>The way to prove that you truly understand what you speak and write, that you truly are original, is to put them into practice. Speak them with your actions more than anything else.</p><h3>I. Amor Fati</h3><p>Something happened that we wish had not. Which of these is easiest to change: our opinion or the event in the past.</p><p>The answer is obvious. Accept what happened and change your wish that it had not happened. And the most practiced Stoics take it a step further. Instead of simply <em>accepting</em> what happens, they urge us to actually enjoy what has happened: whatever it is. A<em>mor fati </em>(love of fate) — it is about feeling gratitude for what happens. This is a recipe for happiness and joy.</p><h3>J. Judge Not, Lest</h3><blockquote>“When philosophy is wielded with arrogance and stubbornly, it is the cause for the ruin of many. Let philosophy scrape off your own faults, rather than be a way to rail against the faults of others.”</blockquote><p>Remember the proper direction of philosophy — of all the things we’re doing here — is focused inwards. To make <em>ourselves</em> better and to leave other people to that task for themselves. Our faults are in our control. Other people’s faults? Not so much.</p><p>Leave other people to their faults. Nothing in stoic philosophy empowers you to judge them — only accept them. Especially when you have so many of your own.</p><h3>K. Meaningless…Like a fine wine</h3><blockquote>“You know what wine and liqueur tastes like. It makes no difference whether a hundred or a thousand bottles pass through your bladder — you are nothing more than a filter.”</blockquote><p>As fun and exciting and pleasurable certain indulgences can be, it’s worth putting them in their place. These can be indulging in food, technology, cars etc. You don’t get a prize at the end of your life for having consumed more, worked more, spent more, collected more or learned more about various vintages than everyone else. You are just a temporary vessel that interacted with these fancy items.</p><h3>L. Memento Mori</h3><blockquote><strong>“The one who puts the finishing touches on their life each day is never short of time.”</strong></blockquote><p>Think of a soldier about to leave for the war. Not knowing whether they will return or not, what do they do? They get their affairs in order. They tell their family that they love them. They don’t have time for quarreling or petty matters. And in the morning, they leave. They hope to come back in one piece but prepared for the possibility that they might not. Let us live today in the same way.</p><p>All things die. In the end, we all succumb, as Marcus said, to the rhythm of events — of which there is always a final, determined beat. There is no need to dwell on this fact, but there is no point in ignoring it either. This is <em>Memento mori</em>: remembering that we are mortals.</p><p>These are the twelve ideas that I find the most powerful and liberating. These surely definitely don’t cover all of the ideas, and neither is my intention. In the end, you are free to accept them or reject them. There are excellent resources available on the internet for further readings, my favorite being <a href="https://tim.blog/2017/07/06/tao-of-seneca/">Tao of Seneca by Tim Ferris.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b40fcc46bd3e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-ascent/amor-fati-memento-mori-carpe-diem-b40fcc46bd3e">Amor Fati. Memento Mori. Carpe Diem</a> was originally published in <a href="https://medium.com/the-ascent">Ascent Publication</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Common Mistake Beginner Software Developers make, and How to Avoid it]]></title>
            <link>https://medium.com/the-post-grad-survival-guide/a-common-mistake-beginner-software-developers-make-and-how-to-avoid-it-750586ac9a44?source=rss-8042864c52bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/750586ac9a44</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[business-software]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Harshdeep Gupta]]></dc:creator>
            <pubDate>Wed, 02 Jan 2019 22:52:56 GMT</pubDate>
            <atom:updated>2019-01-02T22:52:56.606Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2TYE0Kc6q_LObLRy" /><figcaption>Photo by <a href="https://unsplash.com/@fancycrave?utm_source=medium&amp;utm_medium=referral">Fancycrave</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I was just one month into my job as a software developer, fresh out of college. I was warming up to contribute to my team. Somehow, I caught myself having very interesting thoughts while going through the existing code base. My team had built this code base over months and years of effort.</p><p>As my first task, I had a small bug fix that would help in stabilizing future versions of the service. My team explained the architecture of the service to me and where do we fit in the grand scheme of the larger project. It was on me to find where the code had to be added/deleted or modified to make the bug fix.</p><p>I started digging through the code base, most of which had been created in the last two years. By no standard, it was legacy code. As I went deeper and deeper into it, I found myself with quite profane thoughts. To say that code was not aesthetically pleasing, would be a mild way to put it. This is how I reacted to my team’s code base:</p><p><em>This sucks!!!</em></p><p><em>Yuck, there is two hundred line function here.</em></p><p><em>Who wrote this crap!</em></p><p><em>Oh God, there is an if-else block inside an if-else block.</em></p><p><em>This code is a big hairy mess! eff it.</em></p><p><em>This needs to be rewritten from scratch.</em></p><p>I was furious. As I was having these thoughts, a part of me was wondering, could there be a way to make some sense of all this? Were there some things I didn’t know that these senior guys on my team who wrote most of this code. I began to find out.</p><p>I grabbed the senior guy on my team for a quick chat and started throwing my questions at him.</p><p>From what I came to know after the discussion was very enlightening for me. The team was aware that code had some maintenance problems. However, the existing code base was in the shape it is for a few reasons. As he went on to explain those reasons to me, I could see why <a href="https://www.joelonsoftware.com/2000/04/06/things-you-should-never-do-part-i/">this post</a> makes sense.</p><p>Read on to find the answer to why when you ask any software developer the quality of code they are working on, the default response is: “It’s a mess”. And also, why building things up from the ground is not a solution in most cases.</p><h4>Code is written for a different reason</h4><p>Most people new to software development, including me, think that code is written for machines. Wrong. Nada. It was written for humans. The machine doesn’t even see the JavaScript code that you write, all they see is a sequence of 0s and 1s. And as the service for my team was being built up, there were real deadlines with deliverables that had to be delivered. Software developers are already very mentally taxed. Somewhere in the pressure to deliver, getting the code to work takes priority over writing super aesthetically pleasing code.</p><p>A large chunk of code is easier to write and explain to a fellow developer in person, as opposed to hopping from one file to another to make sense of things. These decisions then can remain around for a long time.</p><h4>Production code is battle tested</h4><p>My team gets a lot of incident reports, which sometimes lead to critical bug fixes in the code. An error handling if-else clause here, a try-catch there, and suddenly, the whole code base has grown hairs. This is how code base starts to get messier despite best intentions.</p><p>This is exactly why rewriting code from the ground up is such a naive idea. This would result in throwing away all the bug fixes and improvements that were made. These were accumulated over the course of months and years, possibly by a user having some real issue. A developer might have spent several hours to fix these bugs once they were reported.</p><h4>What works is the way</h4><p>In the world of business, where there might be clients depending on your product or service. No one cares if your code is refactored to the best possible extent. Every line of code is written to solve a business problem. Ask yourself, what value will your refactoring efforts create? Possibly none, and they might end up introducing more bugs. Plus, is it the best use of your time?</p><h3>The antidote</h3><p>The first step is to recognize the problem. The issue was my ego was thinking it could do a better job than these senior developers who clearly didn’t know how to write production level code. This is a very naive way of thinking, and I have been burnt sufficient times in the past to avoid it now.</p><p>Just by acknowledging your ego’s presence, you gain a huge advantage over it. Suddenly, it has no place to hide. Acknowledging the problem is one thing, and solving it is another. Below is my way of getting around this knee-jerk reaction. If you have a different way, write it down in the comments section.</p><h4>Get Curious</h4><p>Start to ask why!</p><p>Why was this piece of code written this way? Who wrote it? Is that person still around, and can I ask this to him/her. What do these guys know that I don’t? What is the problem that that this feature solves?</p><p>Most of the times, you will be surprised by the answer.</p><h4>Develop Humility</h4><p>This is not a difficult task. In all likelihood, you still have huge amounts to learn no matter where you might put yourself on the ladder.</p><p>Adopting a growth mindset is what allowed me to put myself in the right state of mind. It liberated me to ask questions without the fear of looking stupid. When you know that you are not supposed to know all the answers, but learn all the answers, asking questions becomes just a triviality.</p><h3>Conclusion</h3><p>It is very easy to think your way of writing code is best, and everyone else’s sucks. Ask three people on how they would split a string into an array of characters, and all would give three different ways of doing it. Probably, all of them are equally good, and something can be learned from all of them.</p><p>As to dealing with the bad quality code, throwing it away is definitely not the solution. The more business-friendly way would be to start eating the elephant one bite at a time and refactor your way through the code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=750586ac9a44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-post-grad-survival-guide/a-common-mistake-beginner-software-developers-make-and-how-to-avoid-it-750586ac9a44">A Common Mistake Beginner Software Developers make, and How to Avoid it</a> was originally published in <a href="https://medium.com/the-post-grad-survival-guide">The Post-Grad Survival Guide</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 12 Hour guide for Moving to the USA for first timers]]></title>
            <link>https://medium.com/the-post-grad-survival-guide/the-12-hour-guide-for-moving-to-the-usa-for-first-timers-57434ade9f4b?source=rss-8042864c52bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/57434ade9f4b</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[immigration]]></category>
            <category><![CDATA[h1b]]></category>
            <category><![CDATA[usa]]></category>
            <category><![CDATA[jobs]]></category>
            <dc:creator><![CDATA[Harshdeep Gupta]]></dc:creator>
            <pubDate>Thu, 20 Dec 2018 05:29:17 GMT</pubDate>
            <atom:updated>2019-01-02T22:53:27.581Z</atom:updated>
            <content:encoded><![CDATA[<h3>The 12 Hour guide for Moving to the USA for H-1B visa holders</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*OQD2nubmMsaqvFdb" /><figcaption>Photo by <a href="https://unsplash.com/@code_mnml?utm_source=medium&amp;utm_medium=referral">Code Mnml</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So you got your US work visa stamped, and your employer asks you about your choice of relocation benefits. There are two options you can choose from: either take assistance and relax or take a lump sum and make all the travel arrangements yourself. In addition to all the challenges of moving to a new country, you have no close relatives in the place you are going to. This means there is no one from whom you can take advice and have a place to crash at. Still, you decide to make the travel arrangements yourself and take the lump sum, because, why not.</p><p>I salute your warrior spirit. In this article, I share my similar experience of moving to Redmond, Washington, the USA from India, on an H-1B visa working for Microsoft. Let’s get started.</p><p>If the force is with you, you should be in and out of this process in less than 12 hrs. Though there are a lot of minutiae to take care of, the three tasks that take most of the time are:</p><ol><li>Booking the Flight tickets</li><li>Finding an accommodation</li><li>Deciding what to take to the US</li></ol><p>If you have these three wins under your belt, then most of the other things, that I discuss or you might need will be just a windfall.</p><h3>Booking the Flight tickets</h3><p>India and US are nearly opposite in the northern hemisphere. Which means if you dig a tunnel in your backyard, you might just reach the US. Or you can take a flight. Once your starting date at your company is decided, book a flight for travel date of 2–3 days before your starting date. This will allow you to fit into the new environment and adjust your sleep cycle.</p><p>Use any of the online travel sites to book your flight ticket. I used MakeMyTrip. Time taken by flights coming to the west coast is shorter if you come via traveling through Japan etc, which means travel east from India.</p><p>Out of the 12 hrs, allocate 3 hrs from searching for a flight to making the payment to book the ticket. This 3 hrs might be split into multiple 10-minutes of searching and pondering. You might also need to make travel arrangements to the airport your flight is from. Book those train/flight tickets too.</p><h3>Finding an accommodation</h3><p>The next task on the list is to find a place to crash your jet-lagged self after you get out of the airport. Depending on your situation, you might need the place anywhere from the first week to the first couple of months, until you find a leased apartment.</p><p>Some factors to consider while searching for your place are transit times and convenience to your office, bathroom sharing structure, servicing of common areas like hall, kitchen etc, and reviews of the host, if available.</p><p>I first tried booking a place by finding rentals on Sulekha.com, and the experience was just a pain. You can&#39;t contact the hosts directly, and neither there are photos of the listing available. Plus no guarantees against fraud. The only plus point is that you might find a place around $100 cheaper than a verified place. The next resource was to book through Airbnb, and this is the option which I ultimately chose.</p><p>Allocate 4 Hrs from start to finish, and do contact your host before making the payment, and ask any clarifying questions you need.</p><h3>Deciding what to take to the US</h3><p>Ohh, it makes me tired to even think of it. A common mistake, which most people coming to the US do, and which I did too, was moving with your whole household in those two bags.</p><p>No, you don’t need most of the things which you or your parents/family members might be telling you to take. And you shouldn’t be taking advice from those distant relatives who say everything is expensive in the US.</p><p>Some items will definitely help you get kickstarted, and some will just add weight to your luggage. A good strategy for picking items is to see their utility in long term.</p><p>Clothes, a few utensils, books definitely have a long-term utility. Think of items like coffee mugs, spoons, forks, knives, scissors, a couple of plates, bowls etc to be most impactful. See if you can get microwave safe and dishwasher safe versions of some of these items.</p><p>Food packets, fruits, spices, groceries etc will get exhausted, and ultimately you will need to buy them from here. Plus, they are easily available here.</p><p>You can bring some supplies for the initial phase, but I don’t see any point in bringing whole bags of such stuff. I nearly did bring, and it was a waste. This guy has made an <a href="https://devilonwheels.com/usa/list-of-things-to-carry-when-you-travel-to-the-usa-from-india/">excellent list of items</a>, and I don’t intend to repeat the same stuff.</p><h3>How much does it cost?</h3><p>By moving to us in a DIY fashion, you will be saving on a lot of money, provided your company gives you the option of doing so and gives you a lump-sum amount instead. The main upfront expenses will be of flight and accommodation. Companies in the US mostly have a 15-day pay cycle, so within 2 weeks of you coming here, you must have your first paycheck in your hand, which will help to smooth out things.</p><p>My flight cost me around $550 (~38,000 INR), and Airbnb for a two month booking period cost me around $1000 (~75,000 INR) per month. When you book on Airbnb for multiple months, the site automatically splits the payment in monthly installments, which is a cool feature.</p><p>An average meal costs anywhere from $10 to $25, and with travel etc, daily expenses can be rounded at $40 per day, which is still on the higher side.</p><p>When coming to the US, do have some cash with you, because it will be used in the public transport system, and can be used mostly in all stores. Also, bring a prepaid Forex travel card.</p><p>I am not selling anything here, but after a lot of searching, I found the Forex card by ICICI bank (if you are from India) to be the best option. It allows you to refill the card from your online bank account, which did come handy to me. Cards by SBI or other banks either don’t offer many features or are more expensive.</p><p>$1000, split 30:70 between cash and card should do the trick for you. The US is mostly card based, so even if you bring no cash, you will be fine. Plus, ATMs are always there, but using a Forex card at ATM might attract additional fees.</p><p>After coming to the US, I tried to book an Uber from the airport to my Airbnb using my Forex card. The app didn’t accept my Forex card, and Uber doesn’t take cash here (surprising!). This is where the cash came in handy, as I took a normal taxi and paid in cash.</p><h3>Other Things to consider</h3><p>Knocking down the above three tasks should get you all the way. These are the additional things that I found to be helpful in making the Journey less painful.</p><ul><li><strong>Spend time with your family:</strong> Your family might be getting all tensed up and worried/sad, or they might be happy to see you finally leave for good. But for your own sake, spend some quality time with those closest to you, as you might not be seeing them for a year at least</li><li><strong>Get travel insurance: </strong>This might come in handy, or it might not. But getting your travel insured makes sense, especially with such long multiple career flights to a new climate. Buy a plan for seven days, as the premium amount is flat for the first seven days of a trip. Usually, employer insurance kicks in during/after that period. Countless hours of mine were spent on this as I have a knack for going through long insurance documents. It is somewhat my superpower. That is why women find me so irresistible. With no intention of selling, I found Bharti Axa and Bajaj Alliance travel insurances to be value for the buck</li><li><strong>Scan and upload your documents to cloud:</strong> passports of all family members, your visa stamps, transcripts, your passport size photo other official documents</li><li><strong>Print a copy of all your official documents</strong>, and arrange documents such as I-797, labor condition application, passport, offer letter, and all other documents that you think might be needed at Port of Entry in the US. There will be a short interview, and act all confident and data-driven as you did in your job interview.</li><li><strong>Add a unique identifier/contact details to your luggage: </strong>This might be as simple as tying a ribbon on the handle or making a mark with nail paint</li><li><strong>Buy an international SIM: </strong>Worldsim in one of the many companies that sell a US sim in India. I got a Lyca sim from them and within half an hour of landing at Seattle airport, my phone was working on a US number.</li><li><strong>Make your travel comfortable:</strong> Wear comfortable clothes while traveling, and buy a travel pillow/eyemask. A traveling pillow is really helpful in getting you the much-needed shut-eye. Buy an international adapter too, Indian chargers for laptops/mobiles won’t work in US sockets. Amazon.in works well for these services</li></ul><h3>Things to buy/do after coming to the US</h3><p><strong>Shopping List:</strong> I was traveling to Seattle-Tacoma international airport as it is nearest to the Microsoft Redmond office I was supposed to join. It is always a good idea to defer some shopping to the local stores as they have specialized solutions to solve the problems that local people face at a place. For this specific region, you might benefit by shopping for these items here:</p><ul><li>Water resistant clothing, including jackets, gloves, shoes for hiking etc. Don’t hesitate on spending up to $200 on a good quality water-resistant jacket</li><li>Umbrellas are of better quality here, with the same argument for shoes with fur etc</li></ul><p><strong>Get an SSN: </strong>This task should be done as soon as you come to the US. If you are unfamiliar with the concept of Social Security Number, know that almost nothing will work for you without one. Heck, I couldn’t even access my employer’s health benefits portal without one. You need this for getting a credit card, signing a lease for an apartment, accessing your bank account online and what not. <em>Although, a bank account can be opened, have money deposited in it through check/transfers, and taken out using a debit card without an SSN</em></p><p><strong>Bank Accounts and Credit cards: </strong>There are two options here, either go with bigger banks like Bank of America, Wells Fargo etc. or go with smaller credit unions. If you are new to America and have no credit history, bigger banks won’t give you lucrative options.</p><p>A good strategy is to open an account with a credit union, as they are the ones who will offer an unsecured credit card (which is what you really want). Use this card to build a credit history for six months or so, and if needed, apply for a better credit card/bank account with a bigger bank.</p><p><strong>State Identity Card: </strong>You can’t possibly carry your passport everywhere you need to prove who you say you are. You need an identity card issued by the local government. Credits to you if you know how to drive, you can apply for a driving license. If you don’t know how to drive, fret not. You can apply for a state-issued identity card. It usually needs your passport, SSN number, and pay-stubs.</p><p><strong>Finding a leased apartment: </strong>Apartment hunting can be fun or a bane, depending on how you treat it. A good place to start is with online aggregator sites such as <a href="https://www.apartments.com/">apartments.com</a> or <a href="https://www.zillow.com/">zillow.com</a>, shortlist properties from these, and maybe do a site visit. By this time, you will be settled enough to know how things operate here.</p><h3>Conclusion</h3><p>Congratulations on making this journey! Only a handful of people each year get the opportunity you have. I envy you for the journey that you are about to make. The transition will be full of excitement, joy, and wonder. Expect to get a little uncomfortable and lonely in the first few weeks. In time, everything should work out.</p><p>Though I tried to cover most of the things, there might still be a few issues/questions that I might have missed. Feel free to comment below for any additional info/question you might have.</p><p>Read my <a href="https://medium.com/@harshdeepgupta/my-h-1b-interview-experience-at-us-embassy-in-singapore-f6e555521c7c">H-1B interview experience</a> here.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=57434ade9f4b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-post-grad-survival-guide/the-12-hour-guide-for-moving-to-the-usa-for-first-timers-57434ade9f4b">The 12 Hour guide for Moving to the USA for first timers</a> was originally published in <a href="https://medium.com/the-post-grad-survival-guide">The Post-Grad Survival Guide</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recommender Systems using Deep Learning in PyTorch from scratch]]></title>
            <link>https://medium.com/data-science/recommender-systems-using-deep-learning-in-pytorch-from-scratch-f661b8f391d7?source=rss-8042864c52bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f661b8f391d7</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[pytorch]]></category>
            <category><![CDATA[recommender-systems]]></category>
            <category><![CDATA[information-retrieval]]></category>
            <dc:creator><![CDATA[Harshdeep Gupta]]></dc:creator>
            <pubDate>Tue, 04 Dec 2018 17:30:25 GMT</pubDate>
            <atom:updated>2018-12-04T17:30:25.033Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SdW-2pZkufIVckEG" /><figcaption>Photo by <a href="https://unsplash.com/@syinq?utm_source=medium&amp;utm_medium=referral">Susan Yin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Recommender systems (RS) have been around for a long time, and recent advances in deep learning have made them even more exciting. Matrix factorization algorithms have been the workhorse of RS. In this article, I would assume that you are vaguely familiar with collaborative filtering based methods and have basic knowledge about training a neural network in PyTorch.</p><p>In this post, my goal is to show you how to implement a RS in PyTorch from scratch. The theory and model presented in this article were made available in this <a href="https://www.comp.nus.edu.sg/~xiangnan/papers/ncf.pdf">paper</a>. Here is the <a href="https://github.com/HarshdeepGupta/recommender_pytorch">GitHub repository</a> for this article.</p><h3>Problem Definition</h3><p>Given a past record of movies seen by a user, we will build a recommender system that helps the user discover movies of their interest.</p><p>Specifically, given <strong>&lt;userID, itemID&gt; </strong>occurrence pairs, we need to generate a ranked list of movies for each user.</p><p>We model the problem as a <a href="https://en.wikipedia.org/wiki/Binary_classification"><strong>binary classification problem</strong></a><strong>, </strong>where we learn a function to predict whether a particular user will like a particular movie or not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/0*g2yfQG5bKAtabiF4" /><figcaption>Our model will learn this mapping</figcaption></figure><h3>Dataset</h3><p>We use the MovieLens 100K dataset, which has 100,000 ratings from 1000 users on 1700 movies. The dataset can be downloaded from <a href="https://grouplens.org/datasets/movielens/100k/">here</a>.</p><p>The ratings are given to us in form of <strong>&lt;userID,itemID, rating, timestamp&gt; </strong>tuples. Each user has a minimum of 20 ratings.</p><h3>Training</h3><p>We drop the exact value of rating <em>(1,2,3,4,5)</em> and instead convert it to an implicit scenario i.e. any positive interaction is given value of 1. All other interactions are given a value of zero, by default.</p><p>Since we are training a classifier, we need both positive and negative samples. The records present in the dataset are counted as positive samples. We assume that all entries in the user-item interaction matrix are negative samples (a strong assumption, and easy to implement).</p><p>We randomly sample 4 items that are not interacted by the user, for every item interacted by the user. This way, if a user has 20 positive interactions, he will have 80 negative interactions. These negative interactions cannot contain any positive interaction by the user, though they may not be all unique due to random sampling.</p><h3>Evaluation</h3><p>We randomly sample 100 items that are not interacted by the user, ranking the test item among the 100 items. This same strategy is used in the paper, which is the inspiration for this post (referenced below). We truncate the ranked list at 10.</p><p>Since it is too time-consuming to rank all items for every user, for we will have to calculate 1000*1700 ~10⁶ values. With this strategy, we need 1000*100 ~ 10⁵ values, an order of magnitude less.</p><p>For each user, we use the latest rating(according to timestamp) in the test set, and we use the rest for training. This evaluation methodology is also known as leave-one-out strategy and is the same as used in the reference paper.</p><h3>Metrics</h3><p>We use Hit Ratio(HR), and Normalized Discounted Cumulative Gain(NDCG) to evaluate the performance for our RS.</p><p>Our model gives a confidence score between 0 and 1 for each item present in the test set for a given user. The items are sorted in decreasing order of their score, and top 10 items are given as recommendation. If the test item (which is only one for each user) is present in this list, HR is one for this user, else it is zero. The final HR is reported after averaging for all users. A similar calculation is done for NDCG.</p><p>While training, we will be minimizing the cross-entropy loss, which is the standard loss function for a classification problem. The real strength of RS lies in giving a ranked list of top-k items, which a user is most likely to interact. Think about why you mostly click on google search results only on the first page, and never go to other pages. Metrics like NDCG and HR help in capturing this phenomenon by indicating the quality of our ranked lists. Here is a good introduction on <a href="http://fastml.com/evaluating-recommender-systems/">evaluating recommender systems</a>.</p><h4>Baseline: Item Popularity model</h4><p>A baseline model is one we use to provide a first cut, easy, non-sophisticated solution to the problem. In much of use cases for recommender systems, recommending the same list of most popular items to all users gives a tough to beat baseline.</p><p>In the GitHub repository, you will also find the code for implementing item popularity model from scratch. Below are the results for the baseline model.</p><h4>Deep Learning based model</h4><p>With all the fancy architecture and jargon of neural networks, we aim to beat this item popularity model.</p><p>Our next model is a deep multi-layer perceptron (MLP). The input to the model is userID and itemID, which is fed into an embedding layer. Thus, each user and item is given an embedding. There are multiple dense layers afterward, followed by a single neuron with a sigmoid activation. The exact model definition can be found in the file <a href="https://github.com/HarshdeepGupta/recommender_pytorch/blob/master/MLP.py">MLP.py</a>.</p><p>The output of the sigmoid neuron can be interpreted as the probability the user is likely to interact with an item. It is interesting to observe that we end up training a classifier for the task of recommendation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/0*BtMp_0pR2pbjjcsK" /><figcaption>Figure 2: The architecture for Neural Collaborative Filtering</figcaption></figure><p>Our loss function is Binary Cross-entropy loss. We use Adam for gradient descent and L-2 norm for regularization.</p><h3>Results</h3><p>For the popularity based model, which takes less than 5 seconds to train, these are the scores:</p><p>HR = 0.4221 | NDCG = 0.2269</p><p>For the deep learning model, we obtain these results after nearly 30 epochs of training (~3 minutes on CPU):</p><p>HR = 0.6013 | NDCG = 0.3294</p><p>The results are exciting. There is a huge jump in metrics we care about. We observe a <strong>30% reduction in error</strong> according to HR, which is huge. These numbers are obtained from a very coarse hyper-parameter tuning. It might still be possible to extract more juice by hyper-parameter optimization.</p><h3>Conclusion</h3><p>State of the art algorithms for matrix factorization, and much more, can be easily replicated using neural networks. For a non-neural perspective, read this excellent post about<a href="https://towardsdatascience.com/paper-summary-matrix-factorization-techniques-for-recommender-systems-82d1a7ace74"> matrix factorization for recommender systems</a>.</p><p>In this post, we saw how neural networks offer a straightforward way of building recommender systems. The trick is to think of recommendation problem as a classification problem. We implemented a recommender system in PyTorch. We compared our results against a non-personalized baseline algorithm and observed significant gains.</p><p>To gain a deeper understanding, I encourage you to read the original paper (linked below) and head over to the <a href="https://github.com/HarshdeepGupta/recommender_pytorch">GitHub repository</a> for this post.</p><h3>References:</h3><ol><li>The paper, which also links to author’s implementation in Keras: <a href="https://www.comp.nus.edu.sg/~xiangnan/papers/ncf.pdf">https://www.comp.nus.edu.sg/~xiangnan/papers/ncf.pdf</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f661b8f391d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/recommender-systems-using-deep-learning-in-pytorch-from-scratch-f661b8f391d7">Recommender Systems using Deep Learning in PyTorch from scratch</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My H-1B interview experience at US Embassy in Singapore]]></title>
            <link>https://medium.com/@harshdeepgupta/my-h-1b-interview-experience-at-us-embassy-in-singapore-f6e555521c7c?source=rss-8042864c52bf------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6e555521c7c</guid>
            <category><![CDATA[immigration]]></category>
            <category><![CDATA[h1b]]></category>
            <dc:creator><![CDATA[Harshdeep Gupta]]></dc:creator>
            <pubDate>Mon, 19 Nov 2018 16:59:37 GMT</pubDate>
            <atom:updated>2018-12-20T06:03:32.963Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/688/0*mqUx_Uuen5cDkOQ3" /></figure><p>The process for getting the H-1B visa, even after your petition getting selected through the lottery can be quite daunting. You can even think that the real process has just started, as till now, it was your employer and their attorneys doing all the work (well, at least hopefully).</p><p>Being an Indian passport holder, who had never been to USA before, getting my Visa application selected in the process felt like great news to me.</p><p>I falsely assumed that every thing was done now and I just need to pack my bags and leave. As was revealed by quick google searches and an email from my employer, there were next steps. I also happened to be travelling to Singapore during this period, and intended to stay there for some time.</p><p>I decided to complete the rest of my visa process in Singapore itself. I intend to record my experience below, and share the process details. First of all, yes, it is possible to give your visa interview in any US Embassy all over the world, your Indian passport has nothing to do with it. The following are the steps:</p><h3>Collecting Documents</h3><p>The first step is to fill a form known as DS-160. It’s a pretty long form, and needs patience to be filled. The form needs a photo of yours, and it checks if the photo you uploaded meets their standards.</p><p>I was trying to upload mobile scan versions of an old pic of mine which got rejected. That was me being plain lazy! Ultimately, photo shoot at a digital studio got the job done.</p><p>My most of the needed documents were in India which I got delivered. Indian speed post is reliable after all, and much cheaper than courier services. This is the list of documents I took to the interview:</p><ul><li>Passport</li><li>I-797B Notice of Action (Evidence of approved I­-129 )</li><li>Official transcripts and degree</li><li>Appointment Confirmation Letter (you get this after the next step)</li><li>Application Confirmation Page</li><li>Labor Condition Application Form</li><li>Employment Offer Letter</li><li>Bank account statement (of my Indian student back account)</li><li>Copy of H-1B Petition (The I-129)</li><li>Resume</li><li>Singapore Visa (It was a temporary work visa, so its proof of approval)</li><li>Payment Receipt for the Visa interview</li><li>Recent 2×2 pics on white background (although they had a photo booth inside embassy)</li></ul><h3>Scheduling the Interview</h3><p>The US Embassy in SG has much shorter wait times (1 day) than embassies in India. Also, instead of booking two appointments (one for bio-metrics and other for interview), the embassy in SG requires booking of only one appointment.</p><p>After all the documents were gathered, I booked the interview. Slots were available from next day onward, so I went ahead and booked the morning slot of the following day.</p><h3>Preparing for the Interview</h3><p>At this point, there were less than twenty four hours left for the interview. I was trying to calm my nerves, and decided that reading some past experiences of the embassy might help. It was a mistake.</p><p>Online forums were littered with how unfriendly/strict the officials were in the SG office of US embassy, and how they rejected visa applications in an eye blink. By this time, panic had gripped me and I was contemplating a no show on my interview.</p><p>I thought of restarting the process in an embassy/consulate in India. I heard they were more friendly, and also there were much more resources and testimonials available online for embassies in India. Although, this would have caused me a month or more of delay, as I was scheduled to leave Singapore not before that.</p><p>By midnight, I was scrounging my network of friends for anyone who has given an interview in SG office. I talked to interviewees for F-1, J-1 and all the gazillion types of Visas one can have an interview for. The conclusion was that, yes, they grill harder and are more strict. If your case is genuine, they will eventually approve your visa.</p><p>I decided to go ahead with my plan of appearing for interview. I decided that the all-night out I just spent wasn’t going to be wasted.</p><h3>The Interview</h3><p>The interview was at 10:30 AM. I grabbed a Grab and reached by 10:15 AM. It was lonely there, and after greetings with the guard and depositing my mobile (don’t take your laptop, they don’t have facility to store that), I went in the embassy. I would suggest you to take all documents in a plastic folder in a plastic bag or something similar.</p><p>After a second security check, I was guided to a counter where a official greeted me and asked my purpose of visit to the embassy. After mentioning the purpose to be H-1B interview, he asked for a recent photo, passport, and appointment confirmation page. He also scanned my finger prints. Next, he told me to proceed to any of the two available counters for the interview. I saw his finger pointing to the two counters and found my gaze following it.</p><p>The whole place was scary, and I was the only one in queue (does it even count as a queue?).</p><p>Both the counters had different officers, and I had read multiple stories that how interviews are also dependent on the mood the officer is experiencing that day. I went to the younger one, hoping we would connect on some common ground and then together bash the tweet guy in US. I was so wrong.</p><p>My interviewer asked what will be my role in the organization supporting my petition, what is my highest qualification, and asked me to submit a copy of my resume, and my offer letter. After that, I was told that they will let me know the status in a few weeks, and gave me back my passport, and I-797 receipt. That was it, and they asked me to leave.</p><p>I asked them if my visa is approved, the officer said “tentatively approved”. I asked them how much time it would take, and if I need to leave SG, can the case be transferred India? They answered 2–3 weeks, and No. There was no other receipt given to me or any other information shared. I came back and checked the status of my application online.</p><p>They put my case on administrative processing. No amount of being tensed up will help me, I thought. The process is opaque and can’t be expedited.</p><p><em>For the uninitiated, “Administrative processing” is the general term used when visa applications are subjected to a delay as a result of a security background check.</em></p><p>Administrative Processing took exactly 28 days. I received an email from embassy saying my processing is completed and they now need my passport for stamping.</p><p>My flight was scheduled for the next day. I cancelled it. Luckily, my SG visa had enough breathing room to allow a few days of extension.</p><p>I submitted my passport on a Friday afternoon, and picked it up on the next Thursday’s morning. I booked a flight for the next day, and was out of SG.</p><p>My passport had the H1B visa stamp on it. Mission accomplished.</p><p>Here are some resources, in addition to all the googling, that I used during this process:</p><ul><li><a href="http://blog.hguochen.com/guide/2014/11/22/My-H1B1-experience/">My H1B1 experience</a></li><li><a href="https://www.path2usa.com/h1b-visa-guide">H1B Visa Application Process</a></li></ul><p><em>Originally published at </em><a href="http://harshdeepgupta.com/my-h-1b-interview-experience-at-us-embassy-singapore/"><em>harshdeepgupta.com</em></a><em> on November 19, 2018.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6e555521c7c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>