<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nirmal</title>
    <description>The latest articles on DEV Community by Nirmal (@nirmal_kumar).</description>
    <link>https://dev.to/nirmal_kumar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F122203%2F9d98a681-82b5-4142-af47-4a1552a2882b.jpg</url>
      <title>DEV Community: Nirmal</title>
      <link>https://dev.to/nirmal_kumar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nirmal_kumar"/>
    <language>en</language>
    <item>
      <title>How i used a simple python script to compare 2 huge csv file using Pandas</title>
      <dc:creator>Nirmal</dc:creator>
      <pubDate>Sun, 07 Mar 2021 10:56:56 +0000</pubDate>
      <link>https://dev.to/nirmal_kumar/how-i-used-a-simple-python-script-to-compare-2-huge-csv-file-using-pandas-24m9</link>
      <guid>https://dev.to/nirmal_kumar/how-i-used-a-simple-python-script-to-compare-2-huge-csv-file-using-pandas-24m9</guid>
      <description>&lt;p&gt;Recently i came across a requirement to compare a column data in a csv file with another csv file. These files contains 13 columns with 65 million of rows.&lt;/p&gt;

&lt;p&gt;Initially i thought it's simple one and used basic scripting with bash to process line by lines. Then, i realized it took me hours to get that processed. Then i moved to nodejs and then to python. No matter what language i used the result is same. It took more time and i felt it's not worth to process using the regular approach. Then i turned towards pandas library and i tried. To my surprise it processed within 10 seconds.&lt;/p&gt;

&lt;p&gt;The requirement is basically to match the emailId in the file1.csv against the md5 email hash of the file2.csv.&lt;/p&gt;

&lt;p&gt;Here the snippet i used to compare the matched dataset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import pandas as pd

import hashlib 

def md5hash(mailId):
    print(mailId)
    result = hashlib.md5(mailId)
    return result.digest()

df=pd.read_csv("file1.csv",dtype={ "emailId": "string"},low_memory=False)

# First get the has of the emailId and append to the existing row
df['md5_hashed'] = [hashlib.md5(val.encode()).hexdigest() for val in df['emailId']]
df.to_csv("hashed_records.csv",index=False)


#Store the data in a dataframe
df1=pd.read_csv("file1_with_hashed_email.csv",low_memory=False)
df2=pd.read_csv("file2.csv")
df2_hash=df2["md5_emailId"]

matched=df.loc[df1['md5_hashed'].isin(df2_hash)]
matched.to_csv("non-matched.csv",index=False)

#Just add a ~ to filter the unmatched
unmatched=df.loc[~df['md5_hashed'].isin(df2_hash)]
unmatched.to_csv("non-matched.csv",index=False)

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I worked with Pandas earlier. But i realized the power of pandas which has saved my hours instead of parsing with nodejs/db based solutions.&lt;/p&gt;

&lt;p&gt;Hope this helps someone who faced similar scenarios.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Detective Series - Website Down </title>
      <dc:creator>Nirmal</dc:creator>
      <pubDate>Fri, 05 Jul 2019 16:35:16 +0000</pubDate>
      <link>https://dev.to/nirmal_kumar/detective-series-website-down-50l1</link>
      <guid>https://dev.to/nirmal_kumar/detective-series-website-down-50l1</guid>
      <description>&lt;h1&gt;
  
  
  Detective Angadh
&lt;/h1&gt;

&lt;p&gt;Let's see how &lt;strong&gt;Angadh&lt;/strong&gt;, our Detective Master (Imaginary Character) resolved a Case in which the website was down for more than a week in a small company ABC. &lt;/p&gt;

&lt;h3&gt;
  
  
  Case Details :
&lt;/h3&gt;

&lt;p&gt;ABC Agency a small company which runs campaigns and advertisements business. They built a in-house web application and it was running smooth for more than 2 years. Suddenly the site is in-accessible/down for more than 1 week. Initially they had a developer who were taking care of all the development efforts and deployment this application. Unfortunately, the Developer is no more with the ABC Company and the end users has NO knowledge about the Application Hosting or Development or SourceCode related details. Now they are facing heat and their business continuity is completely halted. &lt;/p&gt;

&lt;h3&gt;
  
  
  Current State :
&lt;/h3&gt;

&lt;p&gt;ABC have no clues on how to resolve and bring the Website up. Even though they found some subject experts they couldn't help as ABC  doesn't have any information about the application code, database or hosting details.&lt;/p&gt;

&lt;p&gt;Finally, ABC reached our Detective Master &lt;strong&gt;Angadh&lt;/strong&gt; to get this resolved with the available information they have. The available information is the domain name of the in-house app they developed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Domain Name&lt;/strong&gt; :  &lt;strong&gt;digital-agency.abc.com&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Investigation :
&lt;/h3&gt;

&lt;p&gt;After reviewing the case study &lt;strong&gt;Angadh&lt;/strong&gt; prepared the following list to figure out whats going on behind with a Possible cause list and Troubleshooting checklist&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Possible Causes for the Website Down :&lt;/strong&gt; ( a Typical website with Less users)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;DNS Resolving Issues&lt;/li&gt;
&lt;li&gt;DDOS Attacks&lt;/li&gt;
&lt;li&gt;Server Down&lt;/li&gt;
&lt;li&gt;Web Server may be stopped&lt;/li&gt;
&lt;li&gt;Background Process  may have crashed&lt;/li&gt;
&lt;li&gt;May be Licensing related Issues based on Date&lt;/li&gt;
&lt;li&gt;Server IP Address Changes&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Checklist :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angadh&lt;/strong&gt; felt the only way to identify the issue is to get the details of the server and access them to troubleshoot further.&lt;/p&gt;

&lt;p&gt;Checklist : &lt;strong&gt;Identify Server, Hosting and Source Code&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[x]  Identify the IP Address of the Website&lt;/li&gt;
&lt;li&gt;[x]  Identify where the Application is hosted. (i.e) Where the Server is Local Premise/Cloud&lt;/li&gt;
&lt;li&gt;[x]  Identify the Application Platform (PHP, NodeJS etc)&lt;/li&gt;
&lt;li&gt;[x]  Identify whether they used Apache, PHP-FPM or NGIX&lt;/li&gt;
&lt;li&gt;[x]  Identify whether they had source code repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Angadh&lt;/strong&gt; used the following tools for clearing the above checklist.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A)&lt;/strong&gt; &lt;strong&gt;Where the Server &amp;amp; Location ?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ping the website domain Name from terminal. ping &lt;/li&gt;
&lt;li&gt;
&lt;a href="http://ping.eu"&gt;Ping.eu&lt;/a&gt; to trace the DNS route&lt;/li&gt;
&lt;li&gt;IPLocation using iplocation.net&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With these Tools, &lt;strong&gt;Angadh&lt;/strong&gt; Identified that the application is hosted on one of the Cloud Platform (Google Cloud) along with the IP Address details from the DNS&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B) How to get into the Server ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angadh&lt;/strong&gt; inquired the System Admin of ABC whether they have any account in Google Cloud Platform and he got a read only access to the GCP Platform. He was seeing couple of servers running there and using the VM Instance IP (Public IP Address gathered from Checklist A ), he SSH'ed to the server.&lt;/p&gt;

&lt;p&gt;He knows well by default, GCP will allow you to ssh to the Linux instance by injecting the on-the-fly keys to the server for the respective user who logged in and have access to the GCP Project account.&lt;/p&gt;

&lt;p&gt;He felt he was very close to the solution and trying to explore the files and directories on the server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;C) What is the App Platform &amp;amp; Where is the SourceCode Repository ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Reviewing the source code can give some hints about the platform the application was built. &lt;strong&gt;Angadh&lt;/strong&gt; inquired the same SysAdmin whether they have any accounts with GitHub,TFS, BitBucket etc. The SysAdmin mentioned he has an account with BitBucket and provided an access. &lt;strong&gt;Angadh&lt;/strong&gt; explored the repository and identified the right project and realised that the platform is built on NodeJS&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;D)  How this NodeJS Web App served in the 80 port ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;/var/www/html was one of the popular directory path used by majority of platforms. &lt;strong&gt;Angadh&lt;/strong&gt; tried to change the directory to that folder and he couldn't find anything there. The directory is empty.&lt;/p&gt;

&lt;p&gt;Its going to nightmare to figure out where these files are located and how this has been served. As per the code it was defaulted to port 8080. But someway they would have overridden in the Production server through 80 port or they would have did a reverse proxy using NGINX or Apache Proxy. He thought either these services are stopped or crashed for some unexpected reasons.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angadh&lt;/strong&gt; couldn't find any apache or nginx server running in the server process. So, the app was served in 80 port through a different mechanism.&lt;/p&gt;

&lt;p&gt;He even tried using CURL command to figure out whether the website is working inside the server. &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ curl http://digital-agency.abc.com

Could not resolve host: digital-agency.abc.com

 $ curl http://localhost:80 
Failed to connect to localhost port 80: Connection refused

$ curl http://localhost:8080
&amp;lt;html&amp;gt;
.....
.....
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;Hurray, &lt;strong&gt;Angadh&lt;/strong&gt; happy to see that he is getting some response when he used the curl command. Now what reverse proxy running behind in the server at 80 port.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;E)  Time Travel - Terminal Command History&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Looking at the state of information gathered so far, &lt;strong&gt;Angadh&lt;/strong&gt; realised the only way to resolve the issue this to figure out the recent commands executed in the server by the old developer.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ /etc/passwd
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;The above command listed some of the users.  Using su , he tried to switch to that user and executed the history command&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ history &amp;gt; command-history.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;This one command exported all the commands to a text file and &lt;strong&gt;Angadh&lt;/strong&gt; patiently reviewed each of the one and he is surprised to see the last command used in that user shell.&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;When he looked at this one command he realised that the app is not served through a traditional webserver like Apache or Nginx, but it uses directly the EXPRESS NodeJS Server and re-routed using iptables (feature in Linux Distros to route IP requests using rules)&lt;/p&gt;

&lt;p&gt;Now Angadh executed this command again and tried accessing the site and he was able to access the site without issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;F) The Final Part - Why the Website is up now ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After executing this command, the request to this server with 80 Port are redirected to the NodeJS 8080 Port and the only possible reason for the previous failure is they missed to save this changes in the IPTable.&lt;/p&gt;

&lt;p&gt;The command to save the IPTable Rules permanent &lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# https://unix.stackexchange.com/questions/52376/why-do-iptables-rules-disappear-when-restarting-my-debian-system
sh -c "iptables-save &amp;gt; /etc/iptables.rules"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Angadh&lt;/strong&gt; suspected that this issue have arised due to some server restarts or patches applied in the VM Instance running in the GCP. He went to the VM Instance and checked the last boot time and it exactly 9 days since the website down was reported.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    $ last reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Finally, Angadh Concluded the  root cause of the Website down and tried restarting again as he is very sure that the IPTables are saved as per the previous command. After a restart the WebApp worked well and he provided a detailed report to ABC and the company was very happy that he cracked all these i short duration and get their business running again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angadh&lt;/strong&gt;, knows well that the solution implemented using IPTables are not robust way. But his focus is to investigate and resolve the issues in the current environment which was working well for more than a year.&lt;/p&gt;

&lt;p&gt;Hope you enjoyed this detective series with Angadh.&lt;/p&gt;

</description>
      <category>detective</category>
      <category>websitedown</category>
    </item>
    <item>
      <title>Protect &amp; UnProtect Sheets Excel Sheets using VBA Macros (Excel Online)</title>
      <dc:creator>Nirmal</dc:creator>
      <pubDate>Sat, 29 Jun 2019 05:44:29 +0000</pubDate>
      <link>https://dev.to/nirmal_kumar/protect-unprotect-sheets-excel-sheets-using-vba-macros-excel-online-5ga9</link>
      <guid>https://dev.to/nirmal_kumar/protect-unprotect-sheets-excel-sheets-using-vba-macros-excel-online-5ga9</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1561612510-79b98876075e%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1500%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1561612510-79b98876075e%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D1500%26q%3D80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Excel Online
&lt;/h3&gt;

&lt;p&gt;With the advent of Modern Browsers and Web Standards, users have switched to online version of Spreadsheets and Word processors which are easily accessible from multiple devices and platforms. But still we can't forget the power of Macros written using VBA Scripting  mostly targeted for Excel &amp;amp; Word.&lt;/p&gt;

&lt;p&gt;We have been using Excel Spreadsheets as a Database for one of our Sharepoint Application. This Application generates multiple spreadsheets and provides access to users through Excel Online. We want to protect some of the files based on roles and user designation. Looks like currently Sheet protection/UnProtection is not supported in Excel online. This feature is also requested by 183 people in the &lt;a href="https://excel.uservoice.com/forums/274580-excel-online/suggestions/15642678-enable-protecting-unprotecting-worksheets-in-excel" rel="noopener noreferrer"&gt;Excel UserVoice&lt;/a&gt;. In the post i am sharing the workaround for the same.&lt;/p&gt;

&lt;h3&gt;
  
  
  Macro Solution for Protect/UnProtect
&lt;/h3&gt;

&lt;p&gt;The workaround we followed is to Enable the OneDrive Sync in the Sharepoint Application and then create a Macro to Protect/UnProtect all the 100+ of files. This will be immediately synced with OneDrive sync utility to online cloud. When you open the Excel Online and try editing the file, you will get a message "The sheet is protected."&lt;/p&gt;

&lt;p&gt;Here the Macro to protect/protect all the files in a given folder in the OneDrive folder.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Function ApplyProtection(sourceFolder as String,sheetName as string, isUnProtect As Boolean)


    Dim sheetPassword As String
    sheetPassword="YOUR SHEET PASSWORD"

    Dim actualFile As String

    Dim selFile As String
    actualFile = Dir(sourceFolder &amp;amp; "\*.xlsx")

    Do While Len(actualFile) &amp;gt; 0

        Application.ScreenUpdating = False
        Set wbResults = Workbooks.Open(filename:=sourceFolder &amp;amp; "/" &amp;amp; actualFile, UpdateLinks:=0, ReadOnly:=False)

        Dim reqSheet As Worksheet

        Set reqSheet = wbResults.Sheets(sheetName)
        Dim sheetState As Boolean

        sheetState = SheetProtected(reqSheet)

        If sheetState = False And isUnProtect = False Then
                reqSheet.Protect Password:=sheetPassword
        End If

        If sheetState = True And isUnProtect = True Then
                reqSheet.Unprotect Password:=sheetPassword
        End If

        actualFile = Dir
    Loop

End Function

​    
Private Function SheetProtected(TargetSheet As Worksheet) As Boolean
     'Function purpose:  To evaluate if a worksheet is protected

    If TargetSheet.ProtectContents = True Then
        SheetProtected = True
    Else
        SheetProtected = False
    End If

End Function

'Function Usage. Create Macro "ProtectFiles" and bind this ProtectAllFiles Module

Sub ProtectAllFiles()

Dim sourceFolder As String
sourceFolder="PUT YOUR SOURCE FOLDER PATH"
Call ApplyProtection(sourceFolder,False)

End Sub


'Function Usage. Create Macro "UnProtectFiles" and bind this UnProtectAllFiles Module
Sub UnProtectAllFiles()

Dim sourceFolder As String
sourceFolder="PUT YOUR SOURCE FOLDER PATH"
Call ApplyProtection(sourceFolder,True)

End Sub

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope this is helpful for someone who wants to protect sheets for the Online version of Excel.&lt;/p&gt;

&lt;p&gt;Happy Scripting.&lt;/p&gt;

</description>
      <category>macros</category>
      <category>excel</category>
      <category>protect</category>
      <category>password</category>
    </item>
    <item>
      <title>Proposal for Standardising User Digital Presence Profile using .yml</title>
      <dc:creator>Nirmal</dc:creator>
      <pubDate>Sun, 16 Jun 2019 12:02:55 +0000</pubDate>
      <link>https://dev.to/nirmal_kumar/proposal-for-standardising-user-digital-presence-profile-using-yml-2l3h</link>
      <guid>https://dev.to/nirmal_kumar/proposal-for-standardising-user-digital-presence-profile-using-yml-2l3h</guid>
      <description>&lt;p&gt;Being in a developer community, we come across many People who have been inspiring to us through their great works, blog posts, videos, course tutorials, podcasts and much more. What if we have a standard way to easily share those inspiring digital presence profile using a standard convention.&lt;/p&gt;

&lt;p&gt;Hereby sharing my thoughts on this to the community and would like to hear from you all. What you think and let me know and also share your comments if there any service which is already addressed these challenges.&lt;/p&gt;

&lt;h3&gt;
  
  
  Background
&lt;/h3&gt;

&lt;p&gt;Traditional way of Sharing Profiles in Phones uses VCARD File&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/VCard#jCard"&gt;(VCard, JCARD) - Wiki &lt;/a&gt;. But i don't find one to share a user profile about his  digital presence on the Web.&lt;/p&gt;

&lt;p&gt;Initial Proposal to Standardise Public Profile using a simple .yml file to easily share and consume by applications.&lt;/p&gt;
&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;In this RFC, I am proposing a standardised way to create public profiles and share them easily to other applications. This standardised proposal will not includes and personal details like Phone Number, Address etc. This focusses mostly on the user digital presence and the corresponding links to their works, blogs and any other public account which they want to share with anyone.&lt;/p&gt;
&lt;h3&gt;
  
  
  Challenges
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;With the increasing number of applications used by users, each of these application is using a Custom Registration form, OAuth based/SSO based Integration to collect the profile information. Once registered, the profile details are not updated on regular basis. Either some of the information are obsolete (assume the user blog site is moved to a different site)&lt;/li&gt;
&lt;li&gt;Even the Author doesn't have a common way to manage and update their profiles and keep the version history.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  How if everyone has a common profile as a yaml file :
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Asssume a user ABC, maintains his profile using a source control version like GitHub.com. They can create multiple profiles and share wherever needed with just a Url/file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(e.g) &lt;br&gt;
&lt;a href="http://github.com/"&gt;http://github.com/&lt;/a&gt;/my-profiles/default-profile.yml&lt;br&gt;
&lt;a href="http://github.com/"&gt;http://github.com/&lt;/a&gt;/my-profiles/work-profile.yml&lt;/p&gt;

&lt;p&gt;Applications who want to get the user profile information, they can simply read the yaml file and update them on regular intervals.&lt;/p&gt;

&lt;p&gt;Sample default-profile.yml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;website: gyanmoti.in
country: india
name: Nirmal
profile_image_url: "https://media.licdn.com/dms/image/C4D03AQFgMmks5SVa_w/profile-displayphoto-shrink_200_200/0?e=1566432000&amp;amp;v=beta&amp;amp;t=XehIjAJiGztgNbN42I5fY6RWvY8dpeN4J_czWn0IRY0"
social_accounts: 
  - facebook: NA
  - twitter: nirmal_kumar
  - youtube: NA
  - linked_in: nirmalweb
creations:
  - courses: http://usercourses.com
  - publications: http://userpublications
  - podcasts: http://userpodcasts

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Hereby requesting your comments for this public profile and thus making the web a better place to share and manage one's own profile.&lt;/p&gt;

&lt;p&gt;Feel free to send a PR if you wish to add anything to this proposal &lt;a href="https://github.com/nk-gears/public-user-profile-rfc"&gt;here&lt;/a&gt; in Github.&lt;/p&gt;

</description>
      <category>profile</category>
      <category>sharing</category>
    </item>
    <item>
      <title>Kubernetes - Refresher Notes </title>
      <dc:creator>Nirmal</dc:creator>
      <pubDate>Mon, 20 May 2019 01:51:20 +0000</pubDate>
      <link>https://dev.to/nirmal_kumar/kubernetes-refresher-notes-3aj0</link>
      <guid>https://dev.to/nirmal_kumar/kubernetes-refresher-notes-3aj0</guid>
      <description>&lt;p&gt;This post is for anyone to quickly refresh on the phrases in Kubernetes. If you are starting to explore Kubernetes then this can be used as a checklist on the areas you should be aware of. I have also included some basic commands to work with kubernetes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Concepts :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;KUBECONFIG&lt;/li&gt;
&lt;li&gt;Cluster - Master &amp;amp; Worker&lt;/li&gt;
&lt;li&gt;Node&lt;/li&gt;
&lt;li&gt;Node Port&lt;/li&gt;
&lt;li&gt;ClusterIP&lt;/li&gt;
&lt;li&gt;Statefulset vs Statetless&lt;/li&gt;
&lt;li&gt;Deployment&lt;/li&gt;
&lt;li&gt;Service&lt;/li&gt;
&lt;li&gt;Pod&lt;/li&gt;
&lt;li&gt;Namespace&lt;/li&gt;
&lt;li&gt;Context&lt;/li&gt;
&lt;li&gt;PersistentVolume&lt;/li&gt;
&lt;li&gt;PersistentVolumeClaim&lt;/li&gt;
&lt;li&gt;HostPath (Local)&lt;/li&gt;
&lt;li&gt;Ingress&lt;/li&gt;
&lt;li&gt;LoadBalancer&lt;/li&gt;
&lt;li&gt;ConfigMap&lt;/li&gt;
&lt;li&gt;Secrets&lt;/li&gt;
&lt;li&gt;DNS (..svc.cluster.local)&lt;/li&gt;
&lt;li&gt;KubeAdmin&lt;/li&gt;
&lt;li&gt;RBAC&lt;/li&gt;
&lt;li&gt;ServiceAccount&lt;/li&gt;
&lt;li&gt;Rollout&lt;/li&gt;
&lt;li&gt;Replica Scale&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Scripts
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Annotations,Labels &amp;amp; Selectors&lt;/li&gt;
&lt;li&gt;Kustomize (-k vs -f)&lt;/li&gt;
&lt;li&gt;Apply/Create/Patch&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Local Kubernetes Setup :
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Docker for Desktop Mac&lt;/li&gt;
&lt;li&gt;MiniKube&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Tools
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/kubernetes/dashboard"&gt;Kubernetes Dashboard&lt;/a&gt; - web UI for Kubernetes clusters&lt;/li&gt;
&lt;li&gt;Kubectl and Proxy&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://kubernetic.com/"&gt;Kubernetic Desktop&lt;/a&gt; - View Cluster Resources, Similar to Kitematic for Docker. &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/nownabe/sekret"&gt;Sekret&lt;/a&gt; - Encryption Tool for Kubernetes Secrets YAML&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/Soluto/kamus"&gt;Kamus&lt;/a&gt; - Encryption and Decryption solution for Kubernetes applications&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/ahmetb/kubectx/"&gt;Kubectx&lt;/a&gt; - Switch faster between clusters and namespaces in kubectl &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/jonmosco/kube-ps1"&gt;kube-ps1&lt;/a&gt; - Kubernetes prompt info for bash and zsh to see the current cluster context with namespace&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/txn2/kubefwd"&gt;Kubefwd&lt;/a&gt; - Bulk port forwarding Kubernetes services for local development.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basic Commands&lt;/p&gt;

&lt;h3&gt;
  
  
  Contexts
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
# Get all contexts
kubectl config get-contexts 

# Get Current Context
kubectl config current-context


# Set the default context
kubectl config use-context nk-dev-cluster  

kubectl config set-context nk-dev --namespace=rafa-dev --cluster=docker-for-desktop-cluster --user=docker-for-desktop


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Describe K8 Resources
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# kubectl describe &amp;lt;resource&amp;gt; &amp;lt;resourceName&amp;gt;
kubectl describe pods pod1

# Get the resource definition in yaml
kubectl get pod my-pod -o yaml 

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Expose a Service
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#expose a app named web-app as a service 

kubectl expose deployment web-app --name=web-app --type=NodePort --target-port=8080


# For Testing Locally
kubectl port-forward servicename 8080:8080

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Connect to the running Pod Container
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
kubectl exec web-app-fcc6b5ddf-k2txq -it -- /bin/sh

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Troubleshooting
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
#Simple Container to quickly run some curl commands to the pods
kubectl run curl-test --image=radial/busyboxplus:curl -i --tty --rm

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Thanks for reading this refresher.&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>notes</category>
    </item>
    <item>
      <title>Retrieve entire data from paginated API recursively.</title>
      <dc:creator>Nirmal</dc:creator>
      <pubDate>Sun, 17 Feb 2019 08:52:16 +0000</pubDate>
      <link>https://dev.to/nirmal_kumar/retrieve-entire-data-from-paginated-api-recursively-3pl4</link>
      <guid>https://dev.to/nirmal_kumar/retrieve-entire-data-from-paginated-api-recursively-3pl4</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dXQK8zC1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1536227284117-59ae8d1a69aa%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D800%26q%3D80" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dXQK8zC1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://images.unsplash.com/photo-1536227284117-59ae8d1a69aa%3Fixlib%3Drb-1.2.1%26ixid%3DeyJhcHBfaWQiOjEyMDd9%26auto%3Dformat%26fit%3Dcrop%26w%3D800%26q%3D80" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post i am going to show to retrieve data from a paginated API using recursive method.&lt;/p&gt;

&lt;p&gt;To explain the functionality, I am going to use a dummy REST API which i created in the mockapi.io. Currently the dataset has 91 records. By default it returns 91 records. In realtime, the dataset may be huge of more than 10000's data items. It's not recommended to query the entire dataset in a single api as it burdens the server performance and also place a heavy load on the client side as well. The recommended approach is to paginate the results when you are showing in the client side. That's the reason most of the API's provides some additional filters in the api to return only the records which the user is interested instead of returning the entire datastore.&lt;/p&gt;

&lt;p&gt;Here some of the common filters used by the API's.&lt;/p&gt;

&lt;p&gt;1.offset, limit : "limit" determines how many records to retrieve starting from the "offset"&lt;br&gt;
2.page, limit : "page" determines which data the server needs to return based on number of "limit" -&amp;gt; records per page .&lt;/p&gt;

&lt;p&gt;Please refer the respective API developer manual for more details on how to retrieve paginated results.&lt;/p&gt;

&lt;p&gt;Sample API End Points :&lt;/p&gt;

&lt;p&gt;Without Pagination : &lt;br&gt;
&lt;a href="https://5b5cb0546a725000148a67ab.mockapi.io/api/v1/users"&gt;https://5b5cb0546a725000148a67ab.mockapi.io/api/v1/users&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Pagination :&lt;br&gt;
&lt;a href="https://5b5cb0546a725000148a67ab.mockapi.io/api/v1/users?page=4&amp;amp;limit=2"&gt;https://5b5cb0546a725000148a67ab.mockapi.io/api/v1/users?page=4&amp;amp;limit=2&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above API endpoints are good for a normal use case. But they are requirements in which you need to retrieve all the data from the API and the API is designed to return only 50 records per call. In this scenario, we can create a recursive paginated API call and capture the entire dataset.&lt;/p&gt;

&lt;p&gt;Remember,If you are not handling this properly it may end up with infinite looping and your browser may hang. In this example i have limited 20 items per page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const limitPerPage=20;
const apiUrl="https://5b5cb0546a725000148a67ab.mockapi.io/api/v1/users";

const getUsers = async function(pageNo = 1) {

let actualUrl=apiUrl + `?page=${pageNo}&amp;amp;limit=${limitPerPage}`;
var apiResults=await fetch(actualUrl)
.then(resp=&amp;gt;{
return resp.json();
});

return apiResults;

}

const getEntireUserList = async function(pageNo = 1) {
  const results = await getUsers(pageNo);
  console.log("Retreiving data from API for page : " + pageNo);
  if (results.length&amp;gt;0) {
    return results.concat(await getEntireUserList(pageNo+1));
  } else {
    return results;
  }
};


(async ()=&amp;gt;{

    const entireList=await getEntireUserList();
    console.log(entireList);

})();

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;I have used the browser developer console to show the output. Please see this gif &lt;a href="http://recordit.co/p3FkQS7QpJ"&gt;http://recordit.co/p3FkQS7QpJ&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading &amp;amp; happy coding..&lt;/p&gt;

</description>
      <category>api</category>
      <category>paging</category>
      <category>recursive</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
