<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-IN"><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://how-to-do.online/feed.xml" rel="self" type="application/atom+xml" /><link href="https://how-to-do.online/" rel="alternate" type="text/html" hreflang="en-IN" /><updated>2026-05-11T06:53:21+00:00</updated><id>https://how-to-do.online/feed.xml</id><title type="html">How To Do</title><subtitle>Free online calculators, converters, and developer tools. EMI, SIP, BMI, unit converter, JSON formatter, and 40+ more tools, no sign-up required.</subtitle><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><entry><title type="html">How to Debug with Regex: Real-World Examples</title><link href="https://how-to-do.online/blog/debugging-with-regex/" rel="alternate" type="text/html" title="How to Debug with Regex: Real-World Examples" /><published>2026-04-12T00:00:00+00:00</published><updated>2026-04-12T00:00:00+00:00</updated><id>https://how-to-do.online/blog/debugging-with-regex</id><content type="html" xml:base="https://how-to-do.online/blog/debugging-with-regex/"><![CDATA[<p>Regex isn’t just for form validation. It’s a debugging power tool. When you’re staring at thousands of log lines or need to extract patterns from messy data, regex cuts through the noise faster than any other approach.</p>

<h2 id="1-finding-errors-in-log-files">1. Finding Errors in Log Files</h2>

<p>You have a 50,000-line log file. You need all errors with their timestamps.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.*ERROR.*
</code></pre></div></div>

<p>This grabs every line containing “ERROR” that starts with an ISO timestamp. With <code class="language-plaintext highlighter-rouge">grep -P</code> or your editor’s search, you go from 50,000 lines to the 12 that matter.</p>

<p><strong>Level up</strong>: capture the error message:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\d{4}-\d{2}-\d{2}T[\d:]+.*ERROR\s+(.*)
</code></pre></div></div>
<p>Group 1 gives you just the error messages, stripped of timestamps and metadata.</p>

<h2 id="2-extracting-ids-from-messy-data">2. Extracting IDs from Messy Data</h2>

<p>Your API returns user IDs in different formats across endpoints:</p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">"user_id": "USR-12345"</code></li>
  <li><code class="language-plaintext highlighter-rouge">"userId": 67890</code></li>
  <li><code class="language-plaintext highlighter-rouge">user_id=USR-99999</code></li>
</ul>

<p>One regex catches all of them:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(?:user_?[Ii]d)["\s:=]+(?:"?)([A-Z]*-?\d+)
</code></pre></div></div>

<h2 id="3-finding-slow-database-queries">3. Finding Slow Database Queries</h2>

<p>Database logs often include execution time:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Query completed in 1523ms: SELECT * FROM users WHERE...
Query completed in 45ms: SELECT id FROM products WHERE...
Query completed in 8920ms: SELECT * FROM orders JOIN...
</code></pre></div></div>

<p>Find queries over 1 second:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>completed in (\d{4,})ms
</code></pre></div></div>

<p><code class="language-plaintext highlighter-rouge">\d{4,}</code> matches 4 or more digits, meaning 1000ms or more.</p>

<h2 id="4-refactoring-code-patterns">4. Refactoring Code Patterns</h2>

<p>Need to convert all <code class="language-plaintext highlighter-rouge">console.log</code> statements to use a logger?</p>

<p>Find:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>console\.log\((['"`].*?['"`])\)
</code></pre></div></div>

<p>Replace with:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>logger.info($1)
</code></pre></div></div>

<p>Most editors support regex find-and-replace. This handles thousands of instances in one operation.</p>

<h2 id="5-validating-data-integrity">5. Validating Data Integrity</h2>

<p>You suspect some records in a CSV have malformed email addresses:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>^[^,]+,(?![\w.+-]+@[\w-]+\.[\w.]+,)
</code></pre></div></div>

<p>Using a negative lookahead <code class="language-plaintext highlighter-rouge">(?!...)</code>, this matches rows where the second column (assuming email) doesn’t match a valid email pattern.</p>

<h2 id="6-parsing-stack-traces">6. Parsing Stack Traces</h2>

<p>Extract file names and line numbers from a Python stack trace:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>File "([^"]+)", line (\d+)
</code></pre></div></div>

<p>Group 1: file path. Group 2: line number. Feed this into a script and you have an automated stack trace parser.</p>

<h2 id="7-finding-hardcoded-secrets">7. Finding Hardcoded Secrets</h2>

<p>Scan your codebase for potential API keys and tokens:</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(?:api[_-]?key|token|secret|password)\s*[=:]\s*["']([^"']+)["']
</code></pre></div></div>

<p>This isn’t foolproof, but it’s a solid first pass that catches the obvious ones.</p>

<h2 id="8-cleaning-data">8. Cleaning Data</h2>

<p>Remove all HTML tags from text:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;[^&gt;]+&gt;
</code></pre></div></div>

<p>Strip multiple spaces to single:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\s{2,}
</code></pre></div></div>
<p>Replace with a single space.</p>

<p>Remove non-ASCII characters:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[^\x00-\x7F]
</code></pre></div></div>

<h2 id="practical-tips">Practical Tips</h2>

<ol>
  <li><strong>Build incrementally.</strong> Start with a loose pattern, check what matches, then tighten it.</li>
  <li><strong>Use a tester tool.</strong> Real-time highlighting shows exactly what your pattern captures.</li>
  <li><strong>Anchor when possible.</strong> <code class="language-plaintext highlighter-rouge">^</code> and <code class="language-plaintext highlighter-rouge">$</code> prevent unexpected partial matches.</li>
  <li><strong>Be lazy, not greedy.</strong> Use <code class="language-plaintext highlighter-rouge">.*?</code> instead of <code class="language-plaintext highlighter-rouge">.*</code> when you want the shortest match.</li>
  <li><strong>Test with edge cases.</strong> The line that breaks your regex is the most valuable test case.</li>
</ol>

<h2 id="the-pattern">The Pattern</h2>

<p>Most debugging regex follows the same structure: timestamp/context pattern + separator + the thing you actually care about. Master this template and you can construct a useful pattern in under a minute.</p>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Tech / Dev" /><summary type="html"><![CDATA[Practical examples of using regex for log analysis, data extraction, code refactoring, and debugging production issues.]]></summary></entry><entry><title type="html">Time Zone Math for Remote Teams: A Practical Guide</title><link href="https://how-to-do.online/blog/timezone-math-remote-teams/" rel="alternate" type="text/html" title="Time Zone Math for Remote Teams: A Practical Guide" /><published>2026-04-12T00:00:00+00:00</published><updated>2026-04-12T00:00:00+00:00</updated><id>https://how-to-do.online/blog/timezone-math-remote-teams</id><content type="html" xml:base="https://how-to-do.online/blog/timezone-math-remote-teams/"><![CDATA[<p>Working across time zones is the tax of remote work. Here’s how to pay it efficiently.</p>

<h2 id="the-utc-anchor">The UTC Anchor</h2>

<p>Stop thinking in local times. Think in UTC offsets.</p>

<ul>
  <li>IST (India) = UTC+5:30</li>
  <li>ET (US East) = UTC-5 (or UTC-4 during daylight saving)</li>
  <li>PT (US West) = UTC-8 (or UTC-7 during DST)</li>
  <li>GMT (UK) = UTC+0 (or UTC+1 during BST)</li>
  <li>JST (Japan) = UTC+9</li>
  <li>AEST (Australia) = UTC+10 (or UTC+11 during DST)</li>
</ul>

<p>When someone says “Let’s meet at 2pm,” the first question is: whose 2pm?</p>

<h2 id="finding-overlap">Finding Overlap</h2>

<p>The overlap window between two time zones is where real-time collaboration happens. Everything else should be async.</p>

<p><strong>India (IST) and US East (ET)</strong>: 10.5 hour difference.</p>
<ul>
  <li>If both work 9am-6pm:</li>
  <li>IST 9am = ET 10:30pm (previous day)</li>
  <li>IST 6pm = ET 7:30am</li>
  <li>ET 9am = IST 7:30pm</li>
  <li>Overlap: IST 7:30pm-9pm / ET 9am-10:30am (about 1.5 hours)</li>
</ul>

<p><strong>India and US West (PT)</strong>: 13.5 hour difference.</p>
<ul>
  <li>Overlap is painful. IST 9:30pm = PT 9am.</li>
  <li>Realistic overlap: maybe 30 minutes if someone stretches.</li>
</ul>

<p><strong>India and UK (GMT)</strong>: 5.5 hour difference.</p>
<ul>
  <li>Good overlap: IST 1:30pm-6pm / UK 9am-12:30pm (3.5 hours)</li>
</ul>

<h2 id="scheduling-meetings">Scheduling Meetings</h2>

<h3 id="rule-1-rotate-the-pain">Rule 1: Rotate the pain</h3>
<p>If the meeting is always at a bad time for the same team, resentment builds. Alternate between time slots that inconvenience different groups.</p>

<h3 id="rule-2-anchor-to-the-smallest-overlap">Rule 2: Anchor to the smallest overlap</h3>
<p>If your overlap is 1.5 hours, protect it. Don’t waste it on status updates that could be async. Use synchronous time for decisions, brainstorming, and relationship-building.</p>

<h3 id="rule-3-always-include-the-time-zone">Rule 3: Always include the time zone</h3>
<p>“Meeting at 3pm” is ambiguous. “Meeting at 3pm ET / 12:30am IST” is not. Even better: share a link that converts to local time (Google Calendar does this automatically).</p>

<h3 id="rule-4-account-for-daylight-saving">Rule 4: Account for daylight saving</h3>
<p>The US, Europe, and Australia change clocks on different dates. For 2-3 weeks per year, your carefully calculated offsets are wrong by an hour. Set calendar reminders around DST transitions.</p>

<h2 id="the-async-first-approach">The Async-First Approach</h2>

<p>Time zone overlap is precious and limited. Maximize it by making everything possible async:</p>

<ul>
  <li><strong>Decisions</strong>: Write proposals in documents. Collect feedback async. Use meetings only to resolve disagreements.</li>
  <li><strong>Updates</strong>: Record 3-minute Loom videos instead of calling meetings.</li>
  <li><strong>Code reviews</strong>: Written comments, not live walkthroughs.</li>
  <li><strong>Questions</strong>: Post in Slack/Teams with context. Don’t expect instant replies.</li>
</ul>

<h2 id="quick-conversion-tricks">Quick Conversion Tricks</h2>

<h3 id="ist-to-et">IST to ET</h3>
<p>Subtract 10.5 hours (subtract 11, add 30 min). IST 3pm = ET 4:30am.</p>

<h3 id="ist-to-pt">IST to PT</h3>
<p>Subtract 13.5 hours. IST 3pm = PT 1:30am.</p>

<h3 id="ist-to-gmt">IST to GMT</h3>
<p>Subtract 5.5 hours. IST 3pm = GMT 9:30am.</p>

<h3 id="the-noon-trick">The “noon trick”</h3>
<p>12:00 noon IST = 6:30am GMT = 1:30am ET = 10:30pm PT (previous day).</p>

<p>Memorize one anchor conversion for each zone pair you deal with regularly. Derive everything else from that.</p>

<h2 id="tools-that-help">Tools That Help</h2>

<ul>
  <li>Share a time zone converter link when scheduling</li>
  <li>Use Google Calendar (auto-converts time zones)</li>
  <li>Set a secondary clock on your phone for your team’s zone</li>
  <li>World clock widgets on your desktop</li>
</ul>

<p>The goal isn’t to make time zones disappear. It’s to make them a solved problem that doesn’t consume mental energy every day.</p>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Productivity" /><summary type="html"><![CDATA[Handle time zones without confusion: overlap calculations, meeting scheduling, and practical tips for distributed teams.]]></summary></entry><entry><title type="html">Understanding Color Spaces: HEX, RGB, HSL and When Each Matters</title><link href="https://how-to-do.online/blog/understanding-color-spaces/" rel="alternate" type="text/html" title="Understanding Color Spaces: HEX, RGB, HSL and When Each Matters" /><published>2026-04-12T00:00:00+00:00</published><updated>2026-04-12T00:00:00+00:00</updated><id>https://how-to-do.online/blog/understanding-color-spaces</id><content type="html" xml:base="https://how-to-do.online/blog/understanding-color-spaces/"><![CDATA[<p>Every color on your screen can be described in multiple ways. HEX, RGB, and HSL all describe the same colors, but they think about color differently. Understanding when to use each saves time and makes design work more intuitive.</p>

<h2 id="rgb-how-screens-think">RGB: How Screens Think</h2>

<p>RGB stands for Red, Green, Blue. Each channel ranges from 0 to 255.</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">rgb(255, 0, 0)</code> = pure red</li>
  <li><code class="language-plaintext highlighter-rouge">rgb(0, 255, 0)</code> = pure green</li>
  <li><code class="language-plaintext highlighter-rouge">rgb(0, 0, 255)</code> = pure blue</li>
  <li><code class="language-plaintext highlighter-rouge">rgb(255, 255, 255)</code> = white (all channels maxed)</li>
  <li><code class="language-plaintext highlighter-rouge">rgb(0, 0, 0)</code> = black (all channels off)</li>
</ul>

<p>RGB maps directly to how screens work: each pixel has red, green, and blue sub-pixels that combine to produce color. It’s the native language of displays.</p>

<p><strong>Good for</strong>: programmatic color manipulation, understanding how display hardware works, working with image data.</p>

<p><strong>Bad for</strong>: intuiting what a color looks like from its values. Quick: is <code class="language-plaintext highlighter-rouge">rgb(180, 120, 60)</code> warm or cool? Hard to tell without experience.</p>

<h2 id="hex-rgb-in-disguise">HEX: RGB in Disguise</h2>

<p>HEX is just RGB written in hexadecimal. <code class="language-plaintext highlighter-rouge">#FF0000</code> is <code class="language-plaintext highlighter-rouge">rgb(255, 0, 0)</code>.</p>

<p>The six characters are three pairs: <code class="language-plaintext highlighter-rouge">#RRGGBB</code>. Each pair is a hex value from 00 (0) to FF (255).</p>

<ul>
  <li><code class="language-plaintext highlighter-rouge">#FF0000</code> = red (FF red, 00 green, 00 blue)</li>
  <li><code class="language-plaintext highlighter-rouge">#00FF00</code> = green</li>
  <li><code class="language-plaintext highlighter-rouge">#FFFFFF</code> = white</li>
  <li><code class="language-plaintext highlighter-rouge">#000000</code> = black</li>
</ul>

<p>Shorthand: <code class="language-plaintext highlighter-rouge">#F00</code> expands to <code class="language-plaintext highlighter-rouge">#FF0000</code>.</p>

<p><strong>Good for</strong>: CSS (it’s the most common format), compact notation, copy-pasting between design tools and code.</p>

<p><strong>Bad for</strong>: same as RGB, it’s hard to mentally manipulate. Want a slightly lighter version of <code class="language-plaintext highlighter-rouge">#2563EB</code>? Good luck doing that in your head.</p>

<h2 id="hsl-how-humans-think">HSL: How Humans Think</h2>

<p>HSL stands for Hue, Saturation, Lightness.</p>

<ul>
  <li><strong>Hue</strong>: the color itself, expressed as a degree on a color wheel (0-360). 0 = red, 120 = green, 240 = blue.</li>
  <li><strong>Saturation</strong>: how vivid the color is (0% = gray, 100% = full color).</li>
  <li><strong>Lightness</strong>: how light or dark (0% = black, 50% = pure color, 100% = white).</li>
</ul>

<p><code class="language-plaintext highlighter-rouge">hsl(220, 83%, 53%)</code> is a vivid blue. You can tell because:</p>
<ul>
  <li>220 degrees is in the blue range</li>
  <li>83% saturation means it’s vivid</li>
  <li>53% lightness means it’s close to the pure color</li>
</ul>

<p><strong>Good for</strong>: designing color palettes, creating variations of a color, understanding color relationships.</p>

<h2 id="why-hsl-is-great-for-design">Why HSL Is Great for Design</h2>

<p>Want five shades of your brand blue?</p>

<p>In HEX, you’d need to look up or calculate each one:</p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">#1E40AF</code>, <code class="language-plaintext highlighter-rouge">#2563EB</code>, <code class="language-plaintext highlighter-rouge">#3B82F6</code>, <code class="language-plaintext highlighter-rouge">#60A5FA</code>, <code class="language-plaintext highlighter-rouge">#93C5FD</code></li>
</ul>

<p>In HSL, just change lightness:</p>
<ul>
  <li><code class="language-plaintext highlighter-rouge">hsl(220, 83%, 35%)</code> - dark</li>
  <li><code class="language-plaintext highlighter-rouge">hsl(220, 83%, 45%)</code> - medium dark</li>
  <li><code class="language-plaintext highlighter-rouge">hsl(220, 83%, 53%)</code> - base</li>
  <li><code class="language-plaintext highlighter-rouge">hsl(220, 83%, 65%)</code> - medium light</li>
  <li><code class="language-plaintext highlighter-rouge">hsl(220, 83%, 80%)</code> - light</li>
</ul>

<p>Same hue, same saturation, just sliding the lightness. Intuitive.</p>

<p>Want a muted version? Drop saturation. Want a complementary color? Add 180 to the hue.</p>

<h2 id="when-to-use-which">When to Use Which</h2>

<table>
  <thead>
    <tr>
      <th>Format</th>
      <th>Use when</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>HEX</td>
      <td>Writing CSS, sharing colors, design specs</td>
    </tr>
    <tr>
      <td>RGB</td>
      <td>Working with canvas, image processing, programmatic color generation</td>
    </tr>
    <tr>
      <td>HSL</td>
      <td>Designing palettes, creating hover states, accessible color variations</td>
    </tr>
  </tbody>
</table>

<h2 id="color-accessibility-tip">Color Accessibility Tip</h2>

<p>When choosing text and background colors, what matters is the lightness contrast. In HSL, this is immediately visible: if your background is <code class="language-plaintext highlighter-rouge">hsl(220, 83%, 90%)</code> and your text is <code class="language-plaintext highlighter-rouge">hsl(220, 83%, 20%)</code>, the 70-point lightness gap tells you the contrast is strong.</p>

<p>WCAG requires a contrast ratio of at least 4.5:1 for normal text. Using HSL makes it much easier to intuitively maintain sufficient contrast.</p>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Tech / Dev" /><summary type="html"><![CDATA[Learn the differences between HEX, RGB, and HSL color formats, when to use each, and how they relate to each other.]]></summary></entry><entry><title type="html">Base64 Encoding Explained: When and Why to Use It</title><link href="https://how-to-do.online/blog/base64-encoding-explained/" rel="alternate" type="text/html" title="Base64 Encoding Explained: When and Why to Use It" /><published>2026-04-11T00:00:00+00:00</published><updated>2026-04-11T00:00:00+00:00</updated><id>https://how-to-do.online/blog/base64-encoding-explained</id><content type="html" xml:base="https://how-to-do.online/blog/base64-encoding-explained/"><![CDATA[<p>Base64 is everywhere in software, yet most developers use it without understanding what it does. It’s not encryption. It’s not compression. It’s a way to represent binary data using only text characters.</p>

<h2 id="what-base64-does">What Base64 Does</h2>

<p>Base64 takes any data (text, images, files) and converts it into a string using only 64 characters: A-Z, a-z, 0-9, +, and /. Plus <code class="language-plaintext highlighter-rouge">=</code> for padding.</p>

<p>The input “Hello” becomes “SGVsbG8=”.</p>

<p>Every 3 bytes of input become 4 characters of output. This means Base64 encoded data is always about 33% larger than the original. It’s not compression. It’s the opposite.</p>

<h2 id="why-it-exists">Why It Exists</h2>

<p>Many systems were designed to handle text only. Email (SMTP) was designed for ASCII text. HTTP headers are text. JSON is text. XML is text. URLs are text.</p>

<p>When you need to send binary data (an image, a PDF, raw bytes) through these text-only channels, you have a problem. Binary data contains bytes that can be misinterpreted as control characters, get corrupted by text processing, or simply aren’t valid in the format.</p>

<p>Base64 solves this by encoding binary data into safe text characters that survive any text-based transport.</p>

<h2 id="common-use-cases">Common Use Cases</h2>

<h3 id="1-email-attachments">1. Email attachments</h3>
<p>When you attach a photo to an email, it’s Base64 encoded into the MIME message. Your email client decodes it back to the original image.</p>

<h3 id="2-data-urls-in-htmlcss">2. Data URLs in HTML/CSS</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;img src="data:image/png;base64,iVBORw0KGgo..." /&gt;
</code></pre></div></div>
<p>Small images can be embedded directly in HTML without separate HTTP requests.</p>

<h3 id="3-api-authentication">3. API authentication</h3>
<p>HTTP Basic Auth sends credentials as <code class="language-plaintext highlighter-rouge">username:password</code> Base64 encoded in the Authorization header.</p>

<p><strong>Important</strong>: Base64 is NOT encryption. Anyone can decode it. Basic Auth is only safe over HTTPS.</p>

<h3 id="4-storing-binary-in-json">4. Storing binary in JSON</h3>
<p>JSON has no binary type. If you need to include file data in a JSON payload, Base64 is the standard approach.</p>

<h3 id="5-jwt-tokens">5. JWT tokens</h3>
<p>JSON Web Tokens are three Base64-encoded segments separated by dots. The payload is readable by anyone who decodes it (again, it’s not encryption).</p>

<h2 id="when-not-to-use-base64">When NOT to Use Base64</h2>

<ul>
  <li><strong>For security</strong>: Base64 is encoding, not encryption. It provides zero security. Use AES, RSA, or similar for actual encryption.</li>
  <li><strong>For large files</strong>: The 33% size increase adds up. Sending a 10 MB file as Base64 means sending 13.3 MB. Use proper binary transfer (multipart form data) when possible.</li>
  <li><strong>When binary transport is available</strong>: If you can send raw bytes (WebSocket binary frames, gRPC, direct file upload), do that instead.</li>
</ul>

<h2 id="variants-you-might-encounter">Variants You Might Encounter</h2>

<ul>
  <li><strong>Standard Base64</strong>: Uses <code class="language-plaintext highlighter-rouge">+</code> and <code class="language-plaintext highlighter-rouge">/</code>. Padding with <code class="language-plaintext highlighter-rouge">=</code>.</li>
  <li><strong>URL-safe Base64</strong>: Uses <code class="language-plaintext highlighter-rouge">-</code> and <code class="language-plaintext highlighter-rouge">_</code> instead (because <code class="language-plaintext highlighter-rouge">+</code> and <code class="language-plaintext highlighter-rouge">/</code> have special meaning in URLs).</li>
  <li><strong>No-padding Base64</strong>: Omits the trailing <code class="language-plaintext highlighter-rouge">=</code> signs. Some systems don’t need them.</li>
</ul>

<h2 id="the-bottom-line">The Bottom Line</h2>

<p>Base64 is a tool for making binary data survive text-based transport. It’s not security. It’s not compression. It makes things bigger but compatible. Use it when you must, avoid it when you can send binary directly.</p>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Tech / Dev" /><summary type="html"><![CDATA[Understand what Base64 encoding actually does, why it exists, common use cases, and when to use (or avoid) it.]]></summary></entry><entry><title type="html">JSON for Beginners: What It Is and Why It Matters</title><link href="https://how-to-do.online/blog/json-for-beginners/" rel="alternate" type="text/html" title="JSON for Beginners: What It Is and Why It Matters" /><published>2026-04-11T00:00:00+00:00</published><updated>2026-04-11T00:00:00+00:00</updated><id>https://how-to-do.online/blog/json-for-beginners</id><content type="html" xml:base="https://how-to-do.online/blog/json-for-beginners/"><![CDATA[<p>JSON (JavaScript Object Notation) is the lingua franca of modern software. Every time you use an app, browse a website, or call an API, JSON is almost certainly flowing behind the scenes. Understanding it is one of the highest-leverage skills for anyone working with technology.</p>

<h2 id="what-json-looks-like">What JSON Looks Like</h2>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Amit"</span><span class="p">,</span><span class="w">
  </span><span class="nl">"age"</span><span class="p">:</span><span class="w"> </span><span class="mi">30</span><span class="p">,</span><span class="w">
  </span><span class="nl">"is_developer"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
  </span><span class="nl">"skills"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="s2">"Python"</span><span class="p">,</span><span class="w"> </span><span class="s2">"JavaScript"</span><span class="p">,</span><span class="w"> </span><span class="s2">"SQL"</span><span class="p">],</span><span class="w">
  </span><span class="nl">"address"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
    </span><span class="nl">"city"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Bangalore"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"country"</span><span class="p">:</span><span class="w"> </span><span class="s2">"India"</span><span class="w">
  </span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>That’s it. If you can read the above, you can read JSON.</p>

<h2 id="the-rules">The Rules</h2>

<p>JSON has six data types:</p>

<ol>
  <li><strong>String</strong>: Text in double quotes. <code class="language-plaintext highlighter-rouge">"hello"</code></li>
  <li><strong>Number</strong>: No quotes. <code class="language-plaintext highlighter-rouge">42</code> or <code class="language-plaintext highlighter-rouge">3.14</code></li>
  <li><strong>Boolean</strong>: <code class="language-plaintext highlighter-rouge">true</code> or <code class="language-plaintext highlighter-rouge">false</code> (lowercase, no quotes)</li>
  <li><strong>Null</strong>: <code class="language-plaintext highlighter-rouge">null</code> (represents nothing)</li>
  <li><strong>Array</strong>: Ordered list in square brackets. <code class="language-plaintext highlighter-rouge">[1, 2, 3]</code></li>
  <li><strong>Object</strong>: Key-value pairs in curly braces. <code class="language-plaintext highlighter-rouge">{"key": "value"}</code></li>
</ol>

<p>And a few syntax rules:</p>
<ul>
  <li>Keys must be strings (double quotes required)</li>
  <li>No trailing commas after the last item</li>
  <li>No comments (this annoys everyone)</li>
  <li>Use double quotes, not single quotes</li>
</ul>

<h2 id="why-json-won">Why JSON Won</h2>

<p>Before JSON, XML was the standard data format:</p>

<div class="language-xml highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="nt">&lt;person&gt;</span>
  <span class="nt">&lt;name&gt;</span>Amit<span class="nt">&lt;/name&gt;</span>
  <span class="nt">&lt;age&gt;</span>30<span class="nt">&lt;/age&gt;</span>
<span class="nt">&lt;/person&gt;</span>
</code></pre></div></div>

<p>Compare to JSON:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Amit"</span><span class="p">,</span><span class="w"> </span><span class="nl">"age"</span><span class="p">:</span><span class="w"> </span><span class="mi">30</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<p>JSON is shorter, easier to read, easier to parse, and maps directly to data structures in most programming languages. XML has more features (schemas, namespaces, attributes), but for 90% of use cases, JSON’s simplicity wins.</p>

<h2 id="where-youll-encounter-json">Where You’ll Encounter JSON</h2>

<ul>
  <li><strong>APIs</strong>: Almost every web API sends and receives JSON. When your weather app fetches the forecast, it gets JSON back.</li>
  <li><strong>Configuration files</strong>: <code class="language-plaintext highlighter-rouge">package.json</code>, <code class="language-plaintext highlighter-rouge">tsconfig.json</code>, VS Code settings, all JSON.</li>
  <li><strong>Databases</strong>: MongoDB stores documents as JSON (technically BSON). PostgreSQL has native JSON columns.</li>
  <li><strong>Data exchange</strong>: Any time two systems need to share structured data.</li>
</ul>

<h2 id="common-mistakes">Common Mistakes</h2>

<h3 id="missing-or-extra-commas">Missing or extra commas</h3>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"a"</span><span class="p">:</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w">
  </span><span class="nl">"b"</span><span class="p">:</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w">  
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>That trailing comma after <code class="language-plaintext highlighter-rouge">2</code> is invalid. JSON parsers will reject it.</p>

<h3 id="single-quotes">Single quotes</h3>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="err">'name':</span><span class="w"> </span><span class="err">'Amit'</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>Invalid. JSON requires double quotes.</p>

<h3 id="unquoted-keys">Unquoted keys</h3>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="err">name:</span><span class="w"> </span><span class="s2">"Amit"</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>Invalid. Keys must be quoted strings.</p>

<h3 id="comments">Comments</h3>
<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
  </span><span class="nl">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Amit"</span><span class="w">  </span><span class="err">//</span><span class="w"> </span><span class="err">this</span><span class="w"> </span><span class="err">is</span><span class="w"> </span><span class="err">a</span><span class="w"> </span><span class="err">comment</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>
<p>Invalid. JSON doesn’t support comments. If you need comments in config files, consider JSONC or YAML instead.</p>

<h2 id="validating-json">Validating JSON</h2>

<p>Paste your JSON into a formatter/validator tool. It will instantly tell you if it’s valid and show you where the error is. When debugging API responses or config files, this is the first thing to do.</p>

<h2 id="practical-tips">Practical Tips</h2>

<ol>
  <li>When in doubt about syntax, validate. A missing comma or quote can cause cryptic errors.</li>
  <li>Pretty-print JSON for reading (with indentation). Minify for sending over networks.</li>
  <li>Most languages have built-in JSON parsing: <code class="language-plaintext highlighter-rouge">JSON.parse()</code> in JavaScript, <code class="language-plaintext highlighter-rouge">json.loads()</code> in Python, <code class="language-plaintext highlighter-rouge">json.Unmarshal()</code> in Go.</li>
  <li>If you need comments in config, use YAML or JSONC, not raw JSON.</li>
</ol>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Tech / Dev" /><summary type="html"><![CDATA[A beginner-friendly introduction to JSON, its syntax, common use cases, and how to read and write it correctly.]]></summary></entry><entry><title type="html">Regex Cheat Sheet: 20 Patterns You’ll Use Constantly</title><link href="https://how-to-do.online/blog/regex-cheat-sheet/" rel="alternate" type="text/html" title="Regex Cheat Sheet: 20 Patterns You’ll Use Constantly" /><published>2026-04-11T00:00:00+00:00</published><updated>2026-04-11T00:00:00+00:00</updated><id>https://how-to-do.online/blog/regex-cheat-sheet</id><content type="html" xml:base="https://how-to-do.online/blog/regex-cheat-sheet/"><![CDATA[<p>Regular expressions are one of those tools that feel impossible until they click, then become indispensable. Here are 20 patterns that cover the vast majority of real-world use cases.</p>

<h2 id="the-basics-first">The Basics First</h2>

<table>
  <thead>
    <tr>
      <th>Pattern</th>
      <th>Matches</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">.</code></td>
      <td>Any single character</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">\d</code></td>
      <td>Any digit (0-9)</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">\w</code></td>
      <td>Any word character (a-z, A-Z, 0-9, _)</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">\s</code></td>
      <td>Any whitespace (space, tab, newline)</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">^</code></td>
      <td>Start of string</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">$</code></td>
      <td>End of string</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">*</code></td>
      <td>Zero or more of previous</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">+</code></td>
      <td>One or more of previous</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">?</code></td>
      <td>Zero or one of previous</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">{n,m}</code></td>
      <td>Between n and m of previous</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">[abc]</code></td>
      <td>Any character in the set</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">[^abc]</code></td>
      <td>Any character NOT in the set</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">(...)</code></td>
      <td>Capture group</td>
    </tr>
    <tr>
      <td><code class="language-plaintext highlighter-rouge">\|</code></td>
      <td>OR operator</td>
    </tr>
  </tbody>
</table>

<h2 id="the-20-patterns">The 20 Patterns</h2>

<h3 id="1-email-address-simple">1. Email address (simple)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[\w.+-]+@[\w-]+\.[\w.]+
</code></pre></div></div>
<p>Not RFC-compliant (nothing is, practically), but catches 99% of real emails.</p>

<h3 id="2-url">2. URL</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https?://[\w\-.]+(:\d+)?(/[\w\-./?%&amp;=]*)?
</code></pre></div></div>

<h3 id="3-phone-number-indian">3. Phone number (Indian)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(\+91[\s-]?)?[6-9]\d{9}
</code></pre></div></div>

<h3 id="4-phone-number-us">4. Phone number (US)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(\+?1[\s-]?)?\(?\d{3}\)?[\s-]?\d{3}[\s-]?\d{4}
</code></pre></div></div>

<h3 id="5-ip-address-ipv4">5. IP address (IPv4)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b
</code></pre></div></div>

<h3 id="6-date-yyyy-mm-dd">6. Date (YYYY-MM-DD)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])
</code></pre></div></div>

<h3 id="7-date-ddmmyyyy">7. Date (DD/MM/YYYY)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(?:0[1-9]|[12]\d|3[01])/(?:0[1-9]|1[0-2])/\d{4}
</code></pre></div></div>

<h3 id="8-time-24-hour">8. Time (24-hour)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(?:[01]\d|2[0-3]):[0-5]\d(:[0-5]\d)?
</code></pre></div></div>

<h3 id="9-integer">9. Integer</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>-?\d+
</code></pre></div></div>

<h3 id="10-decimal-number">10. Decimal number</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>-?\d+\.?\d*
</code></pre></div></div>

<h3 id="11-hex-color-code">11. Hex color code</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\b
</code></pre></div></div>

<h3 id="12-html-tag">12. HTML tag</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;/?[\w]+[^&gt;]*&gt;
</code></pre></div></div>

<h3 id="13-whitespace-trimming">13. Whitespace trimming</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>^\s+|\s+$
</code></pre></div></div>
<p>Use with replace to trim leading/trailing whitespace.</p>

<h3 id="14-duplicate-words">14. Duplicate words</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\b(\w+)\s+\1\b
</code></pre></div></div>
<p>Finds “the the”, “is is”, etc.</p>

<h3 id="15-pan-card-india">15. PAN card (India)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[A-Z]{5}\d{4}[A-Z]
</code></pre></div></div>

<h3 id="16-pin-code-india">16. PIN code (India)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\b[1-9]\d{5}\b
</code></pre></div></div>

<h3 id="17-zip-code-us">17. ZIP code (US)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>\b\d{5}(-\d{4})?\b
</code></pre></div></div>

<h3 id="18-password-strength-minimum-8-chars-1-upper-1-lower-1-digit">18. Password strength (minimum 8 chars, 1 upper, 1 lower, 1 digit)</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{8,}$
</code></pre></div></div>

<h3 id="19-extract-domain-from-url">19. Extract domain from URL</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>https?://([^/]+)
</code></pre></div></div>
<p>Capture group 1 gives you the domain.</p>

<h3 id="20-csv-value-parsing">20. CSV value parsing</h3>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>(?:^|,)("(?:[^"]*"")*[^"]*"|[^,]*)
</code></pre></div></div>

<h2 id="tips-for-writing-regex">Tips for Writing Regex</h2>

<ol>
  <li><strong>Start simple, add complexity.</strong> Get a basic pattern working, then handle edge cases.</li>
  <li><strong>Use non-capturing groups</strong> <code class="language-plaintext highlighter-rouge">(?:...)</code> when you don’t need to extract the match.</li>
  <li><strong>Be specific.</strong> <code class="language-plaintext highlighter-rouge">\d{4}</code> is better than <code class="language-plaintext highlighter-rouge">\d+</code> when you know exactly 4 digits are expected.</li>
  <li><strong>Test with real data.</strong> Regex that works on examples can fail on production data. Test with messy, real-world input.</li>
  <li><strong>Don’t parse HTML with regex.</strong> For anything beyond simple tag matching, use a proper HTML parser.</li>
  <li><strong>Comment complex patterns.</strong> Most regex engines support verbose mode where you can add comments.</li>
</ol>

<h2 id="when-not-to-use-regex">When NOT to Use Regex</h2>

<ul>
  <li>Parsing nested structures (HTML, JSON, XML). Use a parser.</li>
  <li>Complex validation that would be clearer as procedural code.</li>
  <li>When a simple <code class="language-plaintext highlighter-rouge">string.contains()</code> or <code class="language-plaintext highlighter-rouge">string.startsWith()</code> would do.</li>
</ul>

<p>Regex is a scalpel. Use it when you need precision. Don’t use it when a butter knife works fine.</p>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Tech / Dev" /><summary type="html"><![CDATA[A practical regex reference with 20 patterns for emails, URLs, numbers, dates, and common text processing tasks.]]></summary></entry><entry><title type="html">How Much Water Do You Really Need? Myths vs Science</title><link href="https://how-to-do.online/blog/how-much-water-do-you-need/" rel="alternate" type="text/html" title="How Much Water Do You Really Need? Myths vs Science" /><published>2026-04-10T00:00:00+00:00</published><updated>2026-04-10T00:00:00+00:00</updated><id>https://how-to-do.online/blog/how-much-water-do-you-need</id><content type="html" xml:base="https://how-to-do.online/blog/how-much-water-do-you-need/"><![CDATA[<p>“Drink 8 glasses of water a day.” You’ve heard this a thousand times. There’s no scientific basis for it. The number was loosely derived from a 1945 US government report that recommended 2.5 liters of daily water intake, but noted that most of this comes from food. That last part got dropped, and a myth was born.</p>

<h2 id="what-the-research-actually-says">What the Research Actually Says</h2>

<p>The Institute of Medicine suggests:</p>
<ul>
  <li><strong>Men</strong>: about 3.7 liters total water per day</li>
  <li><strong>Women</strong>: about 2.7 liters total water per day</li>
</ul>

<p>“Total water” includes water from food (which accounts for roughly 20-30% of intake). So the actual drinking requirement is lower.</p>

<p>But these are averages for temperate climates with moderate activity. Your needs vary based on several factors.</p>

<h2 id="what-changes-your-water-needs">What Changes Your Water Needs</h2>

<h3 id="body-weight">Body weight</h3>
<p>Larger bodies need more water. A rough formula: 30-35 ml per kg of body weight.</p>

<p>A 70 kg person: 2.1 to 2.45 liters.
A 90 kg person: 2.7 to 3.15 liters.</p>

<h3 id="physical-activity">Physical activity</h3>
<p>You lose 0.5 to 1 liter of water per hour of moderate exercise through sweat. Intense exercise in heat can push this to 2+ liters per hour.</p>

<h3 id="climate">Climate</h3>
<p>Hot and humid weather increases sweat losses. Dry climates increase water loss through respiration and skin. Both require extra intake.</p>

<h3 id="diet">Diet</h3>
<p>High-sodium food increases water needs. High-water-content foods (fruits, vegetables, soups) reduce how much you need to drink separately. A person eating lots of watermelon and cucumber needs less drinking water than someone eating mostly dry, processed food.</p>

<h3 id="altitude">Altitude</h3>
<p>Above 2,500 meters, your body loses more water through increased respiration and urine output. High-altitude trekkers should increase intake by 0.5-1 liter.</p>

<h2 id="the-8-glasses-verdict">The “8 Glasses” Verdict</h2>

<p>For a sedentary person in a temperate climate eating a balanced diet, 8 glasses (about 2 liters) is… actually fine. Not because the rule is scientifically derived, but because it happens to land in the right ballpark for many people. It’s an okay default, just not a universal truth.</p>

<h2 id="the-best-indicator-urine-color">The Best Indicator: Urine Color</h2>

<p>Forget counting glasses. Your body has a built-in hydration meter.</p>

<ul>
  <li><strong>Pale yellow</strong>: well hydrated</li>
  <li><strong>Light yellow</strong>: adequately hydrated</li>
  <li><strong>Dark yellow</strong>: drink more water</li>
  <li><strong>Clear/colorless</strong>: you’re overhydrating (yes, this is possible)</li>
</ul>

<p>Check first thing in the morning. That’s your baseline hydration level.</p>

<h2 id="can-you-drink-too-much">Can You Drink Too Much?</h2>

<p>Yes. Hyponatremia (dangerously low blood sodium from excessive water intake) is rare but real. It most commonly affects endurance athletes who drink far more than they sweat. For most people, the kidneys handle excess water efficiently, but there’s no benefit to forcing down 5+ liters when your body doesn’t need it.</p>

<h2 id="practical-guidelines">Practical Guidelines</h2>

<ol>
  <li>Start with 30-35 ml per kg of body weight as a baseline</li>
  <li>Add 500 ml for every 30 minutes of exercise</li>
  <li>Add 500 ml in hot or dry climates</li>
  <li>Drink when thirsty (thirst works well in healthy adults)</li>
  <li>Check urine color once a day</li>
  <li>Water, tea, coffee, and milk all count toward intake</li>
  <li>Coffee is not dehydrating in normal amounts (the diuretic effect is mild and offset by the water content)</li>
</ol>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Health" /><summary type="html"><![CDATA[Debunk the 8-glasses myth, understand what actually determines your water needs, and learn to read your body's signals.]]></summary></entry><entry><title type="html">Understanding Macros: Protein, Carbs, Fat Ratios for Different Goals</title><link href="https://how-to-do.online/blog/understanding-macros/" rel="alternate" type="text/html" title="Understanding Macros: Protein, Carbs, Fat Ratios for Different Goals" /><published>2026-04-10T00:00:00+00:00</published><updated>2026-04-10T00:00:00+00:00</updated><id>https://how-to-do.online/blog/understanding-macros</id><content type="html" xml:base="https://how-to-do.online/blog/understanding-macros/"><![CDATA[<p>Calories tell you how much to eat. Macros tell you what to eat. Both matter, but if you’ve already got your calorie target, dialing in macronutrients is the next step that separates good results from great ones.</p>

<h2 id="the-three-macronutrients">The Three Macronutrients</h2>

<p><strong>Protein</strong>: 4 calories per gram. Builds and repairs muscle, keeps you full, has the highest thermic effect (your body burns ~25% of protein calories just digesting it).</p>

<p><strong>Carbohydrates</strong>: 4 calories per gram. Your body’s preferred energy source, especially for high-intensity activity. Brain fuel. Stored as glycogen in muscles and liver.</p>

<p><strong>Fat</strong>: 9 calories per gram. Essential for hormones, brain function, cell membranes, and absorbing fat-soluble vitamins (A, D, E, K). More calorie-dense, so portions matter.</p>

<h2 id="setting-protein-first">Setting Protein First</h2>

<p>Protein is the most important macro to get right, regardless of your goal. The research is clear:</p>

<ul>
  <li><strong>Minimum for general health</strong>: 0.8 g per kg of body weight</li>
  <li><strong>Active adults</strong>: 1.2-1.6 g per kg</li>
  <li><strong>Muscle building</strong>: 1.6-2.2 g per kg</li>
  <li><strong>Dieting (to preserve muscle)</strong>: 1.8-2.4 g per kg</li>
</ul>

<p>For a 75 kg person building muscle: 120 to 165 grams of protein per day.</p>

<p>Always set protein first, then distribute remaining calories between carbs and fat.</p>

<h2 id="macro-splits-for-different-goals">Macro Splits for Different Goals</h2>

<h3 id="fat-loss">Fat Loss</h3>
<ul>
  <li><strong>Protein</strong>: 2.0 g/kg (high, to preserve muscle in a deficit)</li>
  <li><strong>Fat</strong>: 0.8-1.0 g/kg (enough for hormonal health)</li>
  <li><strong>Carbs</strong>: remaining calories</li>
</ul>

<p>For our 75 kg person eating 2,100 cal/day:</p>
<ul>
  <li>Protein: 150g = 600 cal</li>
  <li>Fat: 65g = 585 cal</li>
  <li>Carbs: (2,100 - 600 - 585) / 4 = 229g</li>
</ul>

<p>Ratio: roughly 30% protein, 28% fat, 42% carbs.</p>

<h3 id="muscle-gain">Muscle Gain</h3>
<ul>
  <li><strong>Protein</strong>: 1.8 g/kg</li>
  <li><strong>Fat</strong>: 0.8-1.0 g/kg</li>
  <li><strong>Carbs</strong>: remaining (higher, to fuel training)</li>
</ul>

<p>At 3,000 cal/day:</p>
<ul>
  <li>Protein: 135g = 540 cal</li>
  <li>Fat: 70g = 630 cal</li>
  <li>Carbs: (3,000 - 540 - 630) / 4 = 458g</li>
</ul>

<p>Ratio: roughly 18% protein, 21% fat, 61% carbs.</p>

<h3 id="general-health--maintenance">General Health / Maintenance</h3>
<ul>
  <li><strong>Protein</strong>: 1.2-1.6 g/kg</li>
  <li><strong>Fat</strong>: 25-35% of calories</li>
  <li><strong>Carbs</strong>: remainder</li>
</ul>

<h2 id="common-macro-sources">Common Macro Sources</h2>

<table>
  <thead>
    <tr>
      <th>Macro</th>
      <th>Good sources</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Protein</td>
      <td>Chicken, eggs, paneer, dal, Greek yogurt, fish, tofu, whey</td>
    </tr>
    <tr>
      <td>Carbs</td>
      <td>Rice, roti, oats, potatoes, fruits, vegetables</td>
    </tr>
    <tr>
      <td>Fat</td>
      <td>Nuts, ghee, olive oil, avocado, cheese, fatty fish</td>
    </tr>
  </tbody>
</table>

<h2 id="what-about-the-ketolow-carb-debate">What About the Keto/Low-Carb Debate?</h2>

<p>Low-carb diets work for fat loss because cutting carbs often means cutting calories. There’s no metabolic magic. At equal calorie and protein levels, high-carb and low-carb diets produce similar fat loss results.</p>

<p>The best carb level is the one you can sustain. If you train intensely, you’ll perform better with moderate to high carbs. If you’re sedentary and find it easier to control hunger on lower carbs, that works too.</p>

<h2 id="the-priority-order">The Priority Order</h2>

<ol>
  <li><strong>Calories</strong>: get total intake right for your goal</li>
  <li><strong>Protein</strong>: hit your target daily</li>
  <li><strong>Fat</strong>: don’t go below 0.6 g/kg (hormonal floor)</li>
  <li><strong>Carbs</strong>: fill remaining calories, adjust based on energy and training needs</li>
</ol>

<p>Perfecting macro ratios while eating the wrong total calories is like optimizing tire pressure on a car with no engine. Get the calories right first, then refine.</p>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Health" /><summary type="html"><![CDATA[Learn what macronutrients are, how much you need for weight loss, muscle gain, or maintenance, and how to set practical macro targets.]]></summary></entry><entry><title type="html">How to Calculate Your TDEE and Actually Use It</title><link href="https://how-to-do.online/blog/calculate-tdee/" rel="alternate" type="text/html" title="How to Calculate Your TDEE and Actually Use It" /><published>2026-04-09T00:00:00+00:00</published><updated>2026-04-09T00:00:00+00:00</updated><id>https://how-to-do.online/blog/calculate-tdee</id><content type="html" xml:base="https://how-to-do.online/blog/calculate-tdee/"><![CDATA[<p>TDEE stands for Total Daily Energy Expenditure. It’s the total number of calories your body burns in a day. Every successful diet, whether the person knows it or not, works by creating a relationship between calories eaten and TDEE.</p>

<h2 id="the-components">The Components</h2>

<p>Your TDEE is made up of four parts:</p>

<p><strong>BMR (Basal Metabolic Rate)</strong>: ~60-70% of total. This is what your body burns just existing. Breathing, circulating blood, maintaining body temperature. Even in a coma, you’d burn this much.</p>

<p><strong>TEF (Thermic Effect of Food)</strong>: ~10%. The energy cost of digesting food. Protein costs more to digest (~25%) than carbs (~8%) or fat (~3%).</p>

<p><strong>EAT (Exercise Activity Thermogenesis)</strong>: ~5-10%. Intentional exercise. The gym, running, sports.</p>

<p><strong>NEAT (Non-Exercise Activity Thermogenesis)</strong>: ~15-20%. Everything else. Walking to the kitchen, fidgeting, standing, typing. This is the most variable and underrated component.</p>

<h2 id="calculating-bmr">Calculating BMR</h2>

<p>The Mifflin-St Jeor equation is the most accurate for most people:</p>

<p><strong>Men</strong>: BMR = 10 x weight(kg) + 6.25 x height(cm) - 5 x age - 5</p>

<p><strong>Women</strong>: BMR = 10 x weight(kg) + 6.25 x height(cm) - 5 x age - 161</p>

<p>Example: 30-year-old male, 75 kg, 175 cm
BMR = 750 + 1094 - 150 + 5 = <strong>1,699 calories</strong></p>

<h2 id="from-bmr-to-tdee">From BMR to TDEE</h2>

<p>Multiply BMR by an activity factor:</p>

<table>
  <thead>
    <tr>
      <th>Activity Level</th>
      <th>Multiplier</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Sedentary (desk job, no exercise)</td>
      <td>1.2</td>
    </tr>
    <tr>
      <td>Lightly active (1-3 days exercise/week)</td>
      <td>1.375</td>
    </tr>
    <tr>
      <td>Moderately active (3-5 days/week)</td>
      <td>1.55</td>
    </tr>
    <tr>
      <td>Very active (6-7 days/week)</td>
      <td>1.725</td>
    </tr>
    <tr>
      <td>Extremely active (physical job + training)</td>
      <td>1.9</td>
    </tr>
  </tbody>
</table>

<p>Our example person, moderately active: 1,699 x 1.55 = <strong>2,633 calories/day</strong></p>

<h2 id="using-tdee-for-goals">Using TDEE for Goals</h2>

<h3 id="weight-loss">Weight loss</h3>
<p>Eat below TDEE. A deficit of 500 calories/day produces roughly 0.5 kg of fat loss per week (since 1 kg of fat = ~7,700 calories).</p>

<p>For our example: 2,633 - 500 = <strong>2,133 calories/day</strong> for steady fat loss.</p>

<h3 id="weight-gain">Weight gain</h3>
<p>Eat above TDEE. A surplus of 300-500 calories supports muscle growth without excessive fat gain.</p>

<p>Target: 2,633 + 400 = <strong>3,033 calories/day</strong> with strength training.</p>

<h3 id="maintenance">Maintenance</h3>
<p>Eat at TDEE. Weight stays stable.</p>

<h2 id="common-mistakes">Common Mistakes</h2>

<h3 id="1-overestimating-activity-level">1. Overestimating activity level</h3>
<p>Most people with desk jobs who exercise 3 times a week are “lightly active,” not “moderately active.” When in doubt, pick the lower multiplier.</p>

<h3 id="2-ignoring-neat">2. Ignoring NEAT</h3>
<p>NEAT can vary by 500-2,000 calories between individuals. Someone who walks 12,000 steps daily and fidgets constantly burns dramatically more than someone who sits still all day. Increasing NEAT (walking more, standing desk, taking stairs) is often easier than adding gym sessions.</p>

<h3 id="3-not-adjusting-over-time">3. Not adjusting over time</h3>
<p>As you lose weight, your BMR drops. A person who lost 10 kg needs to recalculate. This is why weight loss plateaus happen.</p>

<h3 id="4-treating-the-number-as-exact">4. Treating the number as exact</h3>
<p>TDEE calculations are estimates with a margin of error around 10-15%. Use the number as a starting point, track your weight for 2-3 weeks, and adjust based on actual results.</p>

<h2 id="the-practical-approach">The Practical Approach</h2>

<ol>
  <li>Calculate your TDEE</li>
  <li>Set a calorie target based on your goal</li>
  <li>Track food intake for 2 weeks</li>
  <li>Compare actual weight change to expected</li>
  <li>Adjust calories up or down by 200-300 if needed</li>
  <li>Recalculate every 5 kg of weight change</li>
</ol>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Health" /><summary type="html"><![CDATA[Understand Total Daily Energy Expenditure, how it's calculated, and how to use it for weight loss, gain, or maintenance.]]></summary></entry><entry><title type="html">Why BMI Is Useful but Flawed (and What to Track Instead)</title><link href="https://how-to-do.online/blog/why-bmi-is-flawed/" rel="alternate" type="text/html" title="Why BMI Is Useful but Flawed (and What to Track Instead)" /><published>2026-04-09T00:00:00+00:00</published><updated>2026-04-09T00:00:00+00:00</updated><id>https://how-to-do.online/blog/why-bmi-is-flawed</id><content type="html" xml:base="https://how-to-do.online/blog/why-bmi-is-flawed/"><![CDATA[<p>BMI is the most widely used health metric on the planet. It’s also one of the most misunderstood. Here’s what it actually tells you, where it fails, and what to pair it with.</p>

<h2 id="what-bmi-is">What BMI Is</h2>

<p>Body Mass Index = weight (kg) / height (m) squared.</p>

<p>It was invented in the 1830s by a Belgian mathematician named Adolphe Quetelet. He wasn’t a doctor. He was studying population statistics. BMI was designed to categorize populations, not diagnose individuals.</p>

<h2 id="where-bmi-works">Where BMI Works</h2>

<p>For the average person who doesn’t exercise intensely, BMI is a reasonable proxy for body fat. Large population studies consistently show that BMI correlates with health risks:</p>

<ul>
  <li>BMI 18.5-24.9: lowest risk for most diseases</li>
  <li>BMI 25-29.9: elevated risk of heart disease, diabetes</li>
  <li>BMI 30+: significantly elevated risk</li>
</ul>

<p>For a doctor screening thousands of patients, BMI is quick, cheap, and “good enough” to flag who needs closer examination.</p>

<h2 id="where-bmi-fails">Where BMI Fails</h2>

<h3 id="1-it-ignores-body-composition">1. It ignores body composition</h3>
<p>A muscular person and an overweight person at the same height and weight have identical BMIs. Dwayne “The Rock” Johnson’s BMI is around 34 (obese). He’s clearly not.</p>

<h3 id="2-it-doesnt-account-for-fat-distribution">2. It doesn’t account for fat distribution</h3>
<p>Where you carry fat matters more than how much. Visceral fat around your organs is far more dangerous than subcutaneous fat under your skin. Two people with BMI 27 can have very different health profiles.</p>

<h3 id="3-different-populations-different-thresholds">3. Different populations, different thresholds</h3>
<p>The standard BMI categories were developed using data from European populations. For South Asians, health risks rise at lower BMI values. Many researchers suggest using 23 (not 25) as the overweight threshold for Asian populations.</p>

<h3 id="4-age-and-gender-blindness">4. Age and gender blindness</h3>
<p>BMI doesn’t adjust for the fact that body composition naturally changes with age, or that women carry more essential fat than men.</p>

<h2 id="what-to-track-instead-or-in-addition">What to Track Instead (or In Addition)</h2>

<h3 id="waist-circumference">Waist circumference</h3>
<p>The single best addition to BMI. Measure around your navel.</p>

<ul>
  <li>Men: above 90 cm signals elevated risk (for South Asians; 102 cm for Europeans)</li>
  <li>Women: above 80 cm signals elevated risk</li>
</ul>

<h3 id="waist-to-hip-ratio">Waist-to-hip ratio</h3>
<p>Waist measurement divided by hip measurement.</p>

<ul>
  <li>Men: above 0.9 is high risk</li>
  <li>Women: above 0.85 is high risk</li>
</ul>

<h3 id="waist-to-height-ratio">Waist-to-height ratio</h3>
<p>Your waist should be less than half your height. Simple, effective, works across populations.</p>

<h3 id="body-fat-percentage">Body fat percentage</h3>
<p>The gold standard if you can measure it. Healthy ranges:</p>

<ul>
  <li>Men: 10-20%</li>
  <li>Women: 18-28%</li>
</ul>

<p>DEXA scans and bioimpedance scales can estimate this, with varying accuracy.</p>

<h2 id="the-practical-take">The Practical Take</h2>

<p>Don’t ignore BMI entirely. It’s free, instant, and gives you a starting point. But don’t let a number from an 1830s Belgian statistician be your only health metric. Pair it with waist circumference at minimum. If your BMI says you’re fine but your waist says otherwise, trust the waist.</p>]]></content><author><name>Amit Chaudhary</name><email>chaudharyamitiit2007@gmail.com</email></author><category term="Health" /><summary type="html"><![CDATA[Understand what BMI actually measures, where it breaks down, and which health metrics give a more complete picture.]]></summary></entry></feed>