<?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[Developer Student Club, HIT - Medium]]></title>
        <description><![CDATA[Developer Student Clubs HIT, powered by Google Developers, is a non-profit community that seeks to inspire inquisitive minds in the field of technology. DSC provides opportunities where Developers, Designers, and Managers collaborate to build fun and socially-impactful projects. - Medium]]></description>
        <link>https://medium.com/dsc-hit?source=rss----9f825fec75---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Developer Student Club, HIT - Medium</title>
            <link>https://medium.com/dsc-hit?source=rss----9f825fec75---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 22:33:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/dsc-hit" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How I cracked the internship interview for Goldman Sachs 2021]]></title>
            <link>https://medium.com/dsc-hit/how-i-cracked-the-internship-interview-for-goldman-sachs-2021-89117274933b?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/89117274933b</guid>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[internships]]></category>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[goldman-sachs]]></category>
            <dc:creator><![CDATA[Amisha Jodhani]]></dc:creator>
            <pubDate>Sun, 22 Nov 2020 09:49:54 GMT</pubDate>
            <atom:updated>2020-11-22T17:37:26.228Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*vfNDpolGlQH5lNiO.png" /></figure><p>Every year, Goldman Sachs runs it’s<strong> </strong><a href="https://www.goldmansachs.com/careers/students/programs/india/engineers-campus-hiring-program.html"><strong>Engineering Campus Hiring Program</strong></a>, an off campus drive for their Bengaluru office. This year the applications opened from mid-July for about 3 weeks.</p><p>Here, I am (extensively) sharing my own experience with this program, the entire selection process and also some tips and suggestions which worked for me. Hope this helps you as much as possible!</p><h4>Aptitude Test</h4><p>The application will ask you for your basic details and a resume (which you can update later when needed). Their first assessment was an Aptitude Test which took place on 9th August. It was for a duration of 105 minutes with 68 questions divided as follows:</p><ul><li>Numerical Computations — 8 questions</li><li>Numerical Reasoning — 12 questions</li><li>Comprehension — 10 questions</li><li>Abstract Reasoning — 12 questions</li><li>Diagrammatic Reasoning — 12 questions</li><li>Logical Reasoning — 12 questions</li><li>Subjective — 2 questions</li></ul><p>All these MCQ questions had 5 marks for correct answer and -2 for incorrect. The subjective questions had 10 marks each.</p><p><strong>Tip:</strong> I could solve around 40 questions in total as I was confident about those answers. It will help you to practice such kind of problems beforehand to build up good speed and accuracy. They can be found online with a simple Google search, you can also look for CAT questions as they are somewhat similar. You will not be able to go through and answer all the 68 questions in the given time limit, so be smart in choosing the sections you want to solve first and think will give you the maximum score. Also, please do not skip the subjective questions as they are easy, general questions with high score and no negative marking.</p><h4>Technical Test</h4><p>Around two weeks later they announced that I have cleared the first round. Next step was the technical assessment scheduled for 26th September. GS provided us with a general syllabus and pattern of the test. It had 5 sections with total duration of 2 hours 15 minutes.</p><p><strong><em>Section 1: 2 programming questions— 30 mins.</em></strong></p><p>Both questions were of easy to medium level. One of the questions had a given N number of chains, with links which could be opened or closed. The number of links in all N chains were also given. You had the find out the minimum number of links to be opened and closed to join all N chains together. So suppose you are given 2 chains of length 3 each, you can open the last link of the first chain and connect it with the first link of the second chain. So the output should be 1 for this case. I can’t recollect the other question properly as I didn’t get much time for this section :( .</p><p><strong><em>Section 2: Problem Solving 8 MCQs — 20 mins.</em></strong></p><p>These questions were all related to mathematics. Some of the topics were probability, number theory, set theory, algebra and logical reasoning. All questions will be unknown to you and with such a vast range of topics, it’s best to just brush up on some basic formulae and practice some questions available on the internet. I could solve around 4 of these.</p><p><strong><em>Section 3: Computer Science 7 MCQs — 25 mins.</em></strong></p><p>This section had questions on data structures (many about heaps), algorithms (like quicksort, binary search), operating systems (process scheduling), etc. They were all just the basics you study in college DSA lectures, but lengthy to implement in such a short time. Keep your basic DSA knowledge strong, practice the dry-run of all the basic algorithms and this part will be easy for you. Here too I could solve around 4 questions.</p><p><strong><em>Section 4: 1 advanced programming question — 45 mins.</em></strong></p><p>This question would require knowledge of some advanced DSA. The question said a lot of things, but in short it was asking to find out all the <a href="https://www.geeksforgeeks.org/articulation-points-or-cut-vertices-in-a-graph/">cut vertices of a given graph</a>. Graphs is a data structure I struggle with a lot, but I had prepared only the basic graph algorithms and I could complete the question using the concept of DFS. The test was on the HackerRank platform and you would get marked according to the number of test cases you pass.</p><p><strong><em>Section 5: 2 subjective questions — 15 mins.</em></strong></p><p>This had pretty basic questions like describing the motivation behind something you achieved, and what would you do if your friend has to leave in the middle of an important project. There was a 200 word limit for each question. It helps to always give your personal examples to explain the points you’re making.</p><p><strong>Tip:</strong> Considering CGPA as a section, you had to clear cutoff in at least three sections to be eligible for shortlisting. This means that if you have a very good CGPA, then clearing 2 sections in the test would also be enough. (This really helped me because my laptop had stopped working during the early part of my test, due to which I couldn’t attempt the first coding section as well as I could have, and I guess my CGPA saved me :P ) Having a good CGPA will always give you a better chance at off-campus recruitments. Again, don’t skip the subjective questions, and try to mark only the questions you’re sure about to avoid any negative marking. Guessing will not be worth the risk when you have worked so hard to reach here.</p><p>On 2nd October I was informed that I have cleared the technical assessment, and will be giving the interviews soon. To give you a background, I had no competitive programming experience before applying to GS (yes, “noob”). I have my interests in data science and have a few projects on it, an interesting one you can check out <a href="https://medium.com/towards-artificial-intelligence/create-your-own-harry-potter-short-story-using-rnn-and-tensorflow-853b3ed1b8f3"><strong>here</strong></a>. I could still crack GS by being very selective in my preparation, by approaching my seniors and people on LinkedIn to get any guidance I could possibly get, and of course, by consistently working hard for two months.</p><p>I started with reading all the past experiences of people interviewing at GS which you’ll find on <a href="https://www.geeksforgeeks.org/tag/goldman-sachs/">GeeksforGeeks</a>. After reading up all of it, you will get a very good idea about the kind of work you have to put in. You can also check out the company-wise questions on Leetcode and InterviewBit. I found InterviewBit to be better as it will show you a timer while you’re coding, which gives a good feel of the pressure you’ll face during interviews and tests. If you don’t have much prep time, then don’t give more than 1-2 hours to any particular question. Check the solution and try to fully understand the concept used, that’s what I did as many concepts were new to me. It is very important to cover a wider range of coding concepts instead of doing many questions of the same topic.</p><p>I was low on confidence a lot of times as I didn’t have any CP experience like all the others, but I have to thank <a href="https://www.youtube.com/c/AdityaVermaTheProgrammingLord/featured">Aditya Verma</a> for helping me gain my confidence. Anyone can just memorize the solutions to a coding problem, but he will teach you the concepts behind it so well that you’ll never have to learn any code. I religiously followed all his videos and soon I saw myself solving coding problems which seemed complicated to me before, with a lot of ease. I will strongly recommend his channel to everyone reading this. Dynamic Programming is a very important concept asked by GS to almost everybody, and I can safely say that nobody can teach DP better than him. Also check out <a href="https://www.youtube.com/watch?v=WNtzUR_MwUQ">Striver’s SDE Sheet</a> which you can follow as a 30 day routine to be ready for placements. It has problems to be solved daily which will cover all topics in a concise manner. Try to solve them without looking at the video solutions.</p><h4>The Interviews</h4><p>My interview was scheduled for 8th November on Zoom.</p><p><strong>Round 1:</strong></p><p>My first round took place at around 10 am, and my interviewer was very sweet and friendly. He started by introducing himself and then asked me to do the same. Then we discussed things like working on a Sunday, what web series I’d recommend to watch (as I had mentioned in my introduction that I like to binge-watch shows), a good light talk to make me comfortable. He then asked me what subjects I like in college so far. I mentioned Data structures and Algorithms from my previous semesters, then OOPS and DBMS from my ongoing semester.</p><p>He then asked me what is DBMS, and we discussed about a flight booking website like Google Flights, about how they would store the search activities of a user in order to give them email recommendations later on. He asked me how would I resolve any redundancy in storing such data for that website. The discussion went well, he seemed to agree on the idea I proposed.</p><p>Next he shared with me a HackerRank CodePair link. It’s just an online platform where we can see what code the other person is writing. There he asked me to write any algorithm to sort an array. So I wrote and explained the Quick Sort algorithm, along with it’s time complexities.</p><p>He then asked me the difference between an array and a linked list. Overall he was satisfied with all my answers and finally he asked if I had any questions for him.</p><p><strong>Round 2:</strong></p><p>After waiting for more than an hour, I had my second interview. He asked me for my introduction then immediately jumped to coding questions. Again, he shared the CodePair link and the first question was to find the <a href="https://www.youtube.com/watch?v=zmPj_Ee3B8c&amp;list=PL_z_8CaSLPWfxJPz2-YKqL9gXWdgrhvdn&amp;index=3"><em>maximum distance between two leaf nodes of a binary tree</em></a>. For this I had written a recursive function and explained my logic. I had made a mistake in calculating the distance in one part, which then he gave me hints about and I was able to correct it.</p><p>The next question was that given an unsorted integer array, find the minimum number of elements you’ll move in the array to make it sorted. He gave me a few examples to explain what he meant, then I started speaking out loud about the approaches I could take. First I was thinking about sorting the array and then comparing it with the given one to find the answer, but then it struck me that this is a DP problem. I gave him the idea of finding out the <a href="https://www.geeksforgeeks.org/longest-increasing-subsequence-dp-3/"><em>longest increasing subsequence</em></a> to get my answer, and he was satisfied with my logic. He then asked me to code just the DP logic which I did correctly.</p><p>The last question I was asked was a little tricky for me. Given some processes and the dependencies of those processes, how will you find out the order of execution? And which data structure would you use to store the dependencies? I understood that this would require a graph data structure, then I drew the graph in my notebook and tried DFS traversals on it to get the order. I wasn’t able to get the correct answer, but my interviewer was so helpful, he pointed out that I should reconsider the way I have drawn my graph. So then I made a few changes after which I realized it’s a <a href="https://www.geeksforgeeks.org/topological-sorting/"><em>topological sort</em></a> problem. So I immediately explained him the logic of using a stack with DFS, and he was happy. He didn’t require the code for it so with this my second interview was over.</p><p>Round 3:</p><p>Again after a long wait I had my third round of interview. He first asked me how my previous interviews went, then for my introduction and what my projects were about. Then he asked me a problem, that given a positive integer how will you find its square root up to 5 decimal places. I was asked to work out some logic on paper, and I took quite some time in figuring out an optimal solution. He gave me hints about using binary search but I still got stuck at a later point. After giving me a minute he decided to move on. He asked if I had attended their pre-placement talks which were held on Zoom about a month ago and if I had any questions from that session. That discussion went on for a few minutes and then my interview was over.</p><h4>Some more helpful tips:</h4><ul><li>Many other students who gave the interviews were asked about their <strong>projects</strong> in detail, so make sure you only put those things on your resume which you can explain very clearly. Just keeping 2 good projects are enough instead of mentioning10 small projects. Know those 2 projects well. Just keep your resume HONEST.</li><li>Goldman Sachs interviews are famous for asking <strong>puzzles</strong>. Just a day before your interview, read up on all the puzzles given <a href="https://www.geeksforgeeks.org/puzzles/">here</a>, and I feel that’s more than enough. Revising on basic <strong>probability</strong> and math can also be helpful if you have the time. Your questions totally depend on the interviewer and it’s best to be prepared for everything.</li><li>Do prepare on <strong>CS theory</strong> subjects specially if you are from CSE branch. Having basic knowledge of OOPS, DBMS and OS is important along with knowing some practical applications. For DBMS I found <a href="https://www.youtube.com/playlist?list=PLmXKhU9FNesR1rSES7oLdJaNFgmuj0SYV">Knowledge Gate</a> videos to be helpful (play at 1.5x speed, trust me). For OS and OOPS, the various articles on GeeksforGeeks are all you’ll need.</li><li><strong>First impression</strong> matters. So take some time to prepare your introduction as that is the first thing they will hear from you. GS likes smart and trustworthy people, so present your introduction well, and be completely honest about your personality.</li><li>Don’t panic when you get stuck. I know it’s easier said than done. The best way to make it better is to <strong>practice mock interviews</strong> with any teacher or senior (I will not suggest friends XD). Practice your introduction and basic HR questions in front of the mirror regularly so that you don’t stutter on the final day. If your interview will be virtual, do practice mock coding interviews with others by sharing your screen, specially if you don’t have the habit to actually type code on screen. (It’s just a lesson I learnt while giving the interview for another very good company a few days before GS. That failed interview really taught me how to perform better for GS interviews so please follow this point well.) Obviously, follow good coding practices like keeping good variable/function names (not just a, b, c, etc.) and indentation.</li><li>Coding in interviews is very different from competitive coding. So whenever you solve a coding question during your preparation, always <strong>think out loud</strong>. It is best to start with the brute-force solution. Practice writing the code on paper if there’s a face-to-face interview, or type if it’s virtual, and talk to yourself through the logic. Then gradually try to improve the time and space complexities. When you keep up this practice you’ll notice that your communication will improve to a great extent. It’s extremely important to communicate well with the interviewer because along with your code accuracy they also care about your thinking process, and will always give you hints when you’re stuck.</li><li>Reach out to as many people as you can. LinkedIn is a great platform to find employees of the company you’re aiming for, so check out their profiles and connect with them to get to know the kind of people they hire. Do good <strong>research</strong> about the company and it’s latest news. If you know your interviewer beforehand then get to know more about their work and show it during your interview that you’ve done your research and how you share their interests.</li><li>It is important to <strong>ask good questions</strong> to the interviewers in the end. Please do not ask things like how much will you earn, what is the culture and other generic questions. Listen to their introduction and ask them anything you found interesting in it. Ask about their own experience at the company, or anything which caught your eye in the pre placement talks. Basically make sure to show that you’re a good listener and you’re excited to work with them.</li></ul><p>I felt happy with my performance that day. I couldn’t solve the last question completely but I never lost my confidence. I was overwhelmed when I received the congratulations mail from GS on 18th November :)</p><p>Everything you’ll ever need to crack such interviews is already available online. What is required from your end is only consistency, hard work, and a positive mind.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89117274933b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/how-i-cracked-the-internship-interview-for-goldman-sachs-2021-89117274933b">How I cracked the internship interview for Goldman Sachs 2021</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating an Idempotent API using Node.js]]></title>
            <link>https://medium.com/dsc-hit/creating-an-idempotent-api-using-node-js-bdfd7e52a947?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/bdfd7e52a947</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[idempotency]]></category>
            <category><![CDATA[express]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Subhasis Das]]></dc:creator>
            <pubDate>Thu, 01 Oct 2020 16:41:52 GMT</pubDate>
            <atom:updated>2020-10-01T16:41:52.804Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_LAr9EmGwrwnwjwF" /><figcaption>Image Courtesy : <a href="https://zafulabs.com/2019/06/19/humans-can-code-too-idempotency/">https://zafulabs.com/2019/06/19/humans-can-code-too-idempotency/</a></figcaption></figure><p>Imagine this : you get back home from a long day at work, famished and hungry. So, you decide to order some food online and open your favorite food ordering app (lets call it ‘Buggy’ 😉). You select your food from your favorite restaurant on Buggy, place an order by completing the payment but then your app shows ‘Your order was not placed. Please retry’. Now given your ravenous appetite at the moment, you’d probably hit that retry button, pay again and maybe have your order placed successfully this time. You navigate to the order history page and boom! You find that two similar orders were placed and you’ve been charged FOR BOTH! Now how you deal with the Buggy customer service (and your bad luck🌚) is completely up to you but in this blog post I’ll illustrate how this problem could have been avoided in the first place.</p><p>Let’s analyze where things went wrong. In an ideal case, the following would have happened:</p><ol><li>You place an order on the Buggy client side app. The Buggy app would send an HTTP POST request to the Buggy server.</li><li>The Buggy server would handle the incoming request (provided it passes all the server side validations) by creating a new order in the database with the details sent in the request body of the POST request.</li><li>The server would respond with a status code 201 saying that a new order has been created(placed).</li><li>The client would receive this response and display an appropriate feedback (message) to the user.</li></ol><p>Clearly something must have gone wrong between steps 3 and 4. The communication between the client side app and the server might have been disrupted by a network failure (or a similar reason). This led to a false feedback to the end user and made them place another order. For a naïve user, it is natural to hit that retry button, but a good engineer’s job is to ensure that such a scenario never arises in the first place. Our system must have the capability to automatically retry failed requests safely — by not handling the same request twice. In other words, we must be able to identify duplicate requests to place the same order on the server and thus instead of creating a new order on the database, send a 304(not modified) response. This property is called <strong>idempotence</strong>.</p><p><a href="https://en.wikipedia.org/wiki/Idempotence">Wikipedia</a> defines <strong>idempotence </strong>as ‘ the property of certain <a href="https://en.wikipedia.org/wiki/Operation_(mathematics)">operations</a> in <a href="https://en.wikipedia.org/wiki/Mathematics">mathematics</a> and <a href="https://en.wikipedia.org/wiki/Computer_science">computer science</a> whereby they can be applied multiple times without changing the result beyond the initial application.’</p><p>According to the <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#:~:text=(A%20sequence%20is%20idempotent%20if,modified%20in%20the%20same%20sequence."><em>HTTP specification</em> <em>RFC 2616 section 9</em></a><em> </em>the HTTP verbs GET , PUT and DELETE are said to be idempotent whereas the verb <strong>POST is not idempotent by default. </strong>However, we use POST requests to create a resource on the server (or in this case, place an order). So let us see how we can use some minor tweaks to make the POST method act in an idempotent manner.</p><p>The idea is simple :</p><ol><li>Identify all incoming requests for order creation uniquely using a custom header called x-idempotence-key . This header shall bear an ‘idempotence key’, which shall basically be a unique ID generated on the client side (in JS we have the uuid package).</li><li>Every incoming request shall be cached along with it’s corresponding response on the server side using the custom header x-idempotence-key as the key. This cache could something as simple as a hash map or set (or an object in JS) or something as advanced as <a href="https://www.npmjs.com/package/redis">redis</a>.</li><li>We’d have a check (typically a middleware function) on the server side to determine if the incoming request has already been served. We do so by querying the cache using the idempotence key on the request. If it hits the cache, we send the cached response directly, else we pass it on to the handler for processing. This prevents the scenario where duplicate orders could be generated.</li></ol><p>Let’s write some code illustrate the above idea using Node.js and Express. (I’ll assume the reader has some basic familiarity with JavaScript, Node.js and Express).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/406e735cbbdc37527da980eaec49181d/href">https://medium.com/media/406e735cbbdc37527da980eaec49181d/href</a></iframe><p>In the above code, we do some trivial setup for an express project. The orders array is intended to serve as a mock database of orders, where every newly created order shall get stored. The value of the variable walletBalance (initialized to 100) reduces every time a successful order is placed. Now, if we run the server ( node non_idempotent.js ), we can test the endpoints using <a href="https://www.postman.com/">Postman</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gJDzHB89JZ9t6U_J3YWOvQ.png" /><figcaption>POST /place_order without idempotency</figcaption></figure><p>In the above endpoint we have placed an order of amount ‘50’ and that has led to the deduction of the amount from our walletBalance .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pEFO-XsX8XD1QqGVX6KQ3A.png" /><figcaption>GET /wallet_balance returns 50, the balance remaining after the order got placed.</figcaption></figure><p>Now, to replicate the scenario of duplicate requests, we simply send the POST request again using postman using the same request body …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/187/1*DibfbQnIBPpVQ4v674rZwA.png" /></figure><p>…and obtain the following response</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*ttik6qNgbO8B1XX9c3Tfdg.png" /><figcaption>Response with status code 201 on successful order creation</figcaption></figure><p>This also leads to further reduction of the wallet balance to 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/232/1*XmL4ZiD5YTLKY_wTyHTq4A.png" /></figure><p>Our goal is to prevent such a scenario — client may send a duplicate request, but it’s the server’s job to detect that as a duplicate and not process it. So now we introduce idempotency into the system in the following code :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eb0f546b96b606d65f41a370bbfc376d/href">https://medium.com/media/eb0f546b96b606d65f41a370bbfc376d/href</a></iframe><p>In the above code , we have added a new JS object called dummyCache which supposed to act as a mock cache for the application. We expect all POST requests shall have a header called x-idempotence-key . The value of this idempotence key could be anything that is unique in nature. Typically we’d use a <a href="https://www.npmjs.com/package/uuidv4">uuid</a> in JS (something like <em>11bf5b37-e0b8–42e0–8dcf-dc8c4aefc000).</em></p><p>In the POST request handler, we query the cache using x-idempotence-key at first. If if hits the cache, that means the request has been previously processed. So we send a response with a 304 status instead of actually processing it. If it misses the cache, it means this is a new request, so we go on to process it as usual. Note that in line 38, we add every request-response pair to the cache before sending the response to the client.</p><p>Now let’s run the code ( node idempotent.js ) and test the endpoints again using Postman.</p><p>First, we place an order using the POST endpoint, but this time we pass an extra header :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*moV9hwVtnXaGUIGW4ILNYQ.png" /></figure><p>…and the same body as before :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*knL01_p1jHmzNEAWF99KiA.png" /></figure><p>…and the response :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8YUagHDfAwS-QNKg5DZ76A.png" /><figcaption>Response on successful order creation with 201 status</figcaption></figure><p>The wallet balance has now reduced by 50, as expected:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sLBq08A0FgZkhvIWj_16tA.png" /><figcaption>Response from GET /wallet_balance</figcaption></figure><p>Now to replicate the duplicate request scenario, we send the request to the POST endpoint again, with the same header and body. Notice the response this time :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aaJmiysGvBof9v0zoO_umA.png" /><figcaption>Empty response with 304 status</figcaption></figure><p>We receive an empty response with a 304 (Not modified) status. This means that the second order for amount of 50 was not processed. We can further verify this by checking the wallet balance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dn_WPirigmZQKCN3uNVA-Q.png" /><figcaption>Wallet balance after duplicate request call</figcaption></figure><p>As we can see, the wallet balance is still 50, which simply means the second order was not processed by the server.</p><p>So that’s how Idempotency can be implemented on a POST endpoint in an express server. Just a simple caching mechanism! Feel free to have a look at the code <a href="https://github.com/subhasis020299/idempotence-demo">here</a>.</p><p><strong>NOTE: This code is not production grade. It’s only meant for a simple demonstration of the above idea.</strong></p><h3><strong>Client Side :</strong></h3><p>On the client side, we’d typically have a middleware or an interceptor that catches failed requests and retries them with the same idempotence key. If you’re using JS frameworks like React, React Native or Vue, I’d suggest using the <a href="https://www.npmjs.com/package/axios">axios</a> npm package. You can configure “interceptors” in axios that would catch failed requests and retry them using the same idempotence key (somewhat like a middleware!). Refer to <a href="https://medium.com/datadriveninvestor/axios-instance-interceptors-682868f0de2d">this </a>amazing blog post on axios interceptors .You could also use npm packages like <a href="https://www.npmjs.com/package/axios-retry">axios-retry</a>.</p><p>Hope you found this useful. 😃</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdfd7e52a947" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/creating-an-idempotent-api-using-node-js-bdfd7e52a947">Creating an Idempotent API using Node.js</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Data Scientist’s Treasure Trove.]]></title>
            <link>https://medium.com/dsc-hit/a-data-scientists-treasure-trove-5b27af2ed0e?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/5b27af2ed0e</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[data-scientist]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[MD Fazal Mustafa]]></dc:creator>
            <pubDate>Fri, 11 Sep 2020 09:25:14 GMT</pubDate>
            <atom:updated>2020-04-03T06:04:07.901Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*izHbPW5E0E12u9JQrLhTmg.jpeg" /><figcaption>photo by Shutterstock.</figcaption></figure><p>Well, who is a Data Scientist? I know some of you are thinking that. Some who have been reading tech blogs and have the word in media must be wondering What’s the difference between a Data Scientist and Machine Learning Engineer? Aren’t they all the same?</p><p>Well let’s resolve these few questions first then we will go on a Treasure Hunting part, cool. Let’s Begin.</p><p>So a Data Scientist is someone who applies machine learning, statistical methods, and exploratory analysis to data to extract insights and aid decision making. He also does Data Cleaning, ETL(Extract, Transform &amp; Load because sometimes you have raw data that’s not ready to for applying Data Science techniques on it), a little bit of Database Management, Data Visualization and Data Analysis. Yup, that’s it. I know it’s a lot that&#39;s why most companies have Data Science teams.</p><p>Okay, a Data Scientist is not the same as a Machine Learning Engineer. Because a Data Scientist can do all the job of an ML engineer but an ML engineer cannot do all the job of a Data Scientist. Because primarily Data scientists are not required just to train neural networks, many times they have to answer questions. They are provided a database and are asked to answer any number of questions, draw insights from the data. While an ML engineer doesn’t derive insights or cleans data, prepare data or even do database management. ML engineer is required to work with very complex algorithms and many times are required to come up with their own algorithms in order to get a model with the highest accuracy possible.</p><p>Okay now lets dive into Treasure Island of a Data Scientist. We will discuss packages or libraries whatever you prefer to call them. So for a Data Scientist there are 3 kinds of packages:-</p><ol><li>Scientific Computing packages.</li><li>Visualization packages</li><li>Machine Learning packages.</li></ol><h3><strong>Scientific Computing packages</strong></h3><h3>1. Pandas</h3><p><em>Pandas</em> is an open-source Python package that provides high-performance.It helps help developers work with “labeled” and “relational” data intuitively. It’s based on two main data structures: “Series” (one-dimensional, like a list of items) and “Data Frames” (two-dimensional, like a table with multiple columns).</p><p>Pandas is a perfect tool for data wrangling or munging. It is designed for quick and easy data manipulation, reading, aggregation, and visualization. Pandas take data in a CSV or TSV file or a SQL database and create a Python object with rows and columns called a data frame.</p><h3>2. Numpy</h3><p><em>NumPy</em> is one of the most fundamental packages in Python for array-processing. It provides high-performance multidimensional array objects and tools to work with the arrays. NumPy is an efficient container of generic multi-dimensional data.</p><p>The library offers many handy features performing operations on n-arrays and matrices in Python. It helps to process arrays that store values of the same data type and makes performing math operations on arrays (and their vectorization) easier.</p><p>NumPy is used to process arrays that store values of the same datatype. NumPy facilitates math operations on arrays and their vectorization. This significantly enhances performance and speeds up the execution time correspondingly.</p><h3>3. Scipy</h3><p>SciPy library contains modules for efficient mathematical routines as linear algebra, interpolation, optimization, integration, and statistics. The main functionality of the SciPy library is built upon NumPy and its arrays. SciPy makes significant use of NumPy.</p><p>SciPy uses arrays as its basic data structure. It has various modules to perform common scientific programming tasks as linear algebra, integration, calculus, ordinary differential equations, and signal processing.</p><h3>Visualization Packages</h3><h3>1. Matplotlib</h3><p>This is a standard data science library that helps to generate data visualizations such as two-dimensional diagrams and graphs (histograms, scatterplots, non-Cartesian coordinates graphs). Matplotlib is one of those plotting libraries that are really useful in data science projects — it provides an object-oriented API for embedding plots into applications.</p><p>It is a close resemblance to MATLAB embedded in Python programming language. Matplotlib can help in making Histograms, bar plots, scatter plots, area plots to pie plots and many other visualizations.</p><h3>2. Seaborn</h3><p>Seaborn, is a data visualization library based on Matplotlib that provides a high-level interface for drawing attractive and informative statistical graphics. Putting it simply, seaborn is an extension of Matplotlib with advanced features.</p><p>Well, the difference between Matplotlib and Seaborn is that Matplotlib is used for basic plotting; bars, pies, lines, scatter plots and stuff whereas, seaborn provides a variety of visualization patterns with less complex and fewer syntax.</p><h3>3. Folium (Geographic Information System library)</h3><p>It essentially helps in working with maps. Folium makes it easy to visualize data that’s been manipulated in Python on an interactive leaflet map. It enables both the binding of data to a map for choropleth visualizations as well as passing rich vector/raster/HTML visualizations as markers on the map.</p><p>The library has a number of built-in tilesets from OpenStreetMap, Mapbox, and Stamen, and supports custom tilesets with Mapbox or Cloudmade API keys. Folium supports both Image, Video, GeoJSON, and TopoJSON overlays.</p><h3>Machine Learning Libraries</h3><h3>1. Scikit Learn</h3><p>Scikit Learn is a robust machine learning library for Python. It features ML algorithms like SVMs, random forests, k-means clustering, spectral clustering, mean shift, cross-validation and more. Even NumPy, SciPy and related scientific operations are supported by Scikit Learn with Scikit Learn being a part of the SciPy Stack.</p><p>Data scientists use it for handling standard machine learning and data mining tasks such as clustering, regression, model selection, dimensionality reduction, and classification. Another advantage? It comes with quality documentation and offers high performance.</p><h3>2. TensorFlow</h3><p>TensorFlow is an AI library that helps developers to create large-scale neural networks with many layers using data flow graphs. TensorFlow also facilitates the building of Deep Learning models, pushes the state-of-the-art in ML/AI and allow easy deploy of ML-powered applications.</p><p>It is used by all giant companies. It can do Voice/Sound Recognition, Sentiment Analysis, Face Recognition, Time Series, Video Detection, etc. Its really powerful and one of the most mature and highly community-backed ML library in the world.</p><h3>3. Keras</h3><p>Keras is TensorFlow’s high-level API for building and training Deep Neural Network code. It is an open-source neural network library in Python. Keras only provides high-level APIs while TensorFlow provides both high-level and low-level APIs.</p><p>It’s very straightforward to use and provides developers with a good degree of extensibility. The library takes advantage of other packages, (Theano or TensorFlow) as its backends. Moreover, Microsoft integrated CNTK (Microsoft Cognitive Toolkit) to serve as another backend. It’s a great pick if you want to experiment quickly using compact systems.</p><h3>4. Pytorch</h3><p>PyTorch is a framework that is perfect for data scientists who want to perform deep learning tasks easily. The tool allows performing tensor computations with GPU acceleration. It is open-source. The Tesla cars for level 3 autonomy uses Pytorch and have made their own custom stack over Pytorch for training their neural networks.</p><p>PyTorch is based on Torch, which is an open-source deep-learning library implemented in C, with a wrapper in Lua.</p><p>Now there are many other very useful, important and famous packages like NLTK, Spacy, Bokeh, Plotly, ggplot, statsmodel, XGBoost, Bokeh, OpenCV, YOLO, etc. We will discuss them later. Today my aim was to introduce the top 10 most important packages that are like a treasure for Data scientists.</p><h3>Know your author</h3><p>I am a 2nd-year IT undergrad who is mad behind autonomous vehicles. That deep interest of mine makes me study Data Science, Machine Learning, Deep Learning, and Computer Vision. I have a crush on AR too. Thus sometimes to follow that crush I do get involved in Unity and App Development with Android or Flutter. This is my first technical blog. Show your love.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b27af2ed0e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/a-data-scientists-treasure-trove-5b27af2ed0e">A Data Scientist’s Treasure Trove.</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Run, break, study, re-run. The 3G from GNU toolchain is here to make your life easier.]]></title>
            <link>https://medium.com/dsc-hit/run-break-study-re-run-the-3g-from-gnu-toolchain-is-here-to-make-your-life-easier-d5147c9e9bc0?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/d5147c9e9bc0</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[configuring-gdb]]></category>
            <category><![CDATA[process-communication]]></category>
            <category><![CDATA[code-injection]]></category>
            <category><![CDATA[gnu]]></category>
            <dc:creator><![CDATA[Divya Rachel Goswami]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 19:02:11 GMT</pubDate>
            <atom:updated>2021-01-25T23:11:23.607Z</atom:updated>
            <content:encoded><![CDATA[<h3>Run, break, study, re-run, dump. The 3G from GNU tool chain is here to make your life easier.</h3><p>While gorging down your favorite snack, what tells your hands to stop before you die from overeating? Well thanks to our operating systems, we never need to check over our process queue to ensure everything is working smooth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*0x2oyDOACE8mgObB7tbibA.jpeg" /></figure><p>So does this box thingy in our hands also needs a check over it’s workflow?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CIjdZa3Zvh7WZd79aZduVA.jpeg" /><figcaption>Just a screenshot of my dramatic phone’s log file.</figcaption></figure><p>What stops them from <strong>*dying*</strong> from overeating? While diagnosing disorders in us doesn’t require anatomizing ourselves, in the IT world there are tools that can be used to troubleshoot or “Look What’s Inside?” any operating system and how process communication work.</p><blockquote>*enter stage <strong>The 3G</strong>. Here’s a short bio for each:</blockquote><p>gcc : the GNU project C and C++ compiler. Involves preprocessing, compilation, assembly and linking.<br>gdb : the GNU Debugger. Allows you to see what happens “inside” a program when it executes.<br>gcov : the GNU coverage testing tool. Helps you to discover untested parts of your code, helps you to analyze the number of times every line of your code is executed.</p><p>To know more about each of them, open your terminal, type man followed by any of them.</p><p>To investigate their business and their roles in systems development, we will now create a tiny subsystem of 2 processes communicating with each other.</p><blockquote>I will summon the powers of IPC and SIGNALs to help me make them talk.</blockquote><p>A brief little map of how I established communication:</p><ul><li>Neighbour1 creates a shared memory segment and <em>*invites*</em> anyone willing to share the place with him(I have used ftok() to create the key, shmget() to get the memory, shmat() to attach a pointer which will point to the process id).</li><li>Neighbour2, knowing the address of neighbour1’s house, decides to live with him(I have used shmget() to get the memory of the previous process, shmat() to attach pointer to the previous process id, shmdt() to detach the pointer).</li></ul><p>Read more about <a href="https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.3.0/com.ibm.zos.v2r3.bpxbd00/rftok.htm"><strong><em>process communication</em></strong></a> and <a href="http://www.csl.mtu.edu/cs4411.ck/www/NOTES/signal/kill.html"><strong><em>signal handling</em></strong></a>.</p><p>These are the neighbours we’ll be studying today. One annoys, while the other tries to <em>calm</em> things down and provides the user with 3 options:</p><blockquote>The nextdoor neighbour annoys me. What should I do to him? Kidnap, kill or let him go?</blockquote><p>Neighbour 1(annoying infinite looped process disturbing neighbour 2):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d6a1884324dfa3087e7f8fc9b6ab090a/href">https://medium.com/media/d6a1884324dfa3087e7f8fc9b6ab090a/href</a></iframe><p>Neighbour 2(resolves by sending signals to neighbour 1):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9413bb1398c2a7ef2de4c370a47eb22/href">https://medium.com/media/b9413bb1398c2a7ef2de4c370a47eb22/href</a></iframe><p>Compile both the processes using gcc. Although, we will use different flags for each. <br>For process 1, we will analyze code coverage using gcov. Compile using:</p><pre>$gcc -Wall -fprofile-arcs -ftest-coverage neighboour1.c -o neighbour1</pre><p>For process 2, we will experiment and try changing the user input data in the course of execution process using gdb.(Wait. Is that possible?) Compile using:</p><pre>$gcc -g neighbour2.c -o neighbour2</pre><p>Alright! Now that our mini ecosystem is created, we employ the 3G to analyse what’s going on. Execute them to make them talk. You can either execute them in 2 different windows, or use the following to send neighbour1 to background and execute them simultaneously:</p><pre>$./neighbour1 &amp; ./neighbour2</pre><p>Both of them should work. Now, what will a normal user do to a process annoying him? Kill? Kidnap? Let’s see:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fyd2oAlZPoSk%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Dyd2oAlZPoSk&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2Fyd2oAlZPoSk%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/8c8b835a6cd9b28a9c2a7f3c95f682e7/href">https://medium.com/media/8c8b835a6cd9b28a9c2a7f3c95f682e7/href</a></iframe><p>So we see process 2 ended up killing process 1. Although just before getting killed neighbour 1 dumped his execution logs. Let’s analyze that. Remember gcov? Next step:</p><pre>$gcov neighbour1</pre><pre>File &#39;neighbour1.c&#39;<br>Lines executed:55.10% of 49<br>Creating &#39;neighbour1.c.gcov&#39;</pre><pre>$cat neighbour1.c.gcov</pre><p>What you now see is the number of times each line of code is executed/checked. Here’s a snippet for you to relate:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J7iNcgoUYDZvbiCQl1iFlw.png" /><figcaption>neighbour1.c.gcov</figcaption></figure><p>Owkay..time for repentance. Now it’s time to employ gdb . Did you notice that the user opted to spare the life of his fellow neighbour.</p><blockquote>Can’t he be let go once? A second chance? Why so cruel?</blockquote><p>Suppose the user has the evil intention to always kidnap or kill or send corrupted data. So…can you check on the input data and change it while it gets executed? Of course input data is received, there shouldn’t be any way you can change values of variables while they’re still inside your process memory? However gdbcan do it for you! Here’s how:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FsUqmS0sUaFo%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DsUqmS0sUaFo&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FsUqmS0sUaFo%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/1647c3c49f06b2988f9fa730d92238d1/href">https://medium.com/media/1647c3c49f06b2988f9fa730d92238d1/href</a></iframe><ul><li>Invoke debugging using gdb ./neighbour2 . Now we create 2 *stops* in the program where we can examine the value of the variables. Create breakpoints at the declaration and at the calling of find() .</li><li>Use command list or lto view the line numbers and break &lt;line number&gt; or b &lt;line number&gt;to set the breakpoints.</li><li>Now use run or rto start execution inside the debugger. The process will ask for an input as usual, enter a choice(This is the value we will attempt in changing).</li><li>When it reaches it’s 1st breakpoint, examine all the local variables using info locals . After that, enter continueto reach the next breakpoint.</li></ul><pre>Breakpoint 2, main (argc=1, argv=0x7fffffffddc8)<br>    at neighbour2.c:67<br>67                      i=find(randv, randt);<br>(gdb)info locals<br>pid = 8623<br>keygen = 1929685536<br>shmid = 20774943<br>shmptr = 0x7ffff7ff6000<br>i = 21845<br>randt = 2<br>randv = 0x555555757260<br>(gdb)continue<br>Continuing.</pre><ul><li>At the next breakpoint(which will be at the defination of find()), we examine the values again to ensure the input value(which is key=2 in our case)has been passed correctly. As the variables here are not local, we use info args :</li></ul><pre>Breakpoint 1, find (tree=0x555555757260, key=2)<br>    at neighbour2.c:33<br>33          if (! tree)<br>(gdb) info args<br>tree = 0x555555757260<br>key = 2</pre><blockquote>Cool. So… neighbour1 is about to get killed. Can we save him?</blockquote><ul><li>We now attempt in changing the value of key. Follow:</li></ul><pre>(gdb) compile code key=3;<br>(gdb) continue<br>Continuing.</pre><pre>Breakpoint 1, find (tree=0x5555557572c0, key=3)<br>    at neighbour2.c:33<br>33          if (! tree)<br>(gdb) info args<br>tree = 0x5555557572c0<br>key = 3<br>(gdb) continue<br>Continuing.</pre><p>Welps! Using compile code we were successful to change the value of the input data. Guess who just got saved?</p><pre>Sent SIGUSR2 signal to neighbour. Neighbour 8623 is spared</pre><p>So there you go! Today we learnt how to analyze inter-process communication(and even change the messages) with the help of <strong><em>The 3G</em></strong>. Legends say that 3G is always around you. They&#39;re just a few commands away. Give them a call whenever you need ❤.<br>If you’re interested in further reading, these are some nice starting points:</p><ul><li><a href="https://www.gnu.org/software/libc/manual/html_node/Introduction.html#Introduction">Introduction (The GNU C Library)</a></li><li><a href="https://sourceware.org/gdb/talks/esc-west-1999/">The Heisenberg Debugging Technology</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F8PsbM0OpqPl9OClfSw%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F8PsbM0OpqPl9OClfSw%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F8PsbM0OpqPl9OClfSw%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="212" frameborder="0" scrolling="no"><a href="https://medium.com/media/5d1556b521763635bc62c6778f6fdd6b/href">https://medium.com/media/5d1556b521763635bc62c6778f6fdd6b/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5147c9e9bc0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/run-break-study-re-run-the-3g-from-gnu-toolchain-is-here-to-make-your-life-easier-d5147c9e9bc0">Run, break, study, re-run. The 3G from GNU toolchain is here to make your life easier.</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reincarnating Mozart With Tensorflow]]></title>
            <link>https://medium.com/dsc-hit/reincarnating-mozart-with-tensorflow-18b0a3353dff?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/18b0a3353dff</guid>
            <category><![CDATA[music]]></category>
            <category><![CDATA[music-generation]]></category>
            <category><![CDATA[recurrent-neural-network]]></category>
            <category><![CDATA[mozart]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Yashashwee Chakrabarty]]></dc:creator>
            <pubDate>Sun, 19 Apr 2020 17:38:00 GMT</pubDate>
            <atom:updated>2020-04-18T12:37:32.220Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*tCS6TSWQKLWSyc2g.jpg" /><figcaption>Wolfgang Amadeus Mozart (<a href="https://www.classicfm.com/">https://www.classicfm.com</a>)</figcaption></figure><h3>The Inspiration</h3><p>There are a very few things that move and inspire people like the works of Classical Maestros (note: the term classical from here on refers to European classical art music from the 1750s to early 1820s) such as Mozart, Beethoven, Bach, Debussy, Chopin and so many more, and since their demise the world has seen a downfall of Classical Music. So why not bring them back with the help of our friendly neighborhood Neural Networks. If this works out we’ll call it the first AI aided renaissance and maybe rewrite the script of Terminator where Skynet ends up being a grumpy old classical musician.</p><p>As a musician I’ve always taken pride in the fact that while other professions “lose their importance” with progresses made in the field of AI, art will always remain a man made task, or will it?</p><p><a href="https://github.com/Yashashwee/Neural_Nets/blob/master/Mozart.ipynb">Here</a> is the GitHub link to all the code for this project if you have trouble following and if you’re here just to enjoy some sweet AI music skip to the end!</p><h3>Background</h3><p>Before we get into the building neural networks lets first get the basics straight</p><h3>Data</h3><p>We’ll be using the Mozart data from the <a href="https://www.kaggle.com/soumikrakshit/classical-music-midi">Classical Music MIDI</a> data set to train our network. MIDI or Musical Instrument Digital Interface is a standard way for digital transmission of musical instrument data. Technically, its a list of notes, when to play them and for how long. In our data there are 3 different kinds of data points, <a href="https://en.wikipedia.org/wiki/Musical_note">notes</a>, <a href="https://en.wikipedia.org/wiki/Chord_(music)">chords</a> and <a href="https://en.wikipedia.org/wiki/Rest_(music)">rests</a>. Notes are the building blocks of music in western music theory and we have 12 of them, namely A, A#, B, C, C#, D, D#, E, F, F#, G and G#, each occur at multiples of a certain frequency for instance the middle C or C4 on a piano has a frequency of 261.6 Hz. When we bunch a few notes together (in a musical sense) we form a chord. Lastly rests are, as the name suggests, moments of silence in the piece. We omit the rests from the data to make our problem simpler.</p><h3>Music21</h3><p><a href="https://web.mit.edu/music21/">Music21</a> is a Python toolkit used for computer-aided musicology. It allows us to teach the fundamentals of music theory, generate music examples and study music and we’ll be using it to covert our midi data into something our network understands. Think of it as a translator between two unspoken languages.</p><h3>Recurrent Neural Networks</h3><p>Recurrent Neural Networks or RNNs are a class of feed-forward artificial neural networks that have internal memory. Here the output of the current input depends on the past computation (kind of like sequential electronic circuits if you come from an electronic background). After producing the output, it is copied and sent back into the recurrent network. For making a decision, it considers the current input and the output that it has learned from the previous input.</p><h3>Keras</h3><p>Keras (for this project) is TensorFlow’s high-level API for building and training deep learning models. We’ll also be using its Tokenizer class to convert our list of notes to tokens which are easily “understood” by our network.</p><h3>Preprocessing</h3><p>Our midi data once passed through the Music21 parser will be a list of chord and note classes. Something like this</p><pre>.<br>.<br>.<br>&lt;music21.chord.Chord F#4 D4&gt;<br>&lt;music21.note.Note F#&gt;<br>&lt;music21.note.Note E&gt;<br>&lt;music21.note.Note F#&gt;<br>&lt;music21.note.Note A&gt;<br>&lt;music21.chord.Chord E4 G4&gt; <br>&lt;music21.note.Note G&gt;<br>.<br>.<br></pre><p>While it somewhat makes sense to the human eye, our network won’t like it one bit so to please our network we’ll need some coding magic. First, lets get rid of all the unnecessary words and turn this into a list of notes and chords with the following code:</p><pre>notes=[]</pre><pre>count = 0</pre><pre>for file in glob.glob(&#39;classical-music-midi/mozart/*.mid&#39;):<br>    count += 1<br>    print(count)<br>    midi = converter.parse(file)<br>    note_in_song = None</pre><pre>    parts = instrument.partitionByInstrument(midi)<br>    <br>    #check if there are different parts for separate instruments<br>    if parts:<br>        notes_in_song = parts.parts[0].recurse()<br>    else:<br>        notes_in_song = midi.flat.notes</pre><pre>for element in notes_in_song: <br>        if isinstance(element,note.Note):<br>            notes.append(str(element.pitch))<br>        elif isinstance(element,chord.Chord):<br>            notes.append(&#39;z&#39;.join(str(n) for n in element.normalOrder))</pre><p>We get all the midi files in the Mozart folder and we parse it using Music21. If we encounter a note we put it in the list in its alphabetic representation such as ‘C4’, ‘A#3’ etc. If we encounter a chord we put it’s notes in numeric format separated by a ‘z’ such as ‘9z1z4’, ‘1z3’ etc. Notice that we are only looking for chords or notes so all other classes like tempo, rest etc are filtered out, we can take that up in a future project to improve the music sense of our network. In the end we get a list like this:</p><pre>[...&#39;A5&#39;, &#39;D3&#39;, &#39;9z1z4&#39;, &#39;E2&#39;, &#39;E3&#39;, &#39;9z1z4&#39;, &#39;E3&#39;, &#39;E3&#39;, &#39;8z11z2z4&#39;, &#39;E2&#39;, &#39;E3&#39;, &#39;9z1z4&#39;...]</pre><p>Now we tokenize our notes, i.e assign an integer to each note and chord in our data. We could do this manually but keras has the Tokenizer class to help us out with that. We first need to convert our list into a string of notes and chords as tokenizer is meant to be used on sentences and not list of words.</p><pre>music_sentence = [&quot; &quot;.join(str(item) for item in notes)]</pre><pre>print(music_sentence)</pre><pre>tokenizer = Tokenizer()<br>tokenizer.fit_on_texts(music_sentence)<br>total_classes = len(tokenizer.word_index)+1<br>print(total_classes)<br>sequence = tokenizer.texts_to_sequences(music_sentence)[0]</pre><p>We get a sequence of integers that represents our data in a form that the network understands. If we print out the total_classes variable here we see there are 179 different classes of objects in out data. Sounds like a lot but our model can tackle it without breaking a sweat (<a href="https://en.wikipedia.org/wiki/Natural_language_processing">NLP</a> tasks usually have thousands of different classes).</p><p>Now we split the data into inputs and labels. So, lets pause for a second and think this through. Unlike traditional classification tasks where there are separate inputs and labels present, here we have a constant stream of data. One way of tackling this is to take the first ’n’ objects from the list and make the network predict the (n+1)th object. Then we take the next ’n’ objects and repeat the same. That’s our plan, now lets write some code again:</p><pre>sequence_len = 100</pre><pre>network_in = []<br>network_out = []</pre><pre>for i in range(0,len(sequence)-sequence_len):<br>  sequence_in=sequence[i:i+sequence_len]<br>  sequence_out=sequence[i+sequence_len]<br>  network_in.append(sequence_in)<br>  network_out.append(sequence_out)</pre><pre>network_in = np.array(network_in)<br>label = ku.to_categorical(network_out,num_classes=total_classes)</pre><p>We take a sequence of 100 here and make the 101th element our label. We convert the input to a numpy array and the<a href="https://hackernoon.com/what-is-one-hot-encoding-why-and-when-do-you-have-to-use-it-e3c6186d008f"> one hot encode</a> our labels so now they’re matrix of integers where all the elements are zero except for the ones at the index which matches with the number at the output. And with that we come to the end of our preprocessing job.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*NWMC_9THxBvIRE4C.jpg" /><figcaption>(<a href="https://authorpreneur.amymorse.co.uk/">https://authorpreneur.amymorse.co.uk</a>)</figcaption></figure><h3>Building and Training</h3><p>Now we come to the part which is easy to code but difficult to grasp, building and training our neural network. I went through a bunch of models and ended up using this one, which is a pretty common NLP model, because it was just easier to understand and explain, and that’s really important when it comes to building neural networks. So here’s the star of the show:</p><pre>model = Sequential()<br>model.add(Embedding(total_classes,100,input_length=sequence_len))<br>model.add(Bidirectional(LSTM(150, return_sequences = True)))<br>model.add(Dropout(0.2))<br>model.add(LSTM(100))<br>model.add(Dense(total_classes/2, activation=&#39;relu&#39;, kernel_regularizer=regularizers.l2(0.01)))<br>model.add(Dense(total_classes, activation=&#39;softmax&#39;))<br>model.compile(loss=&#39;categorical_crossentropy&#39;, optimizer=&#39;adam&#39;, metrics=[&#39;accuracy&#39;])<br>print(model.summary())</pre><pre><br>################################################################</pre><pre>Model: &quot;sequential_1&quot;<br>_________________________________________________________________<br>Layer (type)                 Output Shape              Param #   <br>=================================================================<br>embedding_1 (Embedding)      (None, 100, 100)          18000     <br>_________________________________________________________________<br>bidirectional_1 (Bidirection (None, 100, 300)          301200    <br>_________________________________________________________________<br>dropout_1 (Dropout)          (None, 100, 300)          0         <br>_________________________________________________________________<br>lstm_3 (LSTM)                (None, 100)               160400    <br>_________________________________________________________________<br>dense_2 (Dense)              (None, 90)                9090      <br>_________________________________________________________________<br>dense_3 (Dense)              (None, 180)               16380     <br>=================================================================<br>Total params: 505,070<br>Trainable params: 505,070<br>Non-trainable params: 0<br>_________________________________________________________________<br>None</pre><h3>The Model</h3><p><a href="https://machinelearningmastery.com/use-word-embedding-layers-deep-learning-keras/"><strong>Embedding</strong></a><strong>:</strong> This layer takes our input and embeds it onto a dense vector. There are many popular methods of learning word embedding (considering our notes and chords to be words) such as word2vec and GloVe.</p><p><a href="https://colah.github.io/posts/2015-08-Understanding-LSTMs/"><strong>LSTM</strong></a><strong>: </strong>is a Recurrent Neural Net layer that takes a sequence as an input and can return either sequences (return_sequences=True) or a matrix.</p><p><a href="https://machinelearningmastery.com/develop-bidirectional-lstm-sequence-classification-python-keras/"><strong>Bidirectional LSTM</strong></a><strong> </strong>are an extension of traditional LSTMs that can improve model performance on sequence classification problems. In problems where all timesteps of the input sequence are available, Bidirectional LSTMs train two instead of one LSTMs on the input sequence. The first on the input sequence as-is and the second on a reversed copy of the input sequence. This can provide additional context to the network and result in faster and even fuller learning on the problem.</p><p><a href="https://machinelearningmastery.com/dropout-regularization-deep-learning-models-keras/"><strong>Dropout</strong></a><strong>: </strong>A simple and powerful regularization technique for neural networks and deep learning models. We use it here to prevent overfitting.</p><p><a href="https://medium.com/datathings/dense-layers-explained-in-a-simple-way-62fe1db0ed75"><strong>Dense layers</strong></a> or <strong>fully connected layers</strong> is a fully connected neural network layer where each input node is connected to each output node.</p><p>Ours is quite a humble model which is more like a proof of concept than state of the art. We use <a href="https://gombru.github.io/2018/05/23/cross_entropy_loss/">categorical cross entropy</a> since this is a multi-class (here the classes are all the notes and chords in our data) problem.</p><h3>Training</h3><p>Let us first train our model for 100 epochs to see whether its even worth our time or not. We’ll train it, save the model so that we can get the trained weights whenever needed and then we’ll analyse it using a plot:</p><pre>history = model.fit(network_in,label,epochs=100,batch_size=512,verbose=1)</pre><pre>model.save(&#39;Models/epoch100Test&#39;)</pre><pre>acc = history.history[&#39;accuracy&#39;]<br>loss = history.history[&#39;loss&#39;]</pre><pre>epochs = range(len(acc))</pre><pre>plt.plot(epochs, acc, &#39;b&#39;, label=&#39;Training accuracy&#39;)<br>plt.title(&#39;Training accuracy&#39;)</pre><pre>plt.figure()</pre><pre>plt.plot(epochs, loss, &#39;b&#39;, label=&#39;Training Loss&#39;)<br>plt.title(&#39;Training loss&#39;)<br>plt.legend()</pre><pre>plt.show()</pre><p>This gives us an accuracy of 0.7802 and a loss of 0.9167 which isn’t great but once you look at the graph, it looks promising and graphs don’t lie:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*Vx6Jnua9FpoIz3IK80Phtg.png" /><figcaption>Trained for 100 epochs with batch_size=512</figcaption></figure><p>You can see both the training accuracy and loss haven’t achieved their minimums or become asymptotic.</p><p>Our next step will be to train it for a larger number of epochs and maybe reduce the batch_size number. Lets go with 200 epochs with batch_size of 256.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*T9JfHvEZkughHegHhr2yYA.png" /><figcaption>Trained for 200 epochs and batch_size of 256</figcaption></figure><p>This time we get an accuracy of 0.9285 and a loss of 0.3151. Quite a huge jump in accuracy so now lets get down to creating a new Mozart with it!</p><h3>Generating Music</h3><p>This is what we’ve been waiting for all along, the final test! But wait we need there’s still one hurdle left, <strong>converting everything back to midi. </strong>We’ll need to make a dictionary to convert our tokens back to notes and chords, then finally we can take all that and convert to midi.</p><pre>note_to_int = tokenizer.word_index<br>int_to_note = {v:k for k,v in note_to_int.items()}</pre><pre>start = np.random.randint(0,len(network_in)-1)</pre><pre>pattern = network_in[start]<br>prediction_output = []</pre><pre>for i in range(500):<br>  prediction_in = np.reshape(pattern,(1,len(pattern),1 ))</pre><pre>  prediction = model.predict(prediction_in,verbose=0)</pre><pre>  pred_index = np.argmax(prediction)<br>  result = int_to_note[pred_index]<br>  prediction_output.append(result)</pre><pre>  pattern = np.append(pattern,pred_index)<br>  pattern = pattern[1:len(pattern)]</pre><p>We take a random starting point as a seed for generating new sequence, this will be our initial input to the predict function. We take this prediction and using numpy’s argmax function we check which index has the highest value, that is our predicted index (or token), we convert it back to a note or chord using the dictionary we created. We append our pattern sequence with this index and slice it to take everything except the first element, this becomes our input for the next iteration. Neat!</p><pre>offset = 0<br>output_notes = []</pre><pre>for pattern in prediction_output:<br>  if(&#39;z&#39; in pattern) or pattern.isdigit():<br>    notes_in_chord = pattern.split(&#39;z&#39;)<br>    notes = []<br>    for curr_note in notes_in_chord:<br>      new_note = note.Note(int(curr_note))<br>      new_note.storedInstrument = instrument.Piano()<br>      notes.append(new_note)<br>    new_chord=chord.Chord(notes)<br>    new_chord.offset = offset<br>    output_notes.append(new_chord)<br>  else:<br>    new_note=note.Note(pattern)<br>    new_note.offset=offset<br>    new_note.storedInstrument = instrument.Piano()<br>    output_notes.append(new_note)<br>  offset += 0.5<br>midi_stream = stream.Stream(output_notes)<br>midi_stream.write(&#39;midi&#39;,fp=&#39;MidiOut/epoch200Mozart2.mid&#39;)</pre><p>Now that we have our predicted sequence of notes and chords we just need to convert everything back to midi and we are done. We take each element in the predicted sequence and check if it is a chord or a note. If its a chord, we get all the building notes for it, stack them together and build a chord class, else we convert the note to a note class and put them in the same list. Here after every iteration we increase the offset by 0.5 else everything will play at the same time. Then we just use the write function to put everything in a midi file and we’re done!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*wZW0MWmmhjnQcRpN.jpg" /><figcaption>(<a href="https://makeameme.org/">https://makeameme.org</a>)</figcaption></figure><h3>Result</h3><p>Before we break it down and analyse things, if you made it here just take a break and pat yourself on the back. You’ve made it through a lot of coding and technical mumbo jumbo. You rock champ! Here is our results:</p><p>This is what our 100 epoch test sounds like</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Fplaylists%252F1034984920%26show_artwork%3Dtrue&amp;display_name=SoundCloud&amp;url=https%3A%2F%2Fsoundcloud.com%2Fyashashwee-chakrabarty%2Fsets%2Fmozartepoch100&amp;image=https%3A%2F%2Fsoundcloud.com%2Fimages%2Ffb_placeholder.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/86001706ed5bfe383f720d6623744b61/href">https://medium.com/media/86001706ed5bfe383f720d6623744b61/href</a></iframe><p>And here’s what 200 epoch sounds like:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fw.soundcloud.com%2Fplayer%2F%3Furl%3Dhttps%253A%252F%252Fapi.soundcloud.com%252Fplaylists%252F1034985682%26show_artwork%3Dtrue&amp;display_name=SoundCloud&amp;url=https%3A%2F%2Fsoundcloud.com%2Fyashashwee-chakrabarty%2Fsets%2Fmozartepoch200&amp;image=https%3A%2F%2Fsoundcloud.com%2Fimages%2Ffb_placeholder.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=soundcloud" width="800" height="166" frameborder="0" scrolling="no"><a href="https://medium.com/media/85633a157d522a4adc99978bda5856db/href">https://medium.com/media/85633a157d522a4adc99978bda5856db/href</a></iframe><p>Although to an untrained ear it sounds like someone’s falling down a staircase made with the keys of a piano, there are some patterns in there, especially in the 200 epoch one which is evident by the sheet given below. Around the 5th bar it starts ascending the scale like its building tension and then falls back into the same pattern. But if you keep listening, the longer it goes the weirder it gets. This is because in models like this the probability of correct prediction starts falling the further we go from the initial seed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fWoAh-mXiZmn_Mgs1i74FA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHipkWhTd0bEHUPLhL3kjA.png" /></figure><h3>Conclusion</h3><p>Some of you may argue that the sounds the model produced is absolute garbage and you’d be right. But it was never the purpose of this project to actually reproduce Mozart’s musical intellect. The purpose of this project was to learn and understand how RNNs work and to understand their interaction with different types of data. While there is no structure to the music, no beginning or ending I am still optimistic about what we can achieve with this method!</p><p>Here are some of the things we can do to improve our results:</p><ol><li>Try out different architectures</li><li>Take rests and tempo changes into account</li><li>Think of <a href="https://www.masterclass.com/articles/melody-vs-harmony-similarities-and-differences-with-musical-examples">melody and harmony</a> separately</li></ol><p>If you followed along and built your own version of this here’s a cat congratulating you:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/0*-oBW8S1M30r1lhu8.jpg" /><figcaption>(SendScraps.com)</figcaption></figure><p>Mail me your queries at yashashwee99@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18b0a3353dff" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/reincarnating-mozart-with-tensorflow-18b0a3353dff">Reincarnating Mozart With Tensorflow</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Piyush talks about S.O.L.I.D Principles.]]></title>
            <link>https://medium.com/dsc-hit/piyush-talks-about-s-o-l-i-d-principles-80130f5133ac?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/80130f5133ac</guid>
            <category><![CDATA[solid-principles]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[uncle-bob]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Piyush Maheswari]]></dc:creator>
            <pubDate>Sat, 11 Apr 2020 15:40:14 GMT</pubDate>
            <atom:updated>2020-04-11T15:40:14.310Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*LEpaMXyU_0qC5IG_z0V2IQ.jpeg" /><figcaption>Just making sure that you know!</figcaption></figure><p>This has to be one of the few questions you would hear in an interview. But there obviously you&#39;ll have only 5 minutes to prove that you know this.</p><p><em>I’m here to make you sure that you&#39;ve got this!</em></p><p><strong>SOLID</strong> is one of the most important acronyms in the world of Object-Oriented Programming.</p><blockquote>Why should you care about SOLID programming?</blockquote><p>First of all, you have to realize you are not going to be forever where you are. If we use standards and well-known architectures, we can be sure that our code will be easy to maintain by other developers that come after us, and I’m sure you wouldn’t want to deal with the task of fixing a code that didn’t apply any known methodology as it would be very hard to understand it.</p><p>Let&#39;s jump right in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*aPcGEHIbYlL_lj2KqQodqQ.gif" /><figcaption>I know you’ve been waiting!</figcaption></figure><h3>What does SOLID stand for?</h3><ol><li><strong>S</strong> — Single Responsibility Principle.</li><li><strong>O</strong> — Open Closed Principle.</li><li><strong>L</strong> — Liskov Substitution Principle.</li><li><strong>I — </strong>Interface Segregation Principle.</li><li><strong>D — </strong>Dependency Inversion Principle.</li></ol><h3><strong>S</strong>ingle <strong>R</strong>esponsibility <strong>P</strong>rinciple:</h3><blockquote>A class should have only one reason to change.</blockquote><p>As its name suggests, this principle implies that a class/module must do only <strong>one</strong> thing, have only <strong>one</strong> responsibility. If our class does more than one thing, then we should <strong>split</strong> the functionalities into different classes.</p><p>In the context of the Single Responsibility Principle (SRP), we define <strong>responsibility</strong> as “a reason for change”. If you can think of more than one motive for changing a class, then that class has more than one responsibility.</p><p><em>Example. Let&#39;s suppose we have a </em><strong>Phone </strong><em>which has different functions like Calling, Messaging, Calculator, FlashLight, etc. Now when we define this class, we’ll have one </em><strong>Phone.java </strong><em>file, which will contain all the functions. Now, this class violates the SRP Principle as this class has been assigned multiple responsibilities. To make the class stop violating the principle, we should define the responsibilities in separate classes like </em><strong>Calling.java, Messaging.java, Calculator.java, </strong><em>thus making short components/classes and dividing the responsibilities.</em></p><p><strong>Android </strong>specific <em>Example. The method </em><strong>onBindViewHolder</strong><em> of the RecyclerView widget. The role of the </em><strong>onBindViewHolder</strong><em> is to map a list item to a view. There should be no logic in this method. So if there&#39;s any code that relates to the logic, you should probably remove from there.</em></p><h3>Open Closed Principle:</h3><blockquote>Software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification.</blockquote><p>This basically means that we should add extension points in classes that implement requirements that are intrinsically unstable due to instability in the business domain and refactor parts of code and introduce additional extension points when these parts proved to be unstable.</p><p><strong>Android </strong>specific <em>Example. Extending </em><strong>RecyclerView.Adapter</strong><em> class is easy and we can easily create custom adapters. Developers can easily extend this class and create their own custom adapter with custom behavior without modifying the existing </em><strong>RecyclerView.Adapter</strong><em> class.</em></p><p><em>Another Example. can be lookin</em>g <em>at Buttons, Switches, Checkboxes inherit all from </em><strong>TextView</strong><em> class. This means that </em><strong>TextView</strong><em> is open to extension but closed for modifications.</em></p><h3>Liskov Substitution Principle:</h3><blockquote>Objects in a program should be replaceable with instances of their subtypes <strong>without changing</strong> the behaviour of that program.</blockquote><p>This means that a subclass should override the methods from a parent class that does not break the functionality of the parent class.</p><p><em>Example. In mathematics, a </em><strong>Square</strong><em> is a </em><strong>Rectangle</strong><em>. Indeed it is a specialization of a rectangle. The “is a” makes you want to model this with inheritance. However if in code you made </em><strong>Square</strong><em> derive from </em><strong>Rectangle</strong><em>, then a </em><strong>Square</strong><em> should be used anywhere you expect a </em><strong>Rectangle</strong><em>. This makes for some strange behavior. Imagine you had </em><strong>SetWidth</strong><em> and </em><strong>SetHeight</strong><em> methods on your </em><strong>Rectangle</strong><em> base class; this seems perfectly logical. However, if your </em><strong>Rectangle</strong><em> reference pointed to a </em><strong><em>Square</em></strong><em>, then </em><strong>SetWidth</strong><em> and </em><strong>SetHeight</strong><em> do not make sense because setting one would change the other to match it. In this case, </em><strong>Square</strong><em> fails the Liskov Substitution Test with </em><strong>Rectangle</strong><em> and the abstraction of having </em><strong>Square</strong><em> inherit from </em><strong>Rectangle</strong><em> is a bad one.</em></p><p><strong>Android </strong>specific <em>Example. We should write the custom RecyclerView adapter class in such a way that it still works with RecyclerView. We should not write something which will lead the RecyclerView to misbehave.</em></p><h3>Interface Segregation Principle:</h3><blockquote>Classes that implement interfaces, should not be forced to implement methods they do not use.</blockquote><p>This means that if an interface becomes too fat, then it should be split into smaller interfaces so that the client implementing the interface does not implement methods that are of no use to it.</p><p>ISP relates to important characteristics — <strong>cohesion</strong> and <strong>coupling</strong>.<br> Ideally, your components must be highly tailored. It improves code robustness and maintainability.</p><p>Enforcing ISP gives you the following bonuses:</p><ul><li>High <strong>cohesion</strong>— better understandability, robustness.</li><li>Low <strong>coupling</strong> — better maintainability, high resistance to changes.</li></ul><p><em>Example. Again going to the previous example of </em><strong><em>Phone, </em></strong><em>if we have a public interface for the whole functionality, like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*AcWeXzVuiihvWZh6wfHDAQ.png" /></figure><p><em>Now if you want to implement a Calculator, the functions </em><strong><em>dial(),lightOn() </em></strong><em>and</em><strong><em> lightOff() </em></strong><em>are useless. Thus we should refactor the code to something like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*h8uEAJgOoVLeGBbAyZhZ_Q.png" /></figure><p><em>Now, the desired class can implement one or more interfaces according to wish. This is how we can prevent violating ISP.</em></p><h3>Dependency Inversion Principle</h3><blockquote>High-level modules should not depend on low-level modules. Both should depend on abstractions.</blockquote><p>and</p><blockquote>Abstractions should not depend on details. Details should depend on abstractions.</blockquote><p>If you use a class inside another class, this class will be dependent on the class injected. The importance of DIP can be distilled down to a singular goal of being able to reuse software components that rely upon external dependencies for a portion of their functionality.</p><p><em>Example. If we have a class </em><strong><em>Bank</em></strong><em> that has the following code, the calling class of Bank is unaware of the </em><strong><em>hidden dependencies</em></strong><em>, thus this violates DIP.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*mOmrwU876tOTMxtS9A7jwg.png" /></figure><p><em>On another hand, if we refactor the code to something like this:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*5s8jAIg3mKVXNKZ3wUUwFQ.png" /></figure><p><em>In this case, we are letting the calling class of </em><strong><em>Bank</em></strong><em> aware of the dependencies involved, instead of letting the class itself create a dependency. This also helps in the case of testing!</em></p><h3>Conclusion:</h3><p>The SOLID Principles, are some of the most important set of principles to learn and implement if you are following Object-Oriented Design. It may seem a bit overwhelming initially, but with practice and time, you will be coding based on these principles, without even realizing it. <em>(Copied from StackOverflow :D)</em></p><figure><img alt="Yayy!" src="https://cdn-images-1.medium.com/max/498/1*5cIdmPVsSvEZtOFLap34kw.gif" /><figcaption>Yayyyy!</figcaption></figure><p>Enjoy! Happy coding!</p><p>Feel free to leave a comment if something is not clear or if you have questions.</p><p>-Piyush Maheswari.</p><p>In case you want to reach out: <a href="https://twitter.com/OnlyMaheswari">Twitter</a> , <a href="https://www.linkedin.com/in/piyush-maheswari-835424138/">LinkedIn</a> , <a href="https://github.com/Piyush2769"><em>Github</em></a><em> .</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80130f5133ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/piyush-talks-about-s-o-l-i-d-principles-80130f5133ac">Piyush talks about S.O.L.I.D Principles.</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[C++ Vectors : Understanding Its Importance & Its Use In Competitive Programming.]]></title>
            <link>https://medium.com/dsc-hit/c-vectors-understanding-its-importance-its-use-in-competitive-programming-1b1efa09aa6c?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/1b1efa09aa6c</guid>
            <category><![CDATA[competitve-programming]]></category>
            <category><![CDATA[cplusplus]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kanisht Agarwal]]></dc:creator>
            <pubDate>Sat, 11 Apr 2020 13:01:30 GMT</pubDate>
            <atom:updated>2021-11-07T11:55:06.611Z</atom:updated>
            <content:encoded><![CDATA[<h3>C++ Vectors: Understanding Its Importance &amp; Its Use In Competitive Programming.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_7ABKnD0Zhb0XLcA85K7jA.jpeg" /></figure><p>The main focus of this blog is to understand <strong>the key concepts </strong>of vector and how to <strong>implement </strong>them with ease in Competitive programming. This has been written on the basis of my experience and I have tried to include all the necessary information related to it. And I hope after going through this blog you will be able to appreciate this fact.</p><h3>What is a Vector?</h3><p>An obvious question for a beginner. So in simple words, a vector is simply an array but it is a little different from an array. It might sound fishy but the catch is: its main use is to overcome the disadvantages of an array.</p><h4>Disadvantages of Array:</h4><ul><li>Elements can not be deleted.</li><li>The dynamic creation of arrays is not possible.</li><li>Multiple data types can not be stored.</li></ul><p>So in a nutshell, a vector is a <strong>dynamic array</strong> that has the ability to resize itself when an element is inserted or deleted.</p><p><strong>Some important points related to vectors:</strong></p><ul><li>Vector elements are placed in contiguous storage so that they can be accessed and traversed using <a href="https://www.geeksforgeeks.org/iterators-c-stl/"><strong>iterators</strong></a>.</li><li>In vectors, data is inserted at the <strong>end</strong>. Inserting at the end takes differential time, as sometimes there may be a need of extending the array.</li><li>Removing the last element takes only constant time because no resizing happens. Inserting and erasing at the <strong>beginning </strong>or in the <strong>middle</strong> is linear in time.</li><li>The header file required for vectors is <strong>#include&lt;vector&gt;.But if we use the header file #include&lt;bits/stdc++.h&gt;,then we don’t need to mention #include&lt;vector&gt;.</strong></li></ul><h3>The syntax for declaring a vector:</h3><pre>vector&lt;data_type&gt;name_of_vector;</pre><p>For example, a vector of <strong>int</strong> data-type can be declared as</p><pre>vector&lt;int&gt;v;</pre><p>Here v is the name of the vector and we can declare any name provided it is not a <strong>reserved keyword</strong>. In a similar fashion, we can have vectors of data types: long and long long int.</p><h3>Insertion and Deletion of data in a vector:</h3><p>To <strong>insert</strong> values into our vector we use the function <strong>push_back() i.e; to push values inside the vector </strong>and to calculate the<strong> size </strong>of the vector being formed we will use the function <strong>size()</strong>. The time complexity of <strong>push_back() </strong>is O(1).</p><p><strong>NOTE:</strong></p><pre>For <strong>push_back():</strong></pre><pre><strong>Parameter:</strong> The value to be inserted in the <strong>vector</strong> is <br>passed as a parameter.</pre><p>For example, refer to the following CPP:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72b9b728f75a11ef1f0ce0dc6f62e254/href">https://medium.com/media/72b9b728f75a11ef1f0ce0dc6f62e254/href</a></iframe><p>The output of the above code:</p><pre>1 3 8 23 99<br>5</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*BYsCiX0_sfPomeJ_GNF4kQ.png" /><figcaption>In this way, values are getting stored in the vector.</figcaption></figure><p>While solving problems we might come across a scenario, where we need to take a large number of integers and if suppose we are storing it in a vector, we can’t go on writing <strong>push_back</strong> function. Instead we use a loop(for/while) and we <strong>declare</strong> a variable say <strong>x, and</strong> then we take <strong>input</strong> into <strong>x</strong> and then we <strong>push</strong> this <strong>x</strong> into our vector.</p><p>For a better understanding refer to the C++ code given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6f662a37fce146323f5c6e0d8ad649db/href">https://medium.com/media/6f662a37fce146323f5c6e0d8ad649db/href</a></iframe><p>Inputs:</p><pre>n: 10<br>1 2 4 6 7 7 8 0 4 6</pre><p>Output:</p><pre>The values inside v are : 1 2 4 6 7 7 8 0 4 6<br>size of v : 10</pre><p>Like we mention the size of an array before taking inputs, the same can be done for vectors as well. For example:</p><pre>vector&lt;int&gt;v(5);  // vector of size 5</pre><p>The above declaration creates a vector of size 5, very similar to an array of size {5}. And then we can take inputs into it as an array and if we want to increase its size we can do it via <strong>push_back().</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d41222eeecddf134cefaf365e5886c98/href">https://medium.com/media/d41222eeecddf134cefaf365e5886c98/href</a></iframe><p><strong>Input:</strong></p><pre>1 4 6 9 8</pre><p><strong>Output:</strong></p><pre>Initial Size : 5<br>1 4 6 9 8 <br>New Size : 6<br>1 4 6 9 8 12</pre><p><strong>One thing to note in the above code</strong> is that we added only one element via push_back function; <strong>we could have added any number of elements </strong>into the vector according to our requirement.</p><h4>Deletion of data from a vector:</h4><p>This can be done by using the function <strong>pop_back() </strong>and its<strong> </strong>time complexity is O(1). <strong>But there is a catch, we can’t delete any element from a vector. </strong>By using<strong> pop_back() we can only remove an element(one element at a time) from the end of a vector </strong>and upon using this function, the size of the vector<strong> automatically reduces by one and it seems like that the element is permanently deleted. “But it is NOT the case the element which was supposed to be deleted still persists and it&#39;s just not being traversed as the length of the vector size decreases by 1 unit.”</strong></p><p><strong>NOTE:</strong></p><pre><strong>For pop_back():</strong></pre><pre><strong>parameter:</strong>No parameters are passed.</pre><p>For a better understanding of the above statements refer to the given C++ code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7eecc717ae19043f78ffab91662f6657/href">https://medium.com/media/7eecc717ae19043f78ffab91662f6657/href</a></iframe><p><strong>Output:</strong></p><pre>5<br>Elements of the vector initially : 1 3 8 23 99<br>updated size : 4<br>Elements of the vector now : 1 3 8 23<br>The last element : 99</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9QBuY_GiFwVnQf1liHghtw.png" /><figcaption>This is how push_back( ) works!</figcaption></figure><p><strong>Now you might be thinking</strong> how to delete an element in the 0th index or any index in a vector. So for this, we use <strong>erase</strong>() function.</p><p><strong>NOTE:</strong></p><pre><strong>Syntax:<br></strong><br>vector_name.erase(index);  <strong>//For erasing a particular element.</strong></pre><pre><strong>/*For removing a range of elements from any position. */</strong></pre><pre>vector_name.erase(starting index,ending index);</pre><pre><strong>Parameter:</strong><br>Position of the element to be removed in the form of <a href="https://www.geeksforgeeks.org/iterators-c-stl/">iterator</a>.<br>or the range specified using start and end iterator.</pre><p>As mentioned in the above parameter we need an iterator to get the position of the element which we want to erase. So for that, we must know about <strong>begin()</strong>.</p><p>Before moving to the C++ code for <strong>understanding the application of erase() ;</strong>lets discuss about <strong>begin()</strong> function. This function returns the beginning position of the vector. In other words, it returns an iterator which points to the 0th index upon using <strong>begin()</strong> function.</p><p><strong>Syntax for begin():</strong></p><pre>vector_name.begin();</pre><pre><strong>Parameters</strong>: No parameters are passed<br></pre><p>Now if suppose the name of the vector is m; so <strong>m.begin()</strong> gives the 0th position or index but if we want the 3rd index. So clearly,( <strong>m.begin()+3) will give the 3rd position.</strong></p><p>Refer to the following C++ code to have a clear understanding.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f496bdfc10f62573ad2eaa14333c65ff/href">https://medium.com/media/f496bdfc10f62573ad2eaa14333c65ff/href</a></iframe><p><strong>Input</strong>:</p><pre>1 4 6 9 8 2 3</pre><p><strong>Output:</strong></p><pre>Initially elements in the vector : 1 4 6 9 8 2 3 <br>Third element: 9<br>Elements in the vector after 1st operation : 1 4 6 8 2 3</pre><p>For a better understanding of <strong>how to erase a range of values from a vector </strong>refer to the C++ code given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dc5fb433fb790b5cccffd3d286b54146/href">https://medium.com/media/dc5fb433fb790b5cccffd3d286b54146/href</a></iframe><p><strong>Input:</strong></p><pre>1 4 6 9 8 2 3</pre><p><strong>Output:</strong></p><pre>Initially elements in the vector : 1 4 6 9 8 2 3 <br>Elements in the vector after 1st operation : 1 4 3</pre><h3><strong>Some important functions of STL for vectors:</strong></h3><ul><li><strong>begin(): </strong>As discussed earlier it returns an iterator which points to the beginning of the vector or the 0th index. Its time complexity is O(1)</li><li><strong>end(): </strong>It returns an iterator that points to the end of the vector or just after the last element of the vector. Its time complexity is O(1).</li></ul><p><strong>Syntax for end():</strong></p><pre>vector_name.end()</pre><pre>Parameters: No parameters are passed.</pre><ul><li><strong>sort(): </strong>As the name suggests this function is used to <strong>sort</strong> the vector elements in <strong>ascending order. </strong>This function is also used for <strong>arrays </strong>and is very useful and it uses <strong>quicksort algorithm.</strong></li></ul><p><strong>Syntax for sort():</strong></p><pre><strong>For arrays</strong>: Consider an <strong>array</strong> <strong>a[n]</strong> of <strong>size n:</strong></pre><pre><strong>sort(a,a+n);</strong></pre><pre><strong>For vectors:</strong>Consider a<strong> vector v :</strong></pre><pre><strong>sort(v.begin(),v.end());</strong></pre><p>Now you must be thinking about how to arrange the vector elements in <strong>descending order</strong> in an efficient way by using <strong>sort(). </strong>So here is the<strong> solution:</strong></p><pre>For<strong> sorting </strong>an<strong> array </strong>in<strong> descending </strong>order of<strong> size n:</strong></pre><pre><strong>sort(a,a+n,greater&lt;int&gt;());</strong></pre><pre>For<strong> sorting a vector </strong>in<strong> descending </strong>order<strong>:</strong></pre><pre><strong>sort(v.begin(),v.end(),greater&lt;int&gt;());</strong></pre><ul><li><strong>reverse(): </strong>This function is used to <strong>reverse</strong> the elements in the vector.</li></ul><p><strong>Syntax for reverse():</strong></p><pre><strong>reverse(v.begin(),v.end());</strong></pre><p>Refer to the C++ code given below for understanding the above concepts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e468817efbd7ebc179af3babb73a3a37/href">https://medium.com/media/e468817efbd7ebc179af3babb73a3a37/href</a></iframe><h4>Output:</h4><pre>5<br>The elements in the vector before sorting : 2 4 3 6 9 <br>The elements in the vector after applying sort() : 2 3 4 6 9 <br>The elements in the vector after applying sort() (descending) : <br>9 6 4 3 2 <br>The elements in the vector after applying reverse() : 2 3 4 6 9</pre><ul><li><strong>swap()</strong>: This function is used to <strong>swap</strong> the contents of one vector with the contents of another vector.</li></ul><p><strong>Syntax for swap():</strong></p><pre><strong>vector_name1.swap(vector_name2);</strong></pre><pre><strong>Parameters:</strong><br>The name of the vector with which<br>the contents have to be swapped.</pre><p>Refer to the C++ code given below for understanding the above concepts:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9dc15157e6e2f6b124f33d6beaa0ca5/href">https://medium.com/media/c9dc15157e6e2f6b124f33d6beaa0ca5/href</a></iframe><h4>Output:</h4><pre>The elements in the 1st vector :2 4 3 6 9 <br>The elements in the 2nd vector :5 7 3 1 6</pre><pre>The elements in the 1st vector :5 7 3 1 6 <br>The elements in the 2nd vector :2 4 3 6 9</pre><ul><li><strong>clear(): </strong>This function<strong> deletes </strong>all the elements from the vector and assigns an empty vector. Its time complexity is O(N) where N is the size of the vector.</li></ul><h4><strong>Syntax:</strong></h4><pre>vector_name.clear();</pre><h4>Illustration:</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9986154da5fe22285f8b43bb6e812046/href">https://medium.com/media/9986154da5fe22285f8b43bb6e812046/href</a></iframe><h4><strong>Output:</strong></h4><pre>The elements in the vector initially : 2 4 3 6 9 <br>The elements in the vector now :</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*t4V2C-OhYq_SeJYwHYOA6Q.jpeg" /></figure><h3><strong>I hope you liked this content.</strong></h3><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b1efa09aa6c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/c-vectors-understanding-its-importance-its-use-in-competitive-programming-1b1efa09aa6c">C++ Vectors : Understanding Its Importance &amp; Its Use In Competitive Programming.</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Developer Communities : A Complete Roadmap(Kolkata Edition)]]></title>
            <link>https://medium.com/dsc-hit/developer-communities-a-complete-roadmap-kolkata-edition-810393a792a1?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/810393a792a1</guid>
            <category><![CDATA[community]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[meetup]]></category>
            <category><![CDATA[kolkata]]></category>
            <dc:creator><![CDATA[Rupdeep Saha]]></dc:creator>
            <pubDate>Sat, 14 Dec 2019 11:11:51 GMT</pubDate>
            <atom:updated>2019-12-14T11:11:51.611Z</atom:updated>
            <content:encoded><![CDATA[<h3>Developer Communities : A Complete Roadmap(Kolkata Edition)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AviJs9VE1CfJHOtfGxjx3A.png" /></figure><h3>Why are they important?</h3><p>Developer communities enable us to share, collaborate and learn with like-minded people in the community. It also provides new developers a place to learn, discover their interests and a support system for all the awesome work they want to do. Being a part of a developer community we stand to gain immense knowledge, skills and tips in order to be a better developer.</p><blockquote>“I am super excited, but where to start?”</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FQNFhOolVeCzPQ2Mx85%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FQNFhOolVeCzPQ2Mx85%2Fgiphy-downsized.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FQNFhOolVeCzPQ2Mx85%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2b6547f21be6457739c4b706fab21dd/href">https://medium.com/media/e2b6547f21be6457739c4b706fab21dd/href</a></iframe><p>This is a question posed by a lot of newbies when they are introduced to the developer universe. For simplicity, we classify the developer communities into two categories- online and offline.</p><h3>Online Communities</h3><p>We have a number of online developer communities and forums where we can post questions, search for answers and gain knowledge about any topic under the sun. The most popular online communities are <a href="https://stackoverflow.com/">StackOverflow</a> and <a href="https://www.reddit.com/">Reddit</a>. StackOverflow is hands down the best platform to post questions, view answers and is the go-to site whenever you get stuck on something.</p><blockquote>NOTE: In order to have a developer profile on the Internet you must have:<br>1. A <a href="https://github.com/">Github</a> Account<br>2. A <a href="https://twitter.com/">Twitter</a> Account<br>3. A <a href="https://www.linkedin.com/">LinkedIn</a> Profile<br>4. A <a href="https://stackoverflow.com/">StackOverflow</a> Account</blockquote><h3>Offline Communities</h3><p>If we go to any major city in the world, we will be able to find a community for just about every major developer platform. These developer communities arrange meetups to discuss what’s new in their fields, what challenges they face on a daily basis and different ways of doing things. The best advantage of being in such a community is we always learn something new and can collaborate with like minded people with similar interests. New developers can discover and learn about their interests and get advice on how to get necessary skills in order to pursue it. Moreover these communities organise frequent bootcamps, study jams and fests so that people with no prior experience can gain proficiency in their area of interest.</p><blockquote>NOTE: All the communities mentioned henceforth are based in Kolkata,India. You can find similar communities in your city and/or campus.</blockquote><h3>Communities on a College/University level</h3><h3>Developer Student Clubs(DSCs)</h3><p>Every major college in the world has a DSC or a Developer Student Club. These clubs are powered by Google Developers and for most newbies is the first place where they are introduced to the developer universe. There are 677 DSCs in the world and 202 DSCs in India as of now.</p><p>We have 6 active DSCs in Kolkata and all of the DSCs have amazing leads who contribute to the community immensely.</p><p>The 6 DSCs are:</p><p>1. DSC NSEC<br>2. DSC HIT<br>3. DSC TIU<br>4. DSC GCELT<br>5. DSC IEM<br>6. DSC University Of Calcutta</p><blockquote>Know more about DSC: <a href="https://youtu.be/DcN_hcHXR_0">https://youtu.be/DcN_hcHXR_0</a><br>Find a DSC near you: <a href="https://developers.google.com/community/dsc/directory">https://developers.google.com/community/dsc/directory</a><br>DSC HIT’s Website: <a href="https://dschit.netlify.com/">https://dschit.netlify.com/</a><br>DSC HIT’s twitter handle: <a href="https://twitter.com/dscheritageit1">https://twitter.com/dscheritageit1</a><br>DSC NSEC’s Website: <a href="https://dscnsec.com/">https://dscnsec.com/</a><br>DSC NSEC’s twitter handle: <a href="https://twitter.com/dscnsec">https://twitter.com/dscnsec</a><br>DSC TIU’s Website: <a href="https://sites.google.com/view/dsc-techno-india-university/home">https://sites.google.com/view/dsc-techno-india-university/home</a><br>DSC TIU’s twitter handle: <a href="https://twitter.com/dsc_tiu">https://twitter.com/dsc_tiu</a><br>DSC GCELT’s website: <a href="https://dscgcelt.github.io/">https://dscgcelt.github.io/</a><br>DSC IEM’s twitter handle: <a href="https://twitter.com/dsc_iem">https://twitter.com/dsc_iem</a></blockquote><h3>Communities on a City/Regional level</h3><h3>Google Developer Groups(GDGs)</h3><p>Every major city in the world has a GDG or a Google Developer Group. They organise meetups and make sure that the developer community grows across the city. There are 936 GDGs in the world and 43 GDGs across India as of now. Our very own GDG Kolkata is one of the most active GDGs in India with amazing people at the helm of affairs. Every DSC works and collaborates with GDG to foster the growth of the developer community across the city. They focus on a range of platforms such as ML,AI,Web,Mobile,etc. They also organise annual DevFests which are community-led developer events hosted by Google Developer Groups around the globe. Recently GDG Kolkata hosted DevFest Kolkata with 650+ attendees and 20+ speakers. Learn more about it in this <a href="https://medium.com/gdg-kolkata/devfest-kolkata-putting-the-pieces-together-ce19d27ae5e6">article</a>.</p><blockquote>NOTE: <a href="https://www.meetup.com/">Meetup</a> is a platform for finding and building local communities. It is the go to platform to know about various meetups across the city organized by different communities.<br>For Android: <a href="http://meetu.ps/2ZhSyb">http://meetu.ps/2ZhSyb</a><br>For iOS: <a href="http://meetu.ps/2ZhShs">http://meetu.ps/2ZhShs</a></blockquote><blockquote>Find a GDG near you: <a href="https://developers.google.com/community/gdg/directory">https://developers.google.com/community/gdg/directory</a><br>DevFest Kolkata Highlights: <a href="https://youtu.be/1pOBvkE1to0">https://youtu.be/1pOBvkE1to0</a><br>GDG Kolkata Website: <a href="https://gdgkolkata.org/">https://gdgkolkata.org/</a><br>Meetup link: <a href="https://www.meetup.com/GDG-Kolkata/">https://www.meetup.com/GDG-Kolkata/</a> <br>Twitter handle: <a href="https://twitter.com/gdgkolkata">https://twitter.com/gdgkolkata</a></blockquote><h3>Women Techmakers(WTM)</h3><p>Google’s Women Techmakers program provides visibility, community, and resources for women in technology. It is an amazing initiative to empower and support women developers. Our own WTM Kolkata has amazing women who ensure that more and more women get associated with tech and contribute to the developer community.</p><blockquote>Women Techmakers Program: <a href="https://www.womentechmakers.com/">https://www.womentechmakers.com/</a><br>Know more about WTM: <a href="https://youtu.be/fknJH4qyOIc">https://youtu.be/fknJH4qyOIc</a><br>WTM Kolkata Website: <a href="https://wtmkolkata.in/">https://wtmkolkata.in/</a><br>Meetup link: Meetups are announced in the GDG Kolkata group<br>Twitter handle: <a href="https://twitter.com/WTMKolkata">https://twitter.com/WTMKolkata</a></blockquote><h3>Facebook Developer Circles</h3><p>Another community which has a worldwide presence is the Facebook Developer Circles powered by Facebook. They also organise frequent meetups on a range of topics and help grow the developer community.</p><blockquote>Find a circle near you: <a href="https://developers.facebook.com/developercircles/find">https://developers.facebook.com/developercircles/find</a><br>Facebook Developer Circle Kolkata: <a href="https://www.facebook.com/groups/186924858495604/">https://www.facebook.com/groups/186924858495604/</a></blockquote><h4><strong><em>We also have communities focussing on a specific platform. Some of the most active ones in Kolkata are:</em></strong></h4><h3>GDG Cloud Kolkata</h3><p>It focusses on GCP or the Google Cloud Platform. It also organises frequent cloud study jams on GCP and their adoption.</p><blockquote>Know more about cloud study jams: <a href="https://youtu.be/FvWl7Ftz1uM">https://youtu.be/FvWl7Ftz1uM</a><br>Meetup link: <a href="https://www.meetup.com/Google-Developer-Group-Cloud-Kolkata/">https://www.meetup.com/Google-Developer-Group-Cloud-Kolkata/</a></blockquote><h3>Kotlin Kolkata UG</h3><p>Kotlin is a programming language developed by JetBrains and is Google’s preferred language for Android app development. It is a very active community and a very enthusiastic one!</p><blockquote>Meetup Link: <a href="https://www.meetup.com/Kotlin-Kolkata-UG/">https://www.meetup.com/Kotlin-Kolkata-UG/</a><br>Twitter handle: <a href="https://twitter.com/KotlinKolkata">https://twitter.com/KotlinKolkata</a></blockquote><h3>AWS Kolkata Group</h3><p>AWS or Amazon Web Services is one of the best cloud computing services and is provided by Amazon. It is one of the most active communities in Kolkata and very recently hosted the AWS Community Day Kolkata which was a grand success.</p><blockquote>Slack Invite: <a href="https://lnkd.in/frbGZB8">https://lnkd.in/frbGZB8</a><br>WhatsApp Invite: <a href="https://chat.whatsapp.com/KCZabhZdo5NBY1IgNLRwjr">https://chat.whatsapp.com/KCZabhZdo5NBY1IgNLRwjr</a><br>Telegram Invite: <a href="https://lnkd.in/fQV5dz6">https://lnkd.in/fQV5dz6</a><br>Meetup Link: <a href="https://lnkd.in/f9Ah2UW">https://lnkd.in/f9Ah2UW</a><br>Twitter handle: <a href="https://lnkd.in/f5RwCPy">https://lnkd.in/f5RwCPy</a></blockquote><h3>Kubernetes and Cloud Native Computing Foundation(CNCF) Kolkata</h3><p>Kubernetes and Cloud Native Computing Foundation is a group for all who want to learn and share experiences about Kubernetes and other CNCF Projects.</p><blockquote>Meetup Link: <a href="https://www.meetup.com/Kubernetes-and-Cloud-Native-Computing-Foundation-Kolkata/">https://www.meetup.com/Kubernetes-and-Cloud-Native-Computing-Foundation-Kolkata/</a><br>Telegram Invite: <a href="https://t.me/joinchat/IDPcPkol7XLClx9ziXVoHA">https://t.me/joinchat/IDPcPkol7XLClx9ziXVoHA</a><br>Twitter handle: <a href="https://twitter.com/k8scncfkol">https://twitter.com/k8scncfkol</a></blockquote><h3>Hyperledger Kolkata</h3><p>Hyperledger is an open source collaborative effort created to advance cross-industry blockchain technologies governed by the Linux Foundation.</p><blockquote>Meetup Link: <a href="https://www.meetup.com/Hyperledger-Kolkata/">https://www.meetup.com/Hyperledger-Kolkata/</a></blockquote><h3>Mozilla Kolkata</h3><p>The community focusses on free and open source software(FOSS). Being a part of this community you can learn how to contribute to open source projects, how to learn programming in a efficient manner and also how to shed laziness of not contributing to open source projects.</p><blockquote>Telegram Invite: <a href="https://t.me/mozillakolkata">https://t.me/mozillakolkata</a><br>Follow <a href="https://twitter.com/dscheritageit1">@dscheritage1</a> on twitter to get updates on Mozilla Kolkata</blockquote><h3>Flutter Kolkata</h3><p>Flutter is Google’s UI toolkit for building beautiful, natively compiled applications for mobile, web, and desktop from a single codebase.</p><blockquote>Know more about Flutter: <a href="https://flutter.dev/">https://flutter.dev/</a><br>WhatsApp Invite: <a href="https://chat.whatsapp.com/JtVOceW0jEnB6pn6wMadyc">https://chat.whatsapp.com/JtVOceW0jEnB6pn6wMadyc</a></blockquote><h4>The above listed communities are in my opinion the most active. Many more communities can be found on Meetup.</h4><blockquote>I will continue to update this post, so stay tuned for more.</blockquote><blockquote>Did you know that you can give upto 50 claps on this post? If you enjoyed the ride, clap your hands 👏 as many times as you can to show your support.</blockquote><blockquote>Did I get something wrong? Lemme know in the comments below. I would love to improve.</blockquote><blockquote>Hello World, I am Rupdeep, just a simple guy who hopes to make it big one day. You can connect with me on <a href="https://www.linkedin.com/in/rupdeep-saha-400793183">LinkedIn</a> or follow me on <a href="https://twitter.com/i_m_Rupdeep">Twitter</a> if you wish to talk tech with me. Have a nice day ahead!</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=810393a792a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/developer-communities-a-complete-roadmap-kolkata-edition-810393a792a1">Developer Communities : A Complete Roadmap(Kolkata Edition)</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Experience with #IndiaBuildsActions]]></title>
            <link>https://medium.com/dsc-hit/my-experience-with-indiabuildsactions-69e7df620f12?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/69e7df620f12</guid>
            <category><![CDATA[actions-on-google]]></category>
            <category><![CDATA[google-developer]]></category>
            <category><![CDATA[indiabuildsactions]]></category>
            <category><![CDATA[dscindia]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Anjali]]></dc:creator>
            <pubDate>Sun, 10 Nov 2019 08:29:40 GMT</pubDate>
            <atom:updated>2019-11-10T08:29:40.387Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fAuNRixtXUpzWfa75_bCvw.jpeg" /></figure><p>Fresh into college, fresh into the club and it begins with #IndiaBuildsActions!</p><p>For a beginner like me, “Intents” meant Purpose, “fulfilment” was not more than an achievement of something but I came to know there is much more to words than just dictionary meanings.</p><p>With just the basic knowledge in programming, it was a bit daunting at first. Building an action that people could talk to, seemed like a lot of intense coding skills would be required for it, turned out there was much more to it than just coding. We had already seen the Heritage Helper in action and I was wondering how it might have been built… it was an Action. <em>*couldn’t resist the pun*</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/0*s_nwaEp-WwUkOwEG" /></figure><p>The First session started with a lot of commotion. Excitement and confusion of 100+ students with the availability of only 60+ seats. It began with students bringing in chairs from adjacent classes. The infamous “Jugaad”. Everyone was quite excited to be a part of AoG and at the same time wondered as — “what are the software requirements?” “How do we install them?” and most importantly, “Am I just wasting my time, or will I actually be able to contribute in this?”</p><p>*<em>Okay, I admit it, I made the last one up</em>*</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*Fquiu4ig7elsPo5J" /></figure><p>To be really honest, the senior students of the college or as they call themselves TA&lt;Teaching Assistant&gt; were there to help us out whenever we needed them both technically and mentally.</p><p>The event began with the senior quickly going through the slides. It was almost a loop of slides coming up, the theory explained, and the theory related to how heritage helper was built… Honestly, it was all mostly a blur because we were sort of busy setting our IDEs up(*hehe*), this was the first time we experienced a decent code editor like VS Code, git and at the in same time anticipating the hands-on.</p><p>Then after all the basic configurations and installation were done, we started working on the Heritage Helper, and that is when the fate turned its back on us :-p</p><p>We did the Intent and entities alright,</p><p>But it took some time for debugging the fulfillment. The fact that the `instructor` had an error on his screen now wasn’t any more encouraging :-p</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*zRuLlLkj8E3vhO7NI_qLZg.jpeg" /></figure><p>To top it all… GITLAB decided to migrate their servers at the same time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/478/1*L59o-QkcG1gkcWHuBIoZ6g.gif" /></figure><p>Then we kept trying to debug till the guard came and made us all run away.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*p6s8WlysClalj0x2fQhGOg.gif" /></figure><p>I also faintly remember having to fight for the Stickers that were a little too less. :)</p><p>Cut to the next session, where we started afresh. Actually better prepared this time, since the master deck had been shared with us, and the codelabs that were awesome. It is pretty obvious that since we all were working of the same project we would encounter some issues, so to discuss this, GitLab provided us with the feature “Issues.” Basically, it’s a great way to keep tracks of tasks, enhancements and bugs for projects like this. We were also given some idea regarding Markdown. GitLab has a syntax for formatting text called the GitLab Flavored Markdown. It has basic features which makes formatting text, comments, interactions with the users and pulling of the requests easier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A4gQU4Mtnz0YVNrl8pCwXg.png" /><figcaption>Why does GitLab’s Tanuki Logo not have any eyes?</figcaption></figure><p>The existing Templates provided by the Actions on google console were amazing as in a lot of cases all we didn’t even need to write a single line of code, all we needed to do was just to fill some basic information, add a few questions and the action was created!</p><p>However, we skipped that and had to work with Dialogflow. It has a good user-interface, is flexible, and also provides an AI powered system to help understand the user’s intent. We were told that this enabled us to make an app without making the effort of extracting the intents from the string(not sure what that means tho 😜)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*Eihz0DSReNK-WcDNFROddA.png" /><figcaption>Dialogflow is awesome and we Kinda loved using it!</figcaption></figure><p>I really got interested in Heritage Helper and joined the team. The basic idea was to create our own assistant that would serve the people on the campus as self-help to find the necessary things such as locations of particular Departments Heads, syllabus for coming semesters or even the canteen menu. On top of that, since this would be an open source, people from other institutes would be able to to use it just by modifying it as per their needs.</p><p>We began discussing on it’s architecture, built the entire dialog, as a play, and started brainstorming on how it worked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D-9-UdQJModQImDQ71v2hA.jpeg" /></figure><p>We were given around 10 links of videos from Google I/O 18, of which one was on how the persona of an assistant can be created. We were to watch them all before the next session. That was a tedious task as none of the videos were less than 40 minutes. The next session was all helter-skelter with no fixed classroom for discussion. In fact, the next three sessions were like that.</p><p><a href="https://events.google.com/io/schedule/?section=may-8&amp;topic=assistant#">Google I/O 2018</a></p><p>We were discussing the plan of action in the canteen or on the stairs or empty classrooms. We were no longer in the role of learners, but developers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TgeFjd8_XYdzgKa6sjkkUQ.png" /><figcaption>and being a developer is… confusing!</figcaption></figure><p>Coming back to the topic of creating a persona for the helper, we had an interactive session where we talked about responses of the helper in different instances and made a rough draft on it. Then came the fun part where we were assigned the work of writing the entire conversation for the Heritage Helper. I was quite excited about working on this. Two of us decided to work on it and made the entire conversation in one night, leaving all the other things which includes our assignments and that night’s sleep. <em>*Which explains the cranky behaviour next morning*</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*z3M3Af9LTAgVgeiQ4I5_Qg.gif" /><figcaption>if the helper wants to get selected, it needs a personality!</figcaption></figure><p>Nothing is perfect, nor was our final conversation draft. There were a few glitches in it, and we are still working on that. Sounds like a night wasted but for me till Bhaiya said ”It’s a great start” and that is exactly what we needed. That’s when we learnt that everything in the industry is made better with iteration. That the final product is built on top of so many un-final versions of it that we don’t see…<br>It will take a little time to lower my expectations maybe.</p><p>In the next session, we discussed other important aspects of the project. It involved coding with Javascript. A few people from the team were intently working on that so much that one of them even forgot to take a bath. For the whole day! <em>*Okay, I shouldn’t have spilled that out :p*</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7cA8j7ZKGhF4Pt5-cQ-uwg.jpeg" /><figcaption>He is in this photo. Sorry!! 🙈</figcaption></figure><p>We are all still working on the project hoping to turn it into a huge success. Plus, I am looking forward to the part where I get to write some code as well.</p><p>The story has not ended yet. There are still some unanswered questions like, did we manage to make a successful effort? Was it all really worth it? By investing so much time and effort working on it, did we actually serve the purpose for which it was created (Did it really save the time and effort of its users)? Did I actually learn some intense coding? :p</p><p>I’ll make sure that I keep you guys updated on what follows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4jDo8nBq3rP0tCdlbwObcw.jpeg" /></figure><p>In the end we all got the stickers by the way :-p</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69e7df620f12" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/my-experience-with-indiabuildsactions-69e7df620f12">My Experience with #IndiaBuildsActions</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to Web Scraping!]]></title>
            <link>https://medium.com/dsc-hit/introduction-to-web-scraping-5eca63f073e9?source=rss----9f825fec75---4</link>
            <guid isPermaLink="false">https://medium.com/p/5eca63f073e9</guid>
            <dc:creator><![CDATA[Akash Modak]]></dc:creator>
            <pubDate>Sun, 10 Nov 2019 07:36:01 GMT</pubDate>
            <atom:updated>2019-11-10T07:36:01.416Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*olJUeL2ziDvUPnXBBbPCYA.jpeg" /></figure><blockquote>Hello guys! This is Akash Modak. I’m pursuing my Master degree in Computer Application from Heritage Institute of Technology, Kolkata. And also I’m the co-founder of Green Grass Studio (<a href="https://www.ggrassstudio.com/">https://www.ggrassstudio.com</a>). Currently, I’m working on Natural Language Processing. Here I’m going to talk about what is web scraping and the basic knowledge needed to implement it using Python and BeautifulSoup.</blockquote><h4>What is Web Scraping?</h4><blockquote>Web scraping is the process of constructing an agent which can extract, analyse and organise useful information from the web automatically. So in a nutshell it is the process of extracting data from websites. All these extraction is carried out by a piece of code which is scraper.</blockquote><p>The data that can be extracted using a scraper can be of the following type-</p><ul><li>Product items</li><li>Videos</li><li>Images</li><li>Text</li><li>Contact Information (i.e., emails, phone numbers, etc.)</li></ul><h4>Different components of Web Scraper and how it works?</h4><p>The different components of Web Scraper are as follows:-</p><ul><li>Web Crawler module</li><li>Extractor</li><li>Data transformation and cleaning module</li><li>Storage module</li></ul><p>The Web Scraper works as follows:-</p><blockquote>The Web Scraper will first download the contents of the requested web pages in an unstructured format(HTML format). Then the scraper will parse and extract structured data from the downloaded contents. And then the scraper will store and save the extracted data in any of the format like Plain text, CSV, JSON or database.</blockquote><h4>Understanding the structure of a web page!</h4><blockquote>You may feel free to skip this section if you are well aware about the structure of a web page.</blockquote><p>Guys, it’s very important to know the structure of a web page and to know about the different tags used in HTML before performing scraping successfully.</p><p>The basic structure of an HTML page is:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yq0MsccBlrVWE2zlHeKfBQ.jpeg" /><figcaption>The basic structure of HTML</figcaption></figure><p>The above structure has various tags as elaborated below:</p><ul><li>&lt;!DOCTYPE html&gt;: HTML documents must start with a type declaration.</li><li>HTML document contains between &lt;html&gt; and &lt;/html&gt;.</li><li>The visible part of an HTML document is between &lt;body&gt; and &lt;/body&gt;.</li><li>The &lt;div&gt; tag defines a division or a section in an HTML document. This is the tag that most of the time will help you to identify the data which you want to extract from the webpage.</li><li>HTML headings are defined by &lt;h1&gt; to &lt;h6&gt; tags.</li><li>HTML paragraphs are defined by &lt;p&gt; tag.</li></ul><p><strong>Some other HTML tags are:</strong></p><ul><li>&lt;table&gt;, &lt;td&gt;, &lt;tr&gt; tags are used to make tables in a webpage.</li><li>&lt;ul&gt;, &lt;ol&gt;: ul stands for unordered list and ol stands for an ordered list. Both of these tags are used to create a list on a webpage.</li></ul><p>Now open the webpage in your browser which you want to scrape. Here I will scrape my website (<em>link- </em><a href="https://akashmodak97.github.io/">https://akashmodak97.github.io/</a>). <em>Open this link in your browser. </em>To understand the structure of the webpage press <em>CTRL+SHIFT+I </em>or just right click on that particular area which you want to extract and select <em>Inspect.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*19H5H8lDuSVziLnDEjI4cA.jpeg" /><figcaption>Right-click on the web page and select Inspect</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HbZh9V_HhSvAimdDft57Ag.jpeg" /><figcaption>This is the structure of the web page</figcaption></figure><h4>Libraries required for Web Scraping</h4><p>As python is an open-source programming language you may find many libraries to perform one function. I prefer BeautifulSoup since it is easy and intuitive to work on. In this article, I’ll use two python modules for scraping data.</p><ul><li>Urllib2: It is a python module that can be used for fetching URLs. For more details refer to the <a href="https://docs.python.org/2/library/urllib2.html">documentation page</a>.</li></ul><blockquote>Note: urllib2 is the name of the library included in Python2. If you’re using Python3 then use urllib.request library instead. This library is already installed in your machine.</blockquote><ul><li>BeautifulSoup: It is a tool used for pulling out information from a webpage. You can use it to extract tables, lists, paragraphs, images, etc. from a website.</li></ul><blockquote>Note: If you’re using Jupyter Notebook or Spyder IDE then this library is already installed or else look at the installation process in its <a href="https://pypi.org/project/beautifulsoup4/">documentation page</a>.</blockquote><h4>Now let us dive into the coding section!</h4><p>The capturing of data from the web starts by sending a request to the web from which you want to capture the data with the help of urllib.request library.</p><p><strong>Coding section:</strong></p><blockquote>from urllib.request import urlopen<br>from bs4 import BeautifulSoup</blockquote><blockquote>url_name=”<a href="https://akashmodak97.github.io/">https://akashmodak97.github.io/</a>” <strong>#store the url in a variable</strong></blockquote><blockquote>try:<br> <strong>(tab)</strong>page=urlopen(url_name) <strong>#connects with the webpage</strong><br>except:<br> <strong>(tab)</strong>print(“Error in opening page”)</blockquote><blockquote>soup = BeautifulSoup(page,’html.parser’) <strong>#downloads the unstructured data(HTML format)</strong><br>content = soup.find(‘div’,{“id”:”about”}) <strong>#The variable “content” will only contains the data of the division whose id name is “about”</strong></blockquote><blockquote><strong>#soup.find finds the portion which you want to scrape</strong><br>article=’ ‘</blockquote><blockquote>for i in content.findAll(‘p’):<br> <strong>(tab)</strong>article=article+ ‘ ‘+i.text <strong>#finally this portion will extract those information which you were looking for and stores it in a variable</strong><br>print(article)</blockquote><blockquote><strong>#if you want to store it in a file then execute the next two lines</strong></blockquote><blockquote><strong>#if the data is of any language other than english then only write encoding=”utf-8&quot;</strong></blockquote><blockquote>file=open(“filename.txt”,”w+”,encoding=”utf-8&quot;)<br>file.write(article)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*-4YwMniOFrBOoHXZUgH42g.jpeg" /><figcaption>A snapshot of the program</figcaption></figure><p><em>PS: Please make sure that your device is connected to the internet while you extract the data from a webpage.</em></p><p><strong>Hope you enjoyed reading and found it useful! Feel free to connect me on </strong><a href="https://www.linkedin.com/in/akash-modak-04a014178/"><strong>LinkedIn</strong></a><strong>.</strong></p><p><strong>That’s all for Web Scraping, thanks for reading. If you enjoyed it then don’t forget to hit that clap button 👏🏻to help others find it.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5eca63f073e9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/dsc-hit/introduction-to-web-scraping-5eca63f073e9">Introduction to Web Scraping!</a> was originally published in <a href="https://medium.com/dsc-hit">Developer Student Club, HIT</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>