<?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 Prasham Ashesh on Medium]]></title>
        <description><![CDATA[Stories by Prasham Ashesh on Medium]]></description>
        <link>https://medium.com/@prasham9.ash?source=rss-4b20cfa6d244------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*T8z0ahGclolNLnjJ</url>
            <title>Stories by Prasham Ashesh on Medium</title>
            <link>https://medium.com/@prasham9.ash?source=rss-4b20cfa6d244------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 17 May 2026 01:57:18 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@prasham9.ash/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[The Mysterious .shift() & .unshift()]]></title>
            <link>https://medium.com/@prasham9.ash/the-mysterious-shift-unshift-af64b7cce70?source=rss-4b20cfa6d244------2</link>
            <guid isPermaLink="false">https://medium.com/p/af64b7cce70</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[stack]]></category>
            <dc:creator><![CDATA[Prasham Ashesh]]></dc:creator>
            <pubDate>Thu, 10 Oct 2019 12:57:06 GMT</pubDate>
            <atom:updated>2019-10-15T14:35:59.192Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Mysterious .shift() &amp; .unshift()</h3><p>Javascript Array’s functions, push and pop is intuitive, but shift and unshift are not.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*YS5tegTmdPerZcAFJjWFag.png" /></figure><p>Push and pop are simple they treat that array as a stack, and the last element is considered to be top of the stack. So, whenever a push and pop is performed its performed on top of the stack,i.e. <strong>at end of the array.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*rlUMeO2mrXoVb_68.gif" /><figcaption>push()</figcaption></figure><pre>let x = [1,2,3,4,5]<br>x.push(6) //returns the length of the new array -&gt; 6<br>console.log(x) //[1,2,3,4,5,6]<br>x.pop() //returns the popped element of the array -&gt; 6<br>console.log(x) //[1,2,3,4,5]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*SK7Vo6U5tQKsXSZs6fxEmQ.gif" /><figcaption>pop()</figcaption></figure><p>Whereas, shift and unshift, assume the first element of the array to be the top of the stack.</p><p><strong>shift() and unshift() are just pop and push, applied on a reversed Stack.</strong></p><p>Now, if any noob(like me) would see it his/her perception would be to assume that push and pop are for arrays assumed as a stack(LIFO), whereas shift() and unshift() are for arrays assumed as Queue (FIFO)</p><pre>let x = [1,2,3,4,5]<br>x.noobShift(6) //would have returned the length of the new array -&gt; 6<br>console.log(x) //[6,1,2,3,4,5]<br>x.noobUnshift() //returns the dropped element of the array -&gt; 5<br>console.log(x) //[6,1,2,3,4]<br>//noobShift &amp; noobUnshift is how I assumed the JavaScript&#39;s shift() and unshift() function to work.</pre><p>But, that’s not the case, I was picturing it all wrong in my head.</p><h4>How .shift() should be pictured:</h4><pre>x=               [1,2,3,4]<br>x.shift()        &lt;-shift the array by one place to the left<br>          1[2,3,4] &lt;= the new state of Array with 1 out of place<br>          x.shift() returns 1, and x becomes [2,3,4]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*aOMvTQslBpRmE3GOI8R86w.gif" /><figcaption>shift()</figcaption></figure><h4>How .unshift() should be pictured:</h4><pre>x=               [1,2,3,4]<br>x.unshift(0)      -&gt; shift the array by one place to the rigt<br>    0[1,2,3,4] &lt;= the new state of Array with 0 ready to be inserted<br>    x.unshift() returns 5, the length of updated array, and x becomes [0,1,2,3,4]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*FjcuuqgIMtw3jYdvlVP5sw.gif" /><figcaption>unshift()</figcaption></figure><p>I have always felt that visualizing a concept, helps create a better picture. After all, “If a picture is worth a thousand words, a video is worth millions”, at least. Hope, this helps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af64b7cce70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[You are a Coder, not Liar, Thief or Vandal]]></title>
            <link>https://medium.com/@prasham9.ash/you-are-a-coder-not-liar-thief-or-vandal-2501913d9341?source=rss-4b20cfa6d244------2</link>
            <guid isPermaLink="false">https://medium.com/p/2501913d9341</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[ethics]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Prasham Ashesh]]></dc:creator>
            <pubDate>Sun, 25 Aug 2019 19:28:50 GMT</pubDate>
            <atom:updated>2019-09-08T18:01:28.371Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*h7N5q1zfugydByON" /><figcaption>Photo by <a href="https://unsplash.com/@ikukevk?utm_source=medium&amp;utm_medium=referral">Kevin Ku</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>You are a Coder, not a Liar, Thief or Vandal</h3><h4>But the question is how would you prove your Innocence? Who would you blame and Who would you trust?</h4><p>Words like ‘Security Threat’, and ‘hacked’ can spread chaos in any boardroom or meeting. Security is no joke in the IT industry, it is taken very seriously. Companies spend millions of Dollars to Test their systems for bugs and vulnerabilities.</p><p>But yet it happens, the bugs (intentional/unintentional) somehow make through the rigorous rounds of testing and scrutiny. And depending upon the severity and size of the bug, it is later discovered. But by then its too late.</p><figure><img alt="From Giphy" src="https://cdn-images-1.medium.com/max/500/1*Djl1675daSlUcnpUK-zJnQ.gif" /><figcaption><a href="https://giphy.com/gifs/funny-cheezburger-bugs-oSUtmrhRz5te0">Bugs in the System</a></figcaption></figure><p>What follows next is an intense round of finger-pointing, and it ends on someone, it has to. Because if there was a slip off someone has to take the blame.</p><p>In a very recent case of ‘Florida Ransomware Hacking’, on June 10, Brian A. Hawkins, former Information Technology Director of Lake City, the northern Florida city, was on the receiving end. The city was forced to shell out approximately half a million dollars. He was being blamed for the Ransomware Attack and the long time that it took in recovery.</p><blockquote>Following which Mr Hawkins filed in Columbia County state court on Aug. 9 raises the inevitable question of liability: When hackers wipe out a city’s computer system, who is to blame?</blockquote><h3>Who is to Blame?</h3><p>Its a question that has been pondered upon by the whole Computer Science Community since its Inception. Who is to blame when something goes wrong? When things fail, and a known or unknown vulnerability is exploited. What do you do? Where do you look for the bug?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*g3Byyhnjxc6-p24mk_MQDQ.gif" /><figcaption><a href="https://gph.is/2QFuFRO">Who is to be blamed?</a></figcaption></figure><p>And more importantly how to find it and then fix it? So that such incidents can be prevented in the future. We are not the first ones to ask such questions, Ken Thompson in 1938 also had a similar question and he had an answer as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*Q2vv6Dl66vB2_MljHUss5g.jpeg" /><figcaption><a href="https://en.wikipedia.org/wiki/Ken_Thompson">Kenneth Lane Thompson</a></figcaption></figure><p>Kenneth Lane Thompson (born February 4, 1943) is an American pioneer of computer science. He designed and implemented the original Unix operating system while working at Bell Labs. He is also credited with the invention of B programming language, the direct predecessor to its popular counterpart the C programming Language. He also presented the backdoor attack now known as the <em>Thompson hack</em> or trusting trust attack.</p><p>“Reflections on Trusting Trust” is a famous speech, given by him in 1983, published in <em>Communications of the ACM journal </em>in<em> August 1984<br>Volume 27 Number 8</em>. This was his acceptance speech after receiving Turing award “for their development of generic operating systems theory and specifically for the implementation of the UNIX operating system”.</p><p>There he put forward a question, “To what extent should one trust a statement that a program is free of Trojan horses? ”. In a programming world where a library is just one `npm` away. How does one ensure the security of the code?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*KBfaxHFReZ9omjcyFITZPQ.gif" /><figcaption><a href="https://gph.is/1jXrrII">Unix was everywhere</a>.</figcaption></figure><p>In 1983, during the time Ken gave this speech. Unix was everywhere and the C compiler was <strong><em>the</em></strong> central piece of software for these systems. Almost everything went through the C compilers and they were a single point of failure and for the obvious reasons very Lucrative for the hackers.</p><p>So basically if you would write your program in C, you would compile your Source code with a C compiler, made in C, to create a binary file which would then be executed in your system, which again is written in C. This is what Mr Thompson described as the “chicken and egg” problem that arises when compilers are written in their own language.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*qTgdXir-Eymb8dkGQb5jGA.gif" /><figcaption><a href="https://gph.is/g/aXm7PxO">Chicken Egg Paradox</a></figcaption></figure><p>So all that a person has to do is infect your Compiler, and instruct it to include malicious code in every binary file that it creates. And every code going through the infected compiler would be an infected code. So a program to subtract 2 numbers would subtract 2 numbers and few files as well.</p><p>No amount of Source code review will reveal the problem in such cases. Because the tools that one automatically assumes to be correct can actually be corrupted. This problem is pretty severe, not because it is complex or anything, but because the problem exists at a place where no one would expect it to be.</p><p>Problems like these, even after so many years of existence and testing, still exist in compilers of many languages. Convenience over Security is a common norm now. One thing that everyone needs to realize is that Trust was scarce back then and is still Scarce now.</p><h3>Aleksey Shipilëv on Twitter</h3><p>Current status: following up on rare compiler bugs like there *is* tomorrow.</p><h3>Conclusion</h3><h4>Who is to blame?</h4><p>The programmer using the trusted Compiler? Bad Design? Unix? and, Who to Trust? Ken Thompson has an answer:-</p><blockquote>“The moral is obvious. You can’t trust code that you did not totally create yourself. No amount of source-level verification or scrutiny will protect you from using untrusted code. In demonstrating the possibility of this kind of attack, I picked on the C compiler. I could have picked on any program-handling program such as an assembler, a loader, or even hardware microcode. As the level of program gets lower, these bugs will be harder and harder to detect. A well-installed microcode bug will be almost impossible to detect.” — Ken Thompson</blockquote><p>When it comes to security you can’t trust anything or anyone, but yourself, but that’s impossible to do so. In this world, you always have to Trust someone. <strong><em>You need to trust the people you work with. The developers, designers and everyone involved with a compromised or buggy software has to share the blame.</em></strong></p><blockquote>To what extent should one trust a statement that a program is free of Trojan<br>horses? Perhaps it is more important to trust the people who wrote the<br>software. — Ken Thompson</blockquote><p>The Programmers/Coders/Software Engineers, need to realise that they are the first line of defence against such threats and bugs, and a small misstep could result in loss of Millions of Dollars and in worst cases Loss of Lifes. Software Engineering is a serious job and it should be treated like such.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*nTrLcLL2BEr75llDml6l6Q.gif" /><figcaption><a href="https://gph.is/2gEjpWf">Making good Software is a responsibility</a></figcaption></figure><p>Testing is a crucial part that ensures that Code Quality and a less buggy system, and still Testing is the most under-rated and neglected part of the Software Industry.</p><blockquote>“A clever person <strong>solves</strong> a problem. A wise person <strong>avoids</strong> it.”<br> — Albert Einstein</blockquote><h4>References:</h4><p><a href="https://www.archive.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf">https://www.archive.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf</a><br><a href="https://softwareengineering.stackexchange.com/questions/184874/is-ken-thompsons-compiler-hack-still-a-threat">https://softwareengineering.stackexchange.com/questions/184874/is-ken-thompsons-compiler-hack-still-a-threat</a><br><a href="https://en.wikipedia.org/wiki/Ken_Thompson#cite_note-22">https://en.wikipedia.org/wiki/Ken_Thompson#cite_note-22</a><br><a href="https://www.nytimes.com/2019/08/22/us/florida-ransomware-hacking-it.html">https://www.nytimes.com/2019/08/22/us/florida-ransomware-hacking-it.html</a><br><a href="https://www.zdnet.com/article/second-florida-city-pays-giant-ransom-to-ransomware-gang-in-a-week/">https://www.zdnet.com/article/second-florida-city-pays-giant-ransom-to-ransomware-gang-in-a-week/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2501913d9341" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>