<?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 Akshay Mohite on Medium]]></title>
        <description><![CDATA[Stories by Akshay Mohite on Medium]]></description>
        <link>https://medium.com/@akshaymohite?source=rss-2c9b02e41f11------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*IkJhRhEPVL68DCX0Ib3M9w.jpeg</url>
            <title>Stories by Akshay Mohite on Medium</title>
            <link>https://medium.com/@akshaymohite?source=rss-2c9b02e41f11------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:26:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@akshaymohite/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[jQuery check if class exists before calling addClass?]]></title>
            <link>https://medium.com/@akshaymohite/jquery-check-if-class-exists-before-calling-addclass-935a260fbec0?source=rss-2c9b02e41f11------2</link>
            <guid isPermaLink="false">https://medium.com/p/935a260fbec0</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[jquery]]></category>
            <dc:creator><![CDATA[Akshay Mohite]]></dc:creator>
            <pubDate>Mon, 15 Oct 2018 19:40:26 GMT</pubDate>
            <atom:updated>2018-10-15T19:40:26.816Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dWnqLjEkC0JadNwR-Dxr3w.jpeg" /></figure><p>Today, I came across a code review comment in one of the project that I work on asking someone to, check if class exists before calling addClass in jQuery.</p><p>The review comment read as,</p><blockquote>Please perform removeClass before calling addClass to avoid adding duplicate class name to the element</blockquote><p>I was under assumption that jQuery takes care of checking if class exists on the element before adding one. I just looked at the source code and below are my learnings.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fd8630cdba9f54b87a6ea36d1f8ce8f8/href">https://medium.com/media/fd8630cdba9f54b87a6ea36d1f8ce8f8/href</a></iframe><p>jQuery performs following checks when <strong>addClass </strong>is called.</p><ol><li>If the value passed is a function, it is called on each child element. This is useful for SVG kind of elements.</li><li>Values passed is converted into an Array.</li><li>Each array element (class) is processed.</li><li>If class does not exist (indexOf method is used to find this), it is added to the classes.</li><li>If class exists on the element, it is skipped.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=935a260fbec0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Luhn’s algorithm to validate credit / debit card Numbers]]></title>
            <link>https://medium.com/@akshaymohite/luhns-algorithm-to-validate-credit-debit-card-numbers-1952e6c7a9d0?source=rss-2c9b02e41f11------2</link>
            <guid isPermaLink="false">https://medium.com/p/1952e6c7a9d0</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[luhns-algorithm]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Akshay Mohite]]></dc:creator>
            <pubDate>Sun, 07 Oct 2018 17:32:16 GMT</pubDate>
            <atom:updated>2018-10-08T06:25:30.130Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fi-xsfqDgTQCivURGd3Ow.jpeg" /></figure><p>Did you ever come across an error shown while paying digitally on a payment gateway page, saying the <strong>Credit Card number is not valid</strong>?</p><p>Usually this happens if you enter an incorrect credit / debit card number in the field. Ever wondered, how do they validate if the credit card number is valid?</p><p>Here is the answer to that question. It’s <strong>Luhn’s Algorithm</strong>.</p><p><strong>What is Luhn’s Algorithm?</strong></p><blockquote>The <strong>Luhn algorithm</strong> or <strong>Luhn formula</strong>, also known as the “<a href="https://en.wikipedia.org/wiki/Modular_arithmetic">modulus</a> 10” or “mod 10” <a href="https://en.wikipedia.org/wiki/Algorithm">algorithm</a>, is a simple <a href="https://en.wikipedia.org/wiki/Checksum">checksum</a> formula used to validate a variety of identification numbers, such as <a href="https://en.wikipedia.org/wiki/Credit_card_number">credit card numbers</a>, <a href="https://en.wikipedia.org/wiki/IMEI">IMEI numbers</a>, <a href="https://en.wikipedia.org/wiki/National_Provider_Identifier">National Provider Identifier numbers</a></blockquote><p><a href="https://en.wikipedia.org/wiki/Luhn_algorithm">Source: Wikipedia</a></p><p>Let’s consider number: 3141 4352 72</p><p>The formula is simple:</p><ol><li>Start from the right side. Double every other number.<br>3141 4352 72 → <strong>6</strong>1<strong>8</strong>1 <strong>8</strong>3<strong>10</strong>2 <strong>14</strong>2</li><li>Sum the resulting number if it is a double digit.<br><strong>6</strong>1<strong>8</strong>1 <strong>8</strong>3<strong>10</strong>2 <strong>14</strong>2 → 6181 83<strong>1</strong>2 <strong>5</strong>2</li><li>Sum the digits from resulting number from step 2.<br>6+1+8+1+8+3+1+2+5+2 = 37</li><li>Find out Modulus 10 of the resulting number.<br>37%10 = 7</li><li>If the modulus 10 is equal to 0. The number is a valid card number.</li></ol><p><strong>Luhn’s Algorithm implementation in Ruby:</strong></p><p>The program below implements an algorithm discussed above.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a386c4386806d3b8fc5ea74adceb3381/href">https://medium.com/media/a386c4386806d3b8fc5ea74adceb3381/href</a></iframe><p>Various (C / Python) implementations of the algorithm can be found on the <a href="https://en.wikipedia.org/wiki/Luhn_algorithm">Luhn_algorithm</a> wiki page.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1952e6c7a9d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up vagrant virtual box on Mac OS]]></title>
            <link>https://medium.com/@akshaymohite/setting-up-vagrant-virtual-box-on-mac-os-359a32257700?source=rss-2c9b02e41f11------2</link>
            <guid isPermaLink="false">https://medium.com/p/359a32257700</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[vagrant]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[virtualbox]]></category>
            <dc:creator><![CDATA[Akshay Mohite]]></dc:creator>
            <pubDate>Tue, 19 Sep 2017 07:22:16 GMT</pubDate>
            <atom:updated>2017-09-19T07:22:16.461Z</atom:updated>
            <content:encoded><![CDATA[<h3>Steps</h3><h4>1. Install vagrant</h4><p>Install vagrant from <a href="https://www.vagrantup.com/downloads.html">https://www.vagrantup.com/downloads.html</a></p><h4>2. Download virtual box</h4><p>Download desired virtual box from <a href="https://dev.windows.com/en-us/microsoft-edge/tools/vms/mac/">Windows Dev</a>. I used <a href="https://modernievirt.blob.core.windows.net/vhd/VMBuild_20140627/Vagrant/IE11.Win7.For.Vagrant.box">IE11.Win7.For.Vagrant.box</a></p><h4>3. Create vagrant directory</h4><p>Let’s say we create directory vagrant-windows-ie11</p><pre>$ mkdir -p vagrant-windows-ie11</pre><p>Change directory to newly created directory.</p><pre>$cd vagrant-windows-ie11</pre><h4>4. Configure</h4><p>Use below given commands to configure virtual box with vagrant<br>Initialize vagrant by command,</p><pre>$ vagrant init windows</pre><pre><br>$ vagrant box add ~/Downloads/IE11.Win7.For.Vagrant.box — name=windows</pre><p>Replace path with your downloaded virtual box path. <br>Start the vagrant by command,</p><pre>$ vagrant up</pre><p>This will start VM with the box configured with vagrant.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=359a32257700" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get Rails logs on Kubernetes POD]]></title>
            <link>https://medium.com/@akshaymohite/how-to-get-rails-logs-on-kubernetes-pod-c1df008c354a?source=rss-2c9b02e41f11------2</link>
            <guid isPermaLink="false">https://medium.com/p/c1df008c354a</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Akshay Mohite]]></dc:creator>
            <pubDate>Sat, 16 Sep 2017 17:31:18 GMT</pubDate>
            <atom:updated>2017-09-16T17:31:18.930Z</atom:updated>
            <content:encoded><![CDATA[<p>This article assumes you have a good understanding of <a href="https://kubernetes.io/">what is Kubernetes</a> and how to <a href="https://engineering.adwerx.com/rails-on-kubernetes-8cd4940eacbe">deploy a Rails application using Kubernetes</a>. Many a times we need to check Rails application logs on staging or production environments.</p><p>There are two ways to get this thing done.</p><h4>From a Shell to a running container</h4><ol><li>Find out the POD to connect to.</li></ol><pre>kubectl get pods</pre><p>2. SSH to the Kubernetes POD</p><pre>kubectl exec -it [pod name] bash</pre><p>3. Tail to see the logs from the log file</p><pre>tail -f log/staging.log</pre><h4>2. Using kubectl logs</h4><p>We can use kubectl logs to connect to a POD using the pod name and cluster name. First get the list of PODs.</p><pre>kubectl get pods</pre><p>The command lists the pod names and the cluster to which they are associated. The sample output would look something like.</p><pre>NAME                           READY   STATUS    RESTARTS  AGE<br>cluster-name-4186638013-kgmq9  3/3     Running   0         16h</pre><p>Then, we can check Rails logs of the POD listed above using the command given below.</p><pre>kubectl logs [pod name] [cluster-name]</pre><p>Let’s say, the POD cluster-name-4186638014-kgmq9 belongs to a cluster with the name as cluster-name , then logs could be seen by the command given below.</p><pre>kubectl logs cluster-name-4186638013-kgmq9 cluster-name</pre><h3>Resources</h3><ol><li><a href="https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/">Get a Shell to a Running Container</a></li><li><a href="https://kubernetes-v1-4.github.io/docs/user-guide/kubectl/kubectl_logs/">Read more on the kubectl logs</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c1df008c354a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>