<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Siddhant Bytes]]></title><description><![CDATA[I am a software engineer who likes to read, write, play guitar and badminton.]]></description><link>https://blog.siddhantbobde.com</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Apr 2026 02:00:40 GMT</lastBuildDate><atom:link href="https://blog.siddhantbobde.com/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Reactive vs Predictive vs Adaptive Rate Limiting]]></title><description><![CDATA[Every distributed system eventually faces this question:

How many requests can we safely handle?

Rate limiting is often treated as a simple middleware feature — add a token bucket, set 100 requests/minute, and move on.
But in production systems — e...]]></description><link>https://blog.siddhantbobde.com/reactive-vs-predictive-vs-adaptive-rate-limiting</link><guid isPermaLink="true">https://blog.siddhantbobde.com/reactive-vs-predictive-vs-adaptive-rate-limiting</guid><category><![CDATA[rate-limiting]]></category><category><![CDATA[coding]]></category><category><![CDATA[System Design]]></category><category><![CDATA[System Architecture]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[backend]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sat, 31 Jan 2026 17:35:11 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1769880869055/e63fe62d-2e79-4ef0-850f-f2e28fc25287.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Every distributed system eventually faces this question:</p>
<blockquote>
<p>How many requests can we safely handle?</p>
</blockquote>
<p>Rate limiting is often treated as a simple middleware feature — add a token bucket, set <code>100 requests/minute</code>, and move on.</p>
<p>But in production systems — especially those running on Kubernetes, backed by databases like RDS, and serving real users — rate limiting becomes a system design decision, not just an API configuration.</p>
<p>In this article, we’ll break down:</p>
<ul>
<li><p>Reactive rate limiting</p>
</li>
<li><p>Predictive rate limiting</p>
</li>
<li><p>Adaptive rate limiting</p>
</li>
<li><p>How they differ</p>
</li>
<li><p>What production systems actually use</p>
</li>
</ul>
<h1 id="heading-why-rate-limiting-exists">Why Rate Limiting Exists</h1>
<p>Rate limiting is not just about stopping abuse.</p>
<p>It exists to:</p>
<ul>
<li><p>Protect infrastructure</p>
</li>
<li><p>Prevent cascading failures</p>
</li>
<li><p>Maintain latency SLOs</p>
</li>
<li><p>Protect downstream dependencies (DB, cache, third-party APIs)</p>
</li>
<li><p>Ensure fairness across users</p>
</li>
</ul>
<p>If your system can safely handle <strong>50 requests per second</strong>, and suddenly receives <strong>200</strong>, something will fail:</p>
<ul>
<li><p>CPU saturates</p>
</li>
<li><p>DB connections exhaust</p>
</li>
<li><p>Latency spikes</p>
</li>
<li><p>Timeouts cascade</p>
</li>
<li><p>Retry storms begin</p>
</li>
</ul>
<p>Good rate limiting prevents that chain reaction.</p>
<hr />
<h1 id="heading-1-reactive-rate-limiting-the-foundation">1️⃣ Reactive Rate Limiting (The Foundation)</h1>
<h2 id="heading-what-it-is">What It Is</h2>
<p>Reactive rate limiting enforces limits <strong>after requests arrive</strong>.</p>
<p>It doesn’t predict anything.<br />It simply checks counters and decides.</p>
<pre><code class="lang-plaintext">Request → Check counter → Allow or Reject
</code></pre>
<h2 id="heading-common-algorithms">Common Algorithms</h2>
<ul>
<li><p>Fixed Window</p>
</li>
<li><p>Sliding Window</p>
</li>
<li><p>Token Bucket</p>
</li>
<li><p>Leaky Bucket</p>
</li>
</ul>
<p><strong>These are deterministic and rule-based.</strong></p>
<p><strong>Example:</strong></p>
<p>If limit = 50 RPS:</p>
<p>The 51st request gets rejected.</p>
<p>No forecasting. No adaptation. Just enforcement.</p>
<hr />
<h2 id="heading-strengths">Strengths</h2>
<ul>
<li><p>Simple to implement</p>
</li>
<li><p>Easy to reason about</p>
</li>
<li><p>Predictable behavior</p>
</li>
<li><p>Low operational complexity</p>
</li>
</ul>
<p>Perfect for:</p>
<ul>
<li><p>Internal APIs</p>
</li>
<li><p>Early-stage products</p>
</li>
<li><p>Controlled traffic environments</p>
</li>
</ul>
<hr />
<h2 id="heading-weaknesses">Weaknesses</h2>
<ul>
<li><p>Doesn’t anticipate spikes</p>
</li>
<li><p>Can cause abrupt throttling</p>
</li>
<li><p>Doesn’t consider system health</p>
</li>
<li><p>Treats all requests equally</p>
</li>
</ul>
<p>If traffic suddenly doubles, reactive systems only respond once limits are breached.</p>
<p>They don’t prepare.</p>
<hr />
<h1 id="heading-2-predictive-rate-limiting-anticipating-load">2️⃣ Predictive Rate Limiting (Anticipating Load)</h1>
<h2 id="heading-what-it-is-1">What It Is</h2>
<p>Predictive rate limiting uses historical traffic data to forecast near-future demand and adjust limits proactively.</p>
<p>Instead of asking:</p>
<blockquote>
<p>“Are we overloaded right now?”</p>
</blockquote>
<p>It asks:</p>
<blockquote>
<p>“Will we be overloaded soon?”</p>
</blockquote>
<hr />
<h2 id="heading-example-scenario">Example Scenario</h2>
<p>Historical data shows:</p>
<ul>
<li><p>Traffic spikes every weekday at 9 AM</p>
</li>
<li><p>Friday evenings see 2x normal traffic</p>
</li>
<li><p>Product launches cause predictable bursts</p>
</li>
</ul>
<p>A predictive system can:</p>
<ul>
<li><p>Increase pod replicas before the spike</p>
</li>
<li><p>Adjust token bucket size</p>
</li>
<li><p>Pre-warm DB connections</p>
</li>
<li><p>Scale caches</p>
</li>
</ul>
<p>Instead of reacting to overload, it prepares for it.</p>
<hr />
<h2 id="heading-important-rule">Important Rule:</h2>
<p>Predicted demand must never exceed safe system capacity.</p>
<p>The safe formula is:</p>
<pre><code class="lang-plaintext">final_limit = min(predicted_demand, safe_capacity)
</code></pre>
<p>Where:</p>
<ul>
<li><p><code>safe_capacity</code> comes from load testing and SLO analysis</p>
</li>
<li><p><code>predicted_demand</code> comes from time-series modeling</p>
</li>
</ul>
<p>If your system can safely handle 50 RPS and the model predicts 60 RPS demand, you either:</p>
<p>Scale capacity to 80 RPS<br />OR<br />Cap limit at 50</p>
<p>Prediction never overrides infrastructure reality.</p>
<hr />
<h2 id="heading-strengths-1">Strengths</h2>
<ul>
<li><p>Smoother user experience</p>
</li>
<li><p>Fewer sudden throttles</p>
</li>
<li><p>Better alignment with autoscaling</p>
</li>
<li><p>Good for seasonal traffic</p>
</li>
</ul>
<hr />
<h2 id="heading-weaknesses-1">Weaknesses</h2>
<ul>
<li><p>Requires high-quality historical data</p>
</li>
<li><p>Model drift risk</p>
</li>
<li><p>Operational complexity</p>
</li>
<li><p>Overengineering for small systems</p>
</li>
</ul>
<p>Best suited for:</p>
<ul>
<li><p>Public SaaS APIs</p>
</li>
<li><p>Large-scale platforms</p>
</li>
<li><p>Systems with strong seasonality</p>
</li>
</ul>
<hr />
<h1 id="heading-3-adaptive-rate-limiting-self-protecting-systems">3️⃣ Adaptive Rate Limiting (Self-Protecting Systems)</h1>
<h2 id="heading-what-it-is-2">What It Is</h2>
<p>Adaptive rate limiting adjusts limits based on <strong>real-time system health</strong>, not forecasts.</p>
<p>It monitors:</p>
<ul>
<li><p>CPU usage</p>
</li>
<li><p>Memory pressure</p>
</li>
<li><p>DB connection pool utilization</p>
</li>
<li><p>P99 latency</p>
</li>
<li><p>Error rate</p>
</li>
</ul>
<p>Instead of asking:</p>
<blockquote>
<p>“How much traffic is coming?”</p>
</blockquote>
<p>It asks:</p>
<blockquote>
<p>“How stressed is the system right now?”</p>
</blockquote>
<hr />
<h2 id="heading-example">Example</h2>
<p>If:</p>
<ul>
<li><p>CPU &gt; 85%</p>
</li>
<li><p>DB pool utilization &gt; 90%</p>
</li>
<li><p>Latency SLO violated</p>
</li>
</ul>
<p>The system dynamically reduces rate limits.</p>
<p>It actively protects itself.</p>
<hr />
<h2 id="heading-conceptual-control-formula">Conceptual Control Formula</h2>
<pre><code class="lang-plaintext">limit = f(system_health_metrics)
</code></pre>
<p>For example:</p>
<pre><code class="lang-plaintext">if latency &gt; threshold:
    reduce limit by 20%
</code></pre>
<p>This prevents cascading failures.</p>
<hr />
<h2 id="heading-strengths-2">Strengths</h2>
<ul>
<li><p>Automatically protects downstream systems</p>
</li>
<li><p>Reduces failure amplification</p>
</li>
<li><p>Prevents retry storms</p>
</li>
<li><p>Ideal for microservices architectures</p>
</li>
</ul>
<hr />
<h2 id="heading-weaknesses-2">Weaknesses</h2>
<ul>
<li><p>Can oscillate if poorly tuned</p>
</li>
<li><p>Harder to debug than static systems</p>
</li>
<li><p>Requires good observability</p>
</li>
</ul>
<p>Adaptive systems require strong monitoring.</p>
<p>Without metrics, they’re blind.</p>
<hr />
<h1 id="heading-a-quick-comparison">A Quick Comparison</h1>
<div class="hn-table">
<table>
<thead>
<tr>
<td>Feature</td><td>Reactive</td><td>Predictive</td><td>Adaptive</td></tr>
</thead>
<tbody>
<tr>
<td>Uses history</td><td>❌</td><td>✅</td><td>❌</td></tr>
<tr>
<td>Uses real-time health</td><td>❌</td><td>Sometimes</td><td>✅</td></tr>
<tr>
<td>Forecasts spikes</td><td>❌</td><td>✅</td><td>❌</td></tr>
<tr>
<td>Protects during overload</td><td>Limited</td><td>Indirect</td><td>Strong</td></tr>
<tr>
<td>Complexity</td><td>Low</td><td>High</td><td>Medium</td></tr>
</tbody>
</table>
</div><hr />
<h1 id="heading-what-production-systems-actually-do">What Production Systems Actually Do</h1>
<p>Most large systems do not pick one approach.</p>
<p>They combine them.</p>
<p>A realistic production model looks like this:</p>
<pre><code class="lang-plaintext">Reactive (base rule)
+ Adaptive (system protection)
+ Predictive (traffic forecasting)
</code></pre>
<p>Final decision formula:</p>
<pre><code class="lang-plaintext">final_limit = min(
    safe_capacity,
    predicted_traffic,
    adaptive_health_limit
)
</code></pre>
<p>This gives:</p>
<ul>
<li><p>Hard safety guardrails</p>
</li>
<li><p>Intelligent anticipation</p>
</li>
<li><p>Real-time protection</p>
</li>
</ul>
<hr />
<h1 id="heading-a-real-backend-example">A Real Backend Example</h1>
<p>Imagine a Kubernetes-based API backed by a relational database.</p>
<p>Your true bottleneck isn’t CPU.</p>
<p>It’s:</p>
<ul>
<li><p>DB connection pool exhaustion</p>
</li>
<li><p>Lock contention</p>
</li>
<li><p>I/O saturation</p>
</li>
</ul>
<p>If you only limit by RPS, you may still overload the database.</p>
<p>Better approach:</p>
<ul>
<li><p>Reactive RPS limiter</p>
</li>
<li><p>Concurrency-based limiter (limit in-flight DB queries)</p>
</li>
<li><p>Adaptive throttling when latency spikes</p>
</li>
</ul>
<p>Rate limiting must reflect real bottlenecks — not just request count.</p>
<hr />
<h1 id="heading-final-thoughts">Final Thoughts</h1>
<p>Reactive rate limiting protects against abuse.<br />Predictive rate limiting prepares for growth.<br />Adaptive rate limiting protects the system itself.</p>
]]></content:encoded></item><item><title><![CDATA[Organize SCSS in React Projects Like a Pro]]></title><description><![CDATA[Hello everyone!This blog is a follow-up to my previous post, “Elevate Your Styling with SASS”, where I explained the advantages of using SCSS over traditional CSS. In this post, I’ll walk you through how to effectively integrate SCSS into a ReactJS p...]]></description><link>https://blog.siddhantbobde.com/organize-scss-in-react-projects-like-a-pro</link><guid isPermaLink="true">https://blog.siddhantbobde.com/organize-scss-in-react-projects-like-a-pro</guid><category><![CDATA[scss]]></category><category><![CDATA[CSS]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Sass]]></category><category><![CDATA[coding]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sat, 31 May 2025 06:38:15 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1748673335242/bfc1dd4d-b07b-4c1b-a500-2d56871b7b52.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello everyone!<br />This blog is a follow-up to my previous post, <a target="_blank" href="https://blog.siddhantbobde.com/elevate-your-styling-with-sass"><strong>“Elevate Your Styling with SASS”</strong></a>, where I explained the advantages of using SCSS over traditional CSS. In this post, I’ll walk you through how to effectively integrate SCSS into a ReactJS project.</p>
<p>You won’t need to import SCSS files for every component, and you’ll also be able to share SCSS styles across components without importing multiple files.</p>
<h2 id="heading-step-1-create-a-new-reactjs-project">🚀 Step 1: Create a New ReactJS Project</h2>
<p>Run the following command to create a new React project named <code>sass-setup</code>:</p>
<pre><code class="lang-javascript">npx create-react-app sass-setup
</code></pre>
<p>After removing unnecessary files, your project structure should look like this:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716348284887/999ebe59-49ff-4041-8c7c-cdd07813ccb6.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-step-2-install-sass">🚀 Step 2: Install Sass</h2>
<p>To install Sass, run:</p>
<pre><code class="lang-javascript">npm install sass
</code></pre>
<p>After installation, convert all <code>.css</code> files to <code>.scss</code> by renaming the file extensions.</p>
<p><strong>Note:</strong> Although the preprocessor is called <strong>Sass</strong>, we use the <code>.scss</code> extension here. The difference between <code>.sass</code> and <code>.scss</code> lies in their syntax. Sass uses indentation-based syntax, while SCSS is more CSS-like, using curly braces and semicolons.</p>
<p>You can read more about SASS vs SCSS <a target="_blank" href="https://www.geeksforgeeks.org/what-is-the-difference-between-scss-and-sass/">here</a>.</p>
<h2 id="heading-step-3-import-scss-files">🚀 Step 3: Import SCSS Files</h2>
<p>Import <code>index.scss</code> in your <code>index.js</code> file:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// index.js</span>
<span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;
<span class="hljs-keyword">import</span> ReactDOM <span class="hljs-keyword">from</span> <span class="hljs-string">'react-dom/client'</span>;
<span class="hljs-keyword">import</span> <span class="hljs-string">'./index.scss'</span>;
<span class="hljs-keyword">import</span> App <span class="hljs-keyword">from</span> <span class="hljs-string">'./App'</span>;

<span class="hljs-keyword">const</span> root = ReactDOM.createRoot(<span class="hljs-built_in">document</span>.getElementById(<span class="hljs-string">'root'</span>));
root.render(
  <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">React.StrictMode</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">App</span> /&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">React.StrictMode</span>&gt;</span></span>
);
</code></pre>
<p>Similarly, import <code>App.scss</code> in your <code>App.js</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// App.js</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">'./App.scss'</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"App"</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<pre><code class="lang-javascript"><span class="hljs-comment">// App.scss</span>
.App {
  <span class="hljs-attr">height</span>: <span class="hljs-number">100</span>%;
  width: <span class="hljs-number">100</span>%;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: <span class="hljs-number">3</span>rem;
  margin-top: <span class="hljs-number">5</span>rem;
}
</code></pre>
<h2 id="heading-step-4-organize-folders">🚀 Step 4: Organize Folders</h2>
<p>Create the following folder structure:</p>
<ul>
<li><p><code>components/</code> → to store React components</p>
</li>
<li><p><code>scss/</code> → to store SCSS files for each component</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716386425359/33d24b76-8c0a-4909-8f23-ddf929451fbf.png" alt class="image--center mx-auto" /></p>
<p>Create a <code>Home.js</code> component inside the <code>components</code> folder:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-keyword">const</span> Home = <span class="hljs-function">() =&gt;</span> {
    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"home-container"</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">h1</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'title'</span>&gt;</span>This is home page<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">p</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'sub-title'</span>&gt;</span>
                Lorem ipsum, dolor sit amet consectetur adipisicing elit. Numquam quaerat quia dolores ut non magni quibusdam sed molestias odio, reprehenderit
                suscipit velit veritatis consequuntur, harum, officia ab similique inventore adipisci.
            <span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
    );
};

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Home;
</code></pre>
<h2 id="heading-understanding-sass-and-the-power-of-partials">💡 Understanding Sass and the Power of Partials</h2>
<p>Before we style our <code>Home</code> component, it's important to understand <strong>how Sass works</strong>, particularly the concept of <strong>partials</strong>.</p>
<p>When you create an <code>.scss</code> file, the <strong>Sass preprocessor</strong> compiles it into regular CSS that your React app can use.</p>
<p>However, when you create a file prefixed with an underscore—like <code>_home.scss</code>—you're creating a <strong>partial</strong> file. Partial SCSS files:</p>
<ul>
<li><p>Are <strong>not compiled</strong> into standalone CSS files.</p>
</li>
<li><p>Are meant to be <strong>imported into other SCSS files</strong>.</p>
</li>
<li><p>Help organize your styles into <strong>modular, maintainable chunks</strong>.</p>
</li>
</ul>
<h3 id="heading-why-use-partials">Why Use Partials?</h3>
<p>Instead of importing an SCSS file into every single component, a better approach is to:</p>
<ol>
<li><p><strong>Create a partial SCSS file</strong> for each component (e.g., <code>_home.scss</code>, <code>_about.scss</code>).</p>
</li>
<li><p><strong>Import all partials into a single main SCSS file</strong> (e.g., <code>styles.scss</code>).</p>
</li>
<li><p><strong>Import just the main SCSS file</strong> into your root-level component (e.g., <code>App.scss</code>).</p>
</li>
</ol>
<p><strong>This centralizes your styles</strong>, reduces repetition, and makes your codebase much easier to manage as your project grows.</p>
<h3 id="heading-lets-do-it">🛠️ Let’s Do It</h3>
<p>Create two files in your <code>scss/</code> folder:</p>
<ul>
<li><p><code>styles.scss</code> – your <strong>main stylesheet</strong></p>
</li>
<li><p><code>_home.scss</code> – a <strong>partial</strong> that holds styles specific to the Home component</p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716393577454/3bf5d3fe-3672-4c01-bd4f-47b0bd06eb8f.png" alt class="image--center mx-auto" /></p>
<p>Add below code <code>_home.scss</code> file.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// _home.scss</span>
.home-container {
    <span class="hljs-attr">height</span>: <span class="hljs-number">20</span>%;
    width: <span class="hljs-number">30</span>%;
    background-color: grey;

    h1 {
        font-size: <span class="hljs-number">20</span>px;
    }

    p {
        font-size: <span class="hljs-number">15</span>px;
        color: lightblue;
    }
}
</code></pre>
<p>In <code>styles.scss</code>, import the partial like this:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// styles.scss</span>
@<span class="hljs-keyword">import</span> <span class="hljs-string">'home'</span>;
</code></pre>
<p>Now add the <code>Home</code> component in your <code>App</code> component and also import <code>styles.scss</code> in your <code>App.scss</code></p>
<pre><code class="lang-javascript"><span class="hljs-comment">// App.js</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">'./App.scss'</span>;
<span class="hljs-keyword">import</span> Home <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/Home'</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"App"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Home</span>/&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p><strong>Now,</strong> <code>App.scss</code> <strong>imports just</strong> <code>styles.scss</code><strong>, and all component styles flow through this single point of entry.</strong></p>
<pre><code class="lang-javascript"><span class="hljs-comment">// App.scss</span>
@<span class="hljs-keyword">import</span> <span class="hljs-string">'./scss/styles.scss'</span>;

.App {
  <span class="hljs-attr">height</span>: <span class="hljs-number">100</span>%;
  width: <span class="hljs-number">100</span>%;
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: <span class="hljs-number">3</span>rem;
  margin-top: <span class="hljs-number">5</span>rem;
}
</code></pre>
<h2 id="heading-step-5-run-the-app">🚀Step 5: Run the App</h2>
<pre><code class="lang-javascript">npm start
</code></pre>
<p>You should now see the styled <code>Home</code> component rendered properly.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716393863619/cecf8d86-f2a2-4355-abab-ce9ac3934702.png" alt class="image--center mx-auto" /></p>
<p>Now you can see that we did not import the SCSS file directly into your component. Instead, we created a main stylesheet to include all the SCSS files for your components. This approach centralizes your styles, making your codebase more organized and easier to manage.</p>
<h3 id="heading-add-another-component">Add Another Component</h3>
<p>Let’s add an <code>About.js</code> component:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// About.js</span>
<span class="hljs-keyword">import</span> React <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>;

<span class="hljs-keyword">const</span> About = <span class="hljs-function">() =&gt;</span> {
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">'about-container'</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>This is a about page<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
        <span class="hljs-tag">&lt;<span class="hljs-name">p</span>&gt;</span>My name is siddhant bobde and i like to write technical blogs.<span class="hljs-tag">&lt;/<span class="hljs-name">p</span>&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  )
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> About;
</code></pre>
<p>Create <code>_about.scss</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// _about.scss</span>
.about-container {
    <span class="hljs-attr">height</span>: <span class="hljs-number">30</span>%;
    width: <span class="hljs-number">50</span>%;
    background-color: whitesmoke;

    h1 {
        font-size: <span class="hljs-number">25</span>px;
    }

    p {
        font-size: <span class="hljs-number">20</span>px;
        color: darkgrey;
    }
}
</code></pre>
<p>Update <code>styles.scss</code> and add <code>_about.scss</code> file.</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// styles.scss</span>
@<span class="hljs-keyword">import</span> <span class="hljs-string">'home'</span>;
@<span class="hljs-keyword">import</span> <span class="hljs-string">'about'</span>;
</code></pre>
<p>Use the newly created component in your App component</p>
<pre><code class="lang-javascript"><span class="hljs-comment">// App.js</span>
<span class="hljs-keyword">import</span> <span class="hljs-string">'./App.scss'</span>;
<span class="hljs-keyword">import</span> About <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/About'</span>;
<span class="hljs-keyword">import</span> Home <span class="hljs-keyword">from</span> <span class="hljs-string">'./components/Home'</span>;

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">App</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">return</span> (
    <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">className</span>=<span class="hljs-string">"App"</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">Home</span>/&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">About</span>/&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
  );
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> App;
</code></pre>
<p>Run your code, and you will see the new component below the Home component.</p>
<h3 id="heading-reusing-scss-across-components">🔁 Reusing SCSS Across Components</h3>
<p>Now, let's say you write some styles in <code>_home.scss</code> and want to apply those styles in your About component. You can do this by adding the styles to <code>_home.scss</code> and using the class name in your About component.</p>
<p>Note that you need to ensure the hierarchy of styling classes is correct when styling the component in SCSS. The <code>_about.scss</code> file will have access to all the CSS defined above it, like <code>_home.scss</code>, because the CSS hierarchy follows a top-down approach.</p>
<p>In this way, you can configure Sass in your React.js application. If you have any thoughts or suggestions, please share them in the comments section. Follow me for more technical blogs.</p>
<h2 id="heading-conclusion">✅ Conclusion</h2>
<p>By integrating SCSS effectively in your React application, you can keep your styles modular, organized, and easy to maintain. Using <strong>partials</strong> and a <strong>centralized main stylesheet</strong> allows you to avoid repetitive imports and ensures a scalable structure as your project grows. This approach not only improves maintainability but also keeps your styling logic clean and consistent across components.</p>
<p>You can find the GitHub link of the above code <a target="_blank" href="https://github.com/SiddhantBobde/sass-setup">here</a>.</p>
<p>Thanks for reading! I hope this guide helped you understand how to set up and manage SCSS in your React projects effectively. If you have any questions, feedback, or suggestions, feel free to leave a comment.</p>
]]></content:encoded></item><item><title><![CDATA[ClickHouse CSV Ingestion with Python: Explicit Schema]]></title><description><![CDATA[Introduction
Hello everyone! Today, I am going to show you how you can create a table in ClickHouse from a CSV using Python.
We use WSL to run ClickHouse on Windows. If you want to know how to run ClickHouse on Windows locally, you can check this art...]]></description><link>https://blog.siddhantbobde.com/clickhouse-csv-ingestion-with-python-explicit-schema</link><guid isPermaLink="true">https://blog.siddhantbobde.com/clickhouse-csv-ingestion-with-python-explicit-schema</guid><category><![CDATA[ClickHouse]]></category><category><![CDATA[Python]]></category><category><![CDATA[Databases]]></category><category><![CDATA[OLAP]]></category><category><![CDATA[SQL]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sun, 04 May 2025 06:37:09 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1746340214713/4bf18d9e-607f-4644-b122-f5b3b9119184.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Hello everyone! Today, I am going to show you how you can create a table in ClickHouse from a CSV using Python.</p>
<p>We use WSL to run ClickHouse on Windows. If you want to know how to run ClickHouse on Windows locally, you can check this article <a target="_blank" href="https://siddhantbytes.hashnode.dev/clickhouse-windows-installation">https://blog.siddhantbobde.com/clickhouse-windows-installation</a></p>
<h2 id="heading-python-setup-for-clickhouse">Python Setup for clickhouse</h2>
<p>I am using VSCode as my Python editor. You can use any editor you like. Create a new Python virtual environment, or you can use your default one.</p>
<p>To connect to the ClickHouse client locally, we need to install the Python library <code>clickhouse-connect</code>.</p>
<p>Run the command below to install <code>clickhouse-connect</code>.</p>
<pre><code class="lang-plaintext">pip install clickhouse-connect
</code></pre>
<p>Now, let's connect to our local ClickHouse client using Python.</p>
<p>Create a Python file and add the code below to establish a connection with ClickHouse.</p>
<p><strong>Make sure your ClickHouse is running locally.</strong></p>
<pre><code class="lang-python"><span class="hljs-comment"># import the package</span>
<span class="hljs-keyword">import</span> clickhouse_connect

<span class="hljs-comment"># Create a connection</span>
clickhouse_client = clickhouse_connect.get_client(host=<span class="hljs-string">'localhost'</span>, database=<span class="hljs-string">"default"</span>, username=<span class="hljs-string">'default'</span>)
</code></pre>
<h2 id="heading-creating-table-using-csv-file">Creating table using csv file.</h2>
<p>Lets create a csv having random data. I am using <a target="_blank" href="https://www.mockaroo.com/">https://www.mockaroo.com/</a> to generate random data.</p>
<p>I have uploaded my CSV file <a target="_blank" href="https://drive.google.com/file/d/1VGxYsBK6ytVZB_GVnktjCULb6ahgsLPK/view?usp=sharing">here</a>. After creating your own test data or downloading test data from the link I've provided, you have to copy the file into your Ubuntu environment.</p>
<p>You can access your ubuntu environment from your file explorer or you can type <code>\\wsl$</code> in windows run command.</p>
<p>then you have to put csv file in user-files folder in ubuntu environment you have created.</p>
<p><strong>The path will be</strong> <code>\Ubuntu\home\{your ubuntu user}\user_files</code></p>
<p>Now lets write one python script to create a table from csv and insert data into it.</p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> clickhouse_connect

<span class="hljs-comment"># Connect to clickhouse client. Below are the default credentials of clickhouse.</span>
clickhouse_client = clickhouse_connect.get_client(host=<span class="hljs-string">'localhost'</span>, database=<span class="hljs-string">"default"</span>, username=<span class="hljs-string">'default'</span>)

<span class="hljs-comment"># put your table name and file name</span>
table_name = <span class="hljs-string">'testdata'</span>
file_name = <span class="hljs-string">'testdata.csv'</span>

<span class="hljs-comment"># Query to column names and their data types from file.</span>
result = clickhouse_client.query(<span class="hljs-string">'DESCRIBE TABLE file({0}, CSVWithNames)'</span>.format(<span class="hljs-string">'testdata.csv'</span>))
columns_and_types = result.result_rows

<span class="hljs-comment"># Create table query</span>
create_table_query = <span class="hljs-string">'CREATE TABLE {0} ('</span>.format(table_name)

<span class="hljs-comment"># Select query to select data from file</span>
select_data_query = <span class="hljs-string">'SELECT '</span>

<span class="hljs-keyword">for</span> column <span class="hljs-keyword">in</span> columns_and_types:
    column_name = column[<span class="hljs-number">0</span>]
    column_type = column[<span class="hljs-number">1</span>]

    create_table_query += column_name + <span class="hljs-string">' '</span> + column_type + <span class="hljs-string">', '</span>
    select_data_query += column_name + <span class="hljs-string">', '</span>


create_table_query = create_table_query[:<span class="hljs-number">-2</span>] + <span class="hljs-string">') ENGINE = MergeTree() ORDER BY tuple() AS '</span>
select_data_query += <span class="hljs-string">" FROM file('{0}', CSVWithNames)"</span>.format(file_name)
create_table_query += select_data_query

print(create_table_query)

clickhouse_client.query(create_table_query)
</code></pre>
<p>After running above python script you can check if your table is created or not. Run following query to print all table names</p>
<pre><code class="lang-sql"><span class="hljs-keyword">show</span> <span class="hljs-keyword">tables</span>
</code></pre>
<p>After running above query you will see all the table names and check if your table name is present here.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746339068086/3f1c87d4-a0f8-4849-a624-29dacf7c826d.png" alt class="image--center mx-auto" /></p>
<p>To get the data from the table we created we can run a simple sql like query.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> testdata <span class="hljs-keyword">limit</span> <span class="hljs-number">5</span>
</code></pre>
<p><strong>Note: I have added limit 5 so that i can show you the full output of query. You can run query without adding the limit.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1746339169600/e0c4551e-3157-4529-b961-ea2310688eb5.png" alt class="image--center mx-auto" /></p>
<p>If you have any doubts regarding the blog, comment down below. I will do my best to answer them.</p>
]]></content:encoded></item><item><title><![CDATA[Git Add with a Prompt: Selectively Stage Files in Terminal]]></title><description><![CDATA[Hello everyone,
Have you ever needed to stage only specific files in Git but found it tedious to manually copy and paste file paths, especially when they are in different folders? If so, I have a simple solution for you!
I’ve created a Bash script th...]]></description><link>https://blog.siddhantbobde.com/git-add-with-a-prompt-selectively-stage-files-in-terminal</link><guid isPermaLink="true">https://blog.siddhantbobde.com/git-add-with-a-prompt-selectively-stage-files-in-terminal</guid><category><![CDATA[Programming Blogs]]></category><category><![CDATA[Bash]]></category><category><![CDATA[Git]]></category><category><![CDATA[GitHub]]></category><category><![CDATA[coding]]></category><category><![CDATA[automation]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sun, 02 Feb 2025 13:10:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1738501951000/e097e8b8-7f4f-4ed5-b17b-afe74403e596.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-hello-everyone"><strong>Hello everyone,</strong></h3>
<p>Have you ever needed to stage only specific files in Git but found it tedious to manually copy and paste file paths, especially when they are in different folders? If so, I have a simple solution for you!</p>
<p>I’ve created a Bash script that streamlines this process by prompting you, file by file, and letting you decide whether to stage each one by simply entering <strong>'y'</strong> (yes) or <strong>'n'</strong> (no).</p>
<p>This eliminates the need to repeatedly run <code>git status</code> and <code>git add</code> with manually copied file paths.</p>
<p>Let's dive in!</p>
<p><strong>Note:</strong> <strong>While many IDEs offer selective staging, this script is a great alternative for those who prefer working in the terminal. It will save you time and effort.</strong></p>
<h2 id="heading-the-script">The Script</h2>
<p>Here’s a Bash script that asks you whether to stage each modified file:</p>
<pre><code class="lang-bash"><span class="hljs-meta">#!/bin/bash</span>

<span class="hljs-comment"># Check if the current directory is a Git repository</span>
<span class="hljs-keyword">if</span> ! git rev-parse --is-inside-work-tree &gt; /dev/null 2&gt;&amp;1; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"Not a Git repository. Please navigate to a Git repository."</span>
    <span class="hljs-built_in">exit</span> 1
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># Get the list of modified files</span>
modified_files=$(git diff --name-only)

<span class="hljs-comment"># Check if there are any modified files</span>
<span class="hljs-keyword">if</span> [ -z <span class="hljs-string">"<span class="hljs-variable">$modified_files</span>"</span> ]; <span class="hljs-keyword">then</span>
    <span class="hljs-built_in">echo</span> <span class="hljs-string">"No modified files to stage."</span>
    <span class="hljs-built_in">exit</span> 0
<span class="hljs-keyword">fi</span>

<span class="hljs-comment"># Loop through each modified file</span>
<span class="hljs-keyword">for</span> file <span class="hljs-keyword">in</span> <span class="hljs-variable">$modified_files</span>; <span class="hljs-keyword">do</span>
    <span class="hljs-built_in">read</span> -p <span class="hljs-string">"Do you want to stage the file '<span class="hljs-variable">$file</span>'? (y/n): "</span> answer
    <span class="hljs-keyword">if</span> [[ <span class="hljs-variable">$answer</span> == <span class="hljs-string">"y"</span> ]]; <span class="hljs-keyword">then</span>
        git add <span class="hljs-string">"<span class="hljs-variable">$file</span>"</span>
        <span class="hljs-built_in">echo</span> <span class="hljs-string">"'<span class="hljs-variable">$file</span>' has been staged."</span>
    <span class="hljs-keyword">else</span>
        <span class="hljs-built_in">echo</span> <span class="hljs-string">"'<span class="hljs-variable">$file</span>' has not been staged."</span>
    <span class="hljs-keyword">fi</span>
<span class="hljs-keyword">done</span>
</code></pre>
<h2 id="heading-adding-the-script-to-system-variables"><strong>Adding the Script to System Variables</strong></h2>
<p>To make this script accessible from anywhere in the terminal, add its path to your system variables.</p>
<h3 id="heading-steps-for-windows-users"><strong>Steps for Windows Users</strong></h3>
<ol>
<li><p>Right-click <strong>"This PC"</strong> or <strong>"Computer"</strong> in File Explorer.</p>
</li>
<li><p>Click <strong>"Properties"</strong> → <strong>"Advanced system settings"</strong> → <strong>"Environment Variables"</strong>.</p>
</li>
<li><p>You can also search for <strong>"Edit environment variables for your account"</strong> in Windows.</p>
</li>
<li><p>Under <strong>System Variables</strong>, find and double-click <strong>"Path"</strong>.</p>
</li>
<li><p>Click <strong>"New"</strong>, then add the folder path where your script is saved (e.g., <code>C:\customScripts</code>).</p>
</li>
<li><p>Click <strong>OK</strong> to save the changes.</p>
</li>
</ol>
<h2 id="heading-creating-a-global-alias-in-git-bash">Creating a Global Alias in Git Bash</h2>
<p>To make running the script even easier, you can create a global alias in Git Bash.</p>
<h3 id="heading-step-1-open-git-bash-and-edit-bashrc-file">Step 1: Open Git Bash and Edit <code>.bashrc</code> File</h3>
<p>Run the following command</p>
<pre><code class="lang-bash">nano ~/.bashrc
</code></pre>
<p>(If <code>nano</code> is not available, use another text editor like <code>vim</code>.)</p>
<h3 id="heading-step-2-add-your-alias">Step 2: Add Your Alias</h3>
<p>At the end of the <code>.bashrc</code> file, add this line:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">alias</span> stage-files=<span class="hljs-string">'bash /c/customScripts/git_stage_files.sh'</span>
</code></pre>
<p><strong>Note:</strong> In Git Bash, Windows paths use forward slashes (<code>/</code>), and <code>C:</code> drive paths start with <code>/c/</code>.</p>
<h3 id="heading-step-3-save-and-exit">Step 3: Save and Exit</h3>
<ul>
<li><p>If using <code>nano</code>, press <code>CTRL + X</code> and then <code>Yes</code> to save</p>
</li>
<li><p>If using <code>vim</code>, press <code>Esc</code>, type <code>:wq</code>, and hit Enter.</p>
</li>
</ul>
<h3 id="heading-step-4-reload-the-bashrc-file">Step 4: Reload the <code>.bashrc</code> File</h3>
<p>Run the following command to apply the changes:</p>
<pre><code class="lang-bash"><span class="hljs-built_in">source</span> ~/.bashrc
</code></pre>
<h2 id="heading-how-to-use-the-script"><strong>How to Use the Script</strong></h2>
<p>Now, whenever you want to selectively stage files, just run:</p>
<pre><code class="lang-bash">stage-files
</code></pre>
<p>This will list all modified files and ask you whether to stage each one.</p>
<h2 id="heading-conclusion"><strong>Conclusion</strong></h2>
<p>This simple script makes it easy to stage specific files in Git without manually copying file paths. If you're a terminal user, this method will help you work more efficiently.</p>
<p>If you encounter any issues, feel free to ask in the comments section.</p>
<p><strong>Happy coding!</strong> 🚀</p>
]]></content:encoded></item><item><title><![CDATA[My One-Year LeetCode Streak: How I Solved a Problem Every Day]]></title><description><![CDATA[Last October, I took on the challenge of solving a LeetCode problem every day for a month and announced it on Twitter. After completing the first month, I decided to extend the challenge for another month. What began as a 30-day commitment eventually...]]></description><link>https://blog.siddhantbobde.com/my-one-year-leetcode-streak-how-i-solved-a-problem-every-day</link><guid isPermaLink="true">https://blog.siddhantbobde.com/my-one-year-leetcode-streak-how-i-solved-a-problem-every-day</guid><category><![CDATA[leetcode]]></category><category><![CDATA[data structure and algorithms ]]></category><category><![CDATA[DSA]]></category><category><![CDATA[Programming Blogs]]></category><category><![CDATA[coding]]></category><category><![CDATA[consistency]]></category><category><![CDATA[challenge]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Thu, 28 Nov 2024 09:58:14 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1732785126615/0c7be74c-2659-4484-90c7-9cb37d77c0b9.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Last October, I took on the challenge of solving a LeetCode problem every day for a month and announced it on Twitter. After completing the first month, I decided to extend the challenge for another month. What began as a 30-day commitment eventually turned into a full year of daily problem-solving. In this blog, I'll share why I started this challenge, the strategies I used to stay consistent, and what kept me motivated throughout the journey.</p>
<h3 id="heading-why-i-started-this-challenge">Why I Started This Challenge?</h3>
<p>I always wanted to excel in problem-solving and data structures and algorithms (DSA). However, after securing an internship, I completely stopped practicing DSA problem solving. I wanted to get back into problem-solving, but I struggled with consistency. Some days, I would solve a few problems, but then I wouldn’t touch them the next day, and this lack of routine hindered my progress.</p>
<p>Additionally, I believed that consistent problem-solving would help me think more critically at work, improve my problem-solving speed, and enhance my coding efficiency. So, I decided to take on a 30-day challenge of solving one LeetCode problem every day, while posting daily updates on Twitter to keep myself accountable.</p>
<h3 id="heading-strategy">Strategy</h3>
<p><strong>On weekdays</strong>, I dedicated about 30 minutes each day to solving a problem. If I couldn’t come up with a solution within that time, I would refer to the solution.</p>
<p><strong>Why only 30 minutes?</strong></p>
<ol>
<li><p>My work hours were from 10 AM to 7 PM, and I also had other side projects to work on.</p>
</li>
<li><p>I wanted to stay engaged. Spending too much time on a problem could lead to burnout and loss of interest, which would make me give up entirely.</p>
</li>
<li><p>Keeping the streak alive motivated me to stay consistent with problem-solving.</p>
</li>
</ol>
<p><strong>On weekends,</strong> I had more time to focus on problem-solving. I also started participating in LeetCode’s weekly coding contests. These contests helped me test my skills under pressure.</p>
<h3 id="heading-what-kept-me-motivated">What Kept Me Motivated?</h3>
<p>Initially, my daily Twitter updates kept me accountable during the first 30 days. After a month, I decided to extend the challenge to 60 days. When I reached 60 days, I stopped posting updates on Twitter, but by then, solving problems daily had become a habit.</p>
<p>The streak itself became a powerful motivator. It felt almost impossible to let a day pass without solving a problem. Even on days when I didn’t have access to my laptop, I used my phone to copy and paste code just to maintain the streak. I probably did this for around 20 problems over the year, and I think that’s fine—it was more important to me to keep going than to give up.</p>
<h3 id="heading-results-after-one-year-of-consistency">Results After One Year of Consistency</h3>
<ol>
<li><p><strong>Easy Problems:</strong> Over time, I became faster at solving easy problems. I also started exploring different approaches and focusing on finding the most optimal solutions.</p>
</li>
<li><p><strong>Medium Problems:</strong> I used to struggle with these problems, but now I can solve them with some effort.</p>
</li>
<li><p><strong>Hard Problems:</strong> Initially, I wouldn’t even attempt hard problems. Now, I at least try to come up with a solution. While I may not always pass all test cases, I am getting better at approaching them.</p>
</li>
<li><p><strong>Thinking and Problem-Solving:</strong> My ability to think in different directions while solving problems has improved. I’m now more comfortable using data structures like stacks, queues, priority queues, etc to optimize solutions.</p>
</li>
<li><p><strong>Mastering Difficult Topics:</strong> I used to struggle with topics like depth-first search (DFS), backtracking, dynamic programming, and graph problems. Now, I can write DFS and backtracking code within minutes, and I’m much more confident in solving dynamic programming problems.</p>
</li>
<li><p><strong>LeetCode Contests:</strong> I didn’t participate in any LeetCode contests for four to five months during the challenge. When I started again, I noticed an improvement—I could solve two to three questions per contest, compared to just one before.</p>
</li>
</ol>
<h3 id="heading-why-a-daily-leetcode-challenge-and-not-a-dsa-sheet"><strong>Why a Daily LeetCode Challenge and Not a DSA Sheet?</strong></h3>
<p>It really depends on your goal with DSA.</p>
<ol>
<li><p><strong>If you're preparing for interviews,</strong> a DSA sheet is a great choice.</p>
</li>
<li><p><strong>If your goal is to get better at problem-solving,</strong> improve your critical thinking, or build a habit of daily practice, then a daily LeetCode challenge is a better option.</p>
</li>
<li><p><strong>If you want to stay in touch with DSA,</strong> regularly solving a LeetCode problem ensures you're consistently practicing even if it's just for 30 minutes a day.</p>
</li>
<li><p><strong>If you're interested in competitive programming,</strong> participating in LeetCode’s weekly and bi-weekly contests can help you practice solving problems under time pressure and measure your performance against other competitive coders.</p>
</li>
</ol>
<p>My reasons are 2 and 3.</p>
<h3 id="heading-conclusion">Conclusion</h3>
<p>This challenge has significantly improved my DSA skills and my overall problem-solving ability. Not only has it made me faster and more efficient at solving problems, but it’s also changed how I approach complex coding challenges. It’s been an incredibly rewarding experience, and I’m excited to keep pushing myself further.</p>
]]></content:encoded></item><item><title><![CDATA[Optimizing React Performance with Lazy State Initialization]]></title><description><![CDATA[Before understanding react lazy state initialization, let's first understand states in React.
Let's take an example. I have a counter app with two states.

count state

data state


import React, { useState } from 'react'

const Counter = () => {
   ...]]></description><link>https://blog.siddhantbobde.com/optimizing-react-performance-with-lazy-state-initialization</link><guid isPermaLink="true">https://blog.siddhantbobde.com/optimizing-react-performance-with-lazy-state-initialization</guid><category><![CDATA[React]]></category><category><![CDATA[ReactHooks]]></category><category><![CDATA[Performance Optimization]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sun, 11 Aug 2024 18:30:56 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1723514512968/0a7bbe9b-37a4-4fe4-99ee-d01dcc3d6516.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Before understanding react lazy state initialization, let's first understand states in React.</p>
<p>Let's take an example. I have a counter app with two states.</p>
<ol>
<li><p><code>count</code> state</p>
</li>
<li><p><code>data</code> state</p>
</li>
</ol>
<pre><code class="lang-javascript"><span class="hljs-keyword">import</span> React, { useState } <span class="hljs-keyword">from</span> <span class="hljs-string">'react'</span>

<span class="hljs-keyword">const</span> Counter = <span class="hljs-function">() =&gt;</span> {
    <span class="hljs-keyword">const</span> [count, setCount] = useState(<span class="hljs-number">1</span>);
    <span class="hljs-keyword">const</span> [data, setData] = useState(<span class="hljs-built_in">console</span>.log(<span class="hljs-string">"expensive operation"</span>));

    <span class="hljs-keyword">return</span> (
        <span class="xml"><span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">h1</span>&gt;</span>{count}<span class="hljs-tag">&lt;/<span class="hljs-name">h1</span>&gt;</span>
            <span class="hljs-tag">&lt;<span class="hljs-name">button</span> <span class="hljs-attr">onClick</span>=<span class="hljs-string">{()</span> =&gt;</span> {
                setCount(prevCount =&gt; prevCount + 1);
            }}&gt;
                +
            <span class="hljs-tag">&lt;/<span class="hljs-name">button</span>&gt;</span>
        <span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span></span>
    )
}

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> Counter
</code></pre>
<p>Whenever the app loads, it initializes the count and data states. Now, click the + button to increase the <code>count</code>, and it will re-render the counter component with the new state values.</p>
<p>Check the console, whenever you click the plus button, the <code>data</code> state is initialized again and again. This can impact the performance of our app if the operation is time-consuming or expensive.</p>
<p>So, how can we improve this? How can we initialize states that are expensive to set up only once?</p>
<p>This is where the concept of lazy state initialization comes in.</p>
<h3 id="heading-how-to-implement-react-lazy-state-initialization">How to implement React lazy state initialization?</h3>
<p>React provides a way to initialize the state lazily by passing a function to the <code>useState</code> hook. This function is called only once when the component is first rendered, and its return value is used as the initial state.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> [count, setCount] = useState(<span class="hljs-number">1</span>);
<span class="hljs-keyword">const</span> [data, setData] = useState(<span class="hljs-function">() =&gt;</span> {
    <span class="hljs-keyword">const</span> expensiveData = computeExpensiveData();
    <span class="hljs-keyword">return</span> expensiveData();
});
</code></pre>
<p>As you can see in the code above, I passed a function to the state instead of a direct value.</p>
<h3 id="heading-how-it-works">How it works?</h3>
<ol>
<li><p><strong>Without Lazy initialization:</strong> If you just pass a value directly to <code>'useState'</code>, it would compute that value every time the component re-renders, which could be wasteful if the computation is expensive.</p>
<pre><code class="lang-javascript">  <span class="hljs-keyword">const</span> [data, setData] = useState(computeExpensiveData());
</code></pre>
</li>
<li><p><strong>With Lazy initialization:</strong> By passing a function to <code>'useState'</code>, the computation inside the function only occurs once during the initial render.</p>
<pre><code class="lang-javascript"> <span class="hljs-keyword">const</span> [data, setData] = useState(<span class="hljs-function">() =&gt;</span> computeExpensiveData());
</code></pre>
</li>
</ol>
<h3 id="heading-when-and-when-not-to-use-lazy-state-initialization">When (and When <strong>N</strong>ot) to Use Lazy State Initialization</h3>
<ul>
<li><p><strong>When to Use:</strong></p>
<ul>
<li><p>Use lazy state initialization when the state setup is expensive and should only be done once.</p>
<ul>
<li><p>Fetching data from the browser's local storage.</p>
</li>
<li><p>Fetching data from an API or database.</p>
</li>
</ul>
</li>
</ul>
</li>
<li><p><strong>When Not to Use:</strong></p>
<ul>
<li><p>Using lazy state initialization for every state may complicate things.</p>
</li>
<li><p>For simple or static initial states, lazy initialization may not offer any significant performance improvement.</p>
</li>
</ul>
</li>
</ul>
<h3 id="heading-benefits-of-lazy-state-initialization">Benefits of Lazy State Initialization</h3>
<ol>
<li><p><strong>Performance Optimization</strong></p>
<ul>
<li>As the expensive computation while the initializing state will be done only once when the app renders for the first time, it will increase the performance of the app significantly.</li>
</ul>
</li>
<li><p><strong>Efficient Resources Usage</strong></p>
<ul>
<li>If you need to fetch data from an API or the browser's local storage and set it in the state only when the app loads for the first time, you can use lazy initialization or you can use the <code>useEffect</code> hook as well.</li>
</ul>
</li>
<li><p><strong>Imporved User Experince:</strong></p>
<ul>
<li>It reduces the time needed to load the entire app, providing a better user experience.</li>
</ul>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[How to set up ClickHouse locally in windows]]></title><description><![CDATA[Hello everyone! In this post, I will demonstrate how to run ClickHouse locally on Windows.
ClickHouse Installation

To run ClickHouse, we need a Linux environment. Therefore, we will download WSL (Windows Subsystem for Linux), enabling us to run a Li...]]></description><link>https://blog.siddhantbobde.com/clickhouse-windows-installation</link><guid isPermaLink="true">https://blog.siddhantbobde.com/clickhouse-windows-installation</guid><category><![CDATA[ClickHouse]]></category><category><![CDATA[coding]]></category><category><![CDATA[Databases]]></category><category><![CDATA[SQL]]></category><category><![CDATA[Windows]]></category><category><![CDATA[WSL]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sun, 26 May 2024 02:22:49 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1711279765757/c8169d81-d7e1-4cc1-b56a-0e4fd06f79e4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello everyone! In this post, I will demonstrate how to run ClickHouse locally on Windows.</p>
<h2 id="heading-clickhouse-installation">ClickHouse Installation</h2>
<ol>
<li><p>To run ClickHouse, we need a Linux environment. Therefore, we will download WSL (Windows Subsystem for Linux), enabling us to run a Linux environment on Windows.</p>
</li>
<li><p>Open Command Prompt in administrator mode by right-clicking and selecting "Run as administrator." Then, type the command "wsl --install."</p>
</li>
</ol>
<pre><code class="lang-plaintext">wsl --install
</code></pre>
<p>You will see something like this</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1711260136818/8e7d42fa-d905-499e-b399-12fde124953f.png" alt class="image--center mx-auto" /></p>
<ol start="3">
<li><p>After that, you will need to create a Linux user and set a password for that user. Create a user with any name you want and set a password that you will remember, as you may need this password for installing any other libraries in your subsystem.</p>
<p> Now run the below command to install ClickHouse</p>
</li>
</ol>
<pre><code class="lang-bash">curl https://clickhouse.com/ | sh
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716694558402/107f5eac-70f1-4ca8-b949-716c977e9690.png" alt class="image--center mx-auto" /></p>
<ol start="4">
<li>After installation is completed. Start the clickHouse server.</li>
</ol>
<pre><code class="lang-bash">./clickhouse server
</code></pre>
<ol start="5">
<li>Keep this server running in the background, open new Linux terminal and run the ClickHouse client</li>
</ol>
<pre><code class="lang-bash">./clickhouse client
</code></pre>
<p>There you go, you can now run ClickHouse on your local machine.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1711278362013/66562925-367c-42b2-8c41-29ba3b401a01.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-running-queries-on-clickhouse">Running queries on ClickHouse</h2>
<p>Let's create a new table. Run the below query to create a table.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">CREATE</span> <span class="hljs-keyword">TABLE</span> <span class="hljs-keyword">TEST</span>
(
    <span class="hljs-string">`userId`</span> UInt64,
    <span class="hljs-string">`name`</span> <span class="hljs-keyword">String</span>,
    <span class="hljs-string">`password`</span> <span class="hljs-keyword">String</span>,
    <span class="hljs-string">`description`</span> Nullable(<span class="hljs-keyword">String</span>)
)
<span class="hljs-keyword">ENGINE</span> = MergeTree
<span class="hljs-keyword">ORDER</span> <span class="hljs-keyword">BY</span> tuple()
</code></pre>
<p>Let's see if we get the table created. To see the list of tables in our ClickHouse client run the below query.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SHOW</span> <span class="hljs-keyword">TABLES</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1716689818817/b15b0019-40d1-4d61-a336-9896d93dd92e.png" alt class="image--center mx-auto" /></p>
<p>Now, let's insert some data in the table.</p>
<pre><code class="lang-sql"><span class="hljs-keyword">INSERT</span> <span class="hljs-keyword">INTO</span> <span class="hljs-keyword">TEST</span> (*) <span class="hljs-keyword">FORMAT</span> <span class="hljs-keyword">Values</span>
(<span class="hljs-number">1</span>, <span class="hljs-string">'Siddhant'</span>, <span class="hljs-string">'password'</span>, <span class="hljs-string">'test description'</span>), 
(<span class="hljs-number">2</span>, <span class="hljs-string">'user2'</span>, <span class="hljs-string">'password2'</span>, <span class="hljs-string">'test description 2'</span>), 
(<span class="hljs-number">3</span>, <span class="hljs-string">'user3'</span>, <span class="hljs-string">'password3'</span>, <span class="hljs-string">'test description 3'</span>)
</code></pre>
<p>To see the data run select the query</p>
<pre><code class="lang-sql"><span class="hljs-keyword">SELECT</span> * <span class="hljs-keyword">FROM</span> <span class="hljs-keyword">TEST</span>
</code></pre>
<p>You will see the following result</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1711277497852/8c7fb4c9-90e3-4479-9b6c-de098388897a.png" alt class="image--center mx-auto" /></p>
<p>At the end of each query, ClickHouse shows how much time it took to process the given query. Additionally, it displays how many rows ClickHouse processed per second to execute the query.</p>
<p>This is how you can run ClickHouse locally. Please let me know if this blog was helpful, and if you have any doubts, write them down in the comments section. I will do my best to answer them.  </p>
<p>More about clickhouse:<br /><a target="_blank" href="https://blog.siddhantbobde.com/clickhouse-csv-ingestion-with-python-explicit-schema">https://blog.siddhantbobde.com/clickhouse-csv-ingestion-with-python-explicit-schema</a></p>
]]></content:encoded></item><item><title><![CDATA[Advantages and Disadvantages of Github Copilot]]></title><description><![CDATA[Hello everyone, today I'm going to discuss the advantages and disadvantages of GitHub Copilot, a tool I've been using for over 6 months. Let's dive right in.
What is GitHub Copilot?

GitHub Copilot is an AI-powered code completion tool developed by G...]]></description><link>https://blog.siddhantbobde.com/advantages-and-disadvantages-of-github-copilot</link><guid isPermaLink="true">https://blog.siddhantbobde.com/advantages-and-disadvantages-of-github-copilot</guid><category><![CDATA[AI]]></category><category><![CDATA[github copilot]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sun, 10 Mar 2024 13:50:54 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1719906421221/98cb456f-5a62-4e60-b3f7-ea53b06df07e.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello everyone, today I'm going to discuss the advantages and disadvantages of GitHub Copilot, a tool I've been using for over 6 months. Let's dive right in.</p>
<h3 id="heading-what-is-github-copilot"><strong>What is GitHub Copilot?</strong></h3>
<ul>
<li><p>GitHub Copilot is an AI-powered code completion tool developed by GitHub in collaboration with OpenAI. It's built on OpenAI’s Codex technology, trained on a vast amount of publicly available code.</p>
</li>
<li><p>Copilot seamlessly integrates with your IDEs like VSCode, PyCharm, IntelliJ, etc., assisting developers by suggesting code completions, generating whole lines or blocks of code, and providing contextual documentation.</p>
</li>
</ul>
<h3 id="heading-what-are-the-advantages-of-github-copilot"><strong>What are the advantages of GitHub Copilot?</strong></h3>
<ul>
<li><p>GitHub Copilot suggests code snippets as you write your code.</p>
</li>
<li><p>It automates repetitive tasks, making it a great time saver.</p>
</li>
<li><p>You can use it for code commenting; it reads your code and adds comments about what each section does.</p>
</li>
<li><p>It even suggests entire code blocks for the file that fits the context of what the programmer is working on.</p>
</li>
</ul>
<h3 id="heading-what-are-the-disadvantages-of-github-copilot"><strong>What are the disadvantages of GitHub Copilot?</strong></h3>
<ul>
<li><p>The major disadvantage of GitHub Copilot is for beginner developers or those starting with a new language. Because Copilot suggests code snippets as you code, you may not develop as strong a grasp of syntax as you would without it.</p>
</li>
<li><p>Code suggestions from GitHub Copilot can be distracting when trying to build logic.</p>
</li>
<li><p>It can provide unoptimized, inefficient, or even insecure code. Therefore, you always need to double-check before finalizing the code.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[ChatGPT for Tech and Non-Tech People]]></title><description><![CDATA[Welcome, tech enthusiasts! Many of you are likely familiar with the incredible capabilities of ChatGPT. However, if this is your first encounter with it, you're in for a treat! Today, we'll be diving into the world of ChatGPT and exploring its myriad...]]></description><link>https://blog.siddhantbobde.com/chatgpt-for-tech-and-non-tech-people</link><guid isPermaLink="true">https://blog.siddhantbobde.com/chatgpt-for-tech-and-non-tech-people</guid><category><![CDATA[chatgpt]]></category><category><![CDATA[Productivity]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Mon, 13 Nov 2023 04:13:06 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1695918356751/a4703181-3a31-44fa-9140-3023041dcfdd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Welcome, tech enthusiasts! Many of you are likely familiar with the incredible capabilities of ChatGPT. However, if this is your first encounter with it, you're in for a treat! Today, we'll be diving into the world of ChatGPT and exploring its myriad applications that can greatly assist you in various tasks.</p>
<p>So, whether you're already acquainted with this powerful tool or it's a discovery for you, go through this blog as we uncover the potential of ChatGPT and how it can help you in your workflow. Let's jump right in!</p>
<h3 id="heading-what-is-chatgpt"><strong>What is ChatGPT</strong></h3>
<p>In the ever-evolving field of artificial intelligence, ChatGPT has emerged as a powerful tool, revolutionizing the way we interact with technology. Developed by OpenAI, ChatGPT is built on the GPT-3.5 architecture, capable of understanding and generating human-like text.</p>
<p>Its applications span a wide array of fields, from content creation to customer support. Let's dive into the various ways we can use ChatGPT to enhance our productivity.</p>
<h3 id="heading-content-creation-and-copywriting">Content Creation and Copywriting</h3>
<p><strong>Generating Ideas:</strong> ChatGPT can help brainstorm ideas for blog posts, articles, advertisements, and other types of content.</p>
<p><strong>Creating Attractive Headlines:</strong> It can assist you in creating attractive headlines to target the potential market.</p>
<p><strong>SEO optimization:</strong> It can provide you with different keywords to improve your search engine optimization.</p>
<p><strong>Marketing:</strong> You can brainstorm with ChatGPT for different marketing schemes.</p>
<p>Suppose you need a slogan for your company, and you're seeking suggestions. You can describe your company's offerings, and ChatGPT will promptly provide you with some compelling options.</p>
<p>For instance, consider a company specializing in producing healthy bread. They're in search of a fitting slogan for their brand. Below are the suggestions provided by ChatGPT.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695916430620/c8dd70ee-8f35-44ca-a6ed-04f882419e7b.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-learning-and-education">Learning and Education</h3>
<p>In the realm of education, ChatGPT serves as a valuable resource.</p>
<p><strong>Tutoring</strong>: ChatGPT can provide personalized assistance in various subjects. You can ask questions, seek explanations, or request help with problems related to your studies. Many Language learning platforms have also integrated ChatGPT to facilitate interactive practice and conversation.</p>
<p><strong>Concept Clarification</strong>: If you're struggling to understand a concept, you can ask ChatGPT for a simplified explanation or examples to help you grasp it better.</p>
<p><strong>Language Learning</strong>: ChatGPT can help with language learning by providing vocabulary explanations, sentence structure examples, and even engaging in conversations to practice language skills.</p>
<p><strong>Writing Assistance</strong>: It can assist with writing tasks, offering suggestions for grammar, style, and content. It can also help generate outlines or brainstorm ideas. Suppose you are writing a research paper. You can give ChatGPT your abstract from the research paper and ask it to make it shorter, correct grammatical errors, or even expand it.</p>
<p><strong>Research:</strong> ChatGPT can help and summarize information on a wide range of topics. It can be a useful tool for gathering data for projects and essays.</p>
<p><strong>Interviewer:</strong> Suppose you are getting ready for a job interview as an English teacher. You can request ChatGPT to conduct a mock interview for the English teaching position.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695917704107/78089494-a14d-4d9a-b8d9-a77eaecae120.png" alt class="image--center mx-auto" /></p>
<p>You can type your answer and the ChatGPT will examine your answer and will give you some tips for better answers or some other suggestions as well.</p>
<p>Now just type the next question and ChatGPT will ask you the next question. You can also tell ChatGPT to increase or decrease the difficulty of questions based on your answer.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1695917887100/7402db86-a560-4a82-af60-9d124fbb1886.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-programming">Programming</h3>
<p><strong>Code Assistance:</strong> Developers and programmers find ChatGPT immensely helpful in their work. It can assist in writing code snippets, debugging, and providing explanations for complex programming concepts.</p>
<p><strong>Learning:</strong> If you are learning new technologies, you can use ChatGPT to ask questions about concepts you're struggling with. It can provide explanations clearly and understandably.</p>
<p><strong>Data Structures and Algorithms:</strong> It can help you understand and implement algorithms and data structures, which are fundamental to programming. You can dry-run the code you wrote for debugging.</p>
<p><strong>Pseudocode Generation:</strong> If you're planning out an algorithm, ChatGPT can help you generate pseudocode to outline your approach.</p>
<p><strong>Code Review:</strong> You can share snippets of your code with ChatGPT, and it can offer feedback on style, and potential issues, or suggest improvements.</p>
<p><strong>Documentation:</strong> If you need to document your code, ChatGPT can help you with generating clear and concise explanations.</p>
<p><strong>Code Explanation:</strong> Suppose you are unable to understand some code. You can either go to Google and search for the code bit by bit, or you can provide a code snippet to ChatGPT, which will give you a complete explanation of the code.</p>
<h3 id="heading-creative-writing-and-storytelling">Creative Writing and Storytelling</h3>
<p><strong>Prompt Generation</strong>: You can ask ChatGPT to generate writing prompts to kickstart your creativity. It can provide ideas for different genres, themes, or styles of writing.</p>
<p><strong>Character Development</strong>: ChatGPT can assist in creating new characters by providing details about their backgrounds, personalities, motivations, and quirks.</p>
<p><strong>Feedback and Editing</strong>: It can offer suggestions for improving grammar, style, and coherence.</p>
<p><strong>Genre-specific Assistance</strong>: ChatGPT can provide specialized help for different genres such as science fiction, fantasy, mystery, romance, and more.</p>
<h3 id="heading-language-translation">Language Translation</h3>
<p><strong>Text Translation</strong>: You can input text in one language and request a translation into another language. Keep in mind that while ChatGPT can provide translations, it might not always be as accurate as specialized translation tools.</p>
<p><strong>Learning New Languages</strong>: ChatGPT can assist with learning new languages by providing translations, grammar explanations, and even offering practice exercises.</p>
]]></content:encoded></item><item><title><![CDATA[Elevate Your Styling with SASS]]></title><description><![CDATA[What is SASS
Sass stands for "Syntactically Awesome Stylesheets." It is a preprocessor scripting language that is interpreted or compiled into Cascading Style Sheets (CSS). SassScript is the scripting language itself.
Sass extends the CSS by adding f...]]></description><link>https://blog.siddhantbobde.com/elevate-your-styling-with-sass</link><guid isPermaLink="true">https://blog.siddhantbobde.com/elevate-your-styling-with-sass</guid><category><![CDATA[Web Development]]></category><category><![CDATA[Sass]]></category><category><![CDATA[CSS3]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Mon, 02 Oct 2023 11:39:10 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1699848902770/10d5bfa1-fe01-48fa-b18c-9d0230cd920e.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-what-is-sass">What is SASS</h2>
<p>Sass stands for "Syntactically Awesome Stylesheets." It is a preprocessor scripting language that is interpreted or compiled into Cascading Style Sheets (CSS). SassScript is the scripting language itself.</p>
<p>Sass extends the CSS by adding features like <strong>variables, nested rules, and mixins</strong>. This allows for more modular, maintainable, and organized stylesheets. It also introduces concepts like inheritance and control directives, which are not present in standard CSS. We create sass files with an extension of <code>'.scss'</code></p>
<h2 id="heading-features-of-sass">Features of SASS</h2>
<h3 id="heading-sass-variables">Sass Variables</h3>
<p>You can store common styles in sass variables like colors, font-sizes, widths, etc. You can make a common <code>'variable.scss'</code> file and store all necessary variables in it. So that you can use it later wherever you need it.</p>
<pre><code class="lang-scss"><span class="hljs-variable">$font-size</span>: <span class="hljs-number">12px</span>;
<span class="hljs-variable">$white-color</span>: white;

<span class="hljs-selector-tag">h1</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-variable">$font-size</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-variable">$white-color</span>;
}
</code></pre>
<h3 id="heading-nesting">Nesting</h3>
<p>Nesting in Sass refers to the practice of placing selectors inside one another in a way that mirrors the structure of the HTML. This makes the CSS more readable and helps organize styles in a logical hierarchy.</p>
<p>CSS code</p>
<pre><code class="lang-css"><span class="hljs-selector-tag">nav</span> {
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#333</span>;
}

<span class="hljs-selector-tag">nav</span> <span class="hljs-selector-tag">ul</span> {
    <span class="hljs-attribute">list-style-type</span>: none;
    <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;
}

<span class="hljs-selector-tag">nav</span> <span class="hljs-selector-tag">ul</span> <span class="hljs-selector-tag">li</span> {
    <span class="hljs-attribute">display</span>: inline-block;
    <span class="hljs-attribute">margin-right</span>: <span class="hljs-number">10px</span>;
}
</code></pre>
<p>The resulting SCSS code</p>
<pre><code class="lang-scss"><span class="hljs-selector-tag">nav</span> {
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#333</span>;

    <span class="hljs-selector-tag">ul</span> {
        <span class="hljs-attribute">list-style-type</span>: none;
        <span class="hljs-attribute">padding</span>: <span class="hljs-number">0</span>;

        <span class="hljs-selector-tag">li</span> {
            <span class="hljs-attribute">display</span>: inline-block;
            <span class="hljs-attribute">margin-right</span>: <span class="hljs-number">10px</span>;
        }
    }
}
</code></pre>
<p>As you can see, we nested all the elements inside one another, just like in HTML. This makes the code more readable and understandable.</p>
<h3 id="heading-mixins">Mixins</h3>
<p>A mixin in Sass is a way to group together a set of CSS declarations and reuse them throughout your stylesheet. It's like a function in programming, allowing you to define a set of styles once and apply them multiple times in different parts of your code.</p>
<p>Here's an example of a basic mixin in Sass:</p>
<pre><code class="lang-scss"><span class="hljs-comment">//You can pass paramters to a mixin.</span>
<span class="hljs-keyword">@mixin</span> border-radius(<span class="hljs-variable">$radius</span>) {
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-variable">$radius</span>;
    -webkit-<span class="hljs-attribute">border-radius</span>: <span class="hljs-variable">$radius</span>;
    -moz-<span class="hljs-attribute">border-radius</span>: <span class="hljs-variable">$radius</span>;
}

<span class="hljs-selector-class">.button</span> {
    <span class="hljs-comment">// To use a mixin you need to use @include and then the mixin name.</span>
    <span class="hljs-keyword">@include</span> border-radius(<span class="hljs-number">5px</span>);
    <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#007bff</span>;
    <span class="hljs-attribute">color</span>: <span class="hljs-number">#ffffff</span>;
}
</code></pre>
<p>After compilation of the above SCSS file into CSS it will just replace the mixin with its code by putting paramter value at appropriate places.</p>
<h3 id="heading-control-directives-if-else-if-else">Control Directives - <code>@if, @else if, @else</code></h3>
<p>The <code>@if</code>, <code>@else if</code>, and <code>@else</code> control directives in Sass allow you to apply styles conditionally based on certain conditions. They work similarly to conditional statements in programming languages.</p>
<pre><code class="lang-scss"><span class="hljs-keyword">@mixin</span> select-width(<span class="hljs-variable">$device</span>) {
    <span class="hljs-selector-class">.button</span> {
        <span class="hljs-keyword">@if</span> <span class="hljs-variable">$device</span> == <span class="hljs-string">"mobile"</span> {
            <span class="hljs-attribute">width</span>: <span class="hljs-number">90%</span>;
        }

        <span class="hljs-keyword">@else</span> if <span class="hljs-variable">$device</span> == <span class="hljs-string">"laptop"</span> {
            <span class="hljs-attribute">width</span>: <span class="hljs-number">70%</span>;
        }

        <span class="hljs-keyword">@else</span> {
            <span class="hljs-attribute">width</span>: <span class="hljs-number">60%</span>;
        }
    }
}
</code></pre>
<h3 id="heading-control-directive-for">Control Directive - <code>@for</code></h3>
<p>The <code>@for</code> control directive in Sass allows you to iterate over a range of values and generate styles based on those values. It works similar to a for loop in programming languages.</p>
<p><strong>Syntax</strong></p>
<pre><code class="lang-scss"><span class="hljs-comment">//end is excluded if you use "start to end"</span>
<span class="hljs-keyword">@for</span> <span class="hljs-variable">$var</span> from (start) to (end) {
  <span class="hljs-comment">// Styles to apply</span>
}

<span class="hljs-comment">//end is included if you use "start through end"</span>
<span class="hljs-keyword">@for</span> <span class="hljs-variable">$var</span> from (start) through (end) {
  <span class="hljs-comment">// Styles to apply</span>
}
</code></pre>
<p><strong>Example</strong></p>
<pre><code class="lang-scss"><span class="hljs-keyword">@for</span> <span class="hljs-variable">$i</span> from <span class="hljs-number">1</span> through <span class="hljs-number">3</span> {
    <span class="hljs-selector-class">.p-</span>#{<span class="hljs-variable">$i</span>} {
        <span class="hljs-attribute">font-size</span>: <span class="hljs-number">10px</span> + <span class="hljs-variable">$i</span> * <span class="hljs-number">2</span>;
    }
}
</code></pre>
<p>The resulting CSS would look like this:</p>
<pre><code class="lang-css"><span class="hljs-selector-class">.p-1</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">12px</span>;
}

<span class="hljs-selector-class">.p-2</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">14px</span>;
}

<span class="hljs-selector-class">.p-3</span> {
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">16px</span>;
}
</code></pre>
<h3 id="heading-control-directive-while">Control Directive - <code>@while</code></h3>
<p>The <code>@while</code> directive in Sass allows you to create a loop that continues as long as a specified condition is true. It's similar to a <code>while</code> loop in many programming languages.</p>
<p><strong>Syntax</strong></p>
<pre><code class="lang-scss"><span class="hljs-keyword">@while</span> &lt;condition&gt; {
  <span class="hljs-comment">// Styles to apply</span>
}
</code></pre>
<p><strong>Example</strong></p>
<pre><code class="lang-scss"><span class="hljs-variable">$var</span>: <span class="hljs-number">1</span>; <span class="hljs-comment">// Initialize a variable just like other programming languages.</span>

<span class="hljs-comment">//Set a condition</span>
<span class="hljs-keyword">@while</span> <span class="hljs-variable">$var</span>&lt;=<span class="hljs-number">3</span> {
    <span class="hljs-selector-class">.div-</span>#{<span class="hljs-variable">$var</span>} {
        <span class="hljs-attribute">width</span>: <span class="hljs-number">100px</span> * <span class="hljs-variable">$var</span>;
    }

    <span class="hljs-comment">// Increment the var</span>
    <span class="hljs-variable">$var</span>: <span class="hljs-variable">$var</span>+ <span class="hljs-number">1</span>;
}
</code></pre>
<p>The resulting CSS would look like this:</p>
<pre><code class="lang-scss"><span class="hljs-selector-class">.div-1</span> {
    <span class="hljs-attribute">width</span>: <span class="hljs-number">100px</span>;
}

<span class="hljs-selector-class">.div-2</span> {
    <span class="hljs-attribute">width</span>: <span class="hljs-number">200px</span>;
}

<span class="hljs-selector-class">.div-3</span> {
    <span class="hljs-attribute">width</span>: <span class="hljs-number">300px</span>;
}
</code></pre>
<h3 id="heading-control-directive-each">Control Directive - <code>@each</code></h3>
<p>The <code>@each</code> directive in Sass allows you to loop over lists or maps and apply styles for each item in the list or map. It's a powerful feature that enables you to generate repetitive styles based on a set of values.</p>
<p><strong>Syntax For List</strong></p>
<pre><code class="lang-scss"><span class="hljs-keyword">@each</span> <span class="hljs-variable">$var</span> in (list) {
  <span class="hljs-comment">// Styles to apply</span>
}
</code></pre>
<p><strong>Example</strong></p>
<pre><code class="lang-scss"><span class="hljs-variable">$colors</span>: red, green, blue, yellow;

<span class="hljs-keyword">@each</span> <span class="hljs-variable">$color</span> in <span class="hljs-variable">$colors</span> {
    <span class="hljs-selector-class">.element-</span>#{<span class="hljs-variable">$color</span>} {
        <span class="hljs-attribute">background-color</span>: <span class="hljs-variable">$color</span>;
    }
}
</code></pre>
<p><strong>Syntax for Map</strong></p>
<pre><code class="lang-scss"><span class="hljs-keyword">@each</span> <span class="hljs-variable">$key</span>, <span class="hljs-variable">$value</span> in (Map) {
    <span class="hljs-comment">// Styles to apply</span>
}
</code></pre>
<p><strong>Example</strong></p>
<pre><code class="lang-scss"><span class="hljs-variable">$font-sizes</span>: (
    small: <span class="hljs-number">12px</span>,
    medium: <span class="hljs-number">16px</span>,
    large: <span class="hljs-number">20px</span>
);

<span class="hljs-keyword">@each</span> <span class="hljs-variable">$size</span>, <span class="hljs-variable">$value</span> in <span class="hljs-variable">$font-sizes</span> {
    <span class="hljs-selector-class">.font-</span>#{<span class="hljs-variable">$size</span>} {
        <span class="hljs-attribute">font-size</span>: <span class="hljs-variable">$value</span>;
    }
}
</code></pre>
<h3 id="heading-control-directive-extend">Control Directive - <code>@extend</code></h3>
<p>The <code>@extend</code> directive in Sass is used for inheritance, allowing one selector to inherit the styles of another selector. This can help reduce duplication in your stylesheets and make your code more maintainable.</p>
<p><strong>Syntax</strong></p>
<pre><code class="lang-scss"><span class="hljs-selector-class">.selector</span> {
    property: value;
    <span class="hljs-keyword">@extend</span> .other-selector;
}
</code></pre>
<p><strong>Example</strong></p>
<pre><code class="lang-scss"><span class="hljs-selector-class">.button-1</span> {
    <span class="hljs-attribute">border-radius</span>: <span class="hljs-number">10px</span>;
    <span class="hljs-attribute">color</span>: white;
    <span class="hljs-attribute">background-color</span>: green;
}

<span class="hljs-selector-class">.button-2</span> {
    <span class="hljs-keyword">@extend</span> .button-<span class="hljs-number">1</span>;
    <span class="hljs-attribute">font-size</span>: <span class="hljs-number">15px</span>;
    <span class="hljs-attribute">font-weight</span>: bold;
}
</code></pre>
<h2 id="heading-partials-and-importing">Partials And Importing</h2>
<p>In Sass, a partial is a Sass file that is intended to be imported into another Sass file. It's a way to break up your stylesheets into smaller, more manageable pieces. Partial files in Sass are denoted by an underscore <code>_</code> at the beginning of the filename.</p>
<p>For example, you can create a common <code>_variables.scss</code> partial file and use it wherever you want. You can also create a common <code>_mixins.scss</code> file which contains all the mixins</p>
<p>For importing partial files you need to use <code>@import</code> directive with name of file in quotes. You don't include the underscore or the file extension in the import statement.</p>
<pre><code class="lang-scss"><span class="hljs-keyword">@import</span> <span class="hljs-string">'variables'</span>;
<span class="hljs-keyword">@import</span> <span class="hljs-string">'mixins'</span>;
</code></pre>
<p>In conclusion, Sass is a powerful tool that can greatly enhance your CSS workflow. Its features, such as variables, nesting, mixins, and more, allow for more maintainable and organized stylesheets.</p>
<p>You can suggest any topics you think I should include in the above blog by leaving a comment💬. If you found my article useful, please give it a like❤.</p>
]]></content:encoded></item><item><title><![CDATA[How I Learned Touch Tying]]></title><description><![CDATA[Hello everyone! Today, I will share my journey of how I learned touch typing, the motivation behind it, and the resources I used to achieve proficiency in touch typing.
I began learning touch typing in September 2020. Over the course of around 8 to 9...]]></description><link>https://blog.siddhantbobde.com/how-i-learned-touch-tying</link><guid isPermaLink="true">https://blog.siddhantbobde.com/how-i-learned-touch-tying</guid><category><![CDATA[touch typing]]></category><category><![CDATA[Skill]]></category><category><![CDATA[coding]]></category><category><![CDATA[Blogging]]></category><category><![CDATA[Programming Blogs]]></category><dc:creator><![CDATA[SIDDHANT BOBDE]]></dc:creator><pubDate>Sun, 10 Sep 2023 09:44:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1694146950939/977a46a5-3d4f-4540-9c0c-14da3e5913fd.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello everyone! Today, I will share my journey of how I learned touch typing, the motivation behind it, and the resources I used to achieve proficiency in touch typing.</p>
<p>I began learning touch typing in September 2020. Over the course of around 8 to 9 months, I practiced on and off, dedicating approximately 10-30 minutes per day. Eventually, I reached a speed of 75 words per minute.</p>
<p>As a computer engineer, coding is a significant part of my daily routine, and I wanted to enhance my speed while coding. Additionally, as a blogger, touch typing has proven to be a significant time-saver.</p>
<h3 id="heading-resources-i-used">Resources I used</h3>
<p>There are three main resources that I utilized, and continue to use, whenever I want to improve my touch typing:</p>
<ol>
<li><p><a target="_blank" href="https://www.typingclub.com/">typingclub</a></p>
<p> This website offers both free and paid versions. While the paid version provides additional lessons and interactive games, I found the free version to be more than sufficient. It covers all the lessons with video tutorials, making it an excellent starting point for anyone looking to learn touch typing.</p>
</li>
<li><p><a target="_blank" href="https://www.keybr.com/">keybr</a></p>
<p> Keybr is primarily used for typing practice. It identifies the mistakes you make while typing certain letters or words and presents them more frequently, helping you become more comfortable with those specific characters.</p>
<p> Additionally, you can include capital letters and other punctuation characters for practice. The website also provides a comprehensive progress profile, including heatmaps, graphs, and comparisons of your typing speed against other users.</p>
</li>
<li><p><a target="_blank" href="https://www.typelit.io/">typelit</a></p>
<p> This website allows you to practice typing entire books listed on their platform. You progress through the book page by page, and afterward, it provides statistics on your average typing speed and accuracy for that page.</p>
</li>
</ol>
<p>The image below illustrates the days on which I practiced touch typing. The darker the color, the more time I spent typing.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1694057372763/74270e79-1d4d-4781-bed7-fcb5255d1599.png" alt="Days on calendar where I practiced touch typing" class="image--center mx-auto" /></p>
<p>You can try the resources I mentioned to learn touch typing. If you have any suggestions or questions, feel free to share them in the comment section.</p>
]]></content:encoded></item></channel></rss>