<?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: Shivam Jain</title>
    <description>The latest articles on DEV Community by Shivam Jain (@shivamjainn).</description>
    <link>https://dev.to/shivamjainn</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%2F1136739%2Fcfad4074-a1f8-4a47-a892-ec9dafafa53c.jpeg</url>
      <title>DEV Community: Shivam Jain</title>
      <link>https://dev.to/shivamjainn</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shivamjainn"/>
    <language>en</language>
    <item>
      <title>Creating and Deploying a Google Cloud Run Service Using Artifact Registry and GitHub Actions</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Sun, 01 Dec 2024 17:14:24 +0000</pubDate>
      <link>https://dev.to/shivamjainn/creating-and-deploying-a-google-cloud-run-service-using-artifact-registry-and-github-actions-4jmc</link>
      <guid>https://dev.to/shivamjainn/creating-and-deploying-a-google-cloud-run-service-using-artifact-registry-and-github-actions-4jmc</guid>
      <description>&lt;p&gt;In this guide, we’ll walk through the process of creating a Google Cloud Run (GCR) service, building and pushing a Docker image to Artifact Registry, and configuring the necessary resources using Terraform. The steps will also cover setting up a service account and IAM roles to ensure proper access control.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 1: Create a Service Account&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Navigate to IAM &amp;amp; Admin &amp;gt; Service Accounts&lt;/strong&gt; in the GCP console.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fill in the required details&lt;/strong&gt;, ensuring meaningful names are chosen for easier debugging and logging.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skip step 3&lt;/strong&gt; and click on &lt;strong&gt;Done&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funnpudfmzz3zxcn4cuyq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Funnpudfmzz3zxcn4cuyq.png" alt="Service account table" width="590" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Manage keys&lt;/strong&gt; by clicking on the three dots under Actions, and select &lt;strong&gt;Manage keys&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsn2u8rk2v1ddwza975r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvsn2u8rk2v1ddwza975r.png" alt="Image description" width="361" height="432"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You will be redirected to a page like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7giye3g21njtg4j8ozo5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7giye3g21njtg4j8ozo5.png" alt="Image description" width="800" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Click on &lt;strong&gt;Add Key &amp;gt; Create New Key &amp;gt; JSON&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;A &lt;strong&gt;JSON file&lt;/strong&gt; will be downloaded — &lt;strong&gt;keep it safe and do not share it&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 2: Set Up Project Structure&lt;/strong&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;|
| ~~~~~~
| ~~~~~~~
| Infra 
    &amp;gt; main.tf
    &amp;gt; providers.tf
    &amp;gt; variables.tf
    &amp;gt; registry.tf
    | environments
        &amp;gt; dev.tfvars
        &amp;gt; prod.tfvars
    | Credentials
        &amp;gt; gcp.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Step 3: Initializing the Provider&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;First, create two files: &lt;code&gt;providers.tf&lt;/code&gt; and &lt;code&gt;variables.tf&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;variables.tf&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"project"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
    &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"GCP project name"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"region"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;type&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"us-central"&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-central1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"us-east1"&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-east1"&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Region mapping"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"zone"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;type&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nx"&gt;default&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"us-central1-a"&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-central1-a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"us-central1-b"&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-central1-b"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"us-central1-c"&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-central1-c"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="s2"&gt;"us-east1-a"&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-east1-a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Zone mapping"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  &lt;code&gt;dev.tfvars&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;project&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"your-app-name"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  &lt;code&gt;providers.tf&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;provider&lt;/span&gt; &lt;span class="s2"&gt;"google"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;project&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;project&lt;/span&gt;
    &lt;span class="nx"&gt;region&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"us-central"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;zone&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;zone&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"us-central1-c"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="nx"&gt;credentials&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"./credentials/gcp.json"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Make sure to add a &lt;code&gt;.gitignore&lt;/code&gt; to avoid committing sensitive data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# .gitignore
credentials
environments
*.tfstate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Step 4: Create an Artifact Registry&lt;/strong&gt;
&lt;/h3&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;registry.tf&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"google_artifact_registry_repository"&lt;/span&gt; &lt;span class="s2"&gt;"executor-repo"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;location&lt;/span&gt;      &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;region&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"us-east1"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="nx"&gt;repository_id&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;var&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;artifact_repository_id&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt;   &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Executor Docker Repository"&lt;/span&gt;
  &lt;span class="nx"&gt;format&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"DOCKER"&lt;/span&gt;

  &lt;span class="nx"&gt;docker_config&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;immutable_tags&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&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;h3&gt;
  
  
  &lt;strong&gt;Step 5: Build and Upload Image via GitHub Actions&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;In your repo, create the &lt;code&gt;.github/workflows&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Inside, create a file called &lt;code&gt;push_image.yml&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;push_image.yml&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Deploy to GCP&lt;/span&gt;

&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;branches&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;master&lt;/span&gt;
    &lt;span class="na"&gt;paths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;images/*&lt;/span&gt;

&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build-and-push&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;

    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Checkout code&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;actions/checkout@v3&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Set up Docker&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker/setup-buildx-action@v2&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Authenticate with GCP&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;google-github-actions/auth@v2&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;credentials_json&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.GCP_CREDENTIALS }}&lt;/span&gt;
          &lt;span class="na"&gt;token_format&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;access_token'&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Set up Cloud SDK&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;google-github-actions/setup-gcloud@v1&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Configure Docker for Artifact Registry&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;gcloud auth configure-docker ${{secrets.gcp_region}}-docker.pkg.dev --quiet&lt;/span&gt;

      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Build and push Docker image&lt;/span&gt;
        &lt;span class="na"&gt;working-directory&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;./images&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;IMAGE_NAME&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.gcp_region }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.ARTIFACT_REPOSITORY_ID }}/executor-image:latest&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
          &lt;span class="s"&gt;# Verify repository exists&lt;/span&gt;
          &lt;span class="s"&gt;gcloud artifacts repositories describe ${{ secrets.ARTIFACT_REPOSITORY_ID }} \&lt;/span&gt;
            &lt;span class="s"&gt;--project=${{ secrets.GCP_PROJECT_ID }} \&lt;/span&gt;
            &lt;span class="s"&gt;--location=${{ secrets.gcp_region }} || \&lt;/span&gt;
          &lt;span class="s"&gt;gcloud artifacts repositories create ${{ secrets.ARTIFACT_REPOSITORY_ID }} \&lt;/span&gt;
            &lt;span class="s"&gt;--project=${{ secrets.GCP_PROJECT_ID }} \&lt;/span&gt;
            &lt;span class="s"&gt;--location=${{ secrets.gcp_region }} \&lt;/span&gt;
            &lt;span class="s"&gt;--repository-format=docker&lt;/span&gt;

          &lt;span class="s"&gt;docker build -t ${IMAGE_NAME} .&lt;/span&gt;
          &lt;span class="s"&gt;docker push ${IMAGE_NAME}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Step 6: Create Cloud Run Service&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now, let’s set up the Cloud Run service using the uploaded Docker image.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;gcr.tf&lt;/code&gt;
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"google_cloud_run_v2_service"&lt;/span&gt; &lt;span class="s2"&gt;"default"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"cloudrun-service"&lt;/span&gt;
  &lt;span class="nx"&gt;location&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"us-central1"&lt;/span&gt;
  &lt;span class="nx"&gt;deletion_protection&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
  &lt;span class="nx"&gt;ingress&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"INGRESS_TRAFFIC_ALL"&lt;/span&gt;

  &lt;span class="nx"&gt;template&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;containers&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;image&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"${var.location["&lt;/span&gt;&lt;span class="nx"&gt;us-east1&lt;/span&gt;&lt;span class="s2"&gt;"]}-docker.pkg.dev/${var.project}/${var.artifact_repository_id}/${var.exec_image_name}:${var.image_tag["&lt;/span&gt;&lt;span class="nx"&gt;latest&lt;/span&gt;&lt;span class="s2"&gt;"]}"&lt;/span&gt;
      &lt;span class="nx"&gt;resources&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;limits&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nx"&gt;cpu&lt;/span&gt;    &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
          &lt;span class="nx"&gt;memory&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"512Mi"&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&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;p&gt;Here, we reference the Docker image URI created in the GitHub Actions workflow.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 7: Configure Variables&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Add the following variables to &lt;code&gt;variables.tf&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"artifact_repository_id"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Artifact repository ID"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"exec_image_name"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Docker image name"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"image_tag"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Tag for executor image"&lt;/span&gt;
  &lt;span class="nx"&gt;default&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"latest"&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"latest"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;variable&lt;/span&gt; &lt;span class="s2"&gt;"cloud_run_service_name"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;type&lt;/span&gt;        &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Cloud Run service name"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Step 8: Add Environment-Specific Configurations&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;In &lt;code&gt;dev.tfvars&lt;/code&gt;, set the values for the variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;artifact_repository_id&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"arti-repo"&lt;/span&gt;
&lt;span class="nx"&gt;exec_image_name&lt;/span&gt; &lt;span class="err"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"cool-image-name"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  &lt;strong&gt;Step 9: IAM Policy for Cloud Run Service&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To protect the Cloud Run service from unauthorized access, configure IAM roles for invocation.&lt;/p&gt;

&lt;h4&gt;
  
  
  &lt;code&gt;gcr.tf&lt;/code&gt; (IAM Configuration)
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight hcl"&gt;&lt;code&gt;&lt;span class="nx"&gt;resource&lt;/span&gt; &lt;span class="s2"&gt;"google_cloud_run_v2_service_iam_binding"&lt;/span&gt; &lt;span class="s2"&gt;"binding"&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;project&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;google_cloud_run_v2_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;executor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;project&lt;/span&gt;
  &lt;span class="nx"&gt;location&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;google_cloud_run_v2_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;executor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt;
  &lt;span class="nx"&gt;name&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;google_cloud_run_v2_service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;executor&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;
  &lt;span class="nx"&gt;role&lt;/span&gt;     &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"roles/run.invoker"&lt;/span&gt;
  &lt;span class="nx"&gt;members&lt;/span&gt;  &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s2"&gt;"serviceAccount:${var.account-email-invoker}"&lt;/span&gt;&lt;span class="p"&gt;,&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;p&gt;This IAM binding ensures that only the designated service account can invoke the Cloud Run service.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Step 10: Conclusion and Extra Steps&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Now that everything is set up, you can deploy your service with the image from Artifact Registry. You should also consider setting up Virtual Private Cloud (VPC) networks to mitigate potential DDoS risks and reduce costs.&lt;/p&gt;




&lt;h3&gt;
  
  
  &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;This guide walks you through setting up a complete pipeline for deploying Dockerized applications to Google Cloud Run with Terraform and GitHub Actions. Keep your credentials and sensitive data secure, and use IAM policies to limit access as needed. If you have any questions or need further help, feel free to reach out to me on &lt;a href="https://www.linkedin.com/in/shivamjainn/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>googlecloud</category>
      <category>githubactions</category>
      <category>docker</category>
    </item>
    <item>
      <title>How to find missing values in dataset using pandas</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Thu, 21 Sep 2023 02:00:06 +0000</pubDate>
      <link>https://dev.to/shivamjainn/how-to-find-missing-values-in-dataset-using-pandas-595o</link>
      <guid>https://dev.to/shivamjainn/how-to-find-missing-values-in-dataset-using-pandas-595o</guid>
      <description>&lt;h3&gt;
  
  
  1st method
&lt;/h3&gt;

&lt;p&gt;If you have a dataset that is uniform , you can use .info() to figure out , which column has missing values.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
housingdata.info()&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;br&gt;
RangeIndex: 20640 entries, 0 to 20639&lt;br&gt;
Data columns (total 10 columns):&lt;br&gt;
 #   Column              Non-Null Count  Dtype  &lt;/p&gt;




&lt;p&gt;0   longitude           20640 non-null  float64&lt;br&gt;
 1   latitude            20640 non-null  float64&lt;br&gt;
 2   housing_median_age  20640 non-null  float64&lt;br&gt;
 3   total_rooms         20640 non-null  float64&lt;br&gt;
 4   total_bedrooms      20433 non-null  float64&lt;br&gt;
 5   population          20640 non-null  float64&lt;br&gt;
 6   households          20640 non-null  float64&lt;br&gt;
 7   median_income       20640 non-null  float64&lt;br&gt;
 8   median_house_value  20640 non-null  float64&lt;br&gt;
 9   ocean_proximity     20640 non-null  object &lt;br&gt;
dtypes: float64(9), object(1)&lt;br&gt;
memory usage: 1.6+ MB&lt;/p&gt;

&lt;p&gt;Look at 4 total_bedrooms , it has less non-null values , hence it has missing data&lt;/p&gt;

&lt;h3&gt;
  
  
  Second method
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
housingdata.isnull().sum()&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;longitude               0&lt;br&gt;
latitude                0&lt;br&gt;
housing_median_age      0&lt;br&gt;
total_rooms             0&lt;br&gt;
total_bedrooms        207&lt;br&gt;
population              0&lt;br&gt;
households              0&lt;br&gt;
median_income           0&lt;br&gt;
median_house_value      0&lt;br&gt;
ocean_proximity         0&lt;br&gt;
dtype: int64&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to find number of columns of dataset using pandas</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Thu, 21 Sep 2023 01:51:55 +0000</pubDate>
      <link>https://dev.to/shivamjainn/how-to-find-number-of-columns-of-dataset-using-pandas-123g</link>
      <guid>https://dev.to/shivamjainn/how-to-find-number-of-columns-of-dataset-using-pandas-123g</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;housingdata = pd.read_csv('oneDataset/housing.csv')
len(housingdata.columns)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Running MongoDB Locally with Podman: Quick Guide</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Thu, 17 Aug 2023 18:05:56 +0000</pubDate>
      <link>https://dev.to/shivamjainn/running-mongodb-locally-with-podman-quick-guide-ogm</link>
      <guid>https://dev.to/shivamjainn/running-mongodb-locally-with-podman-quick-guide-ogm</guid>
      <description>&lt;p&gt;Welcome to our guide on setting up a local MongoDB server using Podman. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Install Podman (if needed)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Check Podman installation:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If not installed, get Podman from &lt;a href="https://podman.io/getting-started/installation"&gt;official instructions&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Pull MongoDB Image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fetch MongoDB Community Server image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman pull docker.io/mongodb/mongodb-community-server:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Verify Image&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Confirm MongoDB image:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman images
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Run MongoDB Container&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choose:&lt;/p&gt;

&lt;p&gt;Option 1: No Volume (Data won't persist)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman run &lt;span class="nt"&gt;--detach&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; todoDB &lt;span class="nt"&gt;-p&lt;/span&gt; HOST_PORT:27017 docker.io/mongodb/mongodb-community-server:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;HOST_PORT&lt;/code&gt; with your preferred port number (e.g., 3000).&lt;/p&gt;

&lt;p&gt;Option 2: With Volume (Data persists)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;podman run &lt;span class="nt"&gt;--detach&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; todoDB &lt;span class="nt"&gt;-p&lt;/span&gt; HOST_PORT:27017 &lt;span class="nt"&gt;-v&lt;/span&gt; /path/to/host/data:/data/db docker.io/mongodb/mongodb-community-server:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace &lt;code&gt;HOST_PORT&lt;/code&gt; with your preferred port number (e.g., 3000).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Understanding Port Mapping:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;-p HOST_PORT:27017&lt;/code&gt; to map a port on your machine to port 27017 in the container.&lt;/li&gt;
&lt;li&gt;For example, &lt;code&gt;-p 3000:27017&lt;/code&gt; maps port 3000 on your machine to port 27017 in the container.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your MongoDB server is accessible at &lt;code&gt;mongodb://localhost:HOST_PORT&lt;/code&gt; from your Node.js application using Mongoose or any MongoDB client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Volume vs. Non-Volume in MongoDB with Podman&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choose wisely:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Non-Volume Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data stored in container.&lt;/li&gt;
&lt;li&gt;Lost if container removed.&lt;/li&gt;
&lt;li&gt;For quick tasks, testing, or learning.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Volume Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data stored outside container.&lt;/li&gt;
&lt;li&gt;Persists even if container removed.&lt;/li&gt;
&lt;li&gt;Recommended for development, production-like scenarios, or staging.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;ul&gt;
&lt;li&gt;Use Non-Volume: Quick tasks or learning.&lt;/li&gt;
&lt;li&gt;Use Volume: Persistent data needs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your choice depends on your use case. Your data, your decision.&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>docker</category>
    </item>
    <item>
      <title>How to setup tailwind CSS with vite</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Thu, 17 Aug 2023 15:21:56 +0000</pubDate>
      <link>https://dev.to/shivamjainn/how-to-setup-tailwind-css-with-vite-4beb</link>
      <guid>https://dev.to/shivamjainn/how-to-setup-tailwind-css-with-vite-4beb</guid>
      <description>&lt;p&gt;&lt;strong&gt;Prerequisites:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node.js and npm installed on your machine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Set Up Your Project&lt;/strong&gt;&lt;br&gt;
Open your terminal and execute the following commands:&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="c"&gt;# Create a new Vite project with React template&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;npm create vite@latest my-project &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="nt"&gt;--template&lt;/span&gt; react
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;my-project
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2: Install Tailwind CSS and PostCSS&lt;/strong&gt;&lt;br&gt;
Next, install Tailwind CSS, PostCSS, and Autoprefixer as development dependencies:&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="nv"&gt;$ &lt;/span&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; tailwindcss postcss autoprefixer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3: Initialize Tailwind CSS&lt;/strong&gt;&lt;br&gt;
Generate the Tailwind CSS configuration file and initialize it:&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="nv"&gt;$ &lt;/span&gt;npx tailwindcss init &lt;span class="nt"&gt;-p&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 4: Configure Tailwind&lt;/strong&gt;&lt;br&gt;
Open the &lt;code&gt;tailwind.config.js&lt;/code&gt; file and modify it as follows:&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;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./index.html&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./src/**/*.{js,ts,jsx,tsx}&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;extend&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{},&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;plugins&lt;/span&gt;&lt;span class="p"&gt;:&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;p&gt;&lt;strong&gt;Step 5: Create Your Styles&lt;/strong&gt;&lt;br&gt;
In the &lt;code&gt;src&lt;/code&gt; directory, create a new file named &lt;code&gt;index.css&lt;/code&gt;. Add the following content to it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;components&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;@tailwind&lt;/span&gt; &lt;span class="n"&gt;utilities&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6: Style Your React Component&lt;/strong&gt;&lt;br&gt;
In the &lt;code&gt;src&lt;/code&gt; directory, open the &lt;code&gt;App.jsx&lt;/code&gt; file and update its contents as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;App&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="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"text-3xl font-bold underline"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      Hello world!
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&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;p&gt;&lt;strong&gt;Step 7: Run Your Development Server&lt;/strong&gt;&lt;br&gt;
Start the development server to see your app in action:&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="nv"&gt;$ &lt;/span&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open your browser and navigate to &lt;code&gt;http://localhost:3000&lt;/code&gt;. You should see the "Hello world!" text styled according to the Tailwind CSS classes you applied.&lt;/p&gt;

&lt;h3&gt;
  
  
  PostCSS
&lt;/h3&gt;

&lt;p&gt;PostCSS is used in your project to enhance and optimize your CSS. It enables you to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Apply modern CSS features and proposals.&lt;/li&gt;
&lt;li&gt;Automatically add vendor prefixes using Autoprefixer.&lt;/li&gt;
&lt;li&gt;Optimize and minimize your CSS for better performance.&lt;/li&gt;
&lt;li&gt;Use a modular, plugin-based approach for customized transformations.&lt;/li&gt;
&lt;li&gt;Ensure cross-browser compatibility for your styles.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>tailwindcss</category>
      <category>vite</category>
      <category>react</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Recursion : pow(x,n)</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Mon, 14 Aug 2023 17:33:27 +0000</pubDate>
      <link>https://dev.to/shivamjainn/recursion-powxn-1hg9</link>
      <guid>https://dev.to/shivamjainn/recursion-powxn-1hg9</guid>
      <description>&lt;ul&gt;
&lt;li&gt;x^n = x*x*x*x.....(n times)
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Solution:
    def powiFunc(self,x:float, n:int):
        if(n==0):
            return 1

        ans = self.powiFunc(x,n-1)

        return x*ans


    def myPow(self, x: float, n: int) -&amp;gt; float:

       return self.powiFunc(x,n)


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

&lt;/div&gt;



&lt;p&gt;Recursion tree for 3^3 &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            powiFunc(3, 3)
               /     \
      powiFunc(3, 2)  * 3
         /     \
powiFunc(3, 1)  * 3
   /     \
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;powiFunc(3, 0)  * 3&lt;/p&gt;

&lt;p&gt;Now, let's evaluate the tree step by step:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;powiFunc(3, 0) returns 1 (base case).&lt;/li&gt;
&lt;li&gt;powiFunc(3, 1) returns 3 * 1 (3).&lt;/li&gt;
&lt;li&gt;powiFunc(3, 2) returns 3 * (3 * 1) (9).&lt;/li&gt;
&lt;li&gt;powiFunc(3, 3) returns 3 * (3 * (3 * 1)) (27).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So, 3^3 is indeed equal to 27&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Learning Linux on the Go : CLI</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Sun, 13 Aug 2023 13:16:28 +0000</pubDate>
      <link>https://dev.to/shivamjainn/learning-linux-on-the-go-cli-10ci</link>
      <guid>https://dev.to/shivamjainn/learning-linux-on-the-go-cli-10ci</guid>
      <description>&lt;p&gt;As a beginner stepping into the world of Linux, the command-line interface (CLI) might seem like a daunting and mysterious realm. However, let me assure you that the CLI is not only a powerful tool but also remarkably fast and productive once you become acquainted with its capabilities. In this blog post, we'll take a dive into the basics of the Linux CLI, shedding light on fundamental commands that will set you on a path to navigating, manipulating files, and performing tasks with confidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Unveiling the Command Line
&lt;/h2&gt;

&lt;p&gt;Linux command syntax: &lt;code&gt;command options arguments&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Gliding Through Folders
&lt;/h3&gt;

&lt;p&gt;The heart of file management lies in moving through directories and manipulating them.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;cd&lt;/code&gt; (Change Directory):&lt;/strong&gt; Navigate between directories effortlessly.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;cd Documents&lt;/code&gt; - Moves to the "Documents" directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;rmdir&lt;/code&gt; (Remove Directory):&lt;/strong&gt; Delete an empty directory.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;rmdir EmptyFolder&lt;/code&gt; - Deletes the empty folder named "EmptyFolder."&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Mastering File Operations
&lt;/h3&gt;

&lt;p&gt;Working with files is a breeze once you know the basics.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;touch&lt;/code&gt;:&lt;/strong&gt; Create empty files.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;touch file.txt&lt;/code&gt; - Creates an empty file named "file.txt."&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;rm&lt;/code&gt;:&lt;/strong&gt; Remove files or directories (use with caution!).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;rm file.txt&lt;/code&gt; - Deletes the file named "file.txt."&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;rm -r Folder&lt;/code&gt; - Recursively deletes the "Folder" directory and its contents.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;mv&lt;/code&gt;:&lt;/strong&gt; Move or rename files and directories.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;mv old.txt new.txt&lt;/code&gt; - Renames "old.txt" to "new.txt."&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;mv file.txt /new/location/&lt;/code&gt; - Moves "file.txt" to a different location.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;cp&lt;/code&gt;:&lt;/strong&gt; Copy files and directories.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;cp file.txt copy.txt&lt;/code&gt; - Copies "file.txt" to a new file named "copy.txt."&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;cp -r Folder /backup/&lt;/code&gt; - Copies the "Folder" directory and its contents to the "/backup/" directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Exploring General Commands
&lt;/h3&gt;

&lt;p&gt;Discover essential commands that provide useful system information.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;pwd&lt;/code&gt; (Print Working Directory):&lt;/strong&gt; Display the current directory's path.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;pwd&lt;/code&gt; - Prints the path of the current directory.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;date&lt;/code&gt;:&lt;/strong&gt; Show the current date and time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;date&lt;/code&gt; - Displays the current date and time.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;cal&lt;/code&gt;:&lt;/strong&gt; Display a calendar for the current month.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;cal&lt;/code&gt; - Shows a calendar for the current month.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;ls&lt;/code&gt;:&lt;/strong&gt; List files and directories in the current location.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example: &lt;code&gt;ls&lt;/code&gt; - Lists files and directories in the current directory.&lt;/li&gt;
&lt;li&gt;Example: &lt;code&gt;ls -l&lt;/code&gt; - Lists files in long format, showing detailed information.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  A challenge :)
&lt;/h3&gt;

&lt;p&gt;Try deleting a folder with some files (make a dummy folder , don't blame me for deleting something important :P )&lt;/p&gt;

&lt;p&gt;try using rmdir . What does it do? &lt;/p&gt;

&lt;p&gt;Well , that's the thing about linux , you need to be the google/gpt genius . &lt;/p&gt;

&lt;p&gt;heed this sage advice: in the Linux realm, be the inquisitive genius, not the reckless fool. Each command wields power; wield it wisely and embrace the journey of discovery. The Linux realm beckons, dear comrade. Welcome!&lt;/p&gt;

</description>
      <category>linux</category>
    </item>
    <item>
      <title>Majority Element I and II : Boyer-Moore Majority Vote algorithm</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Thu, 10 Aug 2023 16:15:39 +0000</pubDate>
      <link>https://dev.to/shivamjainn/majority-element-i-and-ii-boyer-moore-majority-vote-algorithm-1o68</link>
      <guid>https://dev.to/shivamjainn/majority-element-i-and-ii-boyer-moore-majority-vote-algorithm-1o68</guid>
      <description>&lt;p&gt;These are the questions touched :&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;https://leetcode.com/problems/majority-element/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;https://leetcode.com/problems/majority-element-ii/description/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;History and Intent&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Introduced by Robert S. Boyer and J Strother Moore in their paper titled "MJRTY - A Fast Majority Vote Algorithm."&lt;/li&gt;
&lt;li&gt;Solves the problem of finding a majority element in an array (&amp;gt; n/2 times).&lt;/li&gt;
&lt;li&gt;Shows the innovation and ingenuity in tackling computational problems.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Background and Motivation&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Boyer and Moore were known for their work in computer science and formal methods.&lt;/li&gt;
&lt;li&gt;Developed the Boyer-Moore theorem prover, bridging computer science and mathematics.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Majority Element Problem&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Problem: Find an element that appears &amp;gt; n/2 times in an array.&lt;/li&gt;
&lt;li&gt;Applications in voting systems, data analysis, and distributed algorithms.&lt;/li&gt;
&lt;li&gt;Existing algorithms had higher complexities than desired.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Algorithm Innovation&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Developed the Boyer-Moore Majority Vote algorithm to efficiently solve the problem.&lt;/li&gt;
&lt;li&gt;Based on observation and mathematical reasoning.&lt;/li&gt;
&lt;li&gt;Eliminates pairs of different elements, preserving the majority element.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Publication and Impact&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Published in 1981 paper "MJRTY - A Fast Majority Vote Algorithm."&lt;/li&gt;
&lt;li&gt;Presented principles, correctness proofs, and applications.&lt;/li&gt;
&lt;li&gt;Efficient linear time complexity (O(n)) and constant space complexity (O(1)).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Legacy and Continued Use&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Recognized for its elegance and efficiency.&lt;/li&gt;
&lt;li&gt;Extended to various domains beyond computer science.&lt;/li&gt;
&lt;li&gt;Variations used to solve related problems (&amp;gt; n/3 times).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Boyer-Moore Majority Vote Algorithm Overview&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose&lt;/strong&gt;: Efficiently identifies the majority element in an array (&amp;gt; n/2 times).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Origin&lt;/strong&gt;: Introduced in 1981 by Robert S. Boyer and J Strother Moore.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Observation&lt;/strong&gt;: Majority element's count will surpass others during traversal.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Algorithm Steps&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Initialization&lt;/strong&gt;: Start with &lt;code&gt;candidate&lt;/code&gt; and &lt;code&gt;count&lt;/code&gt; variables.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Traverse the Array&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;count&lt;/code&gt; is 0, set &lt;code&gt;candidate&lt;/code&gt; as current element and increment &lt;code&gt;count&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If current element matches &lt;code&gt;candidate&lt;/code&gt;, increment &lt;code&gt;count&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If different, decrement &lt;code&gt;count&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation&lt;/strong&gt;: &lt;code&gt;candidate&lt;/code&gt; holds potential majority element. Validate if it appears &amp;gt; n/2 times.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Algorithm Efficiency&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Single traversal of the array.&lt;/li&gt;
&lt;li&gt;Utilizes constant space for &lt;code&gt;candidate&lt;/code&gt; and &lt;code&gt;count&lt;/code&gt; variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Application: Majority Element I
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;https://leetcode.com/problems/majority-element/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's an example of how the Boyer-Moore Majority Vote algorithm is applied to solve the Majority Element I problem:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;majorityElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;candidate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;vote&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&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;count&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;candidate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;vote&lt;/span&gt;
                &lt;span class="n"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;vote&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="mi"&gt;1&lt;/span&gt;
            &lt;span class="k"&gt;else&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="mi"&gt;1&lt;/span&gt;

        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;check&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;nums&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;check&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;candidate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;

        &lt;span class="n"&gt;majority&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;nums&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;majority&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;candidate&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Application: Majority Element II
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.tourl"&gt;https://leetcode.com/problems/majority-element-ii/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the Majority Element II problem, the Boyer-Moore Majority Vote algorithm can be adjusted to find elements that appear more than n/3 times in an array:&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;majorityElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;nums&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nb"&gt;int&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="n"&gt;mapi&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;i&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&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;nums&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;nums&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="ow"&gt;not&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mapi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;mapi&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;nums&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="mi"&gt;0&lt;/span&gt;

            &lt;span class="n"&gt;mapi&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;nums&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="mi"&gt;1&lt;/span&gt;

        &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;list1&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;nums&lt;/span&gt;&lt;span class="p"&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;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;v&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;mapi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;items&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;v&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="o"&gt;//&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;list1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;list1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>algorithms</category>
      <category>dsa</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>DSA + real life . Intent and goals.</title>
      <dc:creator>Shivam Jain</dc:creator>
      <pubDate>Thu, 10 Aug 2023 14:33:38 +0000</pubDate>
      <link>https://dev.to/shivamjainn/dsa-real-life-intent-and-goals-1nop</link>
      <guid>https://dev.to/shivamjainn/dsa-real-life-intent-and-goals-1nop</guid>
      <description>&lt;p&gt;Hey there, coding enthusiasts! 🌟 Are you ready to level up your Data Structures and Algorithms (DSA) skills while exploring their real-life applications? Join me on this exciting journey as we dive into the world of problem-solving, creativity, and practical coding.&lt;/p&gt;

&lt;p&gt;** These posts will also be hosted on Github , if anyone wants to add code of missing languages , you can just give a pull request **&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--A9-wwsHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/shivam-jainn"&gt;
        shivam-jainn
      &lt;/a&gt; / &lt;a href="https://github.com/shivam-jainn/DSArl"&gt;
        DSArl
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      dev.to first real life DSA series 
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
DSArl&lt;/h1&gt;
&lt;p&gt;dev.to first real life DSA series&lt;/p&gt;
&lt;/div&gt;



&lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/shivam-jainn/DSArl"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h2&gt;
  
  
  Clear Objectives and Goals
&lt;/h2&gt;

&lt;p&gt;My goal is crystal clear: over the next 4 months, I'm taking on the Striver a2z DSA course. But it's not just about acing the course – I'm infusing every challenge with a real-life application twist to make this journey both educational and intriguing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Structured Learning Path
&lt;/h2&gt;

&lt;p&gt;To stay on track, I've meticulously divided the Striver a2z DSA course into smaller, manageable sections. Each topic will be conquered within a set timeframe, giving us a sense of achievement as we progress.&lt;/p&gt;

&lt;h2&gt;
  
  
  Interactive Learning
&lt;/h2&gt;

&lt;p&gt;Learning should be fun and engaging! Along the way, I'll be throwing in quizzes, challenges, and polls related to the DSA concepts we're exploring. Get ready to test your skills and learn through active participation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Real-Life Applications
&lt;/h2&gt;

&lt;p&gt;Here's where the magic happens – I'm not just solving problems, I'm giving each solution a real-world twist. We'll explore how these algorithms can be applied to actual scenarios, from optimizing travel routes to managing inventory systems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Code Walkthroughs
&lt;/h2&gt;

&lt;p&gt;Solutions are great, but understanding the why and how is even better. With detailed code explanations, I'll break down each step, unravel the thought process, and show you how the solution aligns with the problem's real-life context.&lt;/p&gt;

&lt;h2&gt;
  
  
  Showcase Progress
&lt;/h2&gt;

&lt;p&gt;I'm not just sharing the destination, but the journey as well. Expect regular updates on the challenges I faced, the "aha" moments I experienced, and how my DSA skills are evolving over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Community Interaction
&lt;/h2&gt;

&lt;p&gt;Let's learn together and foster a supportive community. Share your solutions, insights, and your own real-life applications of the problems. Collaboration makes the learning experience richer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-Platform Approach
&lt;/h2&gt;

&lt;p&gt;From in-depth blog posts to bite-sized updates on Instagram, Twitter, and LinkedIn, I'll be sharing content across various platforms to ensure you don't miss a thing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Collaborations
&lt;/h2&gt;

&lt;p&gt;Bringing in fresh perspectives is essential. I'll be teaming up with fellow learners and experienced developers to explore new angles and deepen our understanding.&lt;/p&gt;

&lt;h2&gt;
  
  
  Feedback and Improvement
&lt;/h2&gt;

&lt;p&gt;Your feedback is gold! I'm eager to hear your thoughts and suggestions so I can enhance the content and ensure it's serving you the best it can.&lt;/p&gt;

&lt;h2&gt;
  
  
  Consistency is Key
&lt;/h2&gt;

&lt;p&gt;Expect regular updates and a consistent posting schedule. Together, we'll maintain the momentum and keep the learning fire burning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Personal Touch
&lt;/h2&gt;

&lt;p&gt;Coding is personal, and I'll be sharing anecdotes and stories from my journey. Let's connect on a deeper level and inspire each other.&lt;/p&gt;

&lt;p&gt;Are you as excited as I am? If you're ready to master DSA, explore real-life applications, and join a vibrant coding community, hit that follow button and let's embark on this adventure together! Stay tuned for my first post on dev.to where we'll dive into the first topic of the Striver a2z DSA course.&lt;/p&gt;

&lt;p&gt;Happy coding, and remember: it's not just about the code; it's about the impact we create with it. Let's make a difference, one algorithm at a time!&lt;/p&gt;

</description>
      <category>dsa</category>
      <category>algorithms</category>
      <category>python</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
