<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Posts on Shweta Kadam</title>
    <link>https://shwetakadam.com/posts/</link>
    <description>Recent content in Posts on Shweta Kadam</description>
    <image>
      <url>https://shwetakadam.com/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</url>
      <link>https://shwetakadam.com/%3Clink%20or%20path%20of%20image%20for%20opengraph,%20twitter-cards%3E</link>
    </image>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <lastBuildDate>Sun, 20 Apr 2025 21:41:00 +0530</lastBuildDate><atom:link href="https://shwetakadam.com/posts/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title> Exploring TLS Automation — A Proof of Concept with n8n and Vault</title>
      <link>https://shwetakadam.com/posts/exploring-tls-automation-a-proof-of-concept-with-n8n-and-vault/</link>
      <pubDate>Sun, 20 Apr 2025 21:41:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/exploring-tls-automation-a-proof-of-concept-with-n8n-and-vault/</guid>
      <description>Exploring TLS Cert Automation — A Proof of Concept with n8n and Vault Managing TLS certificates often means chasing expiry dates, setting reminders, and manually rotating certs—a process that’s fragile and prone to outages. To prove there’s a better way, I built a prototype combining n8n and HashiCorp Vault that demonstrates the power of automation, and had the opportunity to present this work as a talk at Mumbai FOSS 2025. The Prototype in Action</description>
      <content:encoded><![CDATA[<h2 id="exploring-tls-cert-automation--a-proof-of-concept-with-n8n-and-vault">Exploring TLS Cert Automation — A Proof of Concept with n8n and Vault</h2>
<p>Managing TLS certificates often means chasing expiry dates, setting reminders, and manually rotating certs—a process that’s fragile and prone to outages. To prove there’s a better way, I built a prototype combining n8n and HashiCorp Vault that demonstrates the power of automation, and had the opportunity to present this work as a talk at Mumbai FOSS 2025.
The Prototype in Action</p>
<p>The workflow I showcased was simple yet powerful:</p>
<p>Monitoring expiry with early alerts</p>
<p>Triggering automatic renewals via Vault’s PKI engine</p>
<p>Deploying renewed certificates without manual steps</p>
<p>Validating results in Vault for full transparency</p>
<p>This wasn’t a slide deck—it was about demonstrating the ability such a system can provide: hands-off certificate lifecycle management, built entirely on open-source tools.</p>
<p>Why n8n + Vault?</p>
<p>n8n brings the flexibility of a visual automation platform—easy to extend, no coding required for most steps.</p>
<p>Vault provides a battle-tested PKI engine with strong security guarantees.</p>
<p>Together, they eliminate vendor lock-in, subscription costs, and opaque “black box” processes.</p>
<p>Beyond the Demo</p>
<p>While I shared this prototype in a lightning talk at Mumbai FOSS 2025, the real takeaway is that any team can replicate it today. Whether managing a handful of certs or rolling this out across multiple environments, the approach scales with your needs.</p>
<p>As a bonus, this same session was also wait-listed for the Open Source Summit India 2025, highlighting the growing interest in practical, open-source security automation.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title> My First Tech Talk: The Journey from Panic to Presentation</title>
      <link>https://shwetakadam.com/posts/my-first-tech-talk-the-journey-from-panic-to-presentation/</link>
      <pubDate>Wed, 02 Oct 2024 21:41:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/my-first-tech-talk-the-journey-from-panic-to-presentation/</guid>
      <description>My First Tech Talk: The Journey from Panic to Presentation I recently had an opportunity to give a technical talk at GitTogether Mumbai. This is a small blog post based on my experience of giving a talk and a little behind-the-scenes turmoil written as a blog post.
How Do You Secure a Speaking Slot? This was the big question! It took me countless applications, several rejections, and a sprinkle of luck.</description>
      <content:encoded><![CDATA[<h1 id="my-first-tech-talk-the-journey-from-panic-to-presentation">My First Tech Talk: The Journey from Panic to Presentation</h1>
<p>I recently had an opportunity to give a technical talk at GitTogether Mumbai. This is a small blog post based on my experience of giving a talk and a little behind-the-scenes turmoil written as a blog post.</p>
<h2 id="how-do-you-secure-a-speaking-slot">How Do You Secure a Speaking Slot?</h2>
<p>This was the big question! It took me countless applications, several rejections, and a sprinkle of luck. The trick? Pitch a talk that fits what the audience and organizers are looking for—it&rsquo;s all about relevance.</p>
<h2 id="what-happens-after-my-talk-was-selected">What happens after my talk was selected?</h2>
<p>The talk has been selected &hellip;&hellip;so now what?
The Panic strikes through!!
But so does the cycle of preparation&hellip;&hellip;</p>
<p><img loading="lazy" src="/img/presentation.png" alt=""  />
</p>
<h2 id="will-they-find-it-interesting">Will They Find It Interesting?</h2>
<p>Creating a talk is one thing, delivering it in a way that keeps the audience engaged is another.
Once the panic and excitement strikes through so does the preparation. Preparing the contents for a talk is very different from presenting it. The information you INTEND to convey has to reach the audience in a way they perceive it and it has to be relatable and interesting for them to continue to listen!</p>
<h2 id="feedback-feedback-feedback-and-continuous-feedback">Feedback Feedback Feedback and Continuous Feedback!</h2>
<p>Ah yes, feedback—every speaker’s best friend (and occasional frenemy). It’s the secret sauce to leveling up your presentation, and trust me, you’ll need lots of it! I took every nugget of constructive criticism and tweaked my talk like a codebase on release day.</p>
<p>Now, let’s talk demos. The ultimate double-edged sword. Engineers love them but for presenters? A living nightmare! And guess what? I willingly walked into that nightmare. Yep, I gave a demo!</p>
<p>Why? Well, demos are like live-action thrillers—great for the audience but full of nerve-wracking moments for the speaker. Something is bound to go wrong (and spoiler: it did). Cue the sweaty palms and heart palpitations as things start to go wrong! But hey, the key is to stay calm, crack a joke or two, and power through the glitches.</p>
<p>In hindsight, the demo could’ve been smoother, but for my first big talk, it wasn’t a complete disaster. Want to witness the chaos? Here’s the link to the demo fail <a href="https://www.youtube.com/watch?v=j_D0SG0yMEk">Link</a> I’m open to feedback (and maybe a little sympathy)!</p>
<h2 id="final-thoughts">Final Thoughts</h2>
<p>Every developer should experience the thrill of presenting their work to an appreciative public audience. It&rsquo;s more than just sharing your knowledge—it’s a chance to push your limits, boost your confidence, and ignite a deeper passion for learning. Stepping onto that stage changes the way you see yourself as a developer, fueling your drive to grow and evolve. Plus, there’s nothing quite like the energy of connecting with others and realizing how far you’ve come on your journey!</p>
<p>Do checkout my presentation link and feel free to provide any feedback via <a href="hello@shweta.io">email</a> or on <a href="https://www.linkedin.com/in/shwetarkadam/">Linkedin</a>!</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/j_D0SG0yMEk?si=xC1OJBQE2eM9graJ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt (TIL): Leetcode Mini Bite Heap and Priority Queue </title>
      <link>https://shwetakadam.com/posts/today-i-learnt-til-leetcode-mini-bite-heap-and-priority-queue/</link>
      <pubDate>Tue, 15 Aug 2023 21:24:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/today-i-learnt-til-leetcode-mini-bite-heap-and-priority-queue/</guid>
      <description>I decided to write a blog after a long time of pondering and no ideas to write anything interesting about. So I just decided to write about leetcode today which Im doing. Some mini tricks I learnt by doing the problem https://leetcode.com/problems/kth-largest-element-in-a-stream/description/ When the problem asks for kth smallest or kth largest, typically it is supposed to be solved using Heap. And for Kth largest element the opposite element (which is smallest in this case is on top).</description>
      <content:encoded><![CDATA[<p>I decided to write a blog after a long time of pondering and no ideas to write anything interesting about. So I just decided to write about leetcode today which Im doing.
Some mini tricks I learnt by doing the problem <a href="https://leetcode.com/problems/kth-largest-element-in-a-stream/description/">https://leetcode.com/problems/kth-largest-element-in-a-stream/description/</a>
When the problem asks for kth smallest or kth largest, typically it is supposed to be solved using Heap.
And for Kth largest element the opposite element (which is smallest in this case is on top).
Typically when one says Heap, we usually remember the tree diagram on google. However when in it comes to solving DS leetcode style problem I found out just using a Priority queue is simply enough.
In Priority Queue, you just add the elements and it gives them a priority and sorts it .</p>
<p>In short,</p>
<pre tabindex="0"><code>Kth largest --&gt; Min heap --&gt; where smallest element is at top --&gt; Uses Priority queue 
Kth smallest --&gt; Max heap --&gt; where the Largest element is at top --&gt; Uses Priority queue in reverse Order
</code></pre><p>Also
Priority Queue</p>
<ul>
<li>add : when an element cannot be added in queue it throws an exception</li>
<li>offer : when an element cannot be added in queue it returns false</li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Using Thinking Fast and Slow Concepts on Programming</title>
      <link>https://shwetakadam.com/posts/using-thinking-fast-and-slow-concepts-on-programming/</link>
      <pubDate>Thu, 18 May 2023 23:10:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/using-thinking-fast-and-slow-concepts-on-programming/</guid>
      <description>Recently my friend gave me a Thkinking Fast and Slow Concepts book by Daniel Kahneman. I related to a lot of his. concepts and how it apply to my daily programming life a lot!
The book involves recognizing and managing cognitive biases while leveraging both intuitive and analytical thinking.the book explains 2 systems System 1 (Fast Thinking): This is the intuitive and automatic mode of thinking. It operates quickly and without much effort, making snap judgments and assumptions.</description>
      <content:encoded><![CDATA[<p>Recently my friend gave me a Thkinking Fast and Slow Concepts book by Daniel Kahneman. I related to a lot of his. concepts and how it apply to my daily programming life a lot!</p>
<p>The book involves recognizing and managing cognitive biases while leveraging both intuitive and analytical thinking.the book explains 2 systems
System 1 (Fast Thinking): This is the intuitive and automatic mode of thinking. It operates quickly and without much effort, making snap judgments and assumptions. It’s driven by emotion and instinct.</p>
<p>System 2 (Slow Thinking): This is the deliberate and analytical mode of thinking. It requires effort and is used in complex decision-making, requiring attention and logical thinking.</p>
<p>As a programmer, we need to use System 2 a lot but sometimes in certain deadline situations, we tend to use System 1 a lot. Throughout the book, Kahneman discusses how these two systems influence our decisions and lead to various cognitive biases. Some key concepts include:</p>
<p>Heuristics: Mental shortcuts that ease the cognitive load of making decisions.
Prospect Theory: People value gains and losses differently, leading to irrational decision-making.
The Anchoring Effect: Relying too heavily on the first piece of information seen (the &ldquo;anchor&rdquo;) when making decisions.
Overconfidence Bias: The tendency to overestimate one’s abilities.
Framing Effect: Decisions are influenced by the way information is presented.</p>
<p>Here are some of the strategies that I thought were pretty useful from the book and could apply in my  daily work.</p>
<p>Code Reviews: Engage in regular code reviews with peers. This practice encourages System 2 thinking by requiring you to explain and justify your coding decisions. It also helps identify biases or errors that might have been overlooked by the original coder.</p>
<p>Pair Programming: This technique involves two programmers working together at one workstation/huddle. One writes the code while the other reviews each line as it is typed. The reviewer (navigator) uses System 2 thinking, providing immediate feedback and suggestions, while the driver can engage more in System 1, especially in familiar areas of coding.</p>
<p>Test-Driven Development (TDD): TDD requires you to write tests before you write the actual code. This approach forces you to slow down and think about what you want to achieve (System 2) before getting involved in the coding itself (System 1).</p>
<p>Refactoring with a Purpose: Systematically refactor code to improve its structure and readability without changing its functionality. This requires careful, analytical thinking to ensure that improvements are actual improvements and not just changes based on personal bias or preference.</p>
<p>Using Linters and Static Analysis Tools: Tools that analyze your code for errors, potential bugs, or style issues can help counteract the overconfidence bias by providing a &ldquo;second opinion&rdquo; that challenges your assumptions about your own code&rsquo;s correctness.</p>
<p>Heuristic Checklists: Develop or use existing checklists for code quality, security standards, and performance optimizations. This approach leverages structured thinking to ensure that common pitfalls and best practices are systematically considered.</p>
<p>Mindful Debugging: When debugging, it&rsquo;s easy to quickly form a hypothesis and get tunnel vision. To counteract this, consciously explore multiple hypotheses and systematically verify or dismiss each one, ensuring that your initial assumptions don&rsquo;t blind you to other possibilities.</p>
<p>Documentation and Comments: Writing clear documentation and code comments encourages you to think through your design and implementation choices. This reflective practice can help clarify your thoughts and expose any weak points in your reasoning.Though it should not be overused as people tend to write complicated code and cover it with comments and documentation.</p>
<p>Regular Training on Cognitive Biases: Conduct sessions to educate yourself and your team on different types of cognitive biases and how they can affect programming and decision-making. This awareness can help everyone be more mindful of their thinking patterns and decision-making processes.</p>
<p>Break Large Problems into Smaller Parts: When faced with a complex problem, break it down into smaller, manageable tasks. This strategy helps manage the cognitive load, allowing System 2 to engage more effectively without being overwhelmed.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt : Kubectl commands for debugging</title>
      <link>https://shwetakadam.com/posts/today-i-learnt-kubectl-commands-for-debugging/</link>
      <pubDate>Fri, 03 Mar 2023 23:10:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/today-i-learnt-kubectl-commands-for-debugging/</guid>
      <description>Today I learnt a few kubectl commands which I used to for debugging a few issues in testing environment at work.
To check logs kubectl logs -f pod_name Useful when you need to check logs inside a pod.
To get the bin bash inside a pod kubectl --exec --stdin --tty podname --bin/bash This is useful command to check for certain versions or debugging which is done This command was helpful for determining Java versions inside the pod which was used in a particular environment.</description>
      <content:encoded><![CDATA[<p>Today I learnt a few kubectl commands which I used to for debugging a few issues in testing environment at work.</p>
<h2 id="to-check-logs">To check logs</h2>
<pre tabindex="0"><code class="language-kubectl" data-lang="kubectl">kubectl logs  -f pod_name
</code></pre><p>Useful when you need to check logs inside a pod.</p>
<h2 id="to-get-the-bin-bash-inside-a-pod">To get the bin bash inside a pod</h2>
<pre tabindex="0"><code class="language-kubectl" data-lang="kubectl">kubectl --exec --stdin --tty podname --bin/bash
</code></pre><p>This is useful command to check for certain versions or debugging which is done
This command was helpful for determining Java versions inside the pod which was used in a particular environment.
Anytime you want to run terminal commands such as <code>java --version</code> Or something similar to execute commands which need a bash shell.This is a good approach.
Helps to know which dependencies a pod uses.</p>
<h2 id="scale-up-and-downscale-your-pod">Scale up and downscale your pod</h2>
<pre tabindex="0"><code class="language-kubectl" data-lang="kubectl">kubectl scale deployment &lt;application-name&gt; --replicas=0
kubectl scale deployment &lt;application-name&gt; --replicas=1
</code></pre><p>If your company uses a UI to scale up application pods and that UI tests your patience then this is a quick fix(Not recommended in PROD).</p>
<h2 id="get-description-of-your-pod-dot">Get description of your pod.</h2>
<pre tabindex="0"><code class="language-kubectl" data-lang="kubectl">kubectl describe services
</code></pre><p>This commands gives general information regarding image IDs.
If your company uses Jenkins to make builds and then deploys them uses kubernetes,and if you need a way to verify if Jenkins deployed that particular build.This one helps as you can cross verify that information using attributes such as (sha)</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>When to ask for help as a Software Engineer?</title>
      <link>https://shwetakadam.com/posts/when-to-ask-for-help-as-a-software-engineer/</link>
      <pubDate>Fri, 03 Mar 2023 23:10:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/when-to-ask-for-help-as-a-software-engineer/</guid>
      <description>We have all experienced this often where we are stuck on an issue. We feel we have not earned the right to ask the doubt yet till we reach an imaginary threshold or baseline. The feeling of doing some research before reaching out to someone.
Then time passes and so does the feeling of shame.The shame of not being able to solve the doubt on my own and yet feeling the hesitation to reach out to a senior.</description>
      <content:encoded><![CDATA[<p>We have all experienced this often where we are stuck on an issue. We feel  we have not earned the right to ask the doubt yet till we reach an imaginary threshold or baseline.
The feeling of doing some research before reaching out to someone.</p>
<p>Then time passes and so does the feeling of shame.The shame of not being able to solve the doubt on my own and yet feeling the hesitation to reach out to a senior.</p>
<p>The best resolution no matter how much hesitation or shame is to ASK NOW!
It does two things:-</p>
<ul>
<li>Filters out your misunderstandings and gives you clarity.</li>
<li>Always end up learning something new.</li>
<li>Also if the point is in just the idea or analysis stage ,one can validate the effectiveness of an idea faster . How much important or effective an idea is as a solution to a problem or if there are better solutions.</li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Learning Angular as a Java Developer</title>
      <link>https://shwetakadam.com/posts/learning-angular-as-a-java-developer/</link>
      <pubDate>Fri, 03 Mar 2023 23:03:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/learning-angular-as-a-java-developer/</guid>
      <description>Recently got an opportunity to work on angular project.With no previous experience in angular, I had some catch up to do in terms of web development.So here is a small blog post.
What is Angular ? Framework to build client side applications.
Why would you use Angular? Vanilla JQuery code gets harder to maintain,harder to test.
And like all most of the frameworks Junction, Angular provides:
Angular gave our applications clean structure.</description>
      <content:encoded><![CDATA[<p>Recently got an opportunity to work on angular project.With no previous experience in angular, I had some catch up to do in terms of web development.So here is a small blog post.</p>
<h2 id="what-is-angular">What is Angular ?</h2>
<p>Framework to build client side applications.</p>
<h2 id="why-would-you-use-angular">Why would you use Angular?</h2>
<p>Vanilla JQuery code gets harder to maintain,harder to test.</p>
<p>And like all most of the frameworks Junction, Angular provides:</p>
<h3 id="angular-gave-our-applications-clean-structure-dot">Angular gave our applications clean structure.</h3>
<h3 id="includes-lots-of-reusable-code">Includes lots of Reusable code</h3>
<h3 id="makes-the-application-more-testable">Makes the application more testable</h3>
<h2 id="also-easier-to-co-relate-to-learn-from-java-perspective-because-of-2-features">Also easier to co-relate to learn from Java perspective because of 2 features</h2>
<h3 id="dependency-injection">Dependency Injection</h3>
<h3 id="typescript">Typescript</h3>
<p>gives our plain JS applications some structure &amp; enables static typing.</p>
<h2 id="3-handles-server-side-rendering">3 Handles Server-side Rendering</h2>
<p>We don&rsquo;t save the data in client. We save it in server. Example:  Data is wiped clean when user creates form.</p>
<p>Frontend Backend           &ndash;&gt;     Backend
(Presentation logic)                Data APIs Business</p>
<p>Let&rsquo;s get familiar with some terms in Angular first. Below is small comparison to co relate between Java and angular.</p>
<table>
<thead>
<tr>
<th>What</th>
<th>Java</th>
<th>Angular</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dependency management</td>
<td>Maven</td>
<td>npm(node package manager )</td>
</tr>
<tr>
<td>Build/package</td>
<td>Maven</td>
<td>webpack</td>
</tr>
<tr>
<td>Library  Repo</td>
<td>Maven Central</td>
<td>npmjs.org</td>
</tr>
<tr>
<td>Project Descriptor</td>
<td>pom.xml</td>
<td>package.json</td>
</tr>
<tr>
<td>Programming language</td>
<td>Java</td>
<td>Typescript ,HTML</td>
</tr>
<tr>
<td>Platform runtime</td>
<td>JVM</td>
<td>Browser/NodeJS</td>
</tr>
<tr>
<td>Unit Testing</td>
<td>Junit</td>
<td>Karma/jasmine</td>
</tr>
<tr>
<td>Reactive Programming</td>
<td>RxJava</td>
<td>RxJS</td>
</tr>
<tr>
<td>Code style checks</td>
<td>Sonar</td>
<td>eslint</td>
</tr>
<tr>
<td>Browser End-to-end testing</td>
<td>Webdriver</td>
<td>Protractor (Layer on top of selenium)</td>
</tr>
</tbody>
</table>
<p>Like java has a main file. Similarly in angular, there is a <code>main.ts</code> file which is the starting point of our application.It is present in bootstrapmodule(Appmodule).</p>
<h2 id="webpack">Webpack</h2>
<h3 id="angular-uses-a-tool-called-webpack-which-is-a-static-module-bundler-dot-it-takes-all-our-html-css-and-js-files-and-bundles-them-into-a-single-file-which-is-loaded-by-the-browser-dot-it-bundles-application-source-code-into-convenient-chunks-to-improve-performance-and-load-times-dot">Angular uses a tool called <code>webpack</code> which is a static module bundler.It takes all our HTML,CSS and JS files and bundles them into a single file which is loaded by the browser. It bundles application source code into convenient chunks, to improve performance and load times.</h3>
<h2 id="hot-module-replacement">Hot Module replacement</h2>
<p>Hot Module Replacement (HMR) is a feature of webpack that allows developers to update code changes without the need for a full page reload.
When a code change is made, HMR only updates the module that has been modified, which means the application can continue running while the changes are applied.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt TIL :GIT Modules &amp; How to effectively remove submodules</title>
      <link>https://shwetakadam.com/posts/today-i-learnt-til-git-modules-how-to-effectively-remove-submodules/</link>
      <pubDate>Sun, 01 Jan 2023 00:30:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/today-i-learnt-til-git-modules-how-to-effectively-remove-submodules/</guid>
      <description>While I migrating this website, I came across many issues. One such issue was git submodule.So here is a post on it.
what is a git submodule? Git submodule is a way to include another repository in Git as a sub directory in one repository.
It allows you to keep another repo(your own repo or someone else) in your repo as a subdirectory It is useful for track that repo&amp;rsquo;s changes and use that project repo as a reference.</description>
      <content:encoded><![CDATA[<p>While I migrating this website, I came across many issues. One such issue was git submodule.So here is a post on it.</p>
<h2 id="what-is-a-git-submodule">what is a git submodule?</h2>
<p>Git submodule is a way to include another repository in Git as a sub directory in one repository.</p>
<p>It allows you to keep another repo(your own repo or someone else) in your repo as a subdirectory
It is useful for track that repo&rsquo;s  changes and use that project repo as a reference.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git submodule add https://github.com/username/repo-name.git
</span></span></code></pre></div><p>It’s important to note the <code>username</code> of the repo you are adding.
Because whose username is present in the repo, the repo belongs to them. So they have ownership of the repo and the changes over it.</p>
<h2 id="what-issue-i-faced">What issue I faced ?</h2>
<p>I use Hugo Papermod theme for this website.
I used the git submodule method for installing this theme in my Hugo repo.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git submodule https://github.com/adityatelange/hugo-PaperMod.git --depth<span class="o">=</span><span class="m">1</span>
</span></span></code></pre></div><p>Instead of</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git submodule https://github.com/MY-GITHUB-USERNAME/hugo-PaperMod.git --depth<span class="o">=</span><span class="m">1</span>
</span></span></code></pre></div><h2 id="what-did-this-lead-to">What did this lead to?</h2>
<p>For adding  GitHub comments feature, the changes had to be done inside <code>layout/partials/comments.html</code></p>
<p>This file is present in the submodule directory.This lead to the below error:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">warning: adding embedded git repository: themes/PaperMod
</span></span><span class="line"><span class="cl">hint: You’ve added another git repository inside your current repository.
</span></span><span class="line"><span class="cl">hint: Clones of the outer repository will not contain the contents of
</span></span><span class="line"><span class="cl">hint: the embedded repository and will not know how to obtain it.
</span></span><span class="line"><span class="cl">hint: If you meant to add a submodule, use:
</span></span><span class="line"><span class="cl">hint:
</span></span><span class="line"><span class="cl">hint:     git submodule add &lt;url&gt; themes/PaperMod
</span></span><span class="line"><span class="cl">hint:
</span></span><span class="line"><span class="cl">hint: If you added this path by mistake, you can remove it from the
</span></span><span class="line"><span class="cl">hint: index with:
</span></span><span class="line"><span class="cl">hint:
</span></span><span class="line"><span class="cl">hint:     git rm --cached themes/PaperMod
</span></span><span class="line"><span class="cl">hint:
</span></span><span class="line"><span class="cl">hint: See “git <span class="nb">help</span> submodule” <span class="k">for</span> more information.
</span></span></code></pre></div><p>I couldn’t push my changes into repo since I did not have ownership over it</p>
<h2 id="how-to-solve-this">How to solve this?</h2>
<p>There were two ways to solve this:-</p>
<ol>
<li>I make a PR of my changes in aditya subdirectory.</li>
</ol>
<p>The owner approves my changes.
This is not possible in this case since these changes are custom to my repo and not feature enhancement or bug fix</p>
<ol>
<li>I remove all git submodule of Aditya ’s changes .Fork Aditya papermod theme(so now the forked repo belong to me ) and link the git submodule to my forked repo.</li>
</ol>
<p>I went with the second route.</p>
<p>But turns out removing all references of git submodule can be quite annoying.</p>
<p>Every time I thought I removed all submodule references using stackoverflow answers I ended up on the same above error.
This meant there were still submodule references present.</p>
<p>Found this useful <a href="https://gist.github.com/myusuf3/7f645819ded92bda6677">Github Gist</a></p>
<ul>
<li>Delete the relevant section from the .gitmodules file. Delete the relevant section from the <code>.gitmodules</code> file.</li>
</ul>
<p>In my case entries looked like</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">│ <span class="o">[</span>submodule “themes/PaperMod”<span class="o">]</span>
</span></span><span class="line"><span class="cl">    <span class="m">2</span>   │     <span class="nv">path</span> <span class="o">=</span> themes/PaperMod
</span></span><span class="line"><span class="cl">    <span class="m">3</span>   │     <span class="nv">url</span> <span class="o">=</span> https://github.com/adityatelange/hugo-PaperMod.git
</span></span></code></pre></div><ul>
<li>
<p>Stage the .gitmodules <code>changes git add .gitmodules</code></p>
</li>
<li>
<p>Delete the relevant section from <code>.git/config</code>
For me no submodule entries were present.</p>
</li>
<li>
<p>Run <code>git rm --cached path_to_submodule</code> (no trailing slash).In my case it was <code>git rm --cached themes/Papermod</code></p>
</li>
<li>
<p>Run <code>rm -rf .git/modules/path_to_submodule</code> (no trailing slash).</p>
</li>
<li>
<p>Commit <code>git commit -m “Removed submodule ”</code></p>
</li>
<li>
<p>Delete the now untracked submodule files <code>rm -rf path_to_submodule</code></p>
</li>
</ul>
<p>This removed my git submodules entries.
And then again created a submodule entry with my usernameAnd that&rsquo;s how the git submodule error was solved.
**</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>My 2022 Year Review📓</title>
      <link>https://shwetakadam.com/posts/my-2022-year-review/</link>
      <pubDate>Mon, 26 Dec 2022 01:49:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/my-2022-year-review/</guid>
      <description>It&amp;rsquo;s been a fruitful and amazing year.And that means documenting my small journey as a blog post.
Work New friends and mentors I joined Boku in September 2021 &amp;amp; had the pleasure to meet some amazing developers and colleagues.
I got the opportunity to learn a lot while on the job, through mentors, environment &amp;amp; infrastructure itself.
Promoted to Software Engineer 2 The title says all and I am grateful for it.</description>
      <content:encoded><![CDATA[<p>It&rsquo;s been a fruitful and amazing year.And that means documenting my small journey as a blog post.</p>
<figure>
    <img loading="lazy" src="/img/giphy.webp"/> 
</figure>

<h2 id="work">Work</h2>
<h3 id="new-friends-and-mentors">New friends and mentors</h3>
<p>I joined Boku in September 2021 &amp; had the pleasure to meet some amazing developers and colleagues.</p>
<p>I got the opportunity to learn a lot while on the job, through mentors, environment &amp; infrastructure itself.</p>
<h3 id="promoted-to-software-engineer-2">Promoted to Software Engineer 2</h3>
<p>The title says all and I am grateful for it. Without such an awesome environment, I wouldn&rsquo;t have faced the challenges, support and mentorship that I did.</p>
<h2 id="blogging">Blogging</h2>
<h3 id="migrating-my-blog-from-jekyll-to-hugo">Migrating my  blog from Jekyll to Hugo</h3>
<p>I regretted not writing more posts in 2019 even though I had my blog setup on Jekyll .
It was not the lack of time that bothered me but more of lack of proper process.</p>
<p>As atomic habits books rightly said to develop a habit ,the habit must be easier to execute.After shifting to Doom
Emacs this year to make documentation, it made sense to shift my blog from Jekyll to Hugo(Incoming blog post stay tuned!).</p>
<p>Writing my posts in markdown just for my blog was creating the friction in my writing process.
Writing all my posts in .org mode helped me reduced that friction and made my process better.</p>
<p>Also by introducing small Today I learnt concepts (tils) posts helped me further in being consistent in writing. As I wrote about the the things I learnt while working and didn&rsquo;t need to invest extra time and effort into researching and writing separate posts.</p>
<h2 id="lessons-learnt">Lessons learnt:</h2>
<h3 id="do-one-thing-at-a-time">Do one thing at a time</h3>
<p>One of the biggest lessons I have learnt this year is not to take on too many projects at once .To focus on one thing and to do that properly.
I have realised doing too many things at once , made me rush to one project haphazardly so I could complete the next one .
This is reminder to myself to complete a project to a satisfactory stage  and then move on.</p>
<h3 id="document-your-software-process-journey-before-while-doing-it-dot">Document your software process/journey before/while doing it.</h3>
<p>Documentation  about the work I has always felt like a daunting task to me.But not having proper docs has been more painful.</p>
<p>One of key lessons, I am still learning is to make the document while working on the project.
To treat writing as a part of the development process and not as an afterthought.
One way I recently realised how to do this is to write the titles and subtitles about dos .This helps in breaking down a big problem into a small one.
Example:
Im trying to put in place this strategy for blog writing too.</p>
<h3 id="be-organised">Be organised</h3>
<p>I found my old diary of 2013 (when I was still preparing for JEE mains ).  It showed me a reflection of how I used to organize content for my studies so why not for learning while working and for blogging?
<img loading="lazy" src="/img/diary.jpg" alt=""  />
</p>
<p>This is why I made the decision to learn doom Emacs and vim and use org-mode as a part of being organized.
There is a steep learning curve in Emacs. I myself have given up many times on Emacs and have come back because of the useful features it provides.</p>
<h3 id="done-is-better-than-perfect">Done is better than perfect</h3>
<p>A lesson I learnt the hard way.
All the planning and over thinking can do no good if you don&rsquo;t execute the plan.
Just start with an initial plan and start executing it.  Putting a little thought into the execution can lead to remarkable results.</p>
<h2 id="what-s-next">What&rsquo;s next?</h2>
<h3 id="automation-of-content-creation-flow">Automation of content creation flow</h3>
<p>Continuing to refine my blog content creation post workflow, I will explore ways to reach out to wider audience. To do this in such a way that it doesn&rsquo;t take much mental effort from my side.
And to find a way to reduce my time and effort in the proof reading &amp; editing process.(Any advice or suggestions are welcome!)</p>
<h3 id="getting-better-at-note-taking-and-diagram-making">Getting better at note taking and diagram making</h3>
<p>One of the key goals for 2023 is taking the effort to make quick diagrams. I have understood concepts quicker by looking at diagrams than reading blocks of text .
But diagram making tends to be a long time consuming task. I am currently trying out draw.io and excalidraw for this purpose ,still at experimental stage tho.</p>
<h3 id="trying-out-public-speaking-or-podcast-of-my-learning">Trying out public speaking or podcast of my learning</h3>
<p>While explaining a concept to a friend or colleague helped in finding out the gaps in my learning. Though I tried to explain a concept to myself while learning, I tend to find it awkward or sometimes lazy to re-iterate to explain the concept back to myself. One of my goals is to get better at speaking and hopefully not bore my little audience.</p>
<p>And that&rsquo;s all for my year end review  for 2022 !</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt TIL: jq</title>
      <link>https://shwetakadam.com/posts/today-i-learnt-til-jq/</link>
      <pubDate>Thu, 22 Dec 2022 21:45:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/today-i-learnt-til-jq/</guid>
      <description>Today at work once again I had to inspect a json body which was not beautified. Normally I turn to Postman and use the beautify option. But my mac cried and was freezing in instances begging for me to not open more application :( This is where I came across a nifty tool called jq
jq is a lightweight and flexible command-line JSON processor. It is like sed for JSON data.</description>
      <content:encoded><![CDATA[<p>Today at work once again I had to inspect a json body which was not beautified. Normally I turn to Postman and use the beautify option.
But my mac cried and was freezing in instances begging for me to not open more application :(
This is where I came across a nifty tool called  <strong><strong>jq</strong></strong></p>
<p>jq is a lightweight and flexible command-line JSON processor. It is like sed for JSON data. It can used to transform json data into more readableformat.
For example :</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl">         <span class="err">❯</span> <span class="err">echo</span>  <span class="err">&#39;</span><span class="p">{</span><span class="nt">&#34;fullName&#34;</span><span class="p">:</span> <span class="p">{</span><span class="nt">&#34;firstName&#34;</span><span class="p">:</span> <span class="s2">&#34;Bruce&#34;</span><span class="p">,</span><span class="nt">&#34;middleName&#34;</span><span class="p">:</span> <span class="s2">&#34;Clark&#34;</span><span class="p">,</span> <span class="nt">&#34;lastName&#34;</span><span class="p">:</span> <span class="s2">&#34;Wayne&#34;</span> <span class="p">}}</span><span class="err">&#39;</span> <span class="err">|</span> <span class="err">jq</span> <span class="err">.</span>
</span></span><span class="line"><span class="cl">       <span class="p">{</span>
</span></span><span class="line"><span class="cl">         <span class="nt">&#34;fullName&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">           <span class="nt">&#34;firstName&#34;</span><span class="p">:</span> <span class="s2">&#34;Bruce&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">           <span class="nt">&#34;middleName&#34;</span><span class="p">:</span> <span class="s2">&#34;Clark&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">           <span class="nt">&#34;lastName&#34;</span><span class="p">:</span> <span class="s2">&#34;Wayne&#34;</span>
</span></span><span class="line"><span class="cl">         <span class="p">}</span>
</span></span><span class="line"><span class="cl">       <span class="p">}</span>
</span></span></code></pre></div><h2 id="where-and-why-would-you-use-it">Where and why would you use it?</h2>
<p>There are a few reasons I could think of why I would use jq regularly:</p>
<!--list-separator-->
<ul>
<li>Similarly like my situation above, if you want to avoid opening gui apps or online code beautifiers ,this is a great option.</li>
</ul>
<!--list-separator-->
<ul>
<li>
<p>Once can prettify a curl output with jq.</p>
<p>This is a great option when you pretty json output on the go for example <code>healthcheck</code> urls of your application apis.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl">        <span class="err">curl</span> <span class="err">http:</span><span class="c1">//example-api-url-you-are-calling.com | jq .
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>        <span class="err">curl</span> <span class="err">http:</span><span class="c1">//example-api-healthcheck.com/healthcheck | jq .
</span></span></span></code></pre></div></li>
</ul>
<!--list-separator-->
<ul>
<li>
<p>jq is ubiquitous means it is pre-installed in most machines (even cloud vms such as aws and microsoft vms).</p>
<p>So next time you want pretty output of a json which is present in an ec2 instance.
You dont need to do the manual work of copy and paste and json and figuring it out later.</p>
</li>
</ul>
<!--list-separator-->
<ul>
<li>Also I think its pretty secure than the online third party websites developers tend to use to prettify json ,xml while working. Especially when dealing with secret private data which is sometimes pasted on to a random code beautifier website.</li>
</ul>
<!--list-separator-->
<ul>
<li>And pretty handy when you lose internet connection ;)</li>
</ul>
<!--list-separator-->
<ul>
<li>
<p>When used in shell scripts , it can save a lot of time and manual effort.</p>
<p>This is useful cheat sheet with good example to refer <a href="https://lzone.de/cheat-sheet/jq">https://lzone.de/cheat-sheet/jq</a></p>
</li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt (TIL): jq</title>
      <link>https://shwetakadam.com/posts/til-jq/</link>
      <pubDate>Tue, 20 Dec 2022 21:24:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/til-jq/</guid>
      <description>Today at work once again I had to inspect a json body which was not beautified. Normally I turn to Postman and use the beautify option. But my mac cried and was freezing in instances begging for me to not open more application :( This is where I came across a nifty tool called jq
jq is a lightweight and flexible command-line JSON processor. It is like sed for JSON data.</description>
      <content:encoded><![CDATA[<p>Today at work once again I had to inspect a json body which was not beautified. Normally I turn to Postman and use the beautify option.
But my mac cried and was freezing in instances begging for me to not open more application :(
This is where I came across a nifty tool called  <strong><strong>jq</strong></strong></p>
<p>jq is a lightweight and flexible command-line JSON processor. It is like sed for JSON data. It can used to transform json data into more readableformat.
For example :</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl">         <span class="err">❯</span> <span class="err">echo</span>  <span class="err">&#39;</span><span class="p">{</span><span class="nt">&#34;fullName&#34;</span><span class="p">:</span> <span class="p">{</span><span class="nt">&#34;firstName&#34;</span><span class="p">:</span> <span class="s2">&#34;Bruce&#34;</span><span class="p">,</span><span class="nt">&#34;middleName&#34;</span><span class="p">:</span> <span class="s2">&#34;Clark&#34;</span><span class="p">,</span> <span class="nt">&#34;lastName&#34;</span><span class="p">:</span> <span class="s2">&#34;Wayne&#34;</span> <span class="p">}}</span><span class="err">&#39;</span> <span class="err">|</span> <span class="err">jq</span> <span class="err">.</span>
</span></span><span class="line"><span class="cl">       <span class="p">{</span>
</span></span><span class="line"><span class="cl">         <span class="nt">&#34;fullName&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">           <span class="nt">&#34;firstName&#34;</span><span class="p">:</span> <span class="s2">&#34;Bruce&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">           <span class="nt">&#34;middleName&#34;</span><span class="p">:</span> <span class="s2">&#34;Clark&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">           <span class="nt">&#34;lastName&#34;</span><span class="p">:</span> <span class="s2">&#34;Wayne&#34;</span>
</span></span><span class="line"><span class="cl">         <span class="p">}</span>
</span></span><span class="line"><span class="cl">       <span class="p">}</span>
</span></span></code></pre></div><h2 id="where-and-why-would-you-use-it">Where and why would you use it?</h2>
<p>There are a few reasons I could think of why I would use jq regularly:</p>
<!--list-separator-->
<ul>
<li>Similarly like my situation above, if you want to avoid opening gui apps or online code beautifiers ,this is a great option.</li>
</ul>
<!--list-separator-->
<ul>
<li>
<p>Once can prettify a curl output with jq.</p>
<p>This is a great option when you pretty json output on the go for example <code>healthcheck</code> urls of your application apis.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl">        <span class="err">curl</span> <span class="err">http:</span><span class="c1">//example-api-url-you-are-calling.com | jq .
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>        <span class="err">curl</span> <span class="err">http:</span><span class="c1">//example-api-healthcheck.com/healthcheck | jq .
</span></span></span></code></pre></div></li>
</ul>
<!--list-separator-->
<ul>
<li>
<p>jq is ubiquitous means it is pre-installed in most machines (even cloud vms such as aws and microsoft vms).</p>
<p>So next time you want pretty output of a json which is present in an ec2 instance.
You dont need to do the manual work of copy and paste and json and figuring it out later.</p>
</li>
</ul>
<!--list-separator-->
<ul>
<li>Also I think its pretty secure than the online third party websites developers tend to use to prettify json ,xml while working. Especially when dealing with secret private data which is sometimes pasted on to a random code beautifier website.</li>
</ul>
<!--list-separator-->
<ul>
<li>And pretty handy when you lose internet connection ;)</li>
</ul>
<!--list-separator-->
<ul>
<li>
<p>When used in shell scripts , it can save a lot of time and manual effort.</p>
<p>This is useful cheat sheet with good example to refer <a href="https://lzone.de/cheat-sheet/jq">https://lzone.de/cheat-sheet/jq</a></p>
</li>
</ul>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt:422 HTTP Error code</title>
      <link>https://shwetakadam.com/posts/today-i-learnt422-http-error-code/</link>
      <pubDate>Tue, 20 Dec 2022 19:17:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/today-i-learnt422-http-error-code/</guid>
      <description>Today while testing a soap API at work, I came across this HTTP error code called HTTP/1.1 422 Unprocessable Entity . According to MDN Web docs, it means the following :
The HyperText Transfer Protocol (HTTP) 422 Unprocessable Entity response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.</description>
      <content:encoded><![CDATA[<p>Today while testing a soap API at work, I came across this HTTP error code called <strong><strong>HTTP/1.1 422 Unprocessable Entity</strong></strong> . According to MDN Web docs, it means the following :</p>
<blockquote>
<p>The HyperText Transfer Protocol (HTTP) 422 Unprocessable Entity response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.</p>
</blockquote>
<p>It means that the syntax of the request is correct and well-formed but it has semantic, logical errors. Meaning the soap body xml format will be correct but the issue arises because of the content inside the XML tags*. In this case, it could be the following:</p>
<ul>
<li>Wrong character within the code.</li>
<li>The server doesn’t understand the content within a particular XML tag.</li>
<li>Or it refuses to process any other content inside the tag other than a fixed decided value).</li>
</ul>
<p>Difference between 422,404 and 415 Error codes .Permalink
According to <a href="https://www.rfc-editor.org/rfc/rfc4918#section-11.2">RFC</a>,</p>
<blockquote>
<p>The 422 (Unprocessable Entity) status code means the server understands the content type of the request entity (hence a 415(Unsupported Media Type) status code is inappropriate), and the syntax of the request entity is correct (thus a 400 (Bad Request) status code is inappropriate) but was unable to process the contained instructions. For example, this error condition may occur if an XML request body contains well-formed (i.e., syntactically correct), but semantically erroneous, XML instructions.</p>
</blockquote>
<p>In testing a soap API, the content type of the request body was correct. I checked for Content-Type header while testing) – Hence 415(Unsupported Media Type) was not valid. For soap,it was Content-Type: text/xml; charset=UTF-8. And the syntax of the request body was also correct– Hence 404(Bad request) was not valid.</p>
<p>The error occurred due to an incorrect value in the XML tag in my case. Value should have been <code>&lt;ns8:exampleTag&gt;123&lt;/ns8:exampleTag&gt;</code> instead of <code>&lt;ns8:exampleTag&gt;456&lt;/ns8:exampleTag&gt;</code></p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt: Interesting Things in Java 11</title>
      <link>https://shwetakadam.com/posts/today-i-learnt-interesting-things-in-java-11/</link>
      <pubDate>Sun, 20 Nov 2022 18:48:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/today-i-learnt-interesting-things-in-java-11/</guid>
      <description>I came across a fascinating Java talk on youtube by Devoxx 2022 Hanno Embregts. This article is about a few java snippets I encountered. The purpose of today’s TIL is to have a list of interesting things we could do in Java and not deep dive into each concept.
Today’s TIL : Crazy things to do with Java 11+
Initializing Array and var keywordPermalink Having the var keyword in a statically typed language such as Java was fascinating in itself(an article on this in the future :).</description>
      <content:encoded><![CDATA[<p>I came across a fascinating Java talk on youtube by Devoxx 2022 Hanno Embregts. This article is about a few java snippets I encountered. The purpose of today’s TIL is to have a list of interesting things we could do in Java and not deep dive into each concept.</p>
<p>Today’s TIL : <strong><strong>Crazy things to do with Java 11+</strong></strong></p>
<h2 id="initializing-array-and-var-keywordpermalink">Initializing Array and var keywordPermalink</h2>
<p>Having the <code>var</code> keyword in a statically typed language such as Java was fascinating in itself(an article on this in the future :). But we never thought we would use it to initialize such as</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">var</span> <span class="n">element</span> <span class="o">=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">2</span><span class="o">];</span>       <span class="c1">//WORKS
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">var</span> <span class="o">[]</span> <span class="n">element</span><span class="o">=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">2</span><span class="o">];</span>      <span class="c1">// COMPILE ERROR :error: &#39;var&#39; is not allowed as an element type of an array
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">Since</span> <span class="n">var</span> <span class="n">is</span> <span class="n">a</span> <span class="n">generic</span> <span class="n">element</span> <span class="n">type</span><span class="o">,</span> <span class="n">giving</span> <span class="n">it</span> <span class="n">array</span> <span class="o">[]</span> <span class="n">provides</span> <span class="n">an</span> <span class="n">error</span> <span class="n">since</span> <span class="n">rather</span> <span class="n">than</span> <span class="n">being</span> <span class="n">generic</span> <span class="n">we</span> <span class="n">are</span> <span class="n">giving</span> <span class="n">it</span> <span class="n">an</span> <span class="n">array</span> <span class="n">type</span><span class="o">.</span>
</span></span></code></pre></div><h2 id="c-style-arraypermalink">C style ArrayPermalink</h2>
<p>What is a c style array? Java supports providing [] before and after the variable name in an array</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"> <span class="kt">int</span> <span class="o">[]</span><span class="n">arr</span><span class="o">=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">2</span><span class="o">];</span>
</span></span><span class="line"><span class="cl"> <span class="kt">int</span> <span class="n">arr1</span><span class="o">[]=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">2</span><span class="o">];</span>
</span></span></code></pre></div><p>In C style array, we provide [] after the variable name that is ~int arr1[].</p>
<p>So in Java, suppose we have the following code:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl">       <span class="kt">int</span> <span class="n">arr1</span><span class="o">[],</span><span class="n">arr2</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">       <span class="n">arr1</span><span class="o">=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">1</span><span class="o">];</span>
</span></span><span class="line"><span class="cl">       <span class="n">arr2</span><span class="o">=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">1</span><span class="o">];</span>        <span class="c1">//COMPILE ERROR : error: incompatible types: int[] cannot be converted to int
</span></span></span></code></pre></div><p>The above code will result in COMPILE ERROR for arr2 since arr2 is not an array but a primitive int variable. But if we want to want both arr1 and arr12 as array type we need to change the declaration to</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl">       <span class="kt">int</span> <span class="o">[]</span> <span class="n">arr1</span><span class="o">,</span><span class="n">arr2</span><span class="o">;</span> <span class="c1">//Notice how [] are
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>       <span class="n">arr1</span><span class="o">=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">1</span><span class="o">];</span>
</span></span><span class="line"><span class="cl">       <span class="n">arr2</span><span class="o">=</span><span class="k">new</span> <span class="kt">int</span><span class="o">[</span><span class="mi">1</span><span class="o">];</span>
</span></span></code></pre></div><h2 id="arrays-dot-aslist-and-primitives">Arrays.asList and Primitives</h2>
<p>Let’s look at the following example :</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">String</span> <span class="o">[]</span> <span class="n">strArr</span><span class="o">={</span><span class="s">&#34;one&#34;</span><span class="o">,</span><span class="s">&#34;two&#34;</span><span class="o">,</span><span class="s">&#34;three&#34;</span><span class="o">};</span>
</span></span><span class="line"><span class="cl"><span class="n">var</span> <span class="n">stringList</span><span class="o">=</span> <span class="n">Arrays</span><span class="o">.</span><span class="na">asList</span><span class="o">(</span><span class="n">strArr</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kt">int</span> <span class="o">[]</span> <span class="n">intArray</span> <span class="o">=</span> <span class="o">{</span><span class="mi">1</span><span class="o">,</span><span class="mi">2</span><span class="o">,</span><span class="mi">3</span><span class="o">};</span>
</span></span><span class="line"><span class="cl"><span class="n">var</span> <span class="n">intList</span> <span class="o">=</span> <span class="n">Arrays</span><span class="o">.</span><span class="na">asList</span><span class="o">(</span><span class="n">intArray</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">stringList</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="s">&#34;one&#34;</span><span class="o">)+</span><span class="s">&#34; &#34;</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">print</span><span class="o">(</span><span class="n">intList</span><span class="o">.</span><span class="na">contains</span><span class="o">(</span><span class="mi">1</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"><span class="nl">
</span></span></span><span class="line"><span class="cl"><span class="nl">Output:</span> <span class="kc">true</span> <span class="kc">false</span>
</span></span></code></pre></div><p>Signature of Arrays.asList is var-args or List of T’s.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl">      <span class="kd">public</span> <span class="kd">static</span> <span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">T</span><span class="o">&gt;</span> <span class="nf">asList</span><span class="o">(</span><span class="n">T</span><span class="o">...</span> <span class="n">a</span><span class="o">)</span>
</span></span></code></pre></div><p>T is of generic type so that means it needs to reference a Type such as Integer,Float and not reference Array of Ints</p>
<p>But next question is Can they boxed ? (Autoboxing: Converting primitive to Class Type example : int -&gt; Integer) Answer is no Array of ints -&gt; Cannot be boxed -&gt; Array of Integer</p>
<blockquote>
<p>Don’t use Arrays.asList on primitives</p>
</blockquote>
<h2 id="no-structural-changes-allowed-in-arraypermalink">No structural changes allowed in ArrayPermalink</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">String</span> <span class="o">[]</span> <span class="n">ints</span> <span class="o">={</span><span class="s">&#34;a&#34;</span><span class="o">,</span><span class="s">&#34;b&#34;</span><span class="o">,</span><span class="s">&#34;c&#34;</span><span class="o">,</span><span class="kc">null</span><span class="o">};</span>
</span></span><span class="line"><span class="cl"><span class="n">List</span><span class="o">&lt;</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">strings</span><span class="o">=</span> <span class="n">Arrays</span><span class="o">.</span><span class="na">asList</span><span class="o">(</span><span class="n">ints</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="n">strings</span><span class="o">.</span><span class="na">removeIf</span><span class="o">(</span><span class="n">Objects</span> <span class="o">::</span> <span class="n">isNull</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">strings</span><span class="o">.</span><span class="na">size</span><span class="o">());</span>
</span></span><span class="line"><span class="cl"><span class="nl">Output:</span> <span class="n">Exception</span> <span class="n">in</span> <span class="n">thread</span> <span class="err">“</span><span class="n">main</span><span class="err">”</span> <span class="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">UnsupportedOperationException</span><span class="o">:</span> <span class="n">remove</span> <span class="n">at</span> <span class="n">java</span><span class="o">.</span><span class="na">base</span><span class="o">/</span><span class="n">java</span><span class="o">.</span><span class="na">util</span><span class="o">.</span><span class="na">Iterator</span><span class="o">.</span><span class="na">remove</span><span class="o">(</span><span class="n">Iterator</span><span class="o">.</span><span class="na">java</span><span class="o">:</span><span class="mi">102</span><span class="o">)</span>
</span></span></code></pre></div><p>Because the array does not allow any structural changes to it</p>
<h2 id="a-unique-way-to-remove-null-values-from-map">A Unique way to remove null values from Map</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">Map</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">,</span><span class="n">String</span><span class="o">&gt;</span> <span class="n">map</span><span class="o">=</span><span class="k">new</span> <span class="n">HashMap</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="n">map</span><span class="o">.</span><span class="na">put</span><span class="o">(</span><span class="mi">4</span><span class="o">,</span><span class="kc">null</span><span class="o">);</span> <span class="c1">//currently map has key:4 value: null
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">map</span><span class="o">.</span><span class="na">getOrDefault</span><span class="o">(</span><span class="mi">4</span><span class="o">,</span><span class="s">&#34;four&#34;</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"><span class="n">map</span><span class="o">.</span><span class="na">putIfAbsent</span><span class="o">(</span><span class="mi">4</span><span class="o">,</span><span class="s">&#34;four&#34;</span><span class="o">);</span>     <span class="c1">//key key:4 value:four
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">map</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="mi">4</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"><span class="nl">
</span></span></span><span class="line"><span class="cl"><span class="nl">Output:</span> <span class="kc">null</span><span class="o">,</span><span class="n">four</span>
</span></span></code></pre></div><p>##</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">var</span> <span class="n">numbers</span> <span class="o">=</span> <span class="n">List</span><span class="o">.</span><span class="na">of</span><span class="o">(-</span><span class="mi">1</span><span class="o">,</span><span class="mi">0</span><span class="o">,</span><span class="mi">1</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="n">Map</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">,</span><span class="n">List</span><span class="o">&lt;</span><span class="n">Integer</span><span class="o">&gt;&gt;</span> <span class="n">map</span><span class="o">=</span><span class="k">new</span> <span class="n">HashMap</span><span class="o">&lt;&gt;();</span>
</span></span><span class="line"><span class="cl"><span class="n">numbers</span><span class="o">.</span><span class="na">forEach</span><span class="o">(</span><span class="n">number</span><span class="o">-&gt;</span> <span class="n">map</span><span class="o">.</span><span class="na">putIfAbsent</span><span class="o">(</span><span class="n">number</span><span class="o">,</span><span class="k">new</span> <span class="n">ArrayList</span><span class="o">&lt;&gt;())</span>
</span></span><span class="line"><span class="cl">               <span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">number</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">map</span><span class="o">.</span><span class="na">get</span><span class="o">(</span><span class="mi">0</span><span class="o">));</span>
</span></span><span class="line"><span class="cl"><span class="nl">
</span></span></span><span class="line"><span class="cl"><span class="nl">Output:</span> <span class="n">NullPointerException</span><span class="o">:</span> <span class="n">Exception</span> <span class="n">in</span> <span class="n">thread</span> <span class="err">“</span><span class="n">main</span><span class="err">”</span> <span class="n">java</span><span class="o">.</span><span class="na">lang</span><span class="o">.</span><span class="na">NullPointerException</span> <span class="n">at</span> <span class="n">HelloWorld</span><span class="o">.</span><span class="na">lambda$main$0</span><span class="o">(</span><span class="n">HelloWorld</span><span class="o">.</span><span class="na">java</span><span class="o">:</span><span class="mi">33</span><span class="o">)</span>
</span></span></code></pre></div><p>Because map.putIfAbsent returns null if no value is present</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Today I learnt: Database Version Control</title>
      <link>https://shwetakadam.com/posts/today-i-learnt-database-version-control/</link>
      <pubDate>Mon, 07 Nov 2022 15:49:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/today-i-learnt-database-version-control/</guid>
      <description>Upon stumbling upon this motivating HN post by Simon Willison I have been inspired to start a Today I learnt(TIL) series of my own. This seems like a doable promising idea where I do not have the self-imposed pressure of researching for a blog idea and making a seperate time to write that specific post. Wrting this TIL flows naturally in day-to-day work flow where I could just say “Hey I just learnt about this XYZ ,I should write about it”.</description>
      <content:encoded><![CDATA[<p>Upon stumbling upon this motivating HN post by <a href="https://simonwillison.net/2022/Nov/6/what-to-blog-about/">Simon Willison</a> I have been inspired to start a Today I learnt(TIL) series of my own. This seems like a doable promising idea where I do not have the self-imposed pressure of researching for a blog idea and making a seperate time to write that specific post. Wrting this TIL flows naturally in day-to-day work flow where I could just say “Hey I just learnt about this XYZ ,I should write about it”.</p>
<p>Starting with Today’s TIL : <strong><strong>Database Version Control</strong></strong></p>
<p>What it is : A practice or form of maintining and tracking every change made to database schema, just like git version control(But this is specifically for Database). It acts like a single source of truth (like a git code repository)</p>
<p>This concept solves a lot of problems we face as developers such as :</p>
<p>As a developer,One must have faced a situation where to solve a particular problem statement or feature , you need to do database changes,however for those changes to reflect application needs to be restarted or you might have database and application code changes, an organization already has some processes defined for deployment. In development phase, one usually runs the db changes or sql queries in local generally via a sql client application.For example,Update some existing db property.</p>
<p>But for that same change to be reflected in production db, CICD processes are define fdd for deployment or a seperate team might be responsible for deployment altogether.Hence we cant expect a seperate db team to always be in sync with deployment team or that particular CICD process. Hence, DB schema changes should be deployed as a part of application code changes.</p>
<p>This is where database version control comes in handy where :</p>
<p>You need traceability and a commit history of db schema changes done before.
Protect prodcution database tables from unwanted or uncontrolled changes
Help in communication between teams regarding data(where a member can look at the query and provide feedback as a part of Pull request)
Applications such as liquidbase,flyway scripts come in handy Speaking of liquibase which works on changelog concept where you have</p>
<blockquote>
<p>A Changelog file which inside has -&gt; ChangeSet (which are used to define Db changes)- &gt; Which can include SQL Queries and Rollback queries if the changes dont work in that specific environment.</p>
</blockquote>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-xml" data-lang="xml"><span class="line"><span class="cl"><span class="cp">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
</span></span><span class="line"><span class="cl"><span class="nt">&lt;databaseChangeLog</span>
</span></span><span class="line"><span class="cl">	<span class="na">xmlns=</span><span class="s">&#34;http://www.liquibase.org/xml/ns/dbchangelog&#34;</span>
</span></span><span class="line"><span class="cl">	<span class="na">xmlns:xsi=</span><span class="s">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
</span></span><span class="line"><span class="cl">	<span class="na">xmlns:ext=</span><span class="s">&#34;http://www.liquibase.org/xml/ns/dbchangelog-ext&#34;</span>
</span></span><span class="line"><span class="cl">	<span class="na">xmlns:pro=</span><span class="s">&#34;http://www.liquibase.org/xml/ns/pro&#34;</span>
</span></span><span class="line"><span class="cl">	<span class="na">xsi:schemaLocation=</span><span class="s">&#34;http://www.liquibase.org/xml/ns/dbchangelog
</span></span></span><span class="line"><span class="cl"><span class="s">		http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd
</span></span></span><span class="line"><span class="cl"><span class="s">		http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd
</span></span></span><span class="line"><span class="cl"><span class="s">		http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd&#34;</span><span class="nt">&gt;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">     <span class="nt">&lt;changeSet</span>  <span class="na">id=</span><span class="s">&#34;1&#34;</span>  <span class="na">author=</span><span class="s">&#34;XYZ&#34;</span><span class="nt">&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="nt">&lt;comment&gt;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">        <span class="nt">&lt;/comment&gt;</span>
</span></span><span class="line"><span class="cl">        <span class="nt">&lt;sql&gt;</span>
</span></span><span class="line"><span class="cl">        INSERT INTO Exampledb.exampletable(&#39;id&#39;,&#39;name,&#39;serial&#39;)
</span></span><span class="line"><span class="cl">        VALUES(&#34;1&#34;,&#34;test&#34;,&#34;serial&#34;);
</span></span><span class="line"><span class="cl">        <span class="nt">&lt;/sql&gt;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">        <span class="nt">&lt;rollback&gt;</span>
</span></span><span class="line"><span class="cl">        DELETE FROM  Exampledb.exampletable where id=&#34;1&#34;;
</span></span><span class="line"><span class="cl">        <span class="nt">&lt;/rollback&gt;</span>
</span></span><span class="line"><span class="cl"> <span class="nt">&lt;/databaseChangeLog&gt;</span>
</span></span></code></pre></div><p>This changelog file needs to be included in a master changelog file which consists a list of all change log files (Similar to how a git commit history consists of all commit ids)</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Tackling procrastination and kubernetes study</title>
      <link>https://shwetakadam.com/posts/tackling-procrastination-and-kubernetes-study/</link>
      <pubDate>Fri, 25 Feb 2022 15:45:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/tackling-procrastination-and-kubernetes-study/</guid>
      <description>After a long series of procrastination and getting the hit of motivation from reading Atomic Habits(great book which I recommend others) ,I’m finally learning kubernetes basics.As a motivator to get better at writing and publish more posts as well as learn kubernetes.I have decided to publish 1 article every Sunday.I would like to post 2 posts per week but I want to start small and consistent. Once again I’m treating my blog as a journal to showcase how much I actually understand kubernetes.</description>
      <content:encoded><![CDATA[<p>After a long series of procrastination and getting the hit of motivation from reading Atomic Habits(great book which I recommend others) ,I’m finally learning kubernetes basics.As a motivator to get better at writing and publish more posts as well as learn kubernetes.I have decided to publish 1 article every Sunday.I would like to post 2 posts per week but I want to start small and consistent. Once again I’m treating my blog as a journal to showcase how much I actually understand kubernetes.Also its quite handy to have my own notes on a site. So here is a blog post on kubernetes basics part 1.This will be a multi part series. Before we begin some pre requisites which one needs to know :-</p>
<h2 id="pre-requisite">Pre requisite</h2>
<p>You should be already familiar and comfortable with the concept of containers and container run-time such as docker as kubernetes is for managing different containers and their deployment at a large scale.Another point which is not mandatory but good to know would be basic docker commands like docker run etc.</p>
<h2 id="what-is-kubernetes">What is kubernetes?</h2>
<p>Kubernetes is an open-source technology that is used for container orchestration. And what is container orchestration exactly? It is the process of continuous deployment ,scaling and management of containers.</p>
<p>Lets first look at the kubernetes architecture and the individual components in it.</p>
<h2 id="node">Node:</h2>
<p>A Node is either a physical or virtual machine on wihc kubernetes is installed. A node is like a worker machine on which containers (having our application) will be running by Kubernetes.And like any other machine ,nodes can crash for a number of reasons ;) .So once the node crashes the application will be go down as well. So tackle this we need multiple nodes rather than 1 node.</p>
<p>And mulitple nodes come together to form a group known as the cluster.So even if one node inside the cluster fails,we have our application accessible and running from the other nodes.Plus it helps in sharing load!</p>
<h2 id="master-node">* Master Node :</h2>
<p>So now we have our cluster running on a group of nodes which are running our containerised apps.But who is responsible to manage this cluster:?Also when a node goes down how to direct the traffic of the failed node to other working nodes?Also who stores the information about these worker nodes stored? and How are the nodes monitored?</p>
<p>The master node!</p>
<p>The master node is another machine with kubernetes installed in it and it watches over the nodes and does the actusl orchestration of the worker nodes.</p>
<blockquote>
<p>Note that a cluster can have multiple master nodes depending on the size of the cluster.</p>
</blockquote>
<p>because at the end of the day , a master node is a machine (which can crash) and for high availability we need to avoid that.</p>
<h2 id="other-components">Other components:</h2>
<p>When you install kubernetes in your system,you are actually installing the follwing components:</p>
<ul>
<li>An Kube api server (Master)</li>
<li>An etcd service (Master)</li>
</ul>
<p>-A kubelet service (Worker)</p>
<ul>
<li>Controller (Master)</li>
<li>Scheduler (Master)</li>
<li>Container Runtime</li>
</ul>
<h2 id="kube-api-server">Kube API server:</h2>
<p>Kubeapi server acts as a frontend for kubernetes.The users,commandline tools,managment devices all interact with the cluster via the Kube API server.</p>
<h2 id="etcd">etcd</h2>
<p>etcd is a distributed key value store used to store data about how to manage the cluster.It is also resp0onsible to implement logs within the cluster to ensure there is no conflict between mulitple masters.</p>
<blockquote>
<p>Note that your application data is not stored in etcd only logs and information about the cluster.</p>
</blockquote>
<h2 id="scheduler">Scheduler</h2>
<p>Scheduler is responsible is distributing containers across multiple nodes.It looks for newly created containers and assigns them to nodes.</p>
<h2 id="controllers">Controllers</h2>
<p>Controllers are the brain behind the orchestration. They are responsible for notcining and responding nodes,containers or endpoint goes down.The controller takes decsions to bring up new nodes in this case.</p>
<h2 id="container-runtime">Container Runtime</h2>
<p>The container runtime is the underying software that runs the containers.Most of the times,its docker.I have used docker but there are other runtimes such as CRI-O</p>
<h2 id="kubeletpermalink">KubeletPermalink</h2>
<p>Kubelet is an agent that runs on each worker node in the cluster. The agent is in charge of making sure that containers are running on the nodes as expected.</p>
<h2 id="master-vs-worker-nodespermalink">Master vs Worker nodesPermalink</h2>
<p>So now we know there are 2 types of nodes : Masternode and Worker node. How does a node become master or a worker node? A worker node has the containers are hosted and running .Hence to run these containers we need a Container Runtime such as docker installed in these machines.</p>
<p>The master has a kube API server and this is what differentiates the master from worker nodes. The worker node have the kubelet agent that interacts with the master to proivide health information about the worker nodes and carries out the instrcutions given by the master node on worker nodes.The master has all this information stored in key value store (etcd) known as the etcd.The master also has the controller and scheduler.</p>
<h2 id="kubectlpermalink">KubectlPermalink</h2>
<p>kubectl is a commandline tool is used to deploy and manage applications in a cluster.Basically we are going to use these commands from the kubectl tool to get us information (kubectl get,status describe) about the nodes and other components in the cluster and to manage many other operations.</p>
<p><code>kubectl run</code> –Used to deploy an application onto the cluster</p>
<p><code>kubectl get cluster-info</code> –Used to fetch the cluster information</p>
<p><code>kubectl get nodes</code> –Used to fetch information about nodes.</p>
<p>That is all on basic overview.Next article will be focused on pod and how pods work in nodes in kubernetes.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Tech Recap Journal- January📓</title>
      <link>https://shwetakadam.com/posts/tech-recap-journal-january/</link>
      <pubDate>Tue, 01 Feb 2022 15:15:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/tech-recap-journal-january/</guid>
      <description>I tried a lot of things in January not necessarily everything learnt was used and and not every side project which I worked on got live.
However I learnt many lessons from my own failures and gained more insights when I started some initiatives. So just a small gist of looking back on January and mid February.
My Blog! codeklutz.com I have been wanting to make my own tech blog for a while now but I needed something which didn’t necessary requires much code or db maintenance.</description>
      <content:encoded><![CDATA[<p>I tried a lot of things in January not necessarily everything learnt was used and and not every side project which I worked on got live.</p>
<p>However I learnt many lessons from my own failures and gained more insights when I started some initiatives. So just a small gist of looking back on January and mid February.</p>
<h2 id="my-blog-codeklutz-dot-com">My Blog! <a href="https://codeklutz.com">codeklutz.com</a></h2>
<p>I have been wanting to make my own tech blog for a while now but I needed something which didn’t necessary requires much code or db maintenance.I didn’t want to opt for WordPress for the same reason.</p>
<p>Jekyll with GitHub pages is a life saver here! Also learnt a lot on custom domains after buying my own domain,about Google analytic and SEO.Plus customising Jekyll site with themes has been fun.</p>
<h2 id="letters-to-me">Letters to me</h2>
<p>This idea struck me in the wee hours at night.I always get some random tech ideas or where I am curious about something and think about it as to how I would do this particular task.</p>
<p>I think of this site as an idea jar 💡 or tech journal 📝 where I jot down my wacky, scrambling thoughts.Something which I can look back on for ideas when I don’t feel creative or as starting thinking point for my small side projects.Some tech thoughts which aren’t polished enough for a blog but are useful tiny ideas which provide insight.
Also since it’s on the internet maybe someone might find it useful or insightful? I’m thinking of adding an rss feed to this in the future if anyone would be interested in following this.</p>
<h2 id="expiermenting-with-audio-in-blogs">Expiermenting with audio in blogs</h2>
<p>Based on the idea mentioned in letters.codeklutz.com decided to implement an audio feature for this blog.I tried finding some open source or free alternative.And I did find one but sadly this one proved to be a failure at the current moment.</p>
<p>The audio is decent but the voices which I found are too mechanical and monotonous to listen continuously.I shall still try finding some open source alternative because I don’t want to invest in paid alternatives for this small blog at the moment.</p>
<h2 id="noteklutz-https-note-dot-codeklutz-dot-com">NoteKlutz <a href="https://note.codeklutz.com">https://note.codeklutz.com</a></h2>
<p>This mini project is again a part of implementation of the idea mentioned in letters.codeklutz.com It already proving to be useful;) I realised I write more markdown (for creating study notes +writing this blog) so I felt the need to create my own editor which is suited for myself and at the same time not fear giving my data to someone or idk?(lmao)</p>
<p>But main focus was not to use another app just to create notes and since I use browser more than anything else this seemed like a good idea</p>
<p>It’s a small,minimal project which does exactly what I need it to do and does it right (at least for me biased here🤫) It’s like my second organising brain 🧠.The code is an absolute mess and needs heavy work which I will do my pushing small updates on weekends🤭.</p>
<p>So this was all for January and Mid Feb</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Making Peace with Windows!Installing wsl,zsh,powerlevel10k,fzf &amp; many more fun plugins for easy development</title>
      <link>https://shwetakadam.com/posts/making-peace-with-windowsinstalling-wslzshpowerlevel10kfzf-many-more-fun-plugins-for-easy-development/</link>
      <pubDate>Fri, 21 Jan 2022 23:41:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/making-peace-with-windowsinstalling-wslzshpowerlevel10kfzf-many-more-fun-plugins-for-easy-development/</guid>
      <description>avigation, editing, development using terminal and zsh . But recently due to unforeseen updates, my bios was messed up big time which has led me unable to install Linux for the time being. But the work and learning never stops and nor shall I ! ☺ I don’t hate windows but it’s definitely not my first choice for development and coding after discovering Linux.🤭
But Thanks to WSL, windows terminal, and the beautiful zsh .</description>
      <content:encoded><![CDATA[<p>avigation, editing, development using terminal and zsh . But recently due to unforeseen updates, my bios was messed up big time which has led me unable to install Linux for the time being. But the work and learning never stops and nor shall I ! ☺  I don’t hate windows but it’s definitely not my first choice for development and coding after discovering Linux.🤭</p>
<p>But Thanks to WSL, windows terminal, and the beautiful zsh .I can get that Linux experience on windows!</p>
<p>So this is just a blog post on how I customized my terminal on windows 10 using wsl, windows terminal,zsh, and many more fun plugins which I use on my Linux as well as windows for development(work or home).
<img loading="lazy" src="/img/zsh.PNG" alt=""  />
</p>
<h2 id="what-is-wsl">What is wsl?</h2>
<p>It stands for windows subsystem for Linux and it&rsquo;s a feature of Windows that allows developers to run Linux file systems,command-line tools etc directly on windows!(Goodbye painful windows mouse navigation) First, you need the wsl feature on windows 10 by going to <code>Start -&gt;Type windows feature on search and below checkbox should be checked for enabling windows subsystem for Linux.</code>
<img loading="lazy" src="/img/windowsfeaturecheck.PNG" alt=""  />

Now you need to install wsl which you can by going <code>Start-&gt; Microsoft store -&gt;type ubuntu</code>.Im installing Ubuntu wsl since I&rsquo;m familiar with it you can also change distros. I&rsquo;m also installing another app called windows terminal because it&rsquo;s much better in terms of ui to me as compared to Ubuntu terminal.This is optional.
<img loading="lazy" src="/img/terminalcomparision.PNG" alt=""  />

At this point, it&rsquo;s your choice whether you want to continue with the Ubuntu terminal or use the windows terminal.If you decide with the former,skip the next para and if you decide with the latter then you need to set windows terminal as your default shell.
<img loading="lazy" src="/img/windowstermsettings.PNG" alt=""  />
</p>
<p>Now by default windows terminal opens the power shell, to set to Ubuntu
<img loading="lazy" src="/img/setdefaultshell.PNG" alt=""  />

Go to settings as shown below</p>
<p>Now you have a Ubuntu shell that has bash. I personally use zsh with OhMyZsh for my work for that beautiful productivity. Using OhMyZsh features like navigating without using cd, usage of ll, easier tab-click based navigation, and much more!</p>
<p>Note that zsh and OhMyZsh are different. When you install OhMyZsh, many plugins come with it for your rescue! So to install zsh. Update the libraries first then install zsh.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sudo apt-get install update
</span></span><span class="line"><span class="cl">sudo apt install -y zsh
</span></span></code></pre></div><p>Then Install ohmy zsh</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sh -c <span class="s2">&#34;</span><span class="k">$(</span>curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh<span class="k">)</span><span class="s2">&#34;</span>
</span></span></code></pre></div><p>Now your previous~/.zshrc config will be replaced by ohmyzsh To customize the shell next install powerlevel10k.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git clone - <span class="nv">depth</span><span class="o">=</span><span class="m">1</span> https://github.com/romkatv/powerlevel10k.git <span class="si">${</span><span class="nv">ZSH_CUSTOM</span><span class="k">:-</span><span class="nv">$HOME</span><span class="p">/.oh-my-zsh/custom</span><span class="si">}</span>/themes/powerlevel10k
</span></span></code></pre></div><p>This command clones the repo and now go to your ~/.zshrc and set the theme as power level 10k And then</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nb">source</span> ~/ .zshrc
</span></span></code></pre></div><p>Note: To reflect every change you make, do <code>source ~/.zshrc</code> in the terminal. And then this will give you a set of options to configure which you can decide for your customization.</p>
<h3 id="my-favourite-plugins">My favourite plugins</h3>
<p>I use these plugins daily and they make my life super smooth !</p>
<h4 id="fzf">Fzf</h4>
<p>It&rsquo;s a fuzzy finder command-line tool that lets your fuzzy find anything (files directories git branches you name it )across file system. You can use ti write your custom fuzzy find scripts to find anything.I have posted a link if my current config and aliases for reference. Clone the repo from any directory and just run the install script.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">git clone - depth <span class="m">1</span> https://github.com/junegunn/fzf.git ~/.fzf
</span></span><span class="line"><span class="cl">~/.fzf/install
</span></span></code></pre></div><p><img loading="lazy" src="/img/fzf.PNG" alt=""  />

Here is a small example of small WIP config for reference.</p>
<h4 id="zsh-auto-suggestions">Zsh Auto-suggestions</h4>
<p>This one Autocompletes while you type a command.This is useful especially when you type commands which you use daily but need to to try multiple times such as navigating and printing log at a specific long location. Git Clone the zsh-autocomplete plugin in the OhMyZsh plugin folder.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ sudo git clone https://github.com/zsh-users/zsh-autosuggestions <span class="si">${</span><span class="nv">ZSH_CUSTOM</span><span class="k">:-</span><span class="p">~/.oh-my-zsh/custom</span><span class="si">}</span>/plugins/zsh-autosuggestions
</span></span></code></pre></div><p>Once that is done, add the plugin in the ~/.zshrc file&rsquo;s plugin list.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">plugins</span><span class="o">=(</span>
</span></span><span class="line"><span class="cl"> …
</span></span><span class="line"><span class="cl"> zsh-autosuggestions
</span></span><span class="line"><span class="cl"><span class="o">)</span>
</span></span></code></pre></div><figure>
    <img loading="lazy" src="/img/zshautosuggest.PNG"/> 
</figure>

<h4 id="zsh-syntax-highlighting">Zsh Syntax highlighting</h4>
<p>This one automatically highlights zsh commands as you type. This saves a lot of typing on my part. Git Clone the zsh-syntax-highlighting plugin in the OhMyZsh plugin folder.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">$ sudo git clone https://github.com/zsh-users/zsh-syntax-highlighting.git <span class="si">${</span><span class="nv">ZSH_CUSTOM</span><span class="k">:-</span><span class="p">~/.oh-my-zsh/custom</span><span class="si">}</span>/plugins/zsh-syntax-highlighting
</span></span></code></pre></div><p>And once again add it to the plugins list of the .zshrc file.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="nv">plugins</span><span class="o">=(</span>
</span></span><span class="line"><span class="cl"> …
</span></span><span class="line"><span class="cl"> zsh-syntax-highlighting
</span></span><span class="line"><span class="cl"><span class="o">)</span>
</span></span></code></pre></div><p>Note: To reflect every change you make, do source ~/.zshrc in the terminal.</p>
<h4 id="readymade-github-aliases-from-oh-my-zsh">Readymade Github Aliases from Oh My Zsh</h4>
<p>Usually one defines short github aliases such as g.b forgit branch or g.c for git checkout in ~/.zshrc but you know by using ohMyZsh already has a list of easy git aliases configured. The format is first 2–3 letters of the first letter of the command such as</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">gb git branch List of <span class="nb">local</span> branches
</span></span><span class="line"><span class="cl">gba git branch -a List of <span class="nb">local</span> and remote branches
</span></span><span class="line"><span class="cl">gcam git commit -am Add all files to stage and commit
</span></span><span class="line"><span class="cl">gcmsg git commit -m Git commit message
</span></span><span class="line"><span class="cl">gco git checkout Change branch
</span></span><span class="line"><span class="cl">gco - git checkout to the previous branch Change branch to the previous one
</span></span><span class="line"><span class="cl">gd git diff Files differences in staging
</span></span><span class="line"><span class="cl">gfa git fetch - all - prune Fetch all remote branches, delete branch <span class="k">if</span> upstream is gone
</span></span><span class="line"><span class="cl">gl git pull Pull from remote
</span></span><span class="line"><span class="cl">gp git push Push to remote
</span></span><span class="line"><span class="cl">gpsup git push - set-upstream origin <span class="o">[</span>currentbranch<span class="o">]</span> Set upstream branch
</span></span><span class="line"><span class="cl">gst git status Local files to commit
</span></span></code></pre></div><p>I use these git aliases daily and they make working super fun.I recommend going through oh-my-zsh git aliases cheatsheets</p>
<p>That&rsquo;s all folks! This is my current setup in windows for development and this is still a work in progress that can keep changing but these plugins and zsh are something that has made the experience of using windows quite fun.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Integrating Swagger OpenAPI for easy API documentation in spring boot</title>
      <link>https://shwetakadam.com/posts/integrating-swagger-openapi-for-easy-api-documentation-in-spring-boot/</link>
      <pubDate>Sun, 16 Jan 2022 22:53:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/integrating-swagger-openapi-for-easy-api-documentation-in-spring-boot/</guid>
      <description>These days I am more into creating backend projects which include microservices.But if anyone wants to test these services one needs postman or do the old classic way of curl command.
Both do the job brilliantly but what if I wanted some user who doesn’t want to install postman or use curl and still wants to test my live APIs thru the browser? I came across this swagger open API specification and this is a really handy tool!</description>
      <content:encoded><![CDATA[<p>These days I am more into creating backend projects which include microservices.But if anyone wants to test these services one needs postman or do the old classic way of curl command.</p>
<p>Both do the job brilliantly but what if I wanted some user who doesn’t want to install postman or use curl and still wants to test my live APIs thru the browser? I came across this <strong><strong>swagger open API specification</strong></strong>  and this is a really handy tool!</p>
<p>In layman’s terms, Swagger OpenAPI specification provides API documentation for REST APIs. An OpenAPI file allows you to describe all the APIs within the project and even lets you try out the APIs!</p>
<p>Available endpoints can be /projectApi and all operations on each endpoint which can GET /getProjectApi , POST /insertProjectApi , DELETE /deleteProjectApi .</p>
<p><img loading="lazy" src="/img/swaggerui.PNG" alt=""  />

Also, integration of swagger open API is pretty painless in spring boot and it lets users try out the APIs within the browser without any installation of any software from the user (sounds pretty convenient and sweet to me)</p>
<p>In this post, I will describe how I integrated swagger open API in Spring boot project.First you need a spring boot project having basic dependcies using Spring Initializr <a href="https://start.spring.io/">https://start.spring.io/</a> or you could use this project used in the example here</p>
<p>First add the springdoc-openapi-ui dependency to pom.xml:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-xml" data-lang="xml"><span class="line"><span class="cl"><span class="nt">&lt;dependency&gt;</span>
</span></span><span class="line"><span class="cl">   <span class="nt">&lt;groupId&gt;</span>org.springdoc<span class="nt">&lt;/groupId&gt;</span>
</span></span><span class="line"><span class="cl">   <span class="nt">&lt;artifactId&gt;</span>springdoc-openapi-ui<span class="nt">&lt;/artifactId&gt;</span>
</span></span><span class="line"><span class="cl">   <span class="nt">&lt;version&gt;</span>1.6.4<span class="nt">&lt;/version&gt;</span>
</span></span><span class="line"><span class="cl"><span class="nt">&lt;/dependency&gt;</span>
</span></span><span class="line"><span class="cl"><span class="nt">&lt;dependency&gt;</span>
</span></span></code></pre></div><p>Then run the application and check the below url to check open api specification</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">http://localhost:8080/v3/api-docs/
</span></span></code></pre></div><p>You should be able to see something like this
<img loading="lazy" src="/img/open-apidocs.PNG" alt=""  />

You can also add a custom path by adding entry in <strong><strong>application.properties</strong></strong> file</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">springdoc.api-docs.path<span class="o">=</span>/api
</span></span><span class="line"><span class="cl">springdoc.swagger-ui.path<span class="o">=</span>/swagger
</span></span><span class="line"><span class="cl">springdoc.swagger-ui.operationsSorter<span class="o">=</span>method
</span></span></code></pre></div><p><img loading="lazy" src="/img/custom-open-apidocs.PNG" alt=""  />

Check <a href="http://localhost:8080/swagger">http://localhost:8080/swagger</a> for web UI.To show you in this example we have a following apis in the controller</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kn">package</span> <span class="nn">com.TestDocker.BooksDocker.Controllers</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">java.util.List</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.beans.factory.annotation.Autowired</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.http.HttpStatus</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.GetMapping</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.PathVariable</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.PostMapping</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.RequestBody</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.web.bind.annotation.RestController</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">org.springframework.web.server.ResponseStatusException</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">com.TestDocker.BooksDocker.Models.Book</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="kn">import</span> <span class="nn">com.TestDocker.BooksDocker.Repository.BookRepository</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="nd">@RestController</span>
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">MainController</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">	<span class="nd">@Autowired</span>
</span></span><span class="line"><span class="cl">	<span class="kd">public</span> <span class="n">BookRepository</span> <span class="n">bookRepository</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">	<span class="nd">@GetMapping</span><span class="o">(</span><span class="s">&#34;/test&#34;</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">	<span class="kd">public</span> <span class="n">String</span> <span class="nf">test</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">		<span class="k">return</span> <span class="k">new</span> <span class="n">String</span><span class="o">(</span><span class="s">&#34;Working from DOcker Bopoks proj &#34;</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">	<span class="o">}</span>
</span></span><span class="line"><span class="cl">	<span class="nd">@GetMapping</span><span class="o">(</span><span class="s">&#34;/&#34;</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">	<span class="kd">public</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Book</span><span class="o">&gt;</span> <span class="nf">fetchAllBooks</span><span class="o">()</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">		<span class="n">List</span><span class="o">&lt;</span><span class="n">Book</span><span class="o">&gt;</span> <span class="n">books</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">		<span class="k">try</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">			<span class="n">books</span> <span class="o">=</span> <span class="n">bookRepository</span><span class="o">.</span><span class="na">findAll</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">		<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">ex</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">			<span class="k">throw</span> <span class="k">new</span> <span class="n">ResponseStatusException</span><span class="o">(</span><span class="n">HttpStatus</span><span class="o">.</span><span class="na">INTERNAL_SERVER_ERROR</span><span class="o">,</span> <span class="s">&#34;Error occured in fetchAllBooks&#34;</span><span class="o">,</span> <span class="n">ex</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">		<span class="o">}</span>
</span></span><span class="line"><span class="cl">		<span class="k">return</span> <span class="n">books</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">	<span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">	<span class="nd">@GetMapping</span><span class="o">(</span><span class="s">&#34;/{bookID}&#34;</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">	<span class="kd">public</span> <span class="n">Book</span> <span class="nf">fetchBookfromID</span><span class="o">(</span><span class="nd">@PathVariable</span><span class="o">(</span><span class="s">&#34;bookID&#34;</span><span class="o">)</span> <span class="n">Long</span> <span class="n">bookID</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">		<span class="n">Book</span> <span class="n">book</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">		<span class="k">try</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">			<span class="n">book</span> <span class="o">=</span> <span class="n">bookRepository</span><span class="o">.</span><span class="na">getById</span><span class="o">(</span><span class="n">bookID</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">		<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">ex</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">			<span class="k">throw</span> <span class="k">new</span> <span class="n">ResponseStatusException</span><span class="o">(</span><span class="n">HttpStatus</span><span class="o">.</span><span class="na">INTERNAL_SERVER_ERROR</span><span class="o">,</span> <span class="s">&#34;Error Occured in fetchBookfromID&#34;</span><span class="o">,</span> <span class="n">ex</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">		<span class="o">}</span>
</span></span><span class="line"><span class="cl">		<span class="k">return</span> <span class="n">book</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">	<span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">	<span class="nd">@GetMapping</span><span class="o">(</span><span class="s">&#34;/search/{title}&#34;</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">	<span class="kd">public</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Book</span><span class="o">&gt;</span> <span class="nf">searchBookByTitle</span><span class="o">(</span><span class="nd">@PathVariable</span><span class="o">(</span><span class="s">&#34;title&#34;</span><span class="o">)</span> <span class="n">String</span> <span class="n">title</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">		<span class="n">List</span><span class="o">&lt;</span><span class="n">Book</span><span class="o">&gt;</span> <span class="n">books</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">		<span class="k">try</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">			<span class="c1">//System.out.println(title);
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>			<span class="n">books</span> <span class="o">=</span> <span class="n">bookRepository</span><span class="o">.</span><span class="na">fuzzySearchByTitle</span><span class="o">(</span><span class="n">title</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">			<span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">books</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">		<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">ex</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">			<span class="k">throw</span> <span class="k">new</span> <span class="n">ResponseStatusException</span><span class="o">(</span><span class="n">HttpStatus</span><span class="o">.</span><span class="na">INTERNAL_SERVER_ERROR</span><span class="o">,</span> <span class="s">&#34;Error Occured in searchBookByTitle&#34;</span><span class="o">,</span> <span class="n">ex</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">		<span class="o">}</span>
</span></span><span class="line"><span class="cl">		<span class="k">return</span> <span class="n">books</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">	<span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">	<span class="nd">@PostMapping</span><span class="o">(</span><span class="s">&#34;/insertBooks&#34;</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">	<span class="kd">public</span> <span class="n">String</span> <span class="nf">insertBooks</span><span class="o">(</span><span class="nd">@RequestBody</span> <span class="n">List</span><span class="o">&lt;</span><span class="n">Book</span><span class="o">&gt;</span> <span class="n">books</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">		<span class="k">for</span> <span class="o">(</span><span class="n">Book</span> <span class="n">b</span> <span class="o">:</span> <span class="n">books</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">			<span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">b</span><span class="o">.</span><span class="na">toString</span><span class="o">());</span>
</span></span><span class="line"><span class="cl">			<span class="n">Book</span> <span class="n">b1</span> <span class="o">=</span> <span class="n">bookRepository</span><span class="o">.</span><span class="na">save</span><span class="o">(</span><span class="n">b</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">			<span class="k">if</span> <span class="o">(</span><span class="n">b1</span> <span class="o">==</span> <span class="kc">null</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">				<span class="k">return</span> <span class="s">&#34;Book object is null&#34;</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">		<span class="o">}</span>
</span></span><span class="line"><span class="cl">		<span class="k">return</span> <span class="kc">null</span><span class="o">;</span>
</span></span><span class="line"><span class="cl">	<span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre></div><p>So the swagger ui look something like this.
Also json docs will be available at <a href="http://localhost:8080/api">http://localhost:8080/api</a> springdoc.swagger-ui.operationsSorter=method sorts the API paths in order of their HTTP methods.
You can try and test the apis from web ui too.It also shows schema information!
Overall this is a much convenient way of setting up documentation for your apis which can be handy in some situations.</p>
<p>That’s all folks!</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Which would you go for? Spring boot cron job,scheduled tasks vs Events in Mysql.</title>
      <link>https://shwetakadam.com/posts/which-would-you-go-for-spring-boot-cron-jobscheduled-tasks-vs-events-in-mysql/</link>
      <pubDate>Wed, 12 Jan 2022 23:49:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/which-would-you-go-for-spring-boot-cron-jobscheduled-tasks-vs-events-in-mysql/</guid>
      <description>I was recently studying about using cron jobs in spring boot for a particular use case for my small side project. I ended up not using the cron job but rather went the SQL way(will explain this in detail below). However,in the process I learnt a lot about cron jobs and scheduling in spring boot so this is just a small article about my learnings.
But first I shall tell you a little about my use case and why I thought about cron jobs in the first place….</description>
      <content:encoded><![CDATA[<p>I was recently studying about using cron jobs in spring boot for a particular use case for my small side project. I ended up not using the cron job but rather went the SQL way(will explain this in detail below). However,in the process I learnt a lot about cron jobs and scheduling in spring boot so this is just a small article about my learnings.</p>
<p>But first I shall tell you a little about my use case and why I thought about cron jobs in the first place…..</p>
<h2 id="use-case">Use case</h2>
<p>My application was inserting data (let’s call it smash data for simplicity for now)in the database.Each smash data has a certain expiry period and after that expiry period, that data should no longer remain in the database.But the expiry period will be different for each smash data.</p>
<p>Example:</p>
<p>smash 1, expiryperiod :10mins</p>
<p>smash 2 ,expiryperiod :60mins</p>
<p>smash 3 ,expiryperiod :150mins . . . etc.</p>
<p>Now my first line of thinking ended up being cron jobs which led to me studying about cron jobs and scheduled in spring boot.To answer it simply I didn’t end up taking this route is because cron jobs or scheduled tasks are suited when we expect the task to execute at only a particular point of time or where we expect functionality to be executed at w particular time on an hourly/daily /weekly/monthly basis. I could get the cron job to delete the data but to delete WHICH data smash 1 or smash 2? That would mean I would have to check the DB. So the process would be something like:-</p>
<p>Fetch all rows from DB.
Check timestamp of each row data against current timestamp and delete accordingly.
I wanted to avoid writing the searching, comparing time logic (dates, in general, can be a pain sometimes).The logic which I did ended up going through was events in SQL since I’m using MySQL db for the use case</p>
<blockquote>
<p>Mysql events are tasks that run according to a particular schedule …hence they can be called as scheduled events</p>
</blockquote>
<p>When an event is created in MySQL, a named database object is created and this object consists of one or more SQL statements to be executed at some regular intervals.Using events,I didn’t have to retrieve and search the data (as I had to do in the spring boot controller ) . I could just write an event such as</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-sql" data-lang="sql"><span class="line"><span class="cl"><span class="k">Delete</span><span class="w"> </span><span class="k">from</span><span class="w"> </span><span class="n">table1</span><span class="w"> </span><span class="k">where</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="n">expiry</span><span class="w"> </span><span class="n">period</span><span class="w"> </span><span class="o">&lt;</span><span class="w"> </span><span class="n">NOW</span><span class="p">();</span><span class="w">
</span></span></span></code></pre></div><p>And schedule this to execute <code>every minute</code>. Which was would check for that expiryPeriod column in each row and compare with time NOW() So any rows whose expiryperiod has passed will be deleted from db.</p>
<p>The only thing to note I see in this approach, for now, is that this is database dependent so when I host this side project (a hopeful dream) I need to make sure events is configured for the same. So this was the use case now back to cron jobs!</p>
<h2 id="cron-jobs-or-schedule-tasks-in-spring-boot-dot-permalink">Cron jobs or schedule tasks in spring boot.Permalink</h2>
<p>When a situation arises where we expect the task to execute at only a particular point of time or where we expect functionality to be executed at a particular time on an hourly/daily /weekly/monthly basis. Cron jobs are suitable for this use case. In spring this sort of scheduled task can be achieved through @Scheduled annotation.</p>
<p>There are a few rules while using the @Scheduled annotation:  1. The method should typically have a void return type else the returned value will be ignored.</p>
<p>the method should not expect any parameters. First, to enable scheduling in the spring boot project, use @EnableScheduling in the main class.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">Application</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl"> <span class="n">SpringApplication</span><span class="o">.</span><span class="na">run</span><span class="o">(</span><span class="n">PasteBinApplication</span><span class="o">.</span><span class="na">class</span><span class="o">,</span> <span class="n">args</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"> <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre></div><h2 id="scheduling-using-cron-expressions">Scheduling using CRON expressions</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="nd">@Component</span>
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SchedulerService</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">    <span class="nd">@Scheduled</span><span class="o">(</span><span class="n">cron</span><span class="o">=</span><span class="s">&#34;*/15 * * * * ?&#34;</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">testScheduled</span><span class="o">()</span>
</span></span><span class="line"><span class="cl">    <span class="o">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;Method executed at every 15 seconds. Current time is :: &#34;</span><span class="o">+</span> <span class="k">new</span> <span class="n">Date</span><span class="o">());</span>
</span></span><span class="line"><span class="cl">    <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre></div><p>A guide for cron jobs: cron Image source :Java Techonline
<img loading="lazy" src="/img/cron.PNG" alt=""  />
</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">SEC  MIN   HOURS   DAY  MONTH  WEEKDAY
</span></span><span class="line"><span class="cl"> *    *      *      *     *      *
</span></span></code></pre></div><h2 id="scheduling-using-initial-delay-fixed-delay-or-fixed-rate">Scheduling using initial delay,Fixed Delay or Fixed Rate</h2>
<p>The main difference between Fixed Delay and Fixed Rate is : Fixed Delay : controls the next execution time when the last execution finishes. Fixed Rate : makes Spring run the task on periodic intervals even if the last invocation may be still running.</p>
<p>Fixed Delay</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="nd">@Component</span>
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SchedulerService</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">    <span class="nd">@Scheduled</span><span class="o">(</span><span class="n">fixedDelay</span> <span class="o">=</span> <span class="mi">1000</span><span class="o">,</span> <span class="n">initialDelay</span> <span class="o">=</span> <span class="mi">5000</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">testScheduled</span><span class="o">()</span>
</span></span><span class="line"><span class="cl">    <span class="o">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;Method executed with fixed delay and initial delay . Current time is :: &#34;</span><span class="o">+</span> <span class="k">new</span> <span class="n">Date</span><span class="o">());</span>
</span></span><span class="line"><span class="cl">    <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre></div><p>Also Fixed Delay can take input in String and Integer. @Scheduled(fixedDelayString = “7000”) @Scheduled(fixedDelayString = 7000)
Fixed Rate:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="nd">@Component</span>
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">class</span> <span class="nc">SchedulerService</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">    <span class="nd">@Scheduled</span><span class="o">(</span><span class="n">fixedRate</span> <span class="o">=</span> <span class="mi">1000</span><span class="o">)</span>
</span></span><span class="line"><span class="cl">    <span class="kd">public</span> <span class="kt">void</span> <span class="nf">testScheduled</span><span class="o">()</span>
</span></span><span class="line"><span class="cl">    <span class="o">{</span>
</span></span><span class="line"><span class="cl">        <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;Method executed with fixed rate . Current time is :: &#34;</span><span class="o">+</span> <span class="k">new</span> <span class="n">Date</span><span class="o">());</span>
</span></span><span class="line"><span class="cl">    <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span></code></pre></div><p>That’s all folks.Learning about events and cron jobs and where could be applied was interesting to learn when applied on some small practical application.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Deploying my portfolio website for free on Github Pages using GitHub actions</title>
      <link>https://shwetakadam.com/posts/deploying-my-portfolio-website-for-free-on-github-pages-using-github-actions/</link>
      <pubDate>Sun, 05 Dec 2021 23:23:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/deploying-my-portfolio-website-for-free-on-github-pages-using-github-actions/</guid>
      <description>I deployed my portfolio site and wanted to try out github actions and this is my experience of automating the deployment. This article is more focused on how you can use the GitHub actions and how easy it is to deploy your code to GitHub pages rather than the portfolio site code.So every time you make an update or build to your website ,the changes are automatically reflected and this automated deploying process makes work much faster.</description>
      <content:encoded><![CDATA[<p>I deployed my <a href="https://shwetarkadam.github.io/portfolio/">portfolio site</a> and wanted to try out github actions and this is my experience of automating the deployment.
This article is more focused on how you can use the GitHub actions and how easy it is to deploy your code to GitHub pages rather than the portfolio site code.So every time you make an update or build to your website ,the changes are automatically reflected and this automated deploying process makes work much faster.</p>
<p>The way GitHub action works is you create actions in your repositories by creating one or more yaml files and these are called workflows.Workflows now can handle build tasks like CI CD. This means you use the action to test your code and push the site to the desired hosting platform (in this case GitHub pages ) when the main branch changes .
First step assuming that you have a GitHub account is to create a repository having your website code in it.Now I have a bootstrap website but in the future I do plan on adding node JS so I already added package.json.</p>
<p>{% gist 7fc9e560ec958d6fb9876019e298e02f %}</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-json" data-lang="json"><span class="line"><span class="cl"><span class="p">{</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;name&#34;</span><span class="p">:</span> <span class="s2">&#34;shwetarkadam.github.io&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;version&#34;</span><span class="p">:</span> <span class="s2">&#34;1.0.0&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;description&#34;</span><span class="p">:</span> <span class="s2">&#34;Portfolio&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;main&#34;</span><span class="p">:</span> <span class="s2">&#34;index.html&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;scripts&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;build&#34;</span><span class="p">:</span> <span class="s2">&#34;npm run clean &amp;&amp; npm run imagemin &amp;&amp; npm run copyfonts &amp;&amp; npm run copydata &amp;&amp; npm run usemin&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;clean&#34;</span><span class="p">:</span> <span class="s2">&#34;rimraf dist&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;copyfonts&#34;</span><span class="p">:</span> <span class="s2">&#34;copyfiles -f node_modules/font-awesome/fonts/* dist/fonts&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;copydata&#34;</span><span class="p">:</span> <span class="s2">&#34;copyfiles -f src/js/* dist/js&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;imagemin&#34;</span><span class="p">:</span> <span class="s2">&#34;imagemin src/img/* -o dist/img&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;lite&#34;</span><span class="p">:</span> <span class="s2">&#34;lite-server&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;start&#34;</span><span class="p">:</span> <span class="s2">&#34;npm run lite&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;test&#34;</span><span class="p">:</span> <span class="s2">&#34;echo \&#34;Error: no test specified\&#34; &amp;&amp; exit 1&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;usemin&#34;</span><span class="p">:</span> <span class="s2">&#34;usemin index.html -d dist --htmlmin -o dist/index.html&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="p">},</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;repository&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;type&#34;</span><span class="p">:</span> <span class="s2">&#34;git&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;url&#34;</span><span class="p">:</span> <span class="s2">&#34;git@github.com:shwetarkadam/portfolio.git&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="p">},</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;author&#34;</span><span class="p">:</span> <span class="s2">&#34;Shweta Kadam&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;license&#34;</span><span class="p">:</span> <span class="s2">&#34;MIT&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;dependencies&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;bootstrap&#34;</span><span class="p">:</span> <span class="s2">&#34;^4.4.1&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;font-awesome&#34;</span><span class="p">:</span> <span class="s2">&#34;^4.7.0&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;jquery&#34;</span><span class="p">:</span> <span class="s2">&#34;^3.5.1&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;popper.js&#34;</span><span class="p">:</span> <span class="s2">&#34;^1.16.0&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="p">},</span>
</span></span><span class="line"><span class="cl">  <span class="nt">&#34;devDependencies&#34;</span><span class="p">:</span> <span class="p">{</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;copyfiles&#34;</span><span class="p">:</span> <span class="s2">&#34;^2.2.0&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;imagemin-cli&#34;</span><span class="p">:</span> <span class="s2">&#34;^5.1.0&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;lite-server&#34;</span><span class="p">:</span> <span class="s2">&#34;^2.5.4&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;rimraf&#34;</span><span class="p">:</span> <span class="s2">&#34;^3.0.2&#34;</span><span class="p">,</span>
</span></span><span class="line"><span class="cl">    <span class="nt">&#34;usemin-cli&#34;</span><span class="p">:</span> <span class="s2">&#34;^0.6.0&#34;</span>
</span></span><span class="line"><span class="cl">  <span class="p">}</span>
</span></span><span class="line"><span class="cl"><span class="p">}</span>
</span></span></code></pre></div><p>Verify all your changes as correct by first in your root folder running the command:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">npm install
</span></span></code></pre></div><p>npm install</p>
<p>and after installing node modules run the command:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">run npm start
</span></span></code></pre></div><p>so you should get your output in localhost something like this</p>
<figure>
    <img loading="lazy" src="/img/portfolio-githubactions.PNG"/> 
</figure>

<p>Now that you have ensured that the project runs properly in your local machine,it is ready to be deployed to GitHub pages. You will only need to commit and push your changes to the main branch of a repo and ensure that the settings are pointing to the correct branch to display a site for that.
Now the file that does this is that deploy.yml file which we will use to create the workflow.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-yaml" data-lang="yaml"><span class="line"><span class="cl"><span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Build and Deploy</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">on</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">push</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">branches</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="l">main</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w"></span><span class="nt">jobs</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">  </span><span class="nt">build-and-deploy</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">runs-on</span><span class="p">:</span><span class="w"> </span><span class="l">ubuntu-latest</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nt">steps</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Checkout</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">actions/checkout@v2</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">with</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">persist-credentials</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Install and 06Build</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">run</span><span class="p">:</span><span class="w"> </span><span class="p">|</span><span class="sd">
</span></span></span><span class="line"><span class="cl"><span class="sd">          npm install
</span></span></span><span class="line"><span class="cl"><span class="sd">          npm run build</span><span class="w">          
</span></span></span><span class="line"><span class="cl"><span class="w">      </span>- <span class="nt">name</span><span class="p">:</span><span class="w"> </span><span class="l">Deploy</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">uses</span><span class="p">:</span><span class="w"> </span><span class="l">JamesIves/github-pages-deploy-action@releases/v3</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">        </span><span class="nt">with</span><span class="p">:</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">GITHUB_TOKEN</span><span class="p">:</span><span class="w"> </span><span class="l">${{ secrets.GITHUB_TOKEN }}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">BRANCH</span><span class="p">:</span><span class="w"> </span><span class="l">gh-pages</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">          </span><span class="nt">FOLDER</span><span class="p">:</span><span class="w"> </span><span class="l">dist</span><span class="w">
</span></span></span></code></pre></div><p>Now this yaml file which can be found <code>.github/workflows/deploy.yml</code> file in local ,you can rename the file whatever you like.It tells the github actions to install the project dependencies run a build script and put that required files in a output folder name dist and upload the contents of the dist folder to the gh-pages branch and if the branch does not exist it will create that branch.The workflow to deploy the site to github-pages you can find that from James Ives GitHub pages deploy action.
If you have any existing site or code and you want to publish it to get pages you only need this file to be added into your project.
You could go to your github repo Actions Tab -&gt; Create Simple Workflow and copy paste the above content in your yaml file.</p>
<p>Once you have a site ready for GitHub Pages, and your project includes the <code>.github/workflows/deploy.yml</code> file, you only need to commit and push your changes to the main branch of your repository. You can the ongoing workflow by going to Actions=&gt;build and deploy.Also this is the place where you can debug what went wrong in case your workflow fails.</p>
<figure>
    <img loading="lazy" src="/img/githubaction-build.PNG"/> 
</figure>

<figure>
    <img loading="lazy" src="/img/githubaction-build2.png"/> 
</figure>

<p>After the GitHub Actions have run, ensure settings are pointing to the correct branch to display your site.
Go to the settings of your repository and ensure that the source for GitHub Pages is using the correct branch. It is close to the bottom of the main settings page.</p>
<figure>
    <img loading="lazy" src="/img/gh-pages.PNG"/> 
</figure>

<p>It does take some time at the start to load in the browser but once available you can click on the link in the green bar above.
Now every time you make a push to the main branch ,the changes are reflected in the main site.</p>
<p>My Portfolio Site: <a href="https://shwetarkadam.github.io/portfolio/">Click Here</a></p>
<p>That’s all folks.
Happy Learning.</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>Polymorphism in Java</title>
      <link>https://shwetakadam.com/posts/polymorphism-in-java/</link>
      <pubDate>Wed, 14 Jul 2021 23:28:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/polymorphism-in-java/</guid>
      <description>Just revisiting and explaining myself Polymorphism concept here through a blog post. The words Polymorphism means multiple forms.
In Java ,Polymorphism means multiple forms of an object. We shall divide this article into 3 sections.
1.Syntax
2.Calling a variable polymorphically.
3.Calling a method polymorphically.
1.SyntaxPermalink Now in polymorphism in Java, the thumb key rule to remember is
super = subPermalink Meaning the variable reference (LHS) must always be a super class reference and the object initialization(RHS) must a sub class.</description>
      <content:encoded><![CDATA[<p>Just revisiting and explaining myself Polymorphism concept here through a blog post. The words Polymorphism means multiple forms.</p>
<p>In Java ,Polymorphism means multiple forms of an object. We shall divide this article into 3 sections.</p>
<p>1.Syntax</p>
<p>2.Calling a variable polymorphically.</p>
<p>3.Calling a method polymorphically.</p>
<p>1.SyntaxPermalink
Now in polymorphism in Java, the thumb key rule to remember is</p>
<p>super = subPermalink
Meaning the variable reference (LHS) must always be a super class reference and the object initialization(RHS) must a sub class.</p>
<p>For Example: class A{</p>
<p>} class B extends A{ }
class C extends B{ }
class D extends A{ }</p>
<p>So valid and invalid syntax according to the thumb rule will be</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="n">A</span> <span class="n">a</span> <span class="o">=</span><span class="k">new</span> <span class="n">B</span><span class="o">();</span>           <span class="c1">//VALID
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">B</span> <span class="n">b</span><span class="o">=</span><span class="k">new</span> <span class="n">D</span><span class="o">();</span>            <span class="c1">//NOT VALID
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">C</span> <span class="n">c</span><span class="o">=</span><span class="k">new</span> <span class="n">A</span><span class="o">();</span>           <span class="c1">//VALID
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">A</span> <span class="n">a1</span><span class="o">=</span><span class="k">new</span> <span class="n">D</span><span class="o">();</span>           <span class="c1">//VALID
</span></span></span></code></pre></div><p>2.Calling a variable polymorphically.Permalink
If a variable is called from a polymorphic object,we follow the reference i.e. the super class. And if the variable is not present in the super class ,it results in a COMPILE ERROR. EG:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="kt">int</span> <span class="n">x</span><span class="o">=</span><span class="mi">5</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">B</span> <span class="kd">extends</span> <span class="n">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="kt">int</span> <span class="n">x</span><span class="o">=</span><span class="mi">10</span><span class="o">;</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">App</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span><span class="n">args</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span> <span class="n">a</span><span class="o">=</span><span class="k">new</span> <span class="n">B</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="n">a</span><span class="o">.</span><span class="na">x</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="c1">//What do u think is the output class A x value (5)or class B x value(10)?Follow the rule.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="nl">OUTPUT:</span>
</span></span><span class="line"><span class="cl"><span class="mi">5</span>
</span></span></code></pre></div><p>Calling a method polymorphically.Permalink
If a method is called from a polymorphic object ,we follow a 2 step procedure: 1.We got to the super class and check whther the method is present or not.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="k">if</span><span class="o">(</span>present<span class="o">)</span>
</span></span><span class="line"><span class="cl"> Goto to step <span class="m">2</span>
</span></span><span class="line"><span class="cl"><span class="k">else</span>
</span></span><span class="line"><span class="cl"> COMPILE ERROR
</span></span></code></pre></div><p>2.Come to the sub class and check wther the method is overrided or not.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl"><span class="k">if</span><span class="o">(</span>overrided<span class="o">)</span>
</span></span><span class="line"><span class="cl"> Call the sub-class version
</span></span><span class="line"><span class="cl"><span class="k">else</span>
</span></span><span class="line"><span class="cl"> Call the super -class version.
</span></span></code></pre></div><p>Eg:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="kt">void</span> <span class="nf">m1</span><span class="o">(){</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;A&#34;</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="o">}}</span>
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">B</span> <span class="kd">extends</span> <span class="n">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="kt">void</span> <span class="nf">m1</span><span class="o">(){</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;B&#34;</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="o">}}</span>
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">App</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span><span class="n">args</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span> <span class="n">a</span><span class="o">=</span><span class="k">new</span> <span class="n">B</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="n">a</span><span class="o">.</span><span class="na">m1</span><span class="o">();</span>          <span class="c1">//Follow the rule
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">B</span><span class="o">=</span><span class="k">new</span> <span class="n">B</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="n">b</span><span class="o">.</span><span class="na">m1</span><span class="o">();</span>          <span class="c1">//Normal sub class object method call
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}}</span>
</span></span><span class="line"><span class="cl"><span class="nl">OUTPUT:</span>
</span></span><span class="line"><span class="cl"><span class="n">B</span>
</span></span><span class="line"><span class="cl"><span class="n">B</span>
</span></span></code></pre></div><p>So that’s all for polymorphism in java.</p>
<p>Happy Learning :)</p>
]]></content:encoded>
    </item>
    
    <item>
      <title>How constructors work in Java</title>
      <link>https://shwetakadam.com/posts/how-constructors-work-in-java/</link>
      <pubDate>Mon, 14 Jun 2021 21:41:00 +0530</pubDate>
      
      <guid>https://shwetakadam.com/posts/how-constructors-work-in-java/</guid>
      <description>Constructors are used every time to initialize instance variables. There are some additional rules associated with constructors that are often asked in interviews.Hence revising those here through a blog post.
A constructor is used to initialize instance variables When an object of an class is created,JVM goes to the class and searches for that matching constructor.If Constructor is NOT PRESENT it gives a compile error. By default every class has a constructor called default no argument constructor.</description>
      <content:encoded><![CDATA[<p>Constructors are used every time to initialize instance variables. There are some additional rules associated with constructors that are often asked in interviews.Hence revising those here through a blog post.</p>
<h2 id="a-constructor-is-used-to-initialize-instance-variables">A constructor is used to initialize instance variables</h2>
<h2 id="when-an-object-of-an-class-is-created-jvm-goes-to-the-class-and-searches-for-that-matching-constructor-dot-if-constructor-is-not-present-it-gives-a-compile-error-dot">When an object of an class is created,JVM goes to the class and searches for that matching constructor.If Constructor is NOT PRESENT it gives a compile error.</h2>
<h2 id="by-default-every-class-has-a-constructor-called-default-no-argument-constructor-dot">By default every class has a constructor called default no argument constructor.</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(){</span> <span class="c1">//default no arg constructor
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}}</span>
</span></span></code></pre></div><h2 id="a-programmer-can-have-multiple-constructors-in-a-class-provided-their-signatures-are-different-this-is-called-constructor-overloading-dot">A programmer can have multiple constructors in a class provided their signatures are different this is called constructor overloading.</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(){</span>
</span></span><span class="line"><span class="cl"><span class="c1">//some code
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(</span><span class="kt">int</span> <span class="n">x</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="c1">//some code
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(</span><span class="kt">float</span> <span class="n">x</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="c1">//some code
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(</span><span class="kt">float</span> <span class="n">x</span><span class="o">,</span><span class="kt">int</span> <span class="n">y</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="c1">//some code
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(</span><span class="kt">int</span> <span class="n">x</span><span class="o">,</span><span class="kt">float</span> <span class="n">y</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(</span><span class="kt">int</span> <span class="n">z</span><span class="o">){}</span><span class="c1">//THIS WILL GIVE COMPILE ERROR SInce its already defined on top.
</span></span></span><span class="line"><span class="cl"><span class="c1"></span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">A</span> <span class="n">a</span><span class="o">=</span><span class="k">new</span> <span class="n">A</span><span class="o">();</span>
</span></span><span class="line"><span class="cl"><span class="k">new</span> <span class="n">A</span><span class="o">();</span><span class="c1">//goes to first matching constructor
</span></span></span></code></pre></div><h2 id="jvm-always-calls-the-matching-constructor-from-the-class-dot-however-a-programmer-can-call-other-constructors-of-this-class-by-using-the-the-this-method-dot">JVM always calls the matching constructor from the class.HOWEVER,a programmer can call other constructors of this class by using the the this() method.</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(){</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;A&#34;</span><span class="o">);</span>    <span class="c1">//I
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">A</span><span class="o">(</span><span class="kt">int</span> <span class="n">x</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="k">this</span><span class="o">();</span>                     <span class="c1">//this will go to constructor A();
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;AA&#34;</span><span class="o">);</span>   <span class="c1">//II
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">App</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span><span class="n">args</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="k">new</span> <span class="n">A</span><span class="o">(</span><span class="mi">5</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="o">}}</span>
</span></span><span class="line"><span class="cl"><span class="nl">
</span></span></span><span class="line"><span class="cl"><span class="nl">OUTPUT:</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span>
</span></span><span class="line"><span class="cl"><span class="n">AA</span>
</span></span></code></pre></div><h2 id="if-a-programmer-desires-it-can-call-the-constructor-of-the-super-class-as-well-from-its-own-constructor-using-the-super-method-dot">If a programmer desires it can call the constructor of the super class as well from its own constructor using the super() method.</h2>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(){</span>
</span></span><span class="line"><span class="cl"><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;A&#34;</span><span class="o">);</span>    <span class="c1">//I
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">B</span> <span class="kd">extends</span> <span class="n">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="n">B</span><span class="o">(){</span>
</span></span><span class="line"><span class="cl"><span class="kd">super</span><span class="o">();</span>             <span class="c1">//this is called implicitly refer next point also
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;B&#34;</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="o">}}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">HelloWorld</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">new</span> <span class="n">B</span><span class="o">();</span>
</span></span><span class="line"><span class="cl">    <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="nl">OUTPUT:</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span>
</span></span><span class="line"><span class="cl"><span class="n">B</span>
</span></span></code></pre></div><h2 id="whenever-a-programmer-creates-a-constructor-jvm-writes-super-in-every-constructor-implicitly-as-its-first-line-dot">Whenever a programmer creates a constructor ,JVM writes super() in every constructor implicitly as its first line.</h2>
<p>Note:If a class does not extend any class it by default extends the Object class. Do Try this code in your ide to see it for yourself</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-java" data-lang="java"><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">A</span><span class="o">{</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(){</span>
</span></span><span class="line"><span class="cl"><span class="c1">//super will be called implicitly at the first line of this constructor and here since it does not extend any class it will extend the Object class
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;A&#34;</span><span class="o">);</span>    <span class="c1">//I
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="o">}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">A</span><span class="o">(</span><span class="kt">int</span> <span class="n">x</span><span class="o">){</span>
</span></span><span class="line"><span class="cl"><span class="c1">//super will be called implicitly at the first line of this constructor
</span></span></span><span class="line"><span class="cl"><span class="c1"></span><span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span><span class="s">&#34;AA&#34;</span><span class="o">);</span>
</span></span><span class="line"><span class="cl"><span class="o">}}</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="kd">class</span> <span class="nc">HelloWorld</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">    <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span> <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="o">{</span>
</span></span><span class="line"><span class="cl">        <span class="k">new</span> <span class="n">A</span><span class="o">(</span><span class="mi">5</span><span class="o">);</span>
</span></span><span class="line"><span class="cl">    <span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="o">}</span>
</span></span><span class="line"><span class="cl"><span class="nl">OUTPUT:</span>
</span></span><span class="line"><span class="cl"><span class="n">A</span>
</span></span><span class="line"><span class="cl"><span class="n">AA</span>
</span></span></code></pre></div><p>That’s all for constructors in Java.</p>
<p>Happy Learning :)</p>
]]></content:encoded>
    </item>
    
  </channel>
</rss>
