<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Livnoor Brar on Medium]]></title>
        <description><![CDATA[Stories by Livnoor Brar on Medium]]></description>
        <link>https://medium.com/@livnoorbrar?source=rss-5c96b85cb7fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OMyhvv4aP0iRc9tkqirncA.jpeg</url>
            <title>Stories by Livnoor Brar on Medium</title>
            <link>https://medium.com/@livnoorbrar?source=rss-5c96b85cb7fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:07:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@livnoorbrar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Test user actions on UI invoking JavaScript in Rails Views]]></title>
            <link>https://medium.com/@livnoorbrar/test-user-actions-on-ui-invoking-javascript-in-rails-views-3d270d992452?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/3d270d992452</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[debugging]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Mon, 15 Jul 2019 06:06:20 GMT</pubDate>
            <atom:updated>2019-07-15T06:06:20.605Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Lyu2Cu7Ay61XgcOL" /><figcaption>Photo by <a href="https://unsplash.com/@nesabymakers?utm_source=medium&amp;utm_medium=referral">NESA by Makers</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Everyone loves the magic Javascript provides on your web pages. It opens a whole new level of functionality to your otherwise dull web-page. While developing a web application using rails I also was introduced to this magic. I used this pixie dust all over my views but the problem arose when it had to be tested. I had a tough time testing, but it also taught me a lot of stuff.</p><p>In this blog, I will concentrate on the How to part of testing. I used the Jasmine framework to spec all the JS files. So let us get started!</p><ol><li><strong>Add jasmine as a dependency:</strong> Rails handles dependency via Gemfile. In Gemfile add the below line<br>gem &#39;jasmine&#39;, &#39;3.1.0&#39; <br>and run <br>$ bundle install</li><li><strong>Setup Jasmine Framework: </strong>In order to setup Jasmine framework .ie. create required file and folder structure, for your project run <br>$ rails generate jasmine:install <br>This would create jasmine_helper.rb, jasmine.yml &amp; .gitkeep files in your spec/javascript/support</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*adtt1z0NlLfMgWh9Lq84ig.png" /><figcaption>Arrows point to the files generated by command <strong>rails generate jasmine:install</strong></figcaption></figure><p><strong><em>OPTIONAL</em></strong>: Since some of the actions to be tested can be on a component’s click and other events, we need to load these object in DOM while testing. To access these DOM objects while testing we can use jquery. Hence we need to include ajquery-build file. The compressed version of jquery-build file can be downloaded from <a href="https://jquery.com/download/">here</a> and kept under spec/javascript/support. <br>In the image, you can see the jquery-3.2.1.min.js file kept in the support folder below jasmine_helper.rb file.</p><p>So once the file structure is in place, let us tell jasmine what all files containing JS code must be load in the browser before running the tests. This is done by mentioning these files in jasmine.yml file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*uYgt1I9Xh5GHX-zbzcNg9w.png" /><figcaption><strong>Note:</strong> The file <strong>assets/jamine-jquery.js</strong> would allow jasmine to use jquery in order to render the HTML components on DOM and run tests on them</figcaption></figure><p>3. <strong>Run Jasmine Server to run tests</strong>: Run the javascript tests using the following command<br>$ bundle exec rake jasmine <br>This will run jasmine server on localhost:8888. Once jasmine server is up and running open <a href="http://localhost:8888/">http://localhost:8888</a> in the browser. You will be able to see jasmine suite on your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2FTJrs4uN15fkUa6O4z5Q.png" /><figcaption>Above is just a sample image of how the jasmine specs reporting is shown on screen</figcaption></figure><blockquote>Tips: <br>* To check whether all your js file got loaded in the browser, right click anywhere on the window and select View Source. This will open up a new tab that will show all the files loaded to the browser to run the tests.<br>* All the tests are run in the browser so all the files that you want to test along with any dependencies needed must be uploaded in the browser. Path to these files must be mentioned in jasmine.yml.</blockquote><p>4. <strong>Finally! the actual testing part </strong>🙏 <br>All your spec files lie under spec/javascript.<br>Here I will discuss two types of js method invocations that are often used in the frontend. <br><em>4.1.</em> <em>Once the UI(window/document) gets fully loaded, a user inputs something in an input field so a change event is called on an element</em>.<br><em>4.2. When a user fills the form and hits submit, the form is submitted and is redirected to a new page.</em></p><p><strong>4.1 Test change event invoking a JS function: </strong><br>Here we have taken an input element with input-type = file and id = csvFile. If a file is selected using this input element, we intend to test that onFileChange function is called. <br>The js file app/assets/javascripts/tagging.js contains the onFileChange function.</p><pre>function onFileChange() {<br>   // doSomething..<br>}</pre><pre>$(document).on(‘ready’, function () {<br> $(‘#csvFile’).change(onFileChange);<br>});</pre><p>We don’t need to load the whole HTML file, in DOM, containing the csvFile element. Jasmine fixtures help us to load only those elements in the DOM that we intend to test and then remove them from DOM once the testing is finished. Fixtures are nothing but HTML files that contain the components that you want to load in the browser for testing. For the above-mentioned example, we created a fixture file just containing the csvFile element. <br>File: spec/javascript/fixtures/input-csv.html</p><pre>&lt;div class=”form-group”&gt;<br> &lt;input id=”csvFile” class=”form-control” accept=”.csv” type=”file” /&gt;<br>&lt;/div&gt;</pre><p>The test looks like below and is placed in file spec/javascript/tagging-spec.js</p><pre>describe(&#39;Tagging&#39;,function(){<br><br>    it(&#39;calls onFileChange listener when a change is detected/triggered in the file input&#39;, function () {<br><br>        loadFixtures(&#39;input-csv.html&#39;)<br>        spyOn(window,&#39;onFileChange&#39;)<br>        $(document).trigger(&#39;ready&#39;)<br>        $(&#39;#csvFile&#39;).trigger(&#39;change&#39;)<br><br>        expect(window.onFileChange).toHaveBeenCalled()<br><br>    });<br>});</pre><p>Let us go through the above snippet one by one.</p><ul><li>descrbe and it blocks are used to define specs. While describe is used to combine similar tests, it is the actual block where tests must reside.</li><li>loadFixtures(&#39;input-csv.html&#39;) loads the input component in the browser.</li><li>spyOn(window.&#39;onFileChange&#39;) makes a mock function of ‘onFileChange’ present for object ‘window’ on the browser.</li><li>document.trigger(&#39;ready&#39;) and (&#39;#csvFile&#39;).trigger(&#39;change&#39;) are the actions that must happen in order for the onFileChangeto be called.</li></ul><blockquote>Tip:<br>By default ready will only get loaded when all your tests are run and jasmine server renders its html on browser with the list of all test .ie. when the DOM is ready. But here we want ready to be initiated earlier when our test is still running. So we forcefully trigger it using document.trigger(&#39;ready&#39;).</blockquote><ul><li>Our triggers have provided what is necessary to call the onFileChange method, but since we had mocked theonFileChange method using spyOn, the mocked method gets called. And it makes our spec passed.</li></ul><blockquote>Tip:<br>If any of your spec commands doesnot work try running it in console when you inspect the browser page.</blockquote><p><strong>4.2 Test form submit invoking JS function and redirecting to a new page</strong><br>Below is the function that gets called when a user hits the submit button on a form.<br>File: app/assets/javascripts/submit.js</p><pre>function onSubmit(event) {<br>    //doSomething..<br>}</pre><p>Corresponding fixture file that contains the form definition.<br>File: spec/javascripts/fixtutres/upload-button.html</p><pre>&lt;form id=&quot;upload-form&quot; class=&quot;form&quot; onsubmit=&quot;onSubmit(event)&quot; &gt;<br><br>    &lt;div class=&quot;form-group&quot;&gt;<br>        &lt;input id=&quot;saveCsvUpload&quot; type=&quot;submit&quot; value=&quot;Upload&quot; class=&quot;btn btn-primary&quot; disabled/&gt;<br>    &lt;/div&gt;<br><br>&lt;/form&gt;</pre><p>TEST: spec/javascript/submit-spec.js</p><pre>describe( &#39;Submit&#39;, funciton(){<br>   it(&#39;is only called when Upload button is clicked by user&#39;,        function () {<br><br>    spyOn(window,&#39;onSubmit&#39;)<br>    loadFixtures(&#39;upload-button.html&#39;)<br>    $(&#39;#upload-form&#39;).submit()<br>    expect(window.onSubmit).toHaveBeenCalled()<br><br>    })<br>});</pre><p>Just like we had done it for the previous spec, we create a mock of onSubmit(event). Note that we have mocked the submit button first and then loaded the fixture. This is because we need to define the onSubmitcalled by the onsubmit = “onSubmit(event)”prior to its usage. Now when the submit() is called on the form it will assert calling of spied onSubmitfunction.</p><p>PROBLEM: If you run jasmine server and run the specs you will see that the browser page is getting continuously refreshed. This is because it is making continuous submit calls. [No idea as to why continuous calls are being made. My understanding is that only one submit call must have been made]. <br>To prevent this from happening, we need to prevent the default action .ie. redirection to a new url. Hence instead of just spyOn(window,tagging) add :</p><pre>window.tagging = jasmine.createSpy().and.callFake(function(event) {<br> event.preventDefault();<br> })</pre><p>Now, this fake function will be called instead which prevents the default action(submit + redirection to new url) to take place.</p><p>Let me know if anything was unclear and I will try my best to improve it. I am even open to discussion on Jasmine and its features.</p><p><strong>HAVE FUN TESTING!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3d270d992452" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Get your hands dirty: Build your own auto-expanding scrollable TextView]]></title>
            <link>https://medium.com/@livnoorbrar/the-curious-case-of-uiscrollview-and-uitextview-12aa4a69cd52?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/12aa4a69cd52</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ui]]></category>
            <category><![CDATA[infinite-scroll]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Mon, 25 Sep 2017 09:44:36 GMT</pubDate>
            <atom:updated>2017-09-25T18:29:51.323Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog we would be making a Text View that expands its length as the content in it increases. Like the one below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ykGPTgKv8QUgA-5-5VuieA.gif" /><figcaption><strong>What you want to implement..</strong></figcaption></figure><p>UITextView inherits UIScrollView .ie. when the content size starts to increase than what can be accommodated by UITextView then a scrollbar appears on the sides so that you are able to scroll over the whole content.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*4X9L6xmT8-qLkxLwGL6A9w.gif" /><figcaption><strong>What you have..</strong></figcaption></figure><p><strong>Solution: <br>1. </strong>We shall start off by having 4 views:<br>* Main View(view of View Controller)<br>* Scroll View <br>* Content View <br>* TextView<br>The view hierarchy would appear as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*ALZCPJsIPODAPNDdDUrhiQ.png" /><figcaption><strong>Layout hierarchy (as shown in standard editor window in Xcode 9)</strong></figcaption></figure><p><strong>2.</strong> Toggle off the scrollability of UITextView.<br><strong>3.</strong> Provide minimal possible constraints to your views.ie. <br> * Text View: Has a distance of 8 pixels from all sides inside the Context View.<br> * Content View : Has zero margin from the Scroll View.<br> * Scroll View : Assuming the whole device’s screen to be the scrollable area, Scroll View is bound to the edges of the Main View.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/1*I-wHCB4D8KjsCJx2TClMBA.png" /><figcaption><strong>Constraint list appearing on screen</strong></figcaption></figure><p>No errors appear, yet what you see on the app is unexpected.ie. you are getting a horizontal scrollable screen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*IHB9GNuNXJGtifNWVKgxNw.gif" /><figcaption><strong>Horizontal Scroll available on screen</strong></figcaption></figure><p><strong>Reason:</strong> Since no fixed width for Text View is set so it does not know after what length the input must be directed to next line and hence it goes on expanding in the horizontal direction. Also, all the constraints to components have been given from TextView to Scroll View .ie. from inner components, the outer components take their shapes.<br>Now, you would argue that you have also given constraints to Scroll View wrt the Main View.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*vB0yNEdkemydpNt3bTDdNw.png" /><figcaption><strong>Constraints given to Scroll View wrt Main View</strong></figcaption></figure><p>The above constraints are only meant to tell the Scroll View the amount of area it must show at a particular moment on the screen. They donot limit the content size of Scroll View. Basically, Scroll View is a dumb view and wraps itself around the components inside it. Hence we can conclude that <br> <em>`content size = overall size of components inside it`</em></p><p><strong>4.</strong> Deciding width for Text View: There are two ways to set the width of Text View and prevent it from expanding horizontally beyond the screen:</p><pre> * TextView.width = <em>abc.pixels </em>(hard coded value)<br> * TextView.width = width_of_screen</pre><p>First option works fine if you know that the app you are creating would work only on devices of a particular dimension without any screen rotation.(You have got to be kidding yourself with that!!)<br>Second option works for all types of screens available and in any orientation. <br>I would go for the second option that allows me to ‘Autolayout’ the screen depending on the device’s screen size. Do the changes and run the app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*D1iulm5e4S3tiit3BrmD6A.png" /><figcaption><strong>Text View. width = width of Main View(view of View Controller)</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*YkOsKDNVNrtU9gXh9TcChA.gif" /><figcaption><strong>App after setting Text View width</strong></figcaption></figure><p>Still there is a problem. If you notice above, although the text has started appearing in next line but still the horizontal scroll is not 100% gone. This is because Content View accommodates Text View with a margin of 8 pixels from the edges. So,</p><pre> <em>width_of_Content_View = width_of_Text_View +8 +8<br> since, width_of_Text_View = width_of_screen<br> hence, width_of_Content_View = width_of_screen +8 +8</em></pre><p>Further more the Scroll View encompasses this Content View so it extends its content size to that of the Content View. The Content View width is greater than that of screen hence we are able to get the horizontal scroll.</p><p><strong>5.</strong> Instead of `<em>width_of_Text_View = width_of_screen</em>`,<br> set `<em>width_of_Content_View = width_of_screen</em>` and run the app. You will get an app running like shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*ykGPTgKv8QUgA-5-5VuieA.gif" /><figcaption><strong>Final App with auto expanding UITextView</strong></figcaption></figure><h4>Bravo!! Mission successful!!</h4><p>Hence, we can conclude that in order for the Scroll View to work, the inner view must be given some fixed dimensions as Scroll View is a dumb and knows nothing(‘Jon Snow’ of iOS). This could either be done by providing hard coded dimensions to the inner components or if Auto Layout needs to be done then tying of components to the Main View(view of View Controller)is the answer to the question.</p><p>Beware: In many blogs you might read about vertical alignment of Content View wrt Main View, but that would remove the vertical scrollability as you have limited the height of Content View not to grow according to the text but restrict it to the screen size of the device.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12aa4a69cd52" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Product?]]></title>
            <link>https://medium.com/@livnoorbrar/what-is-a-product-7050b9f12b8c?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/7050b9f12b8c</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[experience]]></category>
            <category><![CDATA[product]]></category>
            <category><![CDATA[problem-solving]]></category>
            <category><![CDATA[solutions]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Tue, 08 Aug 2017 17:52:43 GMT</pubDate>
            <atom:updated>2017-08-08T17:52:43.908Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*EgnadiZVekoR9AuThfzSog.jpeg" /></figure><p>The business dictionary has defined a product as:</p><blockquote>A good, idea, method, information, object or service created as a result of a process and serves a need or satisfies a want. It has a combination of tangible and intangible attributes (benefits, features, functions, uses) that a seller offers a buyer for purchase. For example a seller of a toothbrush not only offers the physical product but also the idea that the consumer will be improving the health of their teeth.</blockquote><blockquote>Read more: http://www.businessdictionary.com/definition/product.html</blockquote><p>But in my opinion ‘Product’ is much more than that. It is a solution to a users’ problem and what ever(tangible or intangible) is delivered to the user is just a slice of whole of the product.</p><p>In order to give the user an experience of fulfilment of his needs the solution you provide is achieved after going through multiple processes. Each process in-turn came into existence when the user need was divided into small requirements. Thus each process has an input(requirements) and an output (solution to the smaller problem addressed to it). Thus the process by above quoted definition becomes a product.</p><p>When you figure out that each process or step to develop is a small product in itself, be it the manufacturing, hiring of people to do job or market analysis etc, you can figure out that that combination of all the small products forms a bigger product .ie. solution to the users’ problem. And what is finally handed over to user .ie. a software tool, a business plan etc. is just the part of the whole product because as we are not only creating a tool but a satisfying experience for the user.</p><p>What can thus be concluded is that <em>product</em> by a company is the satisfying experience it creates for its’ business user.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7050b9f12b8c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An hour with Ranjan Sakalley-VP Back-End GO-JEK India]]></title>
            <link>https://medium.com/@livnoorbrar/an-hour-with-ranjan-sakalley-vp-back-end-go-jek-india-a41c32eeb197?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/a41c32eeb197</guid>
            <category><![CDATA[gojek]]></category>
            <category><![CDATA[honesty]]></category>
            <category><![CDATA[mentorship]]></category>
            <category><![CDATA[hard-work]]></category>
            <category><![CDATA[professional-development]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Tue, 25 Jul 2017 16:15:48 GMT</pubDate>
            <atom:updated>2017-07-25T16:15:48.265Z</atom:updated>
            <content:encoded><![CDATA[<p>All the newly joined graduates at Go-Jek India, attending the bootcamp, had a one hour session with Ranjan Sakalley VP Back-End <a href="https://medium.com/u/fa3989bab2bf">GO-JEK</a> India. He is a man with humble poise. A down-to-earth personality, always open for discussions. The session started on a very positive note where he welcomed people to interrupt him while he was sharing his views if someone wanted to discuss on a topic in more detail.</p><p>I discovered a lot of takeaways from his talk today and have summarized it for you below:</p><ol><li>Hard work never goes out of style.</li><li>One must always maintain honesty and integrity in work if you want people to trust you. Be honest about your mistakes and have the integrity to accept that you don’t know stuff rather than pretending to have knowledge and ask for help when required.</li><li>Find a good mentor for yourself. A good mentor is the one who asks questions on your thought process rather than spoon feeds you with all the answers. If you learn how to learn, then it is a tool that will take you a long way.</li><li>Attention to detail. When reading something try to understand the logic behind it rather than just scrolling your eyes over the text.</li><li>Understand what you want to do, what drives you or motivates you to get up in the morning and come to office.</li><li>Most of the programmers’ life goes in naming things — so be good at it. If naming is good then the code flows.</li><li>Have a personal log. These logs help you find patterns and flaws in yourself.</li><li>Time is not infinite, you only have 24 hours in a day. So keep your focus on improving yourself else you will soon turn into the person in a crowd(mediocre).</li><li>Whenever you are taking a decision write down the pros and cons on a piece of paper. It helps in thinking objectively.</li><li>If you are looking to achieve the zeniths of glory then only a team can take you there, so building good relationships with people is one the important aspects in your success story.</li><li>Prefer reading over listening or watching videos to learn as it gives you time to understand, process information and have your own thoughts and perspective. Also inculcate a habit of reading on regular basis.</li></ol><p>I hope these guidelines help you to improve and grow as an individual and as a professional.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a41c32eeb197" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Lost code by accidentally creating a detached-HEAD? Don’t worry!]]></title>
            <link>https://medium.com/@livnoorbrar/lost-code-by-accidentally-creating-a-detached-head-dont-worry-58919f32b08d?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/58919f32b08d</guid>
            <category><![CDATA[data-recovery]]></category>
            <category><![CDATA[lost]]></category>
            <category><![CDATA[recovery]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Thu, 13 Jul 2017 21:13:05 GMT</pubDate>
            <atom:updated>2017-07-13T21:14:42.845Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MnOb9WsUfs-c7bTy_xYZTw.png" /></figure><p>A recent incident happened when the a ‘detached-HEAD’ of my git repository got created in my local by doing ‘git checkout &lt;<em>commit hash</em>&gt;’.ie. I reverted back to a particular commit made in the past.</p><p>I continued working in the detached git, finished my code and made all the timely commits to it without any changes to the master. Now before pushing the code I tried to check what was there in the master branch and did ‘ git checkout -a’. This lead to all the changes made to my ‘detached-HEAD’ almost lost.</p><p>In an effort to recover the lost code I came across the following article (<a href="https://www.git-tower.com/learn/git/faq/detached-head-when-checkout-commit">https://www.git-tower.com/learn/git/faq/detached-head-when-checkout-commit</a>) . It stated:(‘they’ refers to changes made in detached-HEAD)</p><blockquote>‘This means they can easily get lost once you check out a different revision or branch: not being recorded in the context of a branch, you lack the possibility to access that state easily (unless you have a brilliant memory and can remember the commit hash of that new commit…).’</blockquote><p>But I propose a solution to the above mentioned problem without having a <em>brilliant memory</em>. In the local repository there exists a ‘.git’ folder. In it there is a ‘logs’ folder. It contains a file HEAD that has the list of all your commits with respective hashes made till date to your repository. To go to the last changes you made to your ‘detached-HEAD’, copy the hash of the last commit you made from the list(project_repo/.git/logs/HEAD) and perform the following steps on terminal at (../project_repo):-</p><ol><li>git checkout &lt;<em>copied hash of required commit from the list</em>&gt;</li><li>git checkout -b &lt;<em>new branch name</em>&gt;</li><li>git checkout master</li><li>git merge &lt;<em>branch name</em>&gt;</li></ol><p>In point 4, <em>branch nam</em>e refers to the name of the branch created in point 2.</p><p>And voila!! All your changes made have been recovered and are back in master.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58919f32b08d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Should you commit Gemfile.lock or not?]]></title>
            <link>https://medium.com/@livnoorbrar/should-you-commit-gemfile-lock-or-not-9fbca418bddd?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fbca418bddd</guid>
            <category><![CDATA[gem]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[bundle]]></category>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[file-management]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Tue, 11 Jul 2017 16:21:17 GMT</pubDate>
            <atom:updated>2017-07-12T04:26:04.464Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*ddDddJG_Z3UaE9etBf_g2A.jpeg" /></figure><p>At most places you will find the consensus over committing the Gemfile.lock while committing changes to the your repository. But, I beg to differ.</p><p>Gemfile is the main file responsible for holding the names and the versions of all the dependencies of your current project. So once you pull and do ```bundle install``` , the bundler picks up the versions and the source to download them, from the Gemfile. Once the install is over Gemfile.lock is automatically created with the list of the gems (with versions) required by your project along with their further dependencies on other gems(with versions).</p><p>I agree that when a ```git pull``` is done from a repository which contains Gemfile.lock, the bundler will read this Gemfile.lock to load all the dependencies required for this project with the versions, instead of using Gemfile. However, in a situation where you uninstall a gem(may be because it was causing errors) and update Gemfile but forget to do ```bundle install``` (as you already have the requisite gems) to update Gemfile.lock, the wrong file(Gemfile.lock) gets committed. And in future whoever does a pull and does ```bundle install``` will get the gems from Gemfile.lock which are not required and may encounter the same errors that you had faced with the wrong gems .ie. the inconsistency and error propagates further. Imagine this situation when the amount of people doing pull from your repository is huge.</p><p>So in my opinion these conflicts could be sorted by only committing the correct Gemfile and let others create their own Gemfile.lock files. Also this way you can uphold the DRY principle(Don’t repeat yourself) by not mentioning in two files the gems and the versions to be used.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fbca418bddd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When to ask questions during developer workshops?]]></title>
            <link>https://medium.com/@livnoorbrar/when-to-ask-questions-during-developer-workshops-871944c2e585?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/871944c2e585</guid>
            <category><![CDATA[doubt]]></category>
            <category><![CDATA[aşk]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[questions]]></category>
            <category><![CDATA[now]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Tue, 11 Jul 2017 03:22:15 GMT</pubDate>
            <atom:updated>2017-07-11T03:23:54.891Z</atom:updated>
            <content:encoded><![CDATA[<p>In the developer community, it is considered to ask questions only when you have been let down by all the other avenues where you could find an answer like google searches, manual documents, blogs etc. This can be valid in the situation where you have time at your hand and the developer is approachable only via web.</p><p>However, in situations like bootcamp or workshop, when a topic is being discussed and you stumble upon unknown terminologies and concepts, I would suggest you to raise your doubts then and there. This is because if you sit and try to google, you are detaching yourself from what is being taught at the present and by the time you are finished googling, the topic has progressed far ahead and you find yourself lost again.</p><p>Also, google doesn’t know in which context what terminology is being used in your situation and there is a possibility that even after googling you might not understand what was being talked about in the discussion. So I recommend you to put forward the unknowns ,in person, during discussions, to help you solve the main purpose of attending the workshop .ie. understand and learn.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=871944c2e585" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Problems when you come from Non- Computer Science background and you don’t know what you don’t know]]></title>
            <link>https://medium.com/@livnoorbrar/problems-when-you-come-from-non-computer-science-background-and-you-dont-know-what-you-don-t-know-5840d789f2bc?source=rss-5c96b85cb7fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/5840d789f2bc</guid>
            <category><![CDATA[challenge]]></category>
            <category><![CDATA[fresh-start]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[experience]]></category>
            <dc:creator><![CDATA[Livnoor Brar]]></dc:creator>
            <pubDate>Fri, 07 Jul 2017 04:04:03 GMT</pubDate>
            <atom:updated>2017-07-07T04:04:03.676Z</atom:updated>
            <content:encoded><![CDATA[<p>I am an Instrumentation and Control Engg grad. I had worked on coding for Micro-controllers and Micro-processors and found it really interesting. I became good at it. This helped me to undertake more complex projects without the apprehension of coding for the controller being a hinderence. After college came my first job where I used to form configuration files for tools in a predefined format. I coded my way out of the manual job by making macros to manipulate excel file into desired configuration format. So I finally decided to make coding as my profession full- fledgedly as at any job or in any project I understood, that was what I was doing. Unaware of the recent technological advances in the software field, tasked my friends about where to start if I wanted to pursue coding as profession. I was suggested start with Ruby language as it was easy to understand and grasp. I started learning ruby and used a borrowed laptop that had all the IDEs and editors already configured to ease one’s programming.During that I got to know of a Software company that made customer service apps and had a nurturing working culture where learning was promoted irrespective of your educational background. After i became a little familiar with ruby, i gave the interview in the firm and got a job. I was overwhelmed by that.</p><p>The real problems for not being from a CS background started from the day of commencement of ‘Bootcamp’. Being unfamiliar with the basics of Computer Engineering like compiler, performance of code, memory occupancy, basic terminology etc I was unable to understand the conversations that happened around me. I took more time to develop algorithms for the problem statements given during the camp which made me doubt myself. Since I had used pre-configured IDEs, the new unconfigured IDEs that I had installed in my new PC gave me a hard time. Also when I coded in unfamiliar languages, my google searches would never find me the desired answer. Later one of colleagues suggested to use code blocks that you superficially understand rather than going into deep details. This would help in moving forward with the code rather than being stuck at a place and thinking how to do it. Being unacquainted with the basics of the domain, the knowledge difference between me and others in the room made me feel subordinate to the rest and was stressed about unable to perform like them. Comparisons lead to mental blocks where I wasn’t able to implement the same logic of a problem that I had developed a day before and worked fine, in a language that I was familiar with.</p><p>My current plan to tackle the problems I faced priority-wise are:<br>- Remove any mental blocks or comparisons and take things at my own pace. <br>- all always write your algorithm on a piece of pen and paper(also known as pseudo code).<br>- start with basic functionality implementation and then move further step by step.<br>- set up the IDE on your own and take help from someone how to fix the problems that you are facing.<br>- familiarise yourself with IDE by trying small statement problems and using various functions of IDE.<br>- Once implementation of a problem is done in one language, then move on to the next.<br>- Forward your solutions to the senior to get feedback.</p><p>With so much to learn and time being the main constraint, I am still working to finish tasks as planned as soon as possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5840d789f2bc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>