<?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[Suhail Akhtar | Tech Tips, Hacks, and Code Adventures]]></title><description><![CDATA[Dive into the world of technology with Suhail Akhtar! Explore practical tech tips, solutions to everyday problems, and coding adventures for all experience levels. From web development to digital solutions, find easy-to-follow guides and clear explanations to level up your tech skills. Visit Suhail Akhtar Dev Blog and start your tech journey today!]]></description><link>https://blog.suhail.top</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 03:23:41 GMT</lastBuildDate><atom:link href="https://blog.suhail.top/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Understanding GPT: The AI That Talks Like a Human]]></title><description><![CDATA[Imagine you have a super-smart robot friend who can chat with you, tell stories, answer questions, and even help write essays—all by understanding and using human language. This robot doesn't just repeat phrases it learned but actually generates new ...]]></description><link>https://blog.suhail.top/understanding-gpt-the-ai-that-talks-like-a-human</link><guid isPermaLink="true">https://blog.suhail.top/understanding-gpt-the-ai-that-talks-like-a-human</guid><category><![CDATA[ChaiCode]]></category><category><![CDATA[Chaiaurcode]]></category><category><![CDATA[ChaiCohort]]></category><category><![CDATA[gpt]]></category><category><![CDATA[AI]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Fri, 15 Aug 2025 15:23:27 GMT</pubDate><content:encoded><![CDATA[<p>Imagine you have a super-smart robot friend who can chat with you, tell stories, answer questions, and even help write essays—all by understanding and using human language. This robot doesn't just repeat phrases it learned but actually generates new sentences all on its own. This is what GPT, or Generative Pre-trained Transformer, does.</p>
<h2 id="heading-what-is-gpt">What is GPT?</h2>
<p>GPT stands for <em>Generative Pre-trained Transformer</em>. In simple terms, it’s an advanced computer program designed to understand and generate human-like text. Think of it as a really clever parrot that not only repeats what it hears but also makes up new and meaningful sentences based on the conversation.</p>
<p>It has been “pre-trained” on massive amounts of text from books, articles, websites, and more, so it learns patterns, grammar, facts, and even some reasoning abilities. When you give GPT a prompt or question, it uses what it learned to predict and generate the best possible continuation in natural language.</p>
<hr />
<h2 id="heading-why-is-gpt-important">Why is GPT Important?</h2>
<p>GPT is transforming how software and businesses interact with people by enabling natural communication between humans and machines. Here’s why it matters professionally:</p>
<ul>
<li><p><strong>Improves user experience:</strong> GPT can power chatbots and virtual assistants to give friendly, accurate, and helpful answers without sounding robotic.</p>
</li>
<li><p><strong>Boosts productivity:</strong> Developers and content creators use GPT to generate drafts, code snippets, summaries, and more — saving time and reducing errors.</p>
</li>
<li><p><strong>Makes AI accessible:</strong> Non-experts can interact with complex data and systems through plain English thanks to GPT’s understanding of natural language.</p>
</li>
<li><p><strong>Scalability and flexibility:</strong> GPT models can be fine-tuned for different industries, languages, or tasks, making them versatile tools in products and services.</p>
</li>
</ul>
<p>For project managers and business leaders, GPT means faster innovation cycles, enhanced customer engagement, and streamlined workflows.</p>
<hr />
<h2 id="heading-how-does-gpt-work-a-simple-example-with-javascript">How Does GPT Work? A Simple Example with JavaScript</h2>
<p>At its core, GPT is a neural network model based on a <em>Transformer</em> architecture. While the internal math is complex, you can think about it as a smart predictor guessing what word should come next in a sentence.</p>
<p><strong>Example:</strong> You type "The weather today is", and GPT might generate "sunny with a chance of rain."</p>
<p>To use GPT in your own project, many companies offer APIs (application programming interfaces) that let your app communicate with GPT — like sending it a question and receiving a reply.</p>
<p>Here's a basic example in JavaScript using a fake GPT-like API:</p>
<pre><code class="lang-js"><span class="hljs-comment">// A simple function to mimic asking GPT for a reply</span>
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">askGPT</span>(<span class="hljs-params">question</span>) </span>{
  <span class="hljs-comment">// 'fetch' sends a request to the API endpoint, like mailing a letter to GPT</span>
  <span class="hljs-keyword">const</span> response = <span class="hljs-keyword">await</span> fetch(<span class="hljs-string">'https://api.fake-gpt.com/generate'</span>, {
    <span class="hljs-attr">method</span>: <span class="hljs-string">'POST'</span>,                  <span class="hljs-comment">// We're sending data</span>
    <span class="hljs-attr">headers</span>: { <span class="hljs-string">'Content-Type'</span>: <span class="hljs-string">'application/json'</span> },
    <span class="hljs-attr">body</span>: <span class="hljs-built_in">JSON</span>.stringify({ <span class="hljs-attr">prompt</span>: question }),
  });

  <span class="hljs-comment">// Parse the JSON response (the GPT answer)</span>
  <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> response.json();
  <span class="hljs-keyword">return</span> data.answer;                <span class="hljs-comment">// Extract the generated text</span>
}

<span class="hljs-comment">// Let's ask GPT a question!</span>
askGPT(<span class="hljs-string">"What's a fun fact about space?"</span>).then(<span class="hljs-function"><span class="hljs-params">answer</span> =&gt;</span> {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">"GPT says:"</span>, answer);
});
</code></pre>
<h3 id="heading-whats-happening-here">What’s happening here?</h3>
<ul>
<li><p><code>fetch</code> is like sending a letter to the GPT service with your question.</p>
</li>
<li><p>The service reads your question (<code>prompt</code>), thinks about the best answer, and sends back a reply.</p>
</li>
<li><p>We then log that reply to the console.</p>
</li>
</ul>
<p>This example uses <strong>async/await</strong> syntax for asynchronous programming — meaning the code waits for the GPT answer without freezing the app.</p>
<hr />
<h2 id="heading-tldr-too-long-didnt-read">TL;DR (Too Long; Didn't Read)</h2>
<p><strong>GPT is an AI model that understands and generates human-like text by predicting the best word to come next based on its training from lots of written content. It powers chatbots, writing assistants, and more, making machines talk and write like people.</strong></p>
<hr />
<h2 id="heading-kid-friendly-version">Kid-Friendly Version</h2>
<p>Think of GPT like a magic talking toy that reads millions of books and learns how to speak like a person. When you ask it a question or tell it to write a story, it uses what it learned to give you a cool answer or a fun story all on its own!</p>
<hr />
<h2 id="heading-elderly-friendly-version">Elderly-Friendly Version</h2>
<p>Imagine a very smart helper that has read thousands of books and loves to chat. When you ask this helper a question or want a letter written, it uses its knowledge to answer you clearly and kindly — just like talking with a well-read friend. That’s what GPT does with computers.</p>
<hr />
<h2 id="heading-summary">Summary</h2>
<p>GPT is an amazing breakthrough in AI that lets computers understand and generate human language naturally. It’s useful in many areas: chatbots, writing aids, coding helpers, and more. By predicting what comes next in a sentence, GPT can hold conversations, tell stories, and solve problems with words. Whether you’re a developer or a business leader, understanding GPT opens the door to powerful, conversational AI tools. Start by experimenting with simple API calls or chatbots, and explore the exciting future of AI-driven communication!</p>
]]></content:encoded></item><item><title><![CDATA[How to Fix "Assertion Failed: process_title" Error in Node.js Applications]]></title><description><![CDATA[If you're encountering the error:
Assertion failed: process_title, file util.c, line 412


while running a Node.js application packaged with pkg from bat file using the following command,
start "" "mynodeapp.exe"

the issue is related to the applicat...]]></description><link>https://blog.suhail.top/how-to-fix-assertion-failed-processtitle-error-in-nodejs-applications</link><guid isPermaLink="true">https://blog.suhail.top/how-to-fix-assertion-failed-processtitle-error-in-nodejs-applications</guid><category><![CDATA[pkg]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[executables]]></category><category><![CDATA[error]]></category><category><![CDATA[Windows]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Sun, 06 Apr 2025 06:15:35 GMT</pubDate><content:encoded><![CDATA[<p>If you're encountering the error:</p>
<pre><code class="lang-plaintext">Assertion failed: process_title, file util.c, line 412
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1743919893445/6baf9b26-0a1a-43d5-8504-0eea98926b64.png" alt class="image--center mx-auto" /></p>
<p>while running a Node.js application packaged with <code>pkg</code> from bat file using the following command,</p>
<pre><code class="lang-plaintext">start "" "mynodeapp.exe"
</code></pre>
<p>the issue is related to the application trying to modify the process title, which causes conflicts in certain environments (e.g., Windows).</p>
<h4 id="heading-fix"><strong>Fix:</strong></h4>
<p>To resolve this, change the way you launch your <code>.exe</code> file by using the <code>start</code> command with a title:</p>
<pre><code class="lang-plaintext">start "MyAppName" "mynodeapp.exe"
</code></pre>
<p>This simple fix provides a title for the process, allowing it to run without the error.</p>
<hr />
<p><strong>Keywords</strong>: Node.js error fix, Assertion failed process_title, pkg, Node.js packaged exe error, Windows process title fix.</p>
]]></content:encoded></item><item><title><![CDATA[Optimizing Automation Scripts: How We Reduced Execution Time from 1 Hour to 30 Seconds, a 140x Improvement]]></title><description><![CDATA[TL;DR
We optimized our Pub/Sub automation script, reducing execution time from over 1 hour to less than 30 seconds using Node.js. Here’s a quick overview of the improvements:

Initial Python Script: Sequential processing, took over 1 hour.

Improved ...]]></description><link>https://blog.suhail.top/optimizing-automation-scripts-how-we-reduced-execution-time-from-1-hour-to-30-seconds-a-140x-improvement</link><guid isPermaLink="true">https://blog.suhail.top/optimizing-automation-scripts-how-we-reduced-execution-time-from-1-hour-to-30-seconds-a-140x-improvement</guid><category><![CDATA[Node.js]]></category><category><![CDATA[optimization]]></category><category><![CDATA[promises]]></category><category><![CDATA[Python]]></category><category><![CDATA[PubSub]]></category><category><![CDATA[Cloud]]></category><category><![CDATA[automation]]></category><category><![CDATA[improve performance]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Tue, 11 Feb 2025 04:48:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/34OTzkN-nuc/upload/3ae2c520a9ab2bf2b80bfee9b3e996ac.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-tldr"><strong>TL;DR</strong></h3>
<p>We optimized our Pub/Sub automation script, reducing execution time from over 1 hour to less than 30 seconds using Node.js. Here’s a quick overview of the improvements:</p>
<ol>
<li><p><strong>Initial Python Script</strong>: Sequential processing, took over 1 hour.</p>
</li>
<li><p><strong>Improved Python Script</strong>: Asynchronous processing, reduced time to 5 minutes.</p>
</li>
<li><p><strong>Node.js Script</strong>: Further optimized, reduced time to less than 30 seconds.</p>
</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1739205302199/ea4da3f8-9346-4acc-8e58-7957fa283838.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-from-over-1-hour-to-less-than-30-seconds-optimizing-pubsub-automation"><strong>From Over 1 Hour to Less Than 30 Seconds: Optimizing Pub/Sub Automation</strong></h3>
<p>In our quest to enhance performance, we transformed our Pub/Sub automation script from a slow, sequential process to a lightning-fast, asynchronous one. Here’s how we did it.</p>
<h4 id="heading-initial-python-script"><strong>Initial Python Script</strong></h4>
<p>Our initial script was simple but slow, taking over 1 hour to create Pub/Sub topics and subscriptions sequentially.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1739204068253/38838b1f-18ec-4df4-9967-62afc5956b73.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> google.cloud <span class="hljs-keyword">import</span> pubsub_v1
<span class="hljs-keyword">import</span> mysql.connector

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_topic</span>(<span class="hljs-params">project_id, topic_name</span>):</span>
    publisher = pubsub_v1.PublisherClient()
    publisher.create_topic(request={<span class="hljs-string">"name"</span>: publisher.topic_path(project_id, topic_name)})

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_subscription</span>(<span class="hljs-params">project_id, topic_name, subscription_name, filter_expression</span>):</span>
    subscriber = pubsub_v1.SubscriberClient()
    subscriber.create_subscription(request={
        <span class="hljs-string">"name"</span>: subscriber.subscription_path(project_id, subscription_name),
        <span class="hljs-string">"topic"</span>: subscriber.topic_path(project_id, topic_name),
        <span class="hljs-string">"filter"</span>: filter_expression,
    })

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">fetch_data</span>():</span>
    conn = mysql.connector.connect(host=<span class="hljs-string">""</span>, port=<span class="hljs-string">"3306"</span>, user=<span class="hljs-string">""</span>, password=<span class="hljs-string">""</span>, database=<span class="hljs-string">"ecms"</span>)
    cursor = conn.cursor()
    cursor.execute(<span class="hljs-string">"SELECT name FROM your_table"</span>)
    results = cursor.fetchall()
    conn.close()
    <span class="hljs-keyword">return</span> results

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_pubsub_resources</span>(<span class="hljs-params">project_id, name</span>):</span>
    topic_name = <span class="hljs-string">f"topic-<span class="hljs-subst">{name}</span>"</span>
    subscription_name = <span class="hljs-string">f"subscription-<span class="hljs-subst">{name}</span>"</span>
    filter_expression = <span class="hljs-string">f'attributes.name = "<span class="hljs-subst">{name}</span>"'</span>
    create_topic(project_id, topic_name)
    create_subscription(project_id, topic_name, subscription_name, filter_expression)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    project_id = <span class="hljs-string">"your-project-id"</span>
    data = fetch_data()
    <span class="hljs-keyword">for</span> (name,) <span class="hljs-keyword">in</span> data:
        create_pubsub_resources(project_id, name)
</code></pre>
<p><strong>Key Details:</strong></p>
<ul>
<li><p><strong>Sequential Processing</strong>: Each Pub/Sub resource is created one after the other.</p>
</li>
<li><p><strong>Execution Time</strong>: Over 1 hour due to the sequential nature and blocking I/O operations.</p>
</li>
</ul>
<h4 id="heading-improved-python-script"><strong>Improved Python Script</strong></h4>
<p>By introducing asynchronous processing, we reduced the execution time to 5 minutes.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1739204092222/fc4e49b0-6643-419b-8d3d-8ed110ee280d.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> asyncio
<span class="hljs-keyword">from</span> google.cloud <span class="hljs-keyword">import</span> pubsub_v1
<span class="hljs-keyword">import</span> mysql.connector

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_topic</span>(<span class="hljs-params">publisher, project_id, topic_name</span>):</span>
    <span class="hljs-keyword">await</span> asyncio.to_thread(publisher.create_topic, request={<span class="hljs-string">"name"</span>: publisher.topic_path(project_id, topic_name)})

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_subscription</span>(<span class="hljs-params">subscriber, project_id, topic_name, subscription_name, filter_expression</span>):</span>
    <span class="hljs-keyword">await</span> asyncio.to_thread(subscriber.create_subscription, request={
        <span class="hljs-string">"name"</span>: subscriber.subscription_path(project_id, subscription_name),
        <span class="hljs-string">"topic"</span>: subscriber.topic_path(project_id, topic_name),
        <span class="hljs-string">"filter"</span>: filter_expression,
    })

<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">fetch_data</span>():</span>
    conn = mysql.connector.connect(host=<span class="hljs-string">""</span>, port=<span class="hljs-string">"3306"</span>, user=<span class="hljs-string">""</span>, password=<span class="hljs-string">""</span>, database=<span class="hljs-string">"ecms"</span>)
    cursor = conn.cursor()
    cursor.execute(<span class="hljs-string">"SELECT name FROM your_table"</span>)
    results = cursor.fetchall()
    conn.close()
    <span class="hljs-keyword">return</span> results

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_pubsub_resources</span>(<span class="hljs-params">project_id, name</span>):</span>
    publisher = pubsub_v1.PublisherClient()
    subscriber = pubsub_v1.SubscriberClient()
    topic_name = <span class="hljs-string">f"topic-<span class="hljs-subst">{name}</span>"</span>
    subscription_name = <span class="hljs-string">f"subscription-<span class="hljs-subst">{name}</span>"</span>
    filter_expression = <span class="hljs-string">f'attributes.name = "<span class="hljs-subst">{name}</span>"'</span>
    <span class="hljs-keyword">await</span> create_topic(publisher, project_id, topic_name)
    <span class="hljs-keyword">await</span> create_subscription(subscriber, project_id, topic_name, subscription_name, filter_expression)

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span>():</span>
    project_id = <span class="hljs-string">"your-project-id"</span>
    data = fetch_data()
    tasks = [create_pubsub_resources(project_id, name) <span class="hljs-keyword">for</span> (name,) <span class="hljs-keyword">in</span> data]
    <span class="hljs-keyword">await</span> asyncio.gather(*tasks)

<span class="hljs-keyword">if</span> __name__ == <span class="hljs-string">"__main__"</span>:
    asyncio.run(main())
</code></pre>
<p><strong>Key Details:</strong></p>
<ul>
<li><p><strong>Asynchronous Processing</strong>: Uses <code>asyncio</code> to run tasks concurrently.</p>
</li>
<li><p><strong>Execution Time</strong>: Reduced to 5 minutes by overlapping I/O operations.</p>
</li>
</ul>
<h4 id="heading-nodejs-script"><strong>Node.js Script</strong></h4>
<p>Finally, rewriting the script in Node.js reduced the execution time to less than 30 seconds.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1739204102331/a03ee056-07c3-41af-bce4-975c064f04bb.png" alt class="image--center mx-auto" /></p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> {PubSub} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'@google-cloud/pubsub'</span>);
<span class="hljs-keyword">const</span> mysql = <span class="hljs-built_in">require</span>(<span class="hljs-string">'mysql2'</span>);
<span class="hljs-keyword">const</span> {promisify} = <span class="hljs-built_in">require</span>(<span class="hljs-string">'util'</span>);

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createTopic</span>(<span class="hljs-params">pubSubClient, topicName</span>) </span>{
    <span class="hljs-keyword">const</span> topic = pubSubClient.topic(topicName);
    <span class="hljs-keyword">await</span> topic.create();
}

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createSubscription</span>(<span class="hljs-params">pubSubClient, topicName, subscriptionName, filterExpression</span>) </span>{
    <span class="hljs-keyword">const</span> topic = pubSubClient.topic(topicName);
    <span class="hljs-keyword">const</span> subscription = topic.subscription(subscriptionName);
    <span class="hljs-keyword">await</span> subscription.create({<span class="hljs-attr">filter</span>: filterExpression});
}

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fetchData</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> connection = mysql.createConnection({<span class="hljs-attr">host</span>: <span class="hljs-string">""</span>, <span class="hljs-attr">port</span>: <span class="hljs-number">3306</span>, <span class="hljs-attr">user</span>: <span class="hljs-string">""</span>, <span class="hljs-attr">password</span>: <span class="hljs-string">""</span>, <span class="hljs-attr">database</span>: <span class="hljs-string">"ecms"</span>});
    <span class="hljs-keyword">const</span> query = <span class="hljs-string">"SELECT name FROM your_table"</span>;
    <span class="hljs-keyword">const</span> rows = <span class="hljs-keyword">await</span> promisify(connection.query).bind(connection)(query);
    connection.end();
    <span class="hljs-keyword">return</span> rows;
}

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">createPubSubResources</span>(<span class="hljs-params">pubSubClient, name</span>) </span>{
    <span class="hljs-keyword">const</span> topicName = <span class="hljs-string">`topic-<span class="hljs-subst">${name}</span>`</span>;
    <span class="hljs-keyword">const</span> subscriptionName = <span class="hljs-string">`subscription-<span class="hljs-subst">${name}</span>`</span>;
    <span class="hljs-keyword">const</span> filterExpression = <span class="hljs-string">`attributes.name = "<span class="hljs-subst">${name}</span>"`</span>;
    <span class="hljs-keyword">await</span> createTopic(pubSubClient, topicName);
    <span class="hljs-keyword">await</span> createSubscription(pubSubClient, topicName, subscriptionName, filterExpression);
}

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">main</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> projectId = <span class="hljs-string">"your-project-id"</span>;
    <span class="hljs-keyword">const</span> pubSubClient = <span class="hljs-keyword">new</span> PubSub({projectId});
    <span class="hljs-keyword">const</span> data = <span class="hljs-keyword">await</span> fetchData();
    <span class="hljs-keyword">const</span> tasks = data.map(<span class="hljs-function">(<span class="hljs-params">{name}</span>) =&gt;</span>
        createPubSubResources(pubSubClient, name)
    );
    <span class="hljs-keyword">await</span> <span class="hljs-built_in">Promise</span>.all(tasks);
}

main().catch(<span class="hljs-built_in">console</span>.error);
</code></pre>
<p><strong>Key Details:</strong></p>
<ul>
<li><p><strong>Non-Blocking I/O</strong>: Node.js handles I/O operations asynchronously, making it highly efficient for this task.</p>
</li>
<li><p><strong>Execution Time</strong>: Reduced to less than 30 seconds due to the efficient handling of concurrent operations.</p>
</li>
</ul>
<h4 id="heading-conclusion"><strong>Conclusion</strong></h4>
<p>By leveraging asynchronous programming and Node.js, we achieved a significant performance boost, reducing the execution time from over 1 hour to less than 30 seconds. This journey underscores the importance of optimizing code for better efficiency and scalability.</p>
]]></content:encoded></item><item><title><![CDATA[🚀 Automated ISP Internet Speed Test & Complaint To X(Twitter) in Nodejs]]></title><description><![CDATA[https://github.com/gitSambhal/speedtest-complaint-js
 
This clever Node.js script automatically monitors your internet speed and helps you hold your ISP accountable when they don't deliver the speeds you're paying for!

Key Features:

Runs automated ...]]></description><link>https://blog.suhail.top/automated-isp-internet-speed-test-complaint-to-xtwitter-in-nodejs</link><guid isPermaLink="true">https://blog.suhail.top/automated-isp-internet-speed-test-complaint-to-xtwitter-in-nodejs</guid><category><![CDATA[Node.js]]></category><category><![CDATA[projects]]></category><category><![CDATA[internet speed test]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Sat, 26 Oct 2024 10:17:51 GMT</pubDate><content:encoded><![CDATA[<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/gitSambhal/speedtest-complaint-js">https://github.com/gitSambhal/speedtest-complaint-js</a></div>
<p> </p>
<p>This clever Node.js script automatically monitors your internet speed and helps you hold your ISP accountable when they don't deliver the speeds you're paying for!</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1729937539243/e52659f8-fd1d-491c-9048-2180237c2b42.png" alt class="image--center mx-auto" /></p>
<p>Key Features:</p>
<ul>
<li><p>Runs automated speed tests on a configurable schedule</p>
</li>
<li><p>Compares actual speeds against promised ISP speeds</p>
</li>
<li><p>Generates pre-formatted complaint posts for X (Twitter) when speeds fall below threshold</p>
</li>
<li><p>Tags your ISP's handles automatically</p>
</li>
<li><p>Includes speed test results as proof</p>
</li>
</ul>
<p>Configuration options let you set:</p>
<ul>
<li><p>ISP X handles to tag</p>
</li>
<li><p>Promised internet speed</p>
</li>
<li><p>Minimum acceptable speed threshold</p>
</li>
<li><p>Custom scheduling via cron expressions</p>
</li>
<li><p>Customizable complaint message template</p>
</li>
</ul>
<p>Perfect for:</p>
<ul>
<li><p>Internet users tired of inconsistent speeds</p>
</li>
<li><p>Anyone wanting data-driven evidence for ISP complaints</p>
</li>
<li><p>Tech-savvy folks who love automation</p>
</li>
</ul>
<p>The code uses modern ES modules and the croner package for scheduling. It's clean, well-documented, and ready to help you get the internet service you deserve!</p>
<p>Want to keep your ISP honest? Give this repo a try! 🌐⚡️</p>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://github.com/gitSambhal/speedtest-complaint-js">https://github.com/gitSambhal/speedtest-complaint-js</a></div>
<p> </p>
<p>#ISP #Automation #JavaScript #NodeJS #InternetSpeed</p>
]]></content:encoded></item><item><title><![CDATA[Apple Tried to Stop Me From Uploading 45,000 Contacts to iCloud. What I Did Next Will Shock You.]]></title><description><![CDATA[A friend recently asked me to help upload their 45,000 contacts to iCloud. I knew Apple limits how many contacts you can upload at once, but I was determined to get all 45,000 contacts into iCloud. Here's how I shocked Apple and succeeded in my missi...]]></description><link>https://blog.suhail.top/apple-tried-to-stop-me-from-uploading-45000-contacts-to-icloud-what-i-did-next-will-shock-you</link><guid isPermaLink="true">https://blog.suhail.top/apple-tried-to-stop-me-from-uploading-45000-contacts-to-icloud-what-i-did-next-will-shock-you</guid><category><![CDATA[apple icloud contacts]]></category><category><![CDATA[Apple]]></category><category><![CDATA[icloud]]></category><category><![CDATA[contacts]]></category><category><![CDATA[Vcf]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Sat, 09 Mar 2024 21:25:42 GMT</pubDate><content:encoded><![CDATA[<p>A friend recently asked me to help upload their 45,000 contacts to iCloud. I knew Apple limits how many contacts you can upload at once, but I was determined to get all 45,000 contacts into iCloud. Here's how I shocked Apple and succeeded in my mission.</p>
<h2 id="heading-splitting-up-the-contacts"><strong>Splitting up the Contacts</strong></h2>
<p>First, I took the single 45,000 contact VCF file and split it into multiple files with 1,000 contacts each using my <a target="_blank" href="https://online-vcf-splitter.netlify.app"><strong>online VCF splitter tool</strong></a>.</p>
<p>The tool allows you to easily split a large VCF file into smaller files with a specified number of contacts in each output file.</p>
<p>I split the large VCF into 45 files named <code>split_contacts_1.vcf</code>, <code>split_contacts_2.vcf</code>, etc. Each file had 1,000 contacts.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710015447753/c48913b8-daa4-476d-9201-a3f99cf7e68a.png" alt class="image--center mx-auto" /></p>
<p>Downloaded the zip file of the splitted vcf files and then extracted it to a folder.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710018746843/9bad5aea-0592-4bf2-ac90-d8e3360d8e7d.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-uploading-to-icloud"><strong>Uploading to iCloud</strong></h2>
<p>With the files split up, I was ready to start uploading to iCloud. Here were the steps:</p>
<ol>
<li><p>Go to iCloud.com and login to your account.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710015820720/217c9d1e-cae6-41ee-9178-d3a8a9ecebe2.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Click Contacts.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710016409497/89dc7d46-fd1f-429b-bbc7-18980767e50a.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Click the plus icon(+) and choose "Import contact..."</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710016704692/b6e2b7f9-dabc-4d54-bf34-87ef11d20f8c.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Select the first 1,000 contact VCF file and upload it. (Status code 200 means successful import)</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710017162217/7568ce8d-ea5c-41c3-a472-78ec6ceca538.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Refresh the page and select all the contacts or scroll to the bottom to see the number of contacts uploaded successfully.</p>
</li>
<li><p>Repeat steps 3-5 for each split VCF file until all 45 are uploaded.</p>
</li>
</ol>
<h2 id="heading-progress">Progress</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710019140530/6682e12e-6109-4c71-9ca0-1d582fd2c3f8.jpeg" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710019241326/09df13ef-1066-448b-ae7e-2016aa1edf33.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710019032100/555e135e-1827-4f08-aaa4-14ec4ea567d5.jpeg" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710019015896/9592cacd-9aee-4dfc-8f9a-5a6767184887.jpeg" alt class="image--center mx-auto" /></p>
<p>I monitored the network requests closely to ensure each file was uploading successfully.</p>
<h2 id="heading-apple-tried-to-stop-me"><strong>Apple Tried to Stop Me</strong></h2>
<p>As expected, Apple imposed limits to try and stop me from uploading so many contacts. But I persevered and worked around the errors:</p>
<ol>
<li><p><strong>Contacts is locked</strong> - Due to account maintenance, Contacts is currently unavailable.This error means that iCloud rate limited me temporarily. I waited a few hours and tried uploading again.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710018217599/7cf60cc9-11f0-4752-a3da-b5240b1d54c1.jpeg" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>"Unable to import vCard</strong> - This vCard cannot be imported because it contains invalid contact data."</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710017665347/8cbf43b1-9101-4614-b044-e00a3f8b6b71.png" alt class="image--center mx-auto" /></p>
<p> This error can occurred sometimes even after the contacts are uploaded so just refresh the page and select all contacts or scroll to the end of the contacts list to get the total number of uploaded contacts. If the contacts are uploaded successfully then it will reflect in the count otherwise retry by uploading the vcf file again.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1710018502827/30be7fae-de35-4424-906b-2ff7980f9a5a.png" alt class="image--center mx-auto" /></p>
</li>
<li><p><strong>No error displayed</strong> - Sometimes no error was shown in the UI even though contacts were not uploaded successfully. To confirm, I refreshed the page and checked the contacts count by selecting all or scrolling to the end. I also monitored the network requests in the browser dev tools.</p>
</li>
<li><p>I tried uploading the complete vcf file using the contacts app in Mac but only around 10000 files were synced with iCloud.</p>
</li>
</ol>
<p>With determination and systematically working around Apple's roadblocks, I shocked them by successfully uploading all 45,000 contacts!</p>
]]></content:encoded></item><item><title><![CDATA[How to change git branch in multiple projects at once and pull the latest changes?]]></title><description><![CDATA[$ cd /my-projects

$ cd project1 && git checkout develop && git pull origin develop && cd ..
$ cd project2 && git checkout develop && git pull origin develop && cd ..
$ cd project3 && git checkout develop && git pull origin develop && cd ..
$ cd proj...]]></description><link>https://blog.suhail.top/how-to-change-git-branch-in-multiple-projects-at-once-and-pull-the-latest-changes</link><guid isPermaLink="true">https://blog.suhail.top/how-to-change-git-branch-in-multiple-projects-at-once-and-pull-the-latest-changes</guid><category><![CDATA[Git]]></category><category><![CDATA[Bash]]></category><category><![CDATA[checkout]]></category><category><![CDATA[branch]]></category><category><![CDATA[remote]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Thu, 07 Mar 2024 10:41:27 GMT</pubDate><content:encoded><![CDATA[<pre><code class="lang-bash">$ <span class="hljs-built_in">cd</span> /my-projects

$ <span class="hljs-built_in">cd</span> project1 &amp;&amp; git checkout develop &amp;&amp; git pull origin develop &amp;&amp; <span class="hljs-built_in">cd</span> ..
$ <span class="hljs-built_in">cd</span> project2 &amp;&amp; git checkout develop &amp;&amp; git pull origin develop &amp;&amp; <span class="hljs-built_in">cd</span> ..
$ <span class="hljs-built_in">cd</span> project3 &amp;&amp; git checkout develop &amp;&amp; git pull origin develop &amp;&amp; <span class="hljs-built_in">cd</span> ..
$ <span class="hljs-built_in">cd</span> project4 &amp;&amp; git checkout develop &amp;&amp; git pull origin develop &amp;&amp; <span class="hljs-built_in">cd</span> ..
</code></pre>
<p><img src="https://media.licdn.com/dms/image/D4D22AQHO05-JjP4I3Q/feedshare-shrink_2048_1536/0/1701884889909?e=1712793600&amp;v=beta&amp;t=EvQDyPzAZE_s8R55nFRPTZ-iujAOFqBVxf3WvDlue3c" alt="No alt text provided for this image" /></p>
]]></content:encoded></item><item><title><![CDATA[Introducing VCF Splitter: Online VCF Splitter Tool]]></title><description><![CDATA[tldr:
Explore VCF Splitter here.Link1: https://online-vcf-splitter.pages.devLink2: https://online-vcf-splitter.netlify.app
🚀 Introducing VCF Splitter: Solution for Effortless Contact Management! 🚀I'm thrilled to present VCF Splitter, a helpful tool...]]></description><link>https://blog.suhail.top/introducing-vcf-splitter-online-vcf-splitter-tool</link><guid isPermaLink="true">https://blog.suhail.top/introducing-vcf-splitter-online-vcf-splitter-tool</guid><category><![CDATA[vcf splitter]]></category><category><![CDATA[split vcf online]]></category><category><![CDATA[vcf online splitter]]></category><category><![CDATA[free vcf splitter]]></category><category><![CDATA[Vcf]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Tue, 05 Mar 2024 05:12:15 GMT</pubDate><content:encoded><![CDATA[<p>tldr:</p>
<p>Explore VCF Splitter here.<br />Link1: <a target="_blank" href="https://online-vcf-splitter.pages.dev￼Link2"><strong>https://online-vcf-splitter.pages.dev<br />Link2</strong></a><a target="_blank" href="https://lnkd.in/gcJv-eMs%EF%BF%BCLink2">:</a> <a target="_blank" href="https://online-vcf-splitter.netlify.app"><strong>https://online-vcf-splitter.netlify.app</strong></a></p>
<p><a target="_blank" href="https://online-vcf-splitter.netlify.app/">🚀 Introducing VCF Splitter: Soluti</a>on for Effortless Contact Management! 🚀<br />I'm thrilled to present <a target="_blank" href="https://online-vcf-splitter.pages.dev">VCF Splitter</a>, a helpful tool crafted with care for my friend who juggles a whopping 50,000 contacts! 🎉</p>
<p><a target="_blank" href="https://online-vcf-splitter.pages.dev"><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1709616006163/c86586f2-333d-46a9-a309-2026b65d16be.png" alt class="image--center mx-auto" /></a></p>
<p>What is VCF?<br />VCF, short for vCard File, is the go-to format for digital business cards, holding essential details like names, numbers, and emails.</p>
<p>Features Tailored for You:<br />✅ Local Splitting: Ensure data security by splitting VCF files directly on your device.<br />✅ Custom Chunk Size: Personalize the split size to suit your contact management needs.<br />✅ Download Options: Effortlessly download individual splits or gather them all in a ZIP file.</p>
<p>How It Works:<br />Upload: Select your VCF file.<br />Customize: Choose your preferred chunk size.<br />Split: Click "Split VCF" to get neatly organized contact files.</p>
<p>This project was born out of the desire to simplify contact management for my friend and anyone else dealing with massive contact lists.</p>
<p>Explore VCF Splitter here.<br />Link1: <a target="_blank" href="https://online-vcf-splitter.pages.dev">https://online-vcf-splitter.pages.dev</a><a target="_blank" href="https://lnkd.in/gcJv-eMs%EF%BF%BCLink2"><br />Link2</a>: <a target="_blank" href="https://online-vcf-splitter.netlify.app">https://online-vcf-splitter.netlify.app</a></p>
]]></content:encoded></item><item><title><![CDATA[Nodejs Fix Error connect ECONNREFUSED ::1:80 while using localhost]]></title><description><![CDATA[Introduction
Node.js serves as a powerful platform for building server-side applications, but encountering errors, especially during local development, can disrupt progress. One such error is connect ECONNREFUSED ::1:80, commonly faced while attempti...]]></description><link>https://blog.suhail.top/nodejs-fix-error-connect-econnrefused-180-while-using-localhost</link><guid isPermaLink="true">https://blog.suhail.top/nodejs-fix-error-connect-econnrefused-180-while-using-localhost</guid><category><![CDATA[Node.js]]></category><category><![CDATA[axios]]></category><category><![CDATA[error handling]]></category><category><![CDATA[javscript]]></category><category><![CDATA[localhost]]></category><category><![CDATA[ECONNREFUSED]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Sat, 16 Dec 2023 16:18:24 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1702745568780/26e8c7b6-0a8e-4f5d-a0c5-410bdf8f851b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-introduction">Introduction</h1>
<p>Node.js serves as a powerful platform for building server-side applications, but encountering errors, especially during local development, can disrupt progress. One such error is <code>connect ECONNREFUSED ::1:80</code>, commonly faced while attempting to connect to a local server.</p>
<h1 id="heading-understanding-the-error">Understanding the Error</h1>
<p>The error message <code>connect ECONNREFUSED ::1:80</code> signifies that the Node.js application is attempting to connect to the IPv6 loopback address (::1) on port 80, commonly used for HTTP traffic. However, the connection is being refused, leading to the error.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> axios = <span class="hljs-built_in">require</span>(<span class="hljs-string">"axios"</span>)

<span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">const</span> { data } = <span class="hljs-keyword">await</span> axios.get(<span class="hljs-string">'http://localhost'</span>)
} <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.log(error.message)
    <span class="hljs-comment">// output: "connect ECONNREFUSED ::1:80"</span>
}
</code></pre>
<h1 id="heading-solution-1">Solution 1</h1>
<p>You can fix the <code>connect ECONNREFUSED ::1:80</code> error by explicitly specifying the IPv4 loopback address (127.0.0.1) instead of relying on the IPv6 (::1) address.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> axios = <span class="hljs-built_in">require</span>(<span class="hljs-string">"axios"</span>)

<span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">const</span> { data } = <span class="hljs-keyword">await</span> axios.get(<span class="hljs-string">'http://127.0.0.1'</span>)
    <span class="hljs-comment">// Success Response</span>
} <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.log(error.message)
}
</code></pre>
<h1 id="heading-solution-2">Solution 2</h1>
<p>Starting from Node.js 17 IPv6 connections are prioritized when making network calls. This is great for future-proofing your code, but it can cause problems if the server you're trying to reach only supports IPv4. This is where <code>setDefaultResultOrder()</code> comes in like a knight in shining armor.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> axios = <span class="hljs-built_in">require</span>(<span class="hljs-string">"axios"</span>)
<span class="hljs-keyword">const</span> { setDefaultResultOrder } = <span class="hljs-built_in">require</span>(<span class="hljs-string">"dns"</span>);

setDefaultResultOrder(<span class="hljs-string">"ipv4first"</span>);

<span class="hljs-keyword">try</span> {
    <span class="hljs-keyword">const</span> { data } = <span class="hljs-keyword">await</span> axios.get(<span class="hljs-string">'http://localhost'</span>)
    <span class="hljs-comment">// Success Response</span>
} <span class="hljs-keyword">catch</span> (error) {
    <span class="hljs-built_in">console</span>.log(error.message)
}
</code></pre>
<h1 id="heading-solution-3">Solution 3</h1>
<p>Degrading the version of Nodejs runtime to Nodejs 16 or lower can also fix the issue but it is not recommended.</p>
<h1 id="heading-try-yourself">Try Yourself</h1>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://runkit.com/gitsambhal/nodejs-fix-error-connect-econnrefused-1-80-while-using-localhost">https://runkit.com/gitsambhal/nodejs-fix-error-connect-econnrefused-1-80-while-using-localhost</a></div>
<p> </p>
<h1 id="heading-conclusion"><strong>Conclusion</strong></h1>
<p>Resolving the <code>connect ECONNREFUSED ::1:80</code> error involves understanding the intricacies of local network configurations and resolving conflicts that prevent the successful connection of your Node.js application. By implementing the suggested troubleshooting steps and potential fixes, developers can overcome this error, ensuring uninterrupted progress in their development environment.</p>
<p>We hope this guide helps you tackle the <code>connect ECONNREFUSED ::1:80</code> error, enabling you to focus on building your Node.js applications without connectivity hurdles during local development.</p>
<p>Stay tuned for more insightful troubleshooting tips and solutions!</p>
]]></content:encoded></item><item><title><![CDATA[Node.js Tutorial: Convert Currency Codes to Symbols in Seconds]]></title><description><![CDATA[Introduction:
Working with currency symbols can be tricky in any programming language, but especially so in Node.js. Fortunately, the currency-symbol-map package provides an easy-to-use solution for handling currency symbols in your Node.js applicati...]]></description><link>https://blog.suhail.top/nodejs-tutorial-convert-currency-codes-to-symbols-in-seconds</link><guid isPermaLink="true">https://blog.suhail.top/nodejs-tutorial-convert-currency-codes-to-symbols-in-seconds</guid><category><![CDATA[Node.js]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[npm]]></category><category><![CDATA[Browsers]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Sat, 29 Apr 2023 20:07:23 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1682798698340/b7f7ce55-7daa-409e-907b-66cc55f1aee4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction:</h2>
<p>Working with currency symbols can be tricky in any programming language, but especially so in Node.js. Fortunately, the <code>currency-symbol-map</code> package provides an easy-to-use solution for handling currency symbols in your Node.js application. Whether you're building a financial application or simply need to display currency symbols in your UI, <code>currency-symbol-map</code> can simplify the process for you.</p>
<h2 id="heading-installation">Installation:</h2>
<p>To use <code>currency-symbol-map</code> in your Node.js application, you first need to install it via npm. Open your terminal or command prompt and run the following command:</p>
<pre><code class="lang-bash">npm install currency-symbol-map
</code></pre>
<h2 id="heading-usage">Usage:</h2>
<p>Once you've installed <code>currency-symbol-map</code>, you can use it in your code like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> currencySymbolMap = <span class="hljs-built_in">require</span>(<span class="hljs-string">'currency-symbol-map'</span>);

<span class="hljs-built_in">console</span>.log(currencySymbolMap(<span class="hljs-string">'USD'</span>)); <span class="hljs-comment">// outputs '$'</span>
<span class="hljs-built_in">console</span>.log(currencySymbolMap(<span class="hljs-string">'EUR'</span>)); <span class="hljs-comment">// outputs '€'</span>
<span class="hljs-built_in">console</span>.log(currencySymbolMap(<span class="hljs-string">'JPY'</span>)); <span class="hljs-comment">// outputs '¥'</span>
</code></pre>
<p>As you can see, using <code>currency-symbol-map</code> is as simple as requiring the package and passing in a currency code as a parameter.</p>
<h2 id="heading-examples">Examples:</h2>
<p>Let's take a look at some practical examples of using <code>currency-symbol-map</code> in real-world scenarios.</p>
<h3 id="heading-example-1-displaying-currency-symbols-in-a-ui">Example 1: Displaying Currency Symbols in a UI</h3>
<p>Suppose you're building an e-commerce website and need to display the currency symbol next to the product price. You can easily accomplish this with <code>currency-symbol-map</code>:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> currencySymbolMap = <span class="hljs-built_in">require</span>(<span class="hljs-string">'currency-symbol-map'</span>);

<span class="hljs-keyword">const</span> productPrice = <span class="hljs-number">10.99</span>;
<span class="hljs-keyword">const</span> currencyCode = <span class="hljs-string">'USD'</span>;

<span class="hljs-keyword">const</span> currencySymbol = currencySymbolMap(currencyCode);

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${currencySymbol}</span><span class="hljs-subst">${productPrice}</span>`</span>); 
<span class="hljs-comment">// outputs '$10.99'</span>
</code></pre>
<h3 id="heading-example-2-formatting-currency-values">Example 2: Formatting Currency Values</h3>
<p>In this example, we have an array of products with different currencies. We use the <code>forEach</code> method to loop through each product and get the currency symbol using the <code>currencySymbolMap</code> package. We then format the price by concatenating the currency symbol with the price rounded to 2 decimal places using the <code>toFixed</code> method. Finally, we log the name of the product and the formatted price to the console.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> currencySymbolMap = <span class="hljs-built_in">require</span>(<span class="hljs-string">'currency-symbol-map'</span>);

<span class="hljs-keyword">const</span> products = [
  { <span class="hljs-attr">name</span>: <span class="hljs-string">'Product A'</span>, <span class="hljs-attr">price</span>: <span class="hljs-number">10.99</span>, <span class="hljs-attr">currencyCode</span>: <span class="hljs-string">'USD'</span> },
  { <span class="hljs-attr">name</span>: <span class="hljs-string">'Product B'</span>, <span class="hljs-attr">price</span>: <span class="hljs-number">9.99</span>, <span class="hljs-attr">currencyCode</span>: <span class="hljs-string">'EUR'</span> },
  { <span class="hljs-attr">name</span>: <span class="hljs-string">'Product C'</span>, <span class="hljs-attr">price</span>: <span class="hljs-number">15.99</span>, <span class="hljs-attr">currencyCode</span>: <span class="hljs-string">'JPY'</span> }
];

products.forEach(<span class="hljs-function"><span class="hljs-params">product</span> =&gt;</span> {
  <span class="hljs-keyword">const</span> { name, price, currencyCode } = product;
  <span class="hljs-keyword">const</span> currencySymbol = currencySymbolMap(currencyCode);
  <span class="hljs-keyword">const</span> formattedPrice = <span class="hljs-string">`<span class="hljs-subst">${currencySymbol}</span><span class="hljs-subst">${price.toFixed(<span class="hljs-number">2</span>)}</span>`</span>;
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">`<span class="hljs-subst">${name}</span>: <span class="hljs-subst">${formattedPrice}</span>`</span>);
});

<span class="hljs-comment">// Output:</span>
<span class="hljs-comment">// Product A: $10.99</span>
<span class="hljs-comment">// Product B: €9.99</span>
<span class="hljs-comment">// Product C: ¥15.99</span>
</code></pre>
<h2 id="heading-conclusion">Conclusion:</h2>
<p>The <code>currency-symbol-map</code> package provides a simple and effective way to work with currency symbols in your Node.js application. Whether you're working with financial data or simply need to display currency symbols in your UI, <code>currency-symbol-map</code> can help you streamline your development process.</p>
<p><a target="_blank" href="https://www.freepik.com/free-photo/world-international-golden-coin-currencies_3740833.htm#query=currency%20symbol&amp;position=1&amp;from_view=search&amp;track=robertav1_2_sidr">Image by</a> <a target="_blank" href="http://rawpixel.com">rawpixel.com</a> on Freepik</p>
]]></content:encoded></item><item><title><![CDATA[Node.js Tutorial: How to Easily Convert Axios Requests to cURL Commands with axios-curlirize in Node.js and the Browser]]></title><description><![CDATA[https://youtu.be/YZ6sD9gwbwM
 
Axios is a popular JavaScript library used for making HTTP requests from a web page or Node.js application. When developing APIs, it can be helpful to convert an Axios request to a cURL command for debugging or testing ...]]></description><link>https://blog.suhail.top/nodejs-tutorial-how-to-easily-convert-axios-requests-to-curl-commands-with-axios-curlirize-in-nodejs-and-the-browser</link><guid isPermaLink="true">https://blog.suhail.top/nodejs-tutorial-how-to-easily-convert-axios-requests-to-curl-commands-with-axios-curlirize-in-nodejs-and-the-browser</guid><category><![CDATA[Node.js]]></category><category><![CDATA[node js]]></category><category><![CDATA[JavaScript]]></category><category><![CDATA[axios]]></category><category><![CDATA[curl]]></category><category><![CDATA[ChaiCode]]></category><dc:creator><![CDATA[Suhail Akhtar]]></dc:creator><pubDate>Sat, 29 Apr 2023 18:17:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1743959024729/595f23a3-4b1d-4a57-b12b-5e1fcdce6cca.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://youtu.be/YZ6sD9gwbwM">https://youtu.be/YZ6sD9gwbwM</a></div>
<p> </p>
<p>Axios is a popular JavaScript library used for making HTTP requests from a web page or Node.js application. When developing APIs, it can be helpful to convert an Axios request to a cURL command for debugging or testing purposes. Fortunately, the <code>axios-curlirize</code> npm package makes it easy to do just that. In this tutorial, we'll show you how to use <code>axios-curlirize</code> to convert Axios requests to cURL commands.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>Before we get started, make sure you have the following installed:</p>
<ul>
<li><p>Node.js (version 12 or higher)</p>
</li>
<li><p>NPM (Node Package Manager)</p>
</li>
</ul>
<h2 id="heading-installing-axios-curlirize">Installing axios-curlirize</h2>
<p>To use <code>axios-curlirize</code>, you need to install it using NPM. Open your terminal and run the following command:</p>
<pre><code class="lang-bash">npm install axios-curlirize
</code></pre>
<h2 id="heading-using-axios-curlirize">Using axios-curlirize</h2>
<p>Once you have <code>axios-curlirize</code> installed, you can start using it to convert Axios requests to cURL commands. Here's an example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> axios = <span class="hljs-built_in">require</span>(<span class="hljs-string">'axios'</span>);
<span class="hljs-keyword">const</span> axiosCurlirize = <span class="hljs-built_in">require</span>(<span class="hljs-string">'axios-curlirize'</span>);

axiosCurlirize(axios);

axios.get(<span class="hljs-string">'https://jsonplaceholder.typicode.com/posts/1'</span>)
  .then(<span class="hljs-function"><span class="hljs-params">response</span> =&gt;</span> {
    <span class="hljs-built_in">console</span>.log(response.data);
  })
  .catch(<span class="hljs-function"><span class="hljs-params">error</span> =&gt;</span> {
    <span class="hljs-built_in">console</span>.error(error);
  });
</code></pre>
<p>In this example, we import <code>axios</code> and <code>axios-curlirize</code>. We then call <code>axiosCurlirize</code> with the <code>axios</code> instance as an argument to enable cURL logging for Axios requests. After that, we make a GET request to <a target="_blank" href="https://jsonplaceholder.typicode.com/posts/1"><code>https://jsonplaceholder.typicode.com/posts/1</code></a> using Axios.</p>
<p>When you run this code, you'll see the cURL command for the Axios request logged to the console, along with the response data:</p>
<pre><code class="lang-bash">$ node app.js
$ curl <span class="hljs-string">'https://jsonplaceholder.typicode.com/posts/1'</span> -H <span class="hljs-string">'User-Agent: axios/0.21.1'</span> -H <span class="hljs-string">'Accept: application/json, text/plain, */*'</span> -H <span class="hljs-string">'Host: jsonplaceholder.typicode.com'</span> -H <span class="hljs-string">'Connection: keep-alive'</span>
{ userId: 1,
  id: 1,
  title: <span class="hljs-string">'sunt aut facere repellat provident occaecati excepturi optio reprehenderit'</span>,
  body: <span class="hljs-string">'quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto'</span>
}
</code></pre>
<p>And that's it! You can now use <code>axios-curlirize</code> to convert your Axios requests to cURL commands for debugging or testing purposes. It's a simple and effective tool to have in your developer toolkit.</p>
]]></content:encoded></item></channel></rss>