<?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[rahuldahal]]></title><description><![CDATA[Playing with JavaScript and its tools since 2018.]]></description><link>https://blog.rahuldahal.com.np</link><generator>RSS for Node</generator><lastBuildDate>Mon, 13 Apr 2026 21:43:12 GMT</lastBuildDate><atom:link href="https://blog.rahuldahal.com.np/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Streams: In general and in Node.js]]></title><description><![CDATA[The other day, I had an interview for the backend engineer position. At one point, they asked if I knew about streams. While I had an understanding of network streams, I was thrown off when the interviewer presented a scenario involving memory size a...]]></description><link>https://blog.rahuldahal.com.np/streams-in-general-and-in-nodejs</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/streams-in-general-and-in-nodejs</guid><category><![CDATA[memory-management]]></category><category><![CDATA[streams in nodejs]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Mon, 15 Jul 2024 14:48:33 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/nLgrPHcqPJE/upload/78cc135a8684f07e352fd7d851250527.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The other day, I had an interview for the backend engineer position. At one point, they asked if I knew about streams. While I had an understanding of network streams, I was thrown off when the interviewer presented a scenario involving memory size and file size. This led to realizing how processing large files works through streams.</p>
<h3 id="heading-understanding-streams-and-their-role">Understanding Streams and their Role</h3>
<ul>
<li><p>Streams are a fundamental concept in Node.js for reading or writing data continuously. They allow data to be processed in chunks rather than loading the entire file into memory.</p>
</li>
<li><p>In the scenario presented during the interview, with a memory size of 2MB and a file size of 10MB, the file would be read in smaller chunks through streams. This prevents overwhelming the memory with the entire file at once.</p>
</li>
</ul>
<h3 id="heading-realization-and-connection-to-streaming-services">Realization and Connection to Streaming Services</h3>
<ul>
<li><p>Reflecting on this, I made the connection that the concept of streaming in applications like YouTube or Netflix involves data being processed in small portions, similar to how streams work in programming.</p>
</li>
<li><p>When we watch a video on YouTube, for example, the video is being streamed to our device in small pieces, allowing for smoother playback and less strain on memory.</p>
</li>
</ul>
<h3 id="heading-exploring-streams-in-nodejs">Exploring Streams in Node.js</h3>
<ul>
<li><p>In Node.js, streams are implemented through several types, such as Readable, Writable, Duplex, and Transform streams.</p>
</li>
<li><p>These streams enable developers to efficiently handle reading from and writing to files, communicating with networks, and other data processing tasks.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Importance of learning via official Documentation for software engineers]]></title><description><![CDATA[Official Documentation is my go-to source for accurate information, providing the foundation for a comprehensive understanding of the technology I'm working with.

Source of Accurate Information: Official Documentation is created by experts in the fi...]]></description><link>https://blog.rahuldahal.com.np/importance-of-learning-via-official-documentation-for-software-engineers</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/importance-of-learning-via-official-documentation-for-software-engineers</guid><category><![CDATA[Software Engineering]]></category><category><![CDATA[learning]]></category><category><![CDATA[documentation]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Fri, 21 Jun 2024 14:38:55 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/UmaojK7erQo/upload/fc97a5a91244c9a83701166b93e7479a.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Official Documentation is my go-to source for accurate information, providing the foundation for a comprehensive understanding of the technology I'm working with.</p>
<ul>
<li><p><strong>Source of Accurate Information</strong>: Official Documentation is created by experts in the field, ensuring that the information provided is reliable and up-to-date.</p>
</li>
<li><p><strong>Structured Learning Materials</strong>: The structured format of Official Documentation allows me to progress systematically through the learning process, covering all essential topics and concepts.</p>
</li>
<li><p><strong>Clear Explanation of Concepts</strong>: Official Documentation breaks down complex technical concepts into easy-to-understand language, making it accessible at my skill level.</p>
</li>
</ul>
<h2 id="heading-boosting-my-confidence">Boosting My Confidence</h2>
<p>By learning from Official Documentation, I gain hands-on practice opportunities and witness real-life application demonstrations, boosting my confidence in my skills and abilities.</p>
<blockquote>
<p>"Hands-on practice with Official Documentation not only enhances my understanding but also gives me the confidence to tackle challenging tasks." - Sarah, Software Engineer</p>
</blockquote>
<ul>
<li><p><strong>Hands-on Practice Opportunities</strong>: Official Documentation often includes interactive exercises and projects allowing me to apply my knowledge practically.</p>
</li>
<li><p><strong>Real-life Application Demonstrations</strong>: Through case studies and examples, Official Documentation showcases how the technology can be used in real-world scenarios, giving me a glimpse into its practical applications.</p>
</li>
<li><p><strong>Building Skills and Expertise</strong>: By following Official Documentation closely, I continuously enhance my skills and expertise, becoming proficient in my chosen technology.</p>
</li>
</ul>
<h2 id="heading-time-efficiency">Time Efficiency</h2>
<p>Learning from Official Documentation can significantly save me time by providing quick reference guides for problem-solving, ensuring updated information availability, and ultimately enhancing my productivity.</p>
<ul>
<li><p><strong>Quick Reference for Problem-Solving</strong>: Official Documentation is my go-to resource when I encounter challenges or need clarification on specific topics, enabling fast and efficient problem-solving.</p>
</li>
<li><p><strong>Updated Information Availability</strong>: With regular updates and revisions, Official Documentation ensures that I have access to the most recent information, keeping me abreast of industry trends and best practices.</p>
</li>
<li><p><strong>Enhanced Productivity</strong>: Efficiently utilizing Official Documentation allows me to streamline my workflow, focus on high-priority tasks, and ultimately enhance my overall productivity.</p>
</li>
</ul>
<h2 id="heading-career-advancement">Career Advancement</h2>
<p>The knowledge and skills acquired through learning from Official Documentation not only showcase my professionalism but also lead to industry recognition and open up new employment opportunities for me as a software engineer.</p>
<ul>
<li><p><strong>Showcase of Professionalism</strong>: Mastering Official Documentation demonstrates my dedication to learning and staying informed about the technology I work with, reflecting positively on my professionalism.</p>
</li>
<li><p><strong>Industry Recognition</strong>: Software engineers who excel in utilizing Official Documentation often receive recognition from industry peers and leaders, establishing themselves as experts in their field.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[Understanding Software as a Service (SaaS)]]></title><description><![CDATA[Software as a Service, commonly known as SaaS. Whether you're a business owner, a tech enthusiast, or someone curious about modern software solutions, understanding SaaS can be incredibly beneficial.
What is SaaS?
Software as a Service (SaaS) is a so...]]></description><link>https://blog.rahuldahal.com.np/understanding-software-as-a-service</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/understanding-software-as-a-service</guid><category><![CDATA[SaaS]]></category><category><![CDATA[business]]></category><category><![CDATA[technology]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Sat, 25 May 2024 11:44:17 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/smgTvepind4/upload/ae81d8f77c51b4204129432dffe20ea6.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Software as a Service, commonly known as SaaS. Whether you're a business owner, a tech enthusiast, or someone curious about modern software solutions, understanding SaaS can be incredibly beneficial.</p>
<h2 id="heading-what-is-saas">What is SaaS?</h2>
<p>Software as a Service (SaaS) is a software distribution model where applications are hosted by a service provider and made available to customers over the Internet. Instead of purchasing and installing software on individual computers or servers, users can access these applications via a web browser, paying a subscription fee for the service.</p>
<h2 id="heading-key-benefits-of-saas">Key Benefits of SaaS</h2>
<p>Let's delve into some of the significant advantages that SaaS offers:</p>
<h3 id="heading-1-accessibility">1. Accessibility</h3>
<p>One of the most appealing aspects of SaaS is its accessibility. SaaS applications are available from any device with an internet connection. Whether we are at the office, at home, or on the go, we can easily access our software from our laptop, tablet, or smartphone. This flexibility ensures that we can stay productive no matter where we are.</p>
<h3 id="heading-2-scalability">2. Scalability</h3>
<p>SaaS solutions are designed to scale effortlessly with our business needs. As our business grows, we can easily adjust our subscription to accommodate more users or access additional features. This scalability means that we only pay for what we need, making SaaS a cost-effective solution for businesses of all sizes.</p>
<h3 id="heading-3-cost-effectiveness">3. Cost-Effectiveness</h3>
<p>Traditional software requires significant upfront investment in licenses and hardware. In contrast, SaaS operates on a subscription basis, which spreads the cost over time and reduces the initial financial burden. Moreover, the subscription model includes maintenance, updates, and support, eliminating unexpected expenses and simplifying budgeting.</p>
<h3 id="heading-4-automatic-updates">4. Automatic Updates</h3>
<p>With SaaS, we always have access to the latest version of the software. Updates and patches are managed by the service provider and deployed automatically. This ensures that we benefit from the newest features, security enhancements, and bug fixes without any manual intervention, keeping our software up-to-date and secure.</p>
<h3 id="heading-5-enhanced-collaboration">5. Enhanced Collaboration</h3>
<p>SaaS applications often come with built-in collaboration tools. These features enable teams to work together seamlessly, regardless of their location. Whether it’s sharing documents, managing projects, or communicating in real-time, SaaS fosters a collaborative environment that can boost productivity and innovation within our organization.</p>
<h2 id="heading-real-world-examples-of-saas">Real-World Examples of SaaS</h2>
<p>We might be more familiar with SaaS than we realize. Here are a few well-known examples:</p>
<ul>
<li><p><strong>Google Workspace</strong>: Provides tools like Gmail, Google Docs, and Google Drive, allowing teams to collaborate and communicate efficiently.</p>
</li>
<li><p><strong>Zoom</strong>: A leading virtual meeting platform that enables seamless video conferencing, webinars, and online meetings, helped us extremely during the 2024 pandemic.</p>
</li>
<li><p><strong>Dropbox</strong>: A cloud storage solution that allows users to store and share files easily.</p>
</li>
<li><p><strong>Slack</strong>: A communication tool that facilitates team collaboration through messaging, file sharing, and integrations with other software.</p>
</li>
</ul>
<h2 id="heading-why-our-business-should-consider-saas">Why Our Business Should Consider SaaS</h2>
<p>Adopting SaaS can bring numerous benefits to our business:</p>
<ul>
<li><p><strong>Reduced IT Complexity</strong>: SaaS providers handle the technical aspects, including server maintenance, data backups, and security measures. This reduces the need for a large in-house IT team and allows us to focus on our core business activities.</p>
</li>
<li><p><strong>Quick Deployment</strong>: SaaS applications can be deployed rapidly, often within hours. This means we can start using the software and gaining its value almost immediately.</p>
</li>
<li><p><strong>Flexibility and Customization</strong>: Many SaaS solutions offer customizable features and integrations with other software, allowing us to tailor the application to meet our business needs.</p>
</li>
</ul>
]]></content:encoded></item><item><title><![CDATA[First Make the Code Work, Then Refactor]]></title><description><![CDATA[In the world of software development, there is often a desire to create perfectly designed and optimized code right from the start. While this goal is admirable, it can sometimes hinder progress and slow down the development process. That's where the...]]></description><link>https://blog.rahuldahal.com.np/first-make-the-code-work-then-refactor</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/first-make-the-code-work-then-refactor</guid><category><![CDATA[software development]]></category><category><![CDATA[refactoring]]></category><category><![CDATA[agile]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Sun, 16 Jul 2023 17:30:07 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/B6JINerWMz0/upload/80fa071298e1915fc8a2d3bba4f18725.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the world of software development, there is often a desire to create perfectly designed and optimized code right from the start. While this goal is admirable, it can sometimes hinder progress and slow down the development process. That's where the idea of "first make the code work, then refactor" comes into play.</p>
<h2 id="heading-the-pursuit-of-perfection">The Pursuit of Perfection</h2>
<p>As developers, we strive to create elegant and efficient code. We want our solutions to be scalable, maintainable, and free from any technical debt. We spend hours brainstorming the best possible design patterns and architecture, trying to predict all the possible future scenarios. While these efforts are certainly valuable, they can sometimes lead to over-engineering and unnecessary complexity.</p>
<h2 id="heading-the-pitfalls-of-over-optimization">The Pitfalls of Over-Optimization</h2>
<p>When we focus too much on making the code perfectly designed from the start, we risk losing sight of the bigger picture. We may spend excessive time and effort on small details that don't contribute significantly to the overall functionality of the software. This can result in delays in delivering the main features and cause frustration among the team and stakeholders.</p>
<p>Additionally, trying to predict all future requirements and potential changes can lead to analysis paralysis. We can spend so much time trying to account for every possible scenario that we end up not shipping anything at all. It's essential to strike a balance between planning for the future and delivering value in the present.</p>
<h2 id="heading-first-make-it-work">First, Make it Work</h2>
<p>Instead of getting hung up on making the code "perfectly designed" right from the start, the focus should be on getting it to work. This means prioritizing functionality and delivering the core features of the software. By adopting an iterative and incremental development approach, we can quickly build a working prototype or minimum viable product (MVP) that satisfies the primary requirements.</p>
<p>During this initial phase, the code may not be the most elegant or efficient, and that's okay. The primary goal is to demonstrate that the software can solve the problem it was designed for. This approach allows for faster feedback cycles, as stakeholders can see tangible progress and provide valuable input early in the process.</p>
<h2 id="heading-refactor-for-quality">Refactor for Quality</h2>
<p>Once the code is working and the main features are in place, it's time to shift the focus toward improving the code quality. Refactoring is the process of restructuring existing code without changing its external behavior. It involves eliminating redundancy, improving readability, and optimizing performance. Refactoring allows us to create more maintainable and scalable software while reducing technical debt.</p>
<p>Let's take a look at an example in JavaScript. Imagine we have a simple function that calculates the sum of an array of numbers:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">calculateSum</span>(<span class="hljs-params">numbers</span>) </span>{
  <span class="hljs-keyword">let</span> sum = <span class="hljs-number">0</span>;
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = <span class="hljs-number">0</span>; i &lt; numbers.length; i++) {
    sum += numbers[i];
  }
  <span class="hljs-keyword">return</span> sum;
}
</code></pre>
<p>The above code works and gives us the correct result. However, we can refactor it to make it more concise and readable:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">calculateSum</span>(<span class="hljs-params">numbers</span>) </span>{
  <span class="hljs-keyword">return</span> numbers.reduce(<span class="hljs-function">(<span class="hljs-params">sum, num</span>) =&gt;</span> sum + num, <span class="hljs-number">0</span>);
}
</code></pre>
<p>By refactoring the code, we've eliminated the need for a loop and made use of the <code>reduce</code> method, which simplifies the logic and improves readability.</p>
]]></content:encoded></item><item><title><![CDATA[Mastering JavaScript: A Vanilla Approach to Learning Libraries and Frameworks]]></title><description><![CDATA[Introduction
Learning a new library or framework can be daunting for newbie programmers. To ensure a solid foundation, adopt a vanilla JavaScript approach first. Gain a deep understanding of the language's core features and implement them before reac...]]></description><link>https://blog.rahuldahal.com.np/mastering-javascript-a-vanilla-approach-to-learning-libraries-and-frameworks</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/mastering-javascript-a-vanilla-approach-to-learning-libraries-and-frameworks</guid><category><![CDATA[javascript tips]]></category><category><![CDATA[Learning Journey]]></category><category><![CDATA[Code Implementation]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Wed, 03 May 2023 05:05:22 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/JyJwO0K5fWM/upload/3aaa20b50612ef075f12ef322697ba39.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-introduction">Introduction</h2>
<p>Learning a new library or framework can be daunting for newbie programmers. To ensure a solid foundation, adopt a vanilla JavaScript approach first. Gain a deep understanding of the language's core features and implement them before reaching for external tools. This philosophy promotes problem-solving skills and informed decision-making when incorporating libraries or frameworks.</p>
<ol>
<li><p>Understanding the Language's Core Features:</p>
<ul>
<li><p>Grasp JavaScript fundamentals: variables, functions, arrays, objects, control flow, etc.</p>
</li>
<li><p>Build a strong knowledge base to support your coding journey.</p>
</li>
</ul>
</li>
<li><p>Implementing Without Libraries: Trial and Error Process:</p>
<ul>
<li><p>Gain hands-on experience by implementing features in vanilla JavaScript.</p>
</li>
<li><p>Encounter challenges and limitations, fostering problem-solving skills.</p>
</li>
<li><p>Understand the problems libraries are designed to solve.</p>
</li>
</ul>
</li>
<li><p>Tackling Challenges and Seeking Solutions:</p>
<ul>
<li><p>Break down problems into smaller parts for easier analysis.</p>
</li>
<li><p>Utilize documentation, online resources, and coding communities.</p>
</li>
<li><p>Engage in forums and discussions to learn from experienced developers.</p>
</li>
</ul>
</li>
<li><p>When and How to Incorporate Libraries/Frameworks:</p>
<ul>
<li><p>Assess project requirements and pain points that can benefit from a specific tool.</p>
</li>
<li><p>Understand the purpose and problem domain of the library or framework.</p>
</li>
<li><p>Consider community support, documentation quality, and maintenance status.</p>
</li>
</ul>
</li>
<li><p>Striking the Right Balance:</p>
<ul>
<li><p>Continuously learn and expand your JavaScript knowledge.</p>
</li>
<li><p>Embrace external tools while maintaining a strong understanding of the language.</p>
</li>
<li><p>Reinvent the wheel for learning purposes to sharpen problem-solving skills.</p>
</li>
</ul>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[The Job and Experience Paradox]]></title><description><![CDATA[The Job and Experience Paradox: Breaking the Cycle
As a talented and enthusiastic programmer seeking employment, you may be caught in a frustrating situation: You need experience to get hired, but you must be employed to gain experience. It's a commo...]]></description><link>https://blog.rahuldahal.com.np/the-job-and-experience-paradox</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/the-job-and-experience-paradox</guid><category><![CDATA[jobs]]></category><category><![CDATA[Experience ]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[Career]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Tue, 14 Jun 2022 11:30:43 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/unsplash/TFFn3BYLc5s/upload/v1655184827957/AhCZvRx1I.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-the-job-and-experience-paradox-breaking-the-cycle">The Job and Experience Paradox: Breaking the Cycle</h2>
<p>As a talented and enthusiastic programmer seeking employment, you may be caught in a frustrating situation: You need experience to get hired, but you must be employed to gain experience. It's a common challenge that many aspiring professionals face. However, there is a solution that can help you break free from this cycle: open source.</p>
<h3 id="heading-understanding-open-source">Understanding Open Source</h3>
<p>Open source development revolves around making source code openly available for others to view, modify, and contribute to. This collaborative approach allows developers of all levels of experience and employment status to work together on projects. Platforms like GitHub provide the infrastructure needed to host and manage open-source projects, offering tools for version control, issue tracking, and collaboration.</p>
<h3 id="heading-how-open-source-can-help">How Open Source Can Help</h3>
<p>By actively participating in open-source projects, you can acquire practical experience and demonstrate your skills to potential employers. Here's a step-by-step guide to get you started:</p>
<ol>
<li><p><strong>Choose the Right Project</strong>: Begin by exploring open-source projects on platforms like GitHub. Narrow down your search based on programming languages, labels, or specific topics that interest you. Look for projects that align with your skills and passions.</p>
</li>
<li><p><strong>Immerse Yourself</strong>: Dive into the project you've chosen. Familiarize yourself with its codebase, documentation, and existing issues. This will help you understand the project's goals, architecture, and areas where you can contribute.</p>
</li>
<li><p><strong>Start Small, Learn Big</strong>: Begin by taking on smaller tasks or issues within the project. This could involve fixing bugs, enhancing documentation, or adding small features. By starting with manageable tasks, you can gradually acquaint yourself with the codebase and development processes.</p>
</li>
<li><p><strong>Engage with the Community</strong>: To interact with other contributors and maintainers, join the project's communication channels, such as mailing lists or chat platforms. Seek guidance, ask questions, and learn from experienced developers. Building relationships within the open-source community can provide valuable mentorship and networking opportunities.</p>
</li>
<li><p><strong>Showcase Your Contributions</strong>: Keep track of the contributions you make to open-source projects. Create a portfolio or list them on your resume. You can also provide links to your GitHub profile to demonstrate your involvement. Highlighting your open-source contributions showcases your collaboration skills and willingness to contribute to real-world projects.</p>
</li>
<li><p><strong>Participate in Events</strong>: Take part in events like Hacktoberfest, an annual celebration of open source where individuals are encouraged to make contributions. These events often provide additional incentives and recognition for your contributions, boosting your visibility within the developer community.</p>
</li>
</ol>
<p>By actively engaging in open-source projects, you can gain practical experience, build a portfolio of real-world projects, and establish your reputation as a dedicated programmer. These contributions serve as tangible evidence of your skills and commitment when applying for job opportunities, even if you lack traditional work experience.</p>
]]></content:encoded></item><item><title><![CDATA[Troubleshooting CSS Pseudo-Elements: Unveiling the Mystery]]></title><description><![CDATA[Debugging CSS Pseudo-elements
Have you ever found yourself in a situation where you applied a CSS pseudo-element to an element, but it just didn't seem to work? Fret not; you're not alone! CSS pseudo-elements can be a powerful tool for adding decorat...]]></description><link>https://blog.rahuldahal.com.np/troubleshooting-css-pseudo-elements-unveiling-the-mystery</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/troubleshooting-css-pseudo-elements-unveiling-the-mystery</guid><category><![CDATA[CSS]]></category><category><![CDATA[Frontend Development]]></category><category><![CDATA[debugging]]></category><category><![CDATA[HTML5]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Wed, 15 Sep 2021 09:23:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/stock/unsplash/ipARHaxETRk/upload/976895ea02e08023ff56cc26fa140eb4.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3 id="heading-debugging-css-pseudo-elements">Debugging CSS Pseudo-elements</h3>
<p>Have you ever found yourself in a situation where you applied a CSS pseudo-element to an element, but it just didn't seem to work? Fret not; you're not alone! CSS pseudo-elements can be a powerful tool for adding decorative elements to your web pages, but they come with certain limitations and nuances that might catch you off guard.</p>
<h3 id="heading-understanding-css-pseudo-elements">Understanding CSS Pseudo-elements</h3>
<p>Before diving into the debugging process, let's briefly understand what CSS pseudo-elements are. In CSS, pseudo-elements are used to style parts of an element rather than the element itself. They are denoted by the<code>::before</code> and<code>::after</code> selectors and are often utilized for adding purely presentational elements to the UI, such as horizontal lines below text, decorative overlays, and more. It's essential to note that pseudo-elements don't carry any semantic meaning and are primarily used for enhancing the visual appearance of elements.</p>
<h3 id="heading-application-of-css-pseudo-elements">Application of CSS Pseudo-elements</h3>
<p>Applying a CSS pseudo-element must be done in conjunction with the <strong>content</strong> property of the targeted element. The pseudo-element is inserted just before or after the content of the element, creating the desired effect.</p>
<h3 id="heading-limitations-of-css-pseudo-elements">Limitations of CSS Pseudo-elements</h3>
<p>However, there are certain cases where pseudo-elements may not work as expected. One of the most common pitfalls is attempting to use pseudo-elements on elements without content. For instance, <code>&lt;img&gt;</code> and <code>&lt;hr&gt;</code> tags are self-closing and do not have content inside them. Therefore, applying a pseudo-element like <code>::before</code> or <code>::after</code> to these elements will have no visible effect.</p>
<p>Let's illustrate this with some CSS examples:</p>
<h3 id="heading-example-1-pseudo-element-not-working-on-tag">Example 1: Pseudo-element not working on <code>&lt;img&gt;</code> tag</h3>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
    <span class="hljs-comment">/* This won't work */</span>
    <span class="hljs-selector-tag">img</span><span class="hljs-selector-pseudo">::before</span> {
      <span class="hljs-attribute">content</span>: <span class="hljs-string">"Image Border"</span>;
      <span class="hljs-attribute">border</span>: <span class="hljs-number">1px</span> solid red;
      <span class="hljs-attribute">padding</span>: <span class="hljs-number">5px</span>;
    }
  </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">img</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"example.jpg"</span> <span class="hljs-attr">alt</span>=<span class="hljs-string">"Example Image"</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>In this example, we are trying to add a border with the text "Image Border" before the <code>&lt;img&gt;</code> element using a pseudo-element, but nothing will appear. This is due to the <code>&lt;img&gt;</code> tag's lack of content.</p>
<h3 id="heading-example-2-pseudo-element-working-on-tag">Example 2: Pseudo-element working on <code>&lt;div&gt;</code> tag</h3>
<pre><code class="lang-html"><span class="hljs-meta">&lt;!DOCTYPE <span class="hljs-meta-keyword">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">style</span>&gt;</span><span class="css">
    <span class="hljs-comment">/* This works */</span>
    <span class="hljs-selector-tag">div</span><span class="hljs-selector-pseudo">::before</span> {
      <span class="hljs-attribute">content</span>: <span class="hljs-string">"Decorative Element"</span>;
      <span class="hljs-attribute">background-color</span>: <span class="hljs-number">#006699</span>;
      <span class="hljs-attribute">padding</span>: <span class="hljs-number">10px</span>;
      <span class="hljs-attribute">display</span>: block;
      <span class="hljs-attribute">text-align</span>: center;
    }
  </span><span class="hljs-tag">&lt;/<span class="hljs-name">style</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">div</span>&gt;</span>This is a div element with a pseudo-element.<span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>In this example, we use a <code>&lt;div&gt;</code> element containing content. The pseudo-element will now work as expected and display the text "Decorative Element" above the content of the <code>&lt;div&gt;</code>.</p>
<h3 id="heading-debugging-tips">Debugging Tips</h3>
<p>If your pseudo-elements aren't showing up as intended, consider the following steps for debugging:</p>
<ol>
<li><p><strong>Check the element's content</strong>: Ensure that the element you are targeting with the pseudo-element contains content. If it's an empty element like <code>&lt;img&gt;</code> or <code>&lt;hr&gt;</code>, the pseudo-element won't work.</p>
</li>
<li><p><strong>Inspect the CSS selector</strong>: Double-check the CSS selector you are using for the pseudo-element. Make sure it's correctly written as <code>::before</code> or <code>::after</code>.</p>
</li>
<li><p><strong>Inspect other CSS rules</strong>: Look for any conflicting CSS rules that might be affecting the pseudo-element's appearance. Use your browser's developer tools to inspect the element and its styles.</p>
</li>
<li><p><strong>Content property</strong>: Verify that you have properly used the <code>content</code> property within the pseudo-element. It's required for the pseudo-element to render.</p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[[Tip] You may not need any library to query the GraphQL API]]></title><description><![CDATA[TLDR;

The request needs to be sent using the POST method

The query and variables need to be sent as a JSON object


// sample query
const query = `
    query HeroNameAndFriends($episode: Episode) {
        hero(episode: $episode) {
            name...]]></description><link>https://blog.rahuldahal.com.np/tip-you-may-not-need-any-library-to-query-the-graphql-api</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/tip-you-may-not-need-any-library-to-query-the-graphql-api</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[GraphQL]]></category><category><![CDATA[Programming Tips]]></category><category><![CDATA[vanilla-js]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Thu, 10 Jun 2021 09:23:20 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1623313455611/T7GNWucu4.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-tldr">TLDR;</h1>
<ul>
<li><p>The request needs to be sent using the <strong>POST</strong> method</p>
</li>
<li><p>The <em>query</em> and <em>variables</em> need to be sent as a <strong>JSON</strong> object</p>
</li>
</ul>
<pre><code class="lang-js"><span class="hljs-comment">// sample query</span>
<span class="hljs-keyword">const</span> query = <span class="hljs-string">`
    query HeroNameAndFriends($episode: Episode) {
        hero(episode: $episode) {
            name
            friends {
                  name
            }
      }
}
`</span>;

<span class="hljs-keyword">const</span> variables = {
        <span class="hljs-attr">episode</span>: <span class="hljs-string">"Some Episode Title"</span>
    }

fetch(<span class="hljs-string">"https://someGraphQL/endpoint"</span>, {
    <span class="hljs-attr">method</span>: <span class="hljs-string">"POST"</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({query, variables}),
})
</code></pre>
<p><em>Note: if there are no variables used in the query, send an empty object. Do not omit the key entirely.</em></p>
<h1 id="heading-graphql-query-is-just-an-http-request">GraphQL query is just an HTTP request</h1>
<p>Underneath the hood, the GraphQL query works by sending HTTP request(s) to a certain endpoint. Unlike the REST API, GraphQL API has only one endpoint.</p>
<h1 id="heading-anatomy-of-a-graphql-query">Anatomy of a GraphQL query</h1>
<ol>
<li><p>The query itself</p>
</li>
<li><p>Any query variables</p>
</li>
</ol>
<pre><code class="lang-graphql"> <span class="hljs-keyword">query</span> HeroNameAndFriends(<span class="hljs-variable">$episode</span>: Episode) {
        hero(<span class="hljs-symbol">episode:</span> <span class="hljs-variable">$episode</span>) {
            name
            friends {
                  name
            }
      }
}
</code></pre>
<p><em>This query expects to get the Hero and their friend's name from a particular episode(variable)</em></p>
<h2 id="heading-lets-extract-these-two-components-into-separate-variables">Let's extract these two components into separate variables</h2>
<pre><code class="lang-js"><span class="hljs-comment">// The query itself</span>
<span class="hljs-keyword">const</span> query = <span class="hljs-string">`
    query HeroNameAndFriends($episode: Episode) {
        hero(episode: $episode) {
            name
            friends {
                  name
            }
      }
}
`</span>;

<span class="hljs-comment">// Necessary Variables</span>
<span class="hljs-keyword">const</span> variables = {
        <span class="hljs-attr">episode</span>: <span class="hljs-string">"Some Episode Title"</span>
    }
</code></pre>
<h1 id="heading-using-the-fetch-api">Using the Fetch API</h1>
<ul>
<li><p>The request method must be <strong>POST</strong></p>
</li>
<li><p>The query and variables must be represented as an object and should be passed into the request body as a JSON string.</p>
</li>
<li><p>Necessary headers must be included(content-type, authentication, etc.)</p>
</li>
</ul>
<h1 id="heading-putting-it-all-together">Putting it all together</h1>
<pre><code class="lang-js"><span class="hljs-comment">// The query itself</span>
<span class="hljs-keyword">const</span> query = <span class="hljs-string">`
    query HeroNameAndFriends($episode: Episode) {
        hero(episode: $episode) {
            name
            friends {
                  name
            }
      }
}
`</span>;

<span class="hljs-comment">// Necessary Variables</span>
<span class="hljs-keyword">const</span> variables = {
        <span class="hljs-attr">episode</span>: <span class="hljs-string">"Some Episode Title"</span>
    }

<span class="hljs-comment">// Using Fetch</span>
fetch(<span class="hljs-string">"https://someGraphQL/endpoint"</span>, {
    <span class="hljs-attr">method</span>: <span class="hljs-string">"POST"</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({query, variables}),
})
</code></pre>
]]></content:encoded></item><item><title><![CDATA[Save Hash Links for Future Reference.]]></title><description><![CDATA[The Context
I was reading an amazing article about JavaScript Best Practices.While going through it, there were some points that I found useful and productive.I wanted to save those points, which in turn would make it easier for me to reference back ...]]></description><link>https://blog.rahuldahal.com.np/save-hash-links-for-future-reference</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/save-hash-links-for-future-reference</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[TIL]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Wed, 09 Jun 2021 03:38:45 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1623209772224/-N6KtF_J_.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2 id="heading-the-context">The Context</h2>
<p>I was reading an amazing article about <a target="_blank" href="https://github.com/ryanmcdermott/clean-code-javascript">JavaScript Best Practices</a>.<br />While going through it, there were some <strong>points</strong> that I found useful and productive.<br />I wanted to <strong>save</strong> those points, which in turn would make it easier for me to <strong>reference</strong> back in the future.  </p>
<h2 id="heading-birth-of-savehash">Birth of SaveHash</h2>
<p>As a solution to my problem mentioned above, I created SaveHash. SaveHash makes it easier for readers to <strong>save</strong> <em>hash</em>(#) links and refer back to them in the future.<br /><a target="_blank" href="https://addons.mozilla.org/en-US/firefox/addon/savehash/">Get It Here</a>  </p>
<h2 id="heading-here-is-the-demo">Here is the Demo</h2>
<p><img src="https://res.cloudinary.com/rdaahal/image/upload/v1609770198/saveHash/saveHash_demo_mpx0f3.gif" alt="Demo GIF" /></p>
<h2 id="heading-the-extension-workflow-looks-like-this">The extension workflow looks like this,</h2>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1623209662601/UEUG9dP0W.png" alt="saveHash extension workflow" /></p>
<h3 id="heading-this-project-is-open-source">This project is open source.</h3>
<p>Feel free to contribute by following <a target="_blank" href="https://github.com/rahuldahal/save-hash/blob/master/CONTRIBUTING.md">this</a> guide.</p>
]]></content:encoded></item><item><title><![CDATA[[Resolved] MongoDB Atlas line-break issue]]></title><description><![CDATA[The context
While creating this PWA, I wanted to store the markdown data into the MongoDB's Atlas.
Example Markdown
# Some interesting title
Description about the topic...

- list #1
- list #2

> Maybe a quote ?

The above markdown would be stored as...]]></description><link>https://blog.rahuldahal.com.np/resolved-mongodb-atlas-line-break-issue</link><guid isPermaLink="true">https://blog.rahuldahal.com.np/resolved-mongodb-atlas-line-break-issue</guid><category><![CDATA[Programming Blogs]]></category><category><![CDATA[MongoDB]]></category><category><![CDATA[Node.js]]></category><category><![CDATA[JavaScript]]></category><dc:creator><![CDATA[Rahul Dahal]]></dc:creator><pubDate>Tue, 08 Jun 2021 14:19:32 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1623161592872/SeljvQ06b.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h1 id="heading-the-context">The context</h1>
<p>While creating <a target="_blank" href="https://mynoteit.herokuapp.com">this</a> PWA, I wanted to store the <em>markdown</em> data into the MongoDB's <a target="_blank" href="https://www.mongodb.com/cloud/atlas">Atlas</a>.</p>
<p><strong>Example Markdown</strong></p>
<pre><code class="lang-markdown"><span class="hljs-section"># Some interesting title</span>
Description about the topic...

<span class="hljs-bullet">-</span> list #1
<span class="hljs-bullet">-</span> list #2

<span class="hljs-quote">&gt; Maybe a quote ?</span>
</code></pre>
<p>The above markdown would be stored as a <strong>single string</strong> in the database.</p>
<pre><code class="lang-js">{
  <span class="hljs-comment">// other fields</span>
  <span class="hljs-attr">markdown</span>: <span class="hljs-string">"# Some interesting title\nDescription about the topic...\n- list #1\n- list #2\n&gt; Maybe a quote ?"</span>
  <span class="hljs-comment">// further fields</span>
}
</code></pre>
<h1 id="heading-the-problem">The problem</h1>
<p>While reading the data from the <a target="_blank" href="https://www.mongodb.com/cloud/atlas">Atlas</a>, the line-break escape character, i.e. <code>\n</code> would come as already escaped, i.e. <code>\\n</code> <strong>notice the double '\'</strong>.</p>
<p>Therefore, while parsing it as <em>HTML</em>, the <strong>line-break</strong> wouldn't be read as a line-break character but a literal <em>\n</em> character.</p>
<p><strong>Rendered HTML</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1623161725006/o3zBlcLG1.png" alt="Unexpected Render of Markdown" /></p>
<p><em>The Markdown parser(</em><a target="_blank" href="https://marked.js.org/"><em>marked.js</em></a><em>) expects a line break between each block(headings, lists, paragraphs, quotes, etc.) to render them as expected. Otherwise, it will render them as a single line of string.</em></p>
<p><em>In the example above, it renders everything as a heading level 1.</em></p>
<h2 id="heading-why">Why?</h2>
<p>When the Markdown parser sees <code>#</code> token, it assumes that the text after it(until a line break) is to be rendered as a H₁. Thus, everything including lists, paragraphs, and quotes is rendered as <code>&lt;h1&gt;</code> because of no line-break.</p>
<h1 id="heading-the-solution">The Solution</h1>
<p>I made a mistake by thinking that the problem was with the <em>Markdown parser,</em> while instead, the problem was with the <strong>data</strong> coming from MongoDB.</p>
<p>The doubly escaped character <code>\\n</code> was the culprit.</p>
<p>As a workaround, I tried to <em>replace</em> all <code>\\n</code>s with <code>\n</code>s from the markdown string before passing it to the <a target="_blank" href="https://marked.js.org/">Markdown Parser</a>.</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> parser <span class="hljs-keyword">from</span> <span class="hljs-string">"marked"</span>;

<span class="hljs-comment">// 'markdownString' would be the markdown field read from mongodb</span>
<span class="hljs-keyword">const</span> replacedWithSingleEscape = markdownString.replace(<span class="hljs-regexp">/\\n/g</span>, <span class="hljs-string">"\n"</span>);

parser(replacedWithSingleEscape);
</code></pre>
<p><strong>Solved! This is how the rendered output would look after the fix</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1623161782608/ZqQtQ83jw.png" alt="Expected Render of Markdown" /></p>
]]></content:encoded></item></channel></rss>