<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Prem</title>
    <description>The latest articles on DEV Community by Prem (@prematid).</description>
    <link>https://dev.to/prematid</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F674550%2F98f9b27e-611a-4b17-aaf5-6bf858b40934.jpeg</url>
      <title>DEV Community: Prem</title>
      <link>https://dev.to/prematid</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prematid"/>
    <language>en</language>
    <item>
      <title>Size Doesn't Matter: Why Your Elasticsearch Fields Need to Stop Caring About Length</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Wed, 06 Nov 2024 03:52:06 +0000</pubDate>
      <link>https://dev.to/prematid/size-doesnt-matter-why-your-elasticsearch-fields-need-to-stop-caring-about-length-4cd7</link>
      <guid>https://dev.to/prematid/size-doesnt-matter-why-your-elasticsearch-fields-need-to-stop-caring-about-length-4cd7</guid>
      <description>&lt;h2&gt;
  
  
  Understanding Elasticsearch Field Length Normalization: When and Why to Disable Norms
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;"Why Are My Elasticsearch Scores Wrong?"
-"Why are my documents with identical content scoring differently?" &lt;/li&gt;
&lt;li&gt;"How come shorter fields always seem to rank higher?" &lt;/li&gt;
&lt;li&gt;"Why doesn't my exact-match search return equal scores?" &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've ever asked these questions while working with Elasticsearch, you're not alone. You've probably noticed that documents with the same matching terms sometimes receive unexpectedly different scores. What might appear as random scoring variations actually stems from one of Elasticsearch's most impactful – and often misunderstood – relevance features: field length normalization, also known as norms.&lt;/p&gt;

&lt;p&gt;This built-in feature, while powerful for natural language search, can sometimes be your search results' worst enemy. It's like having an overeager assistant who assumes shorter is always better – helpful when summarizing novels, but problematic when dealing with product codes or categories. Let's unravel this mystery and discover when this "helpful" feature might be secretly sabotaging your search results, and more importantly, how to fix it.&lt;/p&gt;

&lt;p&gt;When working with Elasticsearch, one of the most subtle yet impactful aspects of relevance scoring is field length normalization. While this feature is beneficial for natural language search, it can sometimes work against you depending on your use case. Let's dive deep into what norms are, when they help, when they hurt, and how to control them.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Norms?
&lt;/h2&gt;

&lt;p&gt;Norms are scoring factors in Elasticsearch that contribute to how relevance is calculated for a document. One of their primary functions is field length normalization - making shorter fields score higher than longer ones when they contain the same search term.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Real-World Example
&lt;/h2&gt;

&lt;p&gt;Imagine you're building a recipe search engine. You have two fields:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;title&lt;/code&gt;: The recipe name&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;instructions&lt;/code&gt;: The step-by-step cooking instructions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's look at two recipes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Simple Tomato Pasta"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"instructions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Boil pasta. Add tomato sauce. Serve."&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Tomato and Basil Pasta with Fresh Garden Herbs and Parmesan"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"instructions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1. Boil water and cook pasta until al dente. 2. In a pan, sauté garlic... [50 more detailed steps]"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When someone searches for "tomato pasta", with default norms enabled, the first recipe might score higher because:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The term "tomato" in a shorter title field gets more weight&lt;/li&gt;
&lt;li&gt;The shorter instructions field doesn't dilute the overall score&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When Norms Help
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Article Search&lt;/strong&gt;: When searching article content, a keyword appearing in a 100-word article might be more relevant than the same keyword in a 10,000-word article.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Product Descriptions&lt;/strong&gt;: A product specifically about "bluetooth headphones" might have a shorter, more focused description than one that merely mentions bluetooth headphones as a compatible accessory.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  When Norms Hurt
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;SKU/Product Code Search&lt;/strong&gt;: Consider a product catalog with a &lt;code&gt;product_codes&lt;/code&gt; field:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"product_codes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ABC123"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"XYZ789"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"DEF456"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"product_codes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"ABC123"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When searching for "ABC123", should the first product score lower just because it has more product codes? Probably not!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Category Lists&lt;/strong&gt;: For an e-commerce site with product categories:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"categories"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Electronics"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Computers"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Laptops"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;vs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"categories"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"Electronics"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A search for "Electronics" should treat both products equally, regardless of how many categories they belong to.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Disable Norms
&lt;/h2&gt;

&lt;p&gt;When you decide norms aren't appropriate for your use case, you can disable them in your mapping:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mappings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"properties"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"product_codes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"norms"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Impact of Disabling Norms
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Positive Effects:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;More predictable scoring for structured data&lt;/li&gt;
&lt;li&gt;Reduced index size (saves 1 byte per field per document)&lt;/li&gt;
&lt;li&gt;Slightly improved indexing performance&lt;/li&gt;
&lt;li&gt;Reduced memory usage&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What You Lose:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Field-length normalization&lt;/li&gt;
&lt;li&gt;Index-time field boost capabilities&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Enable norms for&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Full-text fields like article content, descriptions&lt;/li&gt;
&lt;li&gt;Fields where length indicates relevance&lt;/li&gt;
&lt;li&gt;Search scenarios requiring fine-tuned relevance scoring&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Disable norms for&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identifier fields&lt;/li&gt;
&lt;li&gt;Category or tag lists&lt;/li&gt;
&lt;li&gt;Structured data where field length doesn't indicate relevance&lt;/li&gt;
&lt;li&gt;Fields used primarily for filtering rather than scoring&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Implementation Strategy
&lt;/h2&gt;

&lt;p&gt;When implementing norm changes in production:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a new index with updated mappings&lt;/li&gt;
&lt;li&gt;Use aliases to point to the current index&lt;/li&gt;
&lt;li&gt;Reindex data to the new index&lt;/li&gt;
&lt;li&gt;Switch the alias to point to the new index&lt;/li&gt;
&lt;li&gt;Remove the old index&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding and properly configuring norms is crucial for building effective search experiences. While Elasticsearch's defaults work well for natural language text, structured data often benefits from disabling norms. By carefully considering your use case and data characteristics, you can make informed decisions about norm configuration and improve both search relevance and performance.&lt;/p&gt;

&lt;p&gt;Remember: The best configuration is one that matches your users' expectations of what makes a document relevant. Don't be afraid to experiment and test different approaches with real user queries and feedback.&lt;/p&gt;

</description>
      <category>elasticsearch</category>
      <category>fulltextsearch</category>
      <category>softwareengineering</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>How to Clean Up Deleted Git Branches: A Developer's Guide</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Tue, 22 Oct 2024 19:48:41 +0000</pubDate>
      <link>https://dev.to/prematid/how-to-clean-up-deleted-git-branches-a-developers-guide-5681</link>
      <guid>https://dev.to/prematid/how-to-clean-up-deleted-git-branches-a-developers-guide-5681</guid>
      <description>&lt;p&gt;In any active development environment, Git branches can accumulate quickly. While remote branches might be deleted after merging pull requests, their local counterparts often remain, cluttering your workspace. This guide will show you how to efficiently clean up these obsolete local branches.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;When working with Git, especially in a team environment, you'll often create multiple branches for different features, bug fixes, or experiments. After merging these branches into the main codebase and deleting them from the remote repository (like GitHub or GitLab), the local references often stick around on your machine. This can lead to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cluttered branch listings&lt;/li&gt;
&lt;li&gt;Confusion about which branches are still relevant&lt;/li&gt;
&lt;li&gt;Unnecessary use of disk space&lt;/li&gt;
&lt;li&gt;Difficulty in managing active branches&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Here's a step-by-step guide to cleaning up your local Git branches that no longer exist on the remote repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Update Your Local Repository
&lt;/h3&gt;

&lt;p&gt;First, fetch the latest changes from your remote repository and clean up remote tracking branches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git fetch &lt;span class="nt"&gt;--prune&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;--prune&lt;/code&gt; flag is crucial here - it removes references to remote branches that no longer exist on the remote repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Identify Obsolete Branches
&lt;/h3&gt;

&lt;p&gt;To see which local branches no longer have a corresponding remote branch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch &lt;span class="nt"&gt;-vv&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s1"&gt;': gone]'&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $1}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;git branch -vv&lt;/code&gt;: Shows all local branches with their tracking information&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;grep ': gone]'&lt;/code&gt;: Filters for branches whose remote tracking branch is gone&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;awk '{print $1}'&lt;/code&gt;: Extracts just the branch names&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: Delete the Branches
&lt;/h3&gt;

&lt;p&gt;You have two options for deletion:&lt;/p&gt;

&lt;h4&gt;
  
  
  Safe Deletion
&lt;/h4&gt;

&lt;p&gt;To delete only fully merged branches:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git branch &lt;span class="nt"&gt;-vv&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s1"&gt;': gone]'&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $1}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will fail if there are unmerged changes, protecting you from accidentally losing work.&lt;/p&gt;

&lt;h4&gt;
  
  
  Force Deletion
&lt;/h4&gt;

&lt;p&gt;To delete branches regardless of their merge status:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git branch &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;git branch &lt;span class="nt"&gt;-vv&lt;/span&gt; | &lt;span class="nb"&gt;grep&lt;/span&gt; &lt;span class="s1"&gt;': gone]'&lt;/span&gt; | &lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="s1"&gt;'{print $1}'&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ &lt;strong&gt;Warning&lt;/strong&gt;: Use force deletion with caution, as it will delete the branches even if they contain unmerged changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Regular Maintenance&lt;/strong&gt;: Run these commands periodically to keep your repository clean.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check Before Deleting&lt;/strong&gt;: Before force-deleting branches, ensure you won't need the changes later.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backup Important Work&lt;/strong&gt;: If unsure, create a backup branch or tag before cleaning up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Communicate with Team&lt;/strong&gt;: Ensure branches are truly obsolete before removing them locally.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Automating the Process
&lt;/h2&gt;

&lt;p&gt;You can create a Git alias for this cleanup process. Add this to your &lt;code&gt;~/.gitconfig&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;alias&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
    cleanup &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"!git fetch --prune &amp;amp;&amp;amp; git branch -vv | grep ': gone]' | awk '{print &lt;/span&gt;&lt;span class="nv"&gt;$1&lt;/span&gt;&lt;span class="s2"&gt;}' | xargs git branch -d"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then simply run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git cleanup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Keeping your Git repository clean and organized is essential for efficient development. By following these steps, you can easily maintain a clutter-free workspace and focus on what matters most - writing great code.&lt;/p&gt;

&lt;p&gt;Remember: While it's important to clean up unused branches, always verify that you're not deleting important work. When in doubt, use the safe deletion method (&lt;code&gt;-d&lt;/code&gt;) rather than force deletion (&lt;code&gt;-D&lt;/code&gt;).&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Happy coding! 🚀&lt;/em&gt;&lt;/p&gt;

</description>
      <category>git</category>
      <category>github</category>
      <category>gitlab</category>
      <category>coding</category>
    </item>
    <item>
      <title>Amazon Lightsail vs AWS EC2: Which one is better?</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Sat, 24 Feb 2024 21:33:35 +0000</pubDate>
      <link>https://dev.to/prematid/amazon-lightsail-vs-aws-ec2-which-one-is-better-3obg</link>
      <guid>https://dev.to/prematid/amazon-lightsail-vs-aws-ec2-which-one-is-better-3obg</guid>
      <description>&lt;p&gt;So you're diving into the exciting world of cloud computing, and naturally, the question arises: Which server should I choose? Amazon Web Services (AWS) throws two heavyweights into the ring: Amazon Lightsail and AWS EC2. Both offer virtual servers, but they cater to different needs and user profiles. Let's unpack their strengths and weaknesses to help you pick the champion for your cloud journey.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;strong&gt;Lightsail:&lt;/strong&gt; The Easy Breezy Contender
&lt;/h4&gt;

&lt;p&gt;Imagine a server that sets up in minutes, with no complex configurations to wrestle with. That's Lightsail in a nutshell. It's like a pre-built PC, offering bundles that combine virtual machines (VMs), storage, and networking into neat packages. Perfect for beginners or those who value simplicity, Lightsail takes care of the behind-the-scenes stuff, letting you focus on what matters: building your application.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;EC2:&lt;/strong&gt; The Granular Gladiator
&lt;/h2&gt;

&lt;p&gt;EC2 is the seasoned warrior, offering unmatched control and flexibility. It provides a vast arsenal of individual components, from various VM types to intricate networking configurations. This granular approach empowers experienced users to craft their infrastructure with surgical precision. However, like any powerful tool, EC2 comes with a steeper learning curve.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Deciding Factors:&lt;/strong&gt; When to Choose Which
&lt;/h2&gt;

&lt;p&gt;Choosing the right server boils down to a few key considerations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Technical Expertise:&lt;/strong&gt; New to the cloud game? Lightsail is your friendly neighborhood guide. Its intuitive interface and pre-configured options make launching your server a breeze. EC2, on the other hand, demands more technical prowess.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Application Complexity: For simple websites or small projects, Lightsail's bundled resources are your trusty companions. But if you're building a complex application with specific requirements, EC2's granular control becomes your secret weapon.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Need to adapt to growing demands? Lightsail offers limited scaling options, mainly through upgrading bundles. EC2 grants you the freedom to scale individual resources like CPU, memory, and storage independently.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cost: Lightsail's pricing is transparent and predictable, with monthly charges based on your chosen bundle. EC2's pricing is more nuanced, varying based on the specific resources you use and billed hourly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The Verdict:&lt;/strong&gt; Choosing Your Champion&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Lightsail emerges victorious for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users seeking a simple and user-friendly experience&lt;/li&gt;
&lt;li&gt;Quick deployments with pre-configured bundles&lt;/li&gt;
&lt;li&gt;Predictable pricing for small-scale projects&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;EC2 reigns supreme for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Experienced users comfortable with granular control&lt;/li&gt;
&lt;li&gt;Complex applications with specific resource requirements&lt;/li&gt;
&lt;li&gt;Scalability to meet fluctuating demands&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ultimately, the best server is the one that aligns with your specific needs and technical expertise. If you're unsure, starting with Lightsail's user-friendly approach and graduating to EC2 as your skills and requirements grow can be a winning strategy. Remember, the cloud is your playground, so experiment, explore, and find the server that empowers you to build your dreams!&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cloud</category>
      <category>cloudcomputing</category>
      <category>cloudserver</category>
    </item>
    <item>
      <title>Planting Flowers with No Adjacent Restrictions</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Sun, 08 Oct 2023 09:05:27 +0000</pubDate>
      <link>https://dev.to/prematid/planting-flowers-with-no-adjacent-restrictions-492o</link>
      <guid>https://dev.to/prematid/planting-flowers-with-no-adjacent-restrictions-492o</guid>
      <description>&lt;p&gt;Gardening can be a delightful pastime, but it comes with its own set of rules and constraints. In the world of programming, we sometimes encounter similar challenges, such as the "Planting Flowers with No Adjacent Restrictions" problem. In this blog post, we'll explore this problem and discover an efficient solution using the greedy algorithm approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Imagine you have a long flowerbed with some plots where flowers are already planted (denoted by 1) and some empty plots (denoted by 0). However, there's a catch: flowers cannot be planted in adjacent plots. You're given a binary array &lt;code&gt;flowerbed&lt;/code&gt; representing the flowerbed's current status, where 0 indicates an empty plot and 1 indicates a planted flower. You also have an integer &lt;code&gt;n&lt;/code&gt;, representing the number of new flowers you want to plant.&lt;/p&gt;

&lt;p&gt;The task is to determine if it's possible to plant &lt;code&gt;n&lt;/code&gt; new flowers in the flowerbed without violating the no-adjacent-flowers rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Approach
&lt;/h2&gt;

&lt;p&gt;To solve this problem efficiently, we'll use a greedy algorithm approach. The idea is to iterate through the flowerbed and check each empty plot. If a plot is empty and the adjacent plots (if they exist) are also empty, we can plant a flower in that plot. We'll keep track of the number of flowers planted and return &lt;code&gt;true&lt;/code&gt; if we successfully plant &lt;code&gt;n&lt;/code&gt; flowers.&lt;/p&gt;

&lt;p&gt;Here's a step-by-step approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Initialize a variable &lt;code&gt;count&lt;/code&gt; to 0 to keep track of the number of flowers planted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Iterate through the &lt;code&gt;flowerbed&lt;/code&gt; array from left to right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For each empty plot (0), check if the previous and next plots (if they exist) are also empty. If so, plant a flower (set the plot to 1) and increment the &lt;code&gt;count&lt;/code&gt; by 1.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Continue this process until we reach the end of the flowerbed or plant &lt;code&gt;n&lt;/code&gt; flowers.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the loop, check if the &lt;code&gt;count&lt;/code&gt; is equal to &lt;code&gt;n&lt;/code&gt;. If it is, return &lt;code&gt;true&lt;/code&gt;, indicating that we successfully planted &lt;code&gt;n&lt;/code&gt; flowers without violating the adjacent flower rule. Otherwise, return &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;Here's the Go code implementing the described approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;canPlaceFlowers&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flowerbed&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
    &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flowerbed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;flowerbed&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c"&gt;// Check if previous and next plots are empty (or out of bounds)&lt;/span&gt;
            &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;flowerbed&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
            &lt;span class="n"&gt;next&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;flowerbed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;flowerbed&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;prev&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;flowerbed&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;
                &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example Usage
&lt;/h2&gt;

&lt;p&gt;Let's see how to use the &lt;code&gt;canPlaceFlowers&lt;/code&gt; function with some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canPlaceFlowers&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c"&gt;// Output: true&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;canPlaceFlowers&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c"&gt;// Output: false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The "Planting Flowers with No Adjacent Restrictions" problem challenges us to find an efficient way to plant flowers in a flowerbed while adhering to the rule that no two flowers can be adjacent. By applying the greedy algorithm approach, we can iteratively check each plot and decide whether to plant a flower, ultimately determining if it's possible to plant the desired number of flowers.&lt;/p&gt;

&lt;p&gt;This problem-solving technique can be applied to various real-world scenarios where we need to make decisions based on local conditions and constraints.&lt;/p&gt;

</description>
      <category>go</category>
      <category>leetcode</category>
      <category>greedy</category>
      <category>programming</category>
    </item>
    <item>
      <title>Reversing Vowels in a String Using Two Pointers in Golang</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Sun, 08 Oct 2023 09:02:24 +0000</pubDate>
      <link>https://dev.to/prematid/reversing-vowels-in-a-string-using-two-pointers-in-golang-3cib</link>
      <guid>https://dev.to/prematid/reversing-vowels-in-a-string-using-two-pointers-in-golang-3cib</guid>
      <description>&lt;p&gt;When working with strings in Go (Golang), you may come across scenarios where you need to manipulate the characters within the string. One common task is reversing the positions of vowels while keeping consonants and other characters in their original places. In this blog post, we will explore how to achieve this using a simple and efficient approach with the help of two pointers.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Given an input string, we want to reverse the positions of vowels (i.e., 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U') while preserving the positions of consonants and other characters. For example, if the input string is "hello," the output should be "holle."&lt;/p&gt;

&lt;h2&gt;
  
  
  The Approach
&lt;/h2&gt;

&lt;p&gt;To solve this problem, we will use two pointers, one starting from the beginning of the string (left) and the other starting from the end of the string (right). We will iterate through the string and swap vowels found at these two pointers. The process continues until the left pointer is less than the right pointer.&lt;/p&gt;

&lt;p&gt;Here's the step-by-step approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Initialize a string variable &lt;code&gt;vowels&lt;/code&gt; containing all lowercase and uppercase vowel characters: "aeiouAEIOU."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Convert the input string into a mutable rune slice called &lt;code&gt;strRunes&lt;/code&gt;. In Go, strings are immutable, so we need to work with runes to make modifications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Initialize two pointers, &lt;code&gt;left&lt;/code&gt; and &lt;code&gt;right&lt;/code&gt;, to 0 and &lt;code&gt;len(s)-1&lt;/code&gt;, respectively, where &lt;code&gt;s&lt;/code&gt; is the input string.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use a while loop to iterate through the string while the &lt;code&gt;left&lt;/code&gt; pointer is less than the &lt;code&gt;right&lt;/code&gt; pointer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Within the loop:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Increment the &lt;code&gt;left&lt;/code&gt; pointer until a vowel character is found or until &lt;code&gt;left&lt;/code&gt; is no longer less than &lt;code&gt;right&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Decrement the &lt;code&gt;right&lt;/code&gt; pointer until a vowel character is found or until &lt;code&gt;left&lt;/code&gt; is no longer less than &lt;code&gt;right&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the &lt;code&gt;left&lt;/code&gt; pointer is still less than the &lt;code&gt;right&lt;/code&gt; pointer, swap the characters at these positions. Then, increment the &lt;code&gt;left&lt;/code&gt; pointer and decrement the &lt;code&gt;right&lt;/code&gt; pointer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;After the loop, return the string representation of the modified &lt;code&gt;strRunes&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;Here's the Go code implementing the described approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;reverseVowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;vowels&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="s"&gt;"aeiouAEIOU"&lt;/span&gt;
    &lt;span class="n"&gt;strRunes&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;rune&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContainsRune&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vowels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strRunes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;strings&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ContainsRune&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vowels&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;strRunes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;strRunes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;strRunes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;strRunes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;strRunes&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
            &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="o"&gt;--&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strRunes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example Usage
&lt;/h2&gt;

&lt;p&gt;Let's see how to use the &lt;code&gt;reverseVowels&lt;/code&gt; function with some examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reverseVowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c"&gt;// Output: "holle"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reverseVowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"leetcode"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c"&gt;// Output: "leotcede"&lt;/span&gt;
&lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reverseVowels&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"GoLang"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="c"&gt;// Output: "GoLeNg"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Reversing vowels in a string is a common string manipulation task that can be efficiently solved using two pointers in Go. By following the approach described in this blog post, you can easily reverse the positions of vowels while maintaining the order of consonants and other characters in the string. This technique can be handy in various text processing scenarios where you need to modify or analyze text data.&lt;/p&gt;

</description>
      <category>go</category>
      <category>tutorial</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>How to install make on windows</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Sat, 26 Aug 2023 11:32:15 +0000</pubDate>
      <link>https://dev.to/prematid/how-to-install-make-on-windows-5dek</link>
      <guid>https://dev.to/prematid/how-to-install-make-on-windows-5dek</guid>
      <description>&lt;p&gt;Installing &lt;code&gt;make&lt;/code&gt; on Windows involves using tools like MinGW or Cygwin to provide a Unix-like environment that includes the &lt;code&gt;make&lt;/code&gt; utility. Here's a step-by-step guide using MinGW:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install Chocolatey (Optional but Recommended):&lt;/strong&gt;
Chocolatey is a package manager for Windows that makes it easy to install software from the command line.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Open a Command Prompt with administrator privileges and run the following command to install Chocolatey:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   Set-ExecutionPolicy Bypass &lt;span class="nt"&gt;-Scope&lt;/span&gt; Process &lt;span class="nt"&gt;-Force&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;System.Net.ServicePointManager]::SecurityProtocol &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;System.Net.ServicePointManager]::SecurityProtocol &lt;span class="nt"&gt;-bor&lt;/span&gt; 3072&lt;span class="p"&gt;;&lt;/span&gt; iex &lt;span class="o"&gt;(&lt;/span&gt;iwr https://chocolatey.org/install.ps1&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Install MinGW:&lt;/strong&gt;
MinGW (Minimalist GNU for Windows) is a development environment that provides a Unix-like command-line environment on Windows.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Run the following command in the Command Prompt to install MinGW using Chocolatey:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   choco &lt;span class="nb"&gt;install &lt;/span&gt;mingw &lt;span class="nt"&gt;-y&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Add MinGW Bin Directory to PATH:&lt;/strong&gt;
After installing MinGW, you need to add its &lt;code&gt;bin&lt;/code&gt; directory to your system's PATH environment variable.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Right-click on "This PC" or "My Computer" and select "Properties."&lt;/li&gt;
&lt;li&gt;Click on "Advanced system settings."&lt;/li&gt;
&lt;li&gt;In the "System Properties" window, click on the "Environment Variables" button.&lt;/li&gt;
&lt;li&gt;Under the "System variables" section, find and select the "Path" variable, then click the "Edit" button.&lt;/li&gt;
&lt;li&gt;Click the "New" button and add the path to the MinGW &lt;code&gt;bin&lt;/code&gt; directory (usually &lt;code&gt;C:\MinGW\bin&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Click "OK" to close all the windows.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Verify Installation:&lt;/strong&gt;
To verify that &lt;code&gt;make&lt;/code&gt; has been successfully installed, open a new Command Prompt and run the following command:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   make &lt;span class="nt"&gt;--version&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the version information of the &lt;code&gt;make&lt;/code&gt; utility if the installation was successful.&lt;/p&gt;

&lt;p&gt;That's it! You've now successfully installed &lt;code&gt;make&lt;/code&gt; on your Windows system using MinGW. You can now use the &lt;code&gt;make&lt;/code&gt; command to build projects that use Makefiles for compilation and other tasks.&lt;/p&gt;

</description>
      <category>make</category>
      <category>makefile</category>
      <category>tutorial</category>
      <category>windows</category>
    </item>
    <item>
      <title>How to install mockery in windows?</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Wed, 07 Dec 2022 16:22:14 +0000</pubDate>
      <link>https://dev.to/prematid/how-to-install-mockery-in-windows-2hfh</link>
      <guid>https://dev.to/prematid/how-to-install-mockery-in-windows-2hfh</guid>
      <description>&lt;p&gt;Struggling with installing mockery in windows?&lt;br&gt;
Say no more. Just a single command and there you go.&lt;/p&gt;

&lt;p&gt;Step 1: open cmd. (Or Terminal, your choice)&lt;br&gt;
Step 2: Run the following command. &lt;br&gt;
&lt;strong&gt;&lt;code&gt;go install github.com/vektra/mockery/v2@latest&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And that's it. &lt;br&gt;
This single command would suffice.&lt;/p&gt;

&lt;p&gt;Thanks for stopping by btw.&lt;/p&gt;

&lt;p&gt;Cheers!!!&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Setting up golang-migrate for windows</title>
      <dc:creator>Prem</dc:creator>
      <pubDate>Mon, 13 Sep 2021 20:56:33 +0000</pubDate>
      <link>https://dev.to/prematid/setting-up-golang-migrate-for-windows-2nnb</link>
      <guid>https://dev.to/prematid/setting-up-golang-migrate-for-windows-2nnb</guid>
      <description>&lt;h3&gt;
  
  
  First Install scoop
&lt;/h3&gt;

&lt;h6&gt;
  
  
  But Wait! What is scoop
&lt;/h6&gt;

&lt;p&gt;Scoop is a command-line package manager for Windows which makes it easier to install and use common programs and tools.&lt;/p&gt;

&lt;p&gt;Make sure PowerShell 5 (or later, include PowerShell Core) and .NET Framework 4.5 (or later) are installed. Then run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;Invoke&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;Expression&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;New&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nb"&gt;Object&lt;/span&gt; &lt;span class="nx"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Net&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;WebClient&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;DownloadString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://get.scoop.sh&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;or&lt;/span&gt; 
&lt;span class="nx"&gt;iwr&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nx"&gt;useb&lt;/span&gt; &lt;span class="kd"&gt;get&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;scoop&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sh&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;iex&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In case you get an error, you might need to change the execution policy (i.e. enable Powershell) with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;Set&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;ExecutionPolicy&lt;/span&gt; &lt;span class="n"&gt;RemoteSigned&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="n"&gt;CurrentUser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that you have installed scoop on your windows system, we can move ahead with our main task i.e. golang-migrate &lt;/p&gt;

&lt;h5&gt;
  
  
  Download pre-built binary (Windows, MacOS, or Linux)
&lt;/h5&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -L https://github.com/golang-migrate/migrate/releases/download/$version/migrate.$platform-amd64.tar.gz | tar xvz
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we have downloaded scoop and the pre-built library for golang-migrate, we will go ahead and install it using this simple command&lt;/p&gt;

&lt;h4&gt;
  
  
  For Windows
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scoop install migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And There You GO!!!&lt;br&gt;
Your golang-migrate is setup for windows.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
