<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: lguaregua</title>
    <description>The latest articles on DEV Community by lguaregua (@guaregua19).</description>
    <link>https://dev.to/guaregua19</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1084567%2F5e8db5a8-51a7-48e2-b1e2-b93850b65d26.png</url>
      <title>DEV Community: lguaregua</title>
      <link>https://dev.to/guaregua19</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/guaregua19"/>
    <language>en</language>
    <item>
      <title>A Step-by-Step Guide to Strapi with Docker, PostgreSQL, and TypeScript</title>
      <dc:creator>lguaregua</dc:creator>
      <pubDate>Wed, 15 May 2024 00:32:34 +0000</pubDate>
      <link>https://dev.to/guaregua19/a-step-by-step-guide-to-strapi-with-docker-postgresql-and-typescript-2ihe</link>
      <guid>https://dev.to/guaregua19/a-step-by-step-guide-to-strapi-with-docker-postgresql-and-typescript-2ihe</guid>
      <description>&lt;p&gt;Dive deep into the essential configurations of our comprehensive boilerplate that integrates Strapi, Docker, PostgreSQL, and TypeScript for full-stack development.&lt;/p&gt;

&lt;p&gt;Looking for the actual code? No problem! You can access the complete setup on our &lt;a href="https://github.com/guaregua19/strapi-boilerplate"&gt;GitHub boilerplate&lt;/a&gt;. If you find it useful, don't forget to star the repository ⭐ and share your thoughts through comments! Your feedback helps us improve and grow. ❤️&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding the Docker Configuration
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Dockerfile.local&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This file builds our Strapi application's Docker image based on Node.js, specifically using an Alpine Linux variant for a lightweight environment. It installs necessary system dependencies like vips-dev for image processing which Strapi often requires, especially for media handling. The Dockerfile also handles the installation of NPM packages and builds the Strapi project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Docker Compose Setup&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In our docker-compose.yml, we define the services required for our application: the Strapi service and a PostgreSQL service. Docker Compose allows us to manage multiple containers as a single application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Up TypeScript with Strapi&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;To use TypeScript in Strapi, we configure it through a tsconfig.json file. This configuration file allows us to specify compiler options and include/exclude files for our project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With this setup, you have a powerful boilerplate that leverages Strapi, Docker, PostgreSQL, and TypeScript to kickstart your full-stack development projects. Feel free to customize and extend it according to your needs.&lt;/p&gt;

&lt;p&gt;Access the complete setup on our GitHub boilerplate. If you find it useful, don't forget to star the repository ⭐ and share your thoughts through comments! Your feedback helps us improve and grow. ❤️&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>docker</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>The Two Pillars of Algorithm Performance: Time and Space Complexity</title>
      <dc:creator>lguaregua</dc:creator>
      <pubDate>Sun, 04 Jun 2023 21:18:48 +0000</pubDate>
      <link>https://dev.to/guaregua19/the-two-pillars-of-algorithm-performance-time-and-space-complexity-1118</link>
      <guid>https://dev.to/guaregua19/the-two-pillars-of-algorithm-performance-time-and-space-complexity-1118</guid>
      <description>&lt;p&gt;Hey Coders!&lt;/p&gt;

&lt;p&gt;Have you ever looked at your code and wondered why it's taking ages to run, or why it's eating up your memory like there's no tomorrow? Well, fret no more! Let's dive deep into the world of Time and Space complexities and decode their mysteries!&lt;/p&gt;

&lt;h2&gt;
  
  
  Time Complexity – The Need for Speed
&lt;/h2&gt;

&lt;p&gt;Simply put, time complexity is how long your code takes to run. But as the cool kids of computer science say, we express it using Big O notation – because who doesn't like a little math in their life?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(1): Constant Time -&lt;/strong&gt; When your code is lightning fast and doesn't care about the size of the input, it's got O(1) complexity. Like when you just get the first item from an array:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getFirst&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(n): Linear Time -&lt;/strong&gt; This one's a straight shooter. Your code takes time proportional to the input size. A good old-fashioned linear search is a perfect example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;linearSearch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(n^2): Quadratic Time -&lt;/strong&gt; Here's when things start to slow down a bit. For every input, you're running another loop – like a clumsy bubble sort:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;bubbleSort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;len&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;len&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]){&lt;/span&gt;
                &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
                &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
                &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;j&lt;/span&gt;&lt;span class="o"&gt;+&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;temp&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;O(log n): Logarithmic Time -&lt;/strong&gt; Now, this is where it gets fancy. Your code becomes faster as the input size increases, like with a binary search:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;binarySearch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nx"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;right&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;mid&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nx"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;mid&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Space Complexity – How Much Room Do You Need?
&lt;/h2&gt;

&lt;p&gt;Space complexity is all about how much memory your code needs. Because while time is money, memory isn't free either!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your code creates a new array of the same size, the space complexity is O(n). Like doubling the elements of an array:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;doubleArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;newArray&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;newArray&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;newArray&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If your code uses a fixed amount of space no matter the size of the input, it has O(1) space complexity. Like summing up an array:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;sumArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
    &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
        &lt;span class="nx"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;arr&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So, there you have it, folks! Understanding time and space complexities is a game-changer. It helps us write more efficient code, and who doesn't love that? But remember, balancing time and space efficiency is an art. So keep experimenting, keep coding, and most importantly, keep having fun!&lt;/p&gt;

&lt;p&gt;Stay tuned for more exciting dives into the world of coding!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>programming</category>
      <category>algorithms</category>
      <category>architecture</category>
    </item>
    <item>
      <title>PaceTrace ⏳: A Lightweight Progress Bar CLI Library</title>
      <dc:creator>lguaregua</dc:creator>
      <pubDate>Thu, 01 Jun 2023 18:20:46 +0000</pubDate>
      <link>https://dev.to/guaregua19/pacetrace-a-lightweight-progress-bar-cli-library-1a01</link>
      <guid>https://dev.to/guaregua19/pacetrace-a-lightweight-progress-bar-cli-library-1a01</guid>
      <description>&lt;p&gt;Hey there, fellow code enthusiasts! 🖐️&lt;/p&gt;

&lt;p&gt;Ever found yourself staring at the screen, waiting for an endless script to finish or a gigantic file to upload? 😓 Well, I've been there, done that. After some sleepless nights of coding and tons of coffee ☕, I'm proud to present: PaceTrace, a progress bar library for Node.js that's as customizable as it is user-friendly!&lt;/p&gt;

&lt;h2&gt;
  
  
  🌟 Here's What PaceTrace Can Do 🌟
&lt;/h2&gt;

&lt;p&gt;So, why should PaceTrace be your new darling in the vast sea of progress bar libraries? 🌊 Let's dive in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Make it your own:&lt;/strong&gt; With PaceTrace, you choose your progress bar's length and appearance. Stick with the trusty '=' or '#', go for a sleek '█', or add some fun with '⣿', '★', '♥', or even a character of your own choosing! 🌈&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pick a side... or the middle:&lt;/strong&gt; Left? Right? Center? Your progress bar, your call! 🎯&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Show or hide the progress percentage:&lt;/strong&gt; It's your choice whether to display the progress percentage or keep it hidden. 🕵️&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Play with the format:&lt;/strong&gt; PaceTrace lets you set your progress bar format. You can use placeholders for the bar, percentage, current value, and total value. 🛠️&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Automatic stop and clear:&lt;/strong&gt; Configure PaceTrace to pause the progress bar automatically when it's done, or even wipe the console clean. 🧹&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cursor visibility:&lt;/strong&gt; If you prefer not having the console cursor showing while the progress bar is active, simply hide it. 🐭&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  📦 Installation: A Walk in the Park 🌳
&lt;/h2&gt;

&lt;p&gt;Getting PaceTrace on your system is a breeze. All it takes is a simple npm command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;pace-trace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For those of you using yarn, fear not! We've got you covered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;pace-trace
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  🚀 How Do You Use PaceTrace? 🚀
&lt;/h2&gt;

&lt;p&gt;Getting PaceTrace up and running is as easy as pie 🥧. Just import it, create a new instance, and you're off to the races:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;PaceTrace&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;pacetrace&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;progress&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;PaceTrace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;barStyle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;star&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, increment or decrement the progress to your heart's content:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;increment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;decrement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you're ready to show off the progress bar, simply call the log method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  👨‍💻 Behind the Scenes 👩‍💻
&lt;/h2&gt;

&lt;p&gt;PaceTrace is brought to life with TypeScript, promising type safety and providing Visual Studio Code users with top-notch IntelliSense support. And of course, we've got a suite of tests to ensure the library is as reliable as it gets, covering both main functionalities and those tricky edge cases. 💪&lt;/p&gt;

&lt;h2&gt;
  
  
  🎈 Wrapping Up 🎈
&lt;/h2&gt;

&lt;p&gt;In a nutshell, PaceTrace is here to jazz up your console output with a customizable progress bar. It's open-source and just an npm install away. So, what are you waiting for? Give it a whirl and drop a line to let me know your thoughts. Happy coding! 🚀🎉&lt;/p&gt;

&lt;h2&gt;
  
  
  🤝 Let's Collaborate and Innovate Together 🚀
&lt;/h2&gt;

&lt;p&gt;PaceTrace is more than just a library; it's a testament to the power of open-source collaboration. Your insights, your creativity, and your passion can take it to new heights.&lt;/p&gt;

&lt;p&gt;So, don't be a stranger! If you've got a great idea or a constructive critique, we're all ears. Feel free to open issues, submit pull requests, or just drop a 🌟 if you like what you see. After all, it's the thoughts and contributions from you, the amazing coding community, that keep the wheels of innovation turning.&lt;/p&gt;

&lt;p&gt;Here's where the magic happens: &lt;a href="https://github.com/guaregua19/pace-trace"&gt;PaceTrace on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Together, we can make PaceTrace an even more powerful tool for Node.js developers worldwide. Ready to jump in? Let's code a better tomorrow, one progress bar at a time! 🛠️🌐🎉&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
    </item>
    <item>
      <title>Extending Strapi plugins 🚀 Ultimate guide 👨‍💻</title>
      <dc:creator>lguaregua</dc:creator>
      <pubDate>Thu, 18 May 2023 13:01:47 +0000</pubDate>
      <link>https://dev.to/guaregua19/extending-strapi-plugins-ultimate-guide-56in</link>
      <guid>https://dev.to/guaregua19/extending-strapi-plugins-ultimate-guide-56in</guid>
      <description>&lt;p&gt;Hey folks! 🤙&lt;/p&gt;

&lt;p&gt;You've chosen the right post if you're keen on flexing your JavaScript muscles and going on a coding adventure with Strapi. Strapi, the open-source CMS powerhouse, comes with a plugin system that is all about flexibility and adaptability, and today, we're going to nudge it a bit to suit our unique requirements. 🧗‍♂️&lt;/p&gt;

&lt;h2&gt;
  
  
  The Mission 🎯
&lt;/h2&gt;

&lt;p&gt;Our goal was simple but crucial - to ensure that users don't keep leaning on their old faithfuls when resetting their passwords. The good news is that Strapi provides a plugin system that we can tweak to ensure users always choose new passwords.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Preparation 📝
&lt;/h2&gt;

&lt;p&gt;Before we dive into the code, here are a few important points to keep in mind:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;We can apply this approach to various methods declared in Strapi plugins.&lt;/strong&gt; Whether it's register, forgotPassword, resetPassword, user or any other method within the &lt;code&gt;@node_modules/@strapi/plugin-&amp;lt;name-of-the-plugin&amp;gt;&lt;/code&gt; (in our case users-permissions), you can bend it to your will.&lt;/p&gt;

&lt;p&gt;To extend a Strapi plugin, create a new folder inside src/extensions/. This is where you'll make your changes without disturbing the core plugin code.&lt;/p&gt;

&lt;p&gt;In the new folder, add a file named strapi-server.js or strapi-server.ts and place your custom code there. Now, let's see how this works in practice!&lt;/p&gt;

&lt;h2&gt;
  
  
  The Code 🚀
&lt;/h2&gt;

&lt;p&gt;Check out the final solution below:&lt;/p&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&lt;p&gt;const utils = require('@strapi/utils');&lt;/p&gt;

&lt;p&gt;module.exports = (plugin) =&amp;gt; {&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { ValidationError } = utils.errors;
const originalControllers = {
    callback: plugin.controllers.auth.callback,
    resetPassword: plugin.controllers.auth.resetPassword,
}

plugin.controllers.auth.resetPassword = async (ctx) =&amp;amp;gt; {
    const { password, passwordConfirmation } = ctx.request.body;
    // Fetch user
    const user = await strapi
        .query('plugin::users-permissions.user')
        .findOne({ resetPasswordToken: ctx.params.code });

    // Compare old and new passwords
    const validPassword = await strapi.plugins['users-permissions'].services.user.validatePassword(password, user.password);

    if (validPassword) {
        throw new ValidationError('Passwords cannot match previous passwords');
    }

    await originalControllers.resetPassword(ctx);
}

return plugin;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;};&lt;/p&gt;

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

&lt;/div&gt;
&lt;h2&gt;
&lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
  Dissecting the Code 🧐&lt;br&gt;
&lt;/h2&gt;

&lt;p&gt;Let's take a magnifying glass to this code snippet:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;We're using Strapi's utility library, which has a plethora of helpful tools.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We're exporting a function that accepts a plugin as an argument.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Within this function, we're preserving the original controllers for callback and resetPassword.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then, we're defining a new resetPassword function. This doesn't discard the original function; rather, it only executes after we've added our own validation.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In this new function, we're retrieving the user requesting the password reset.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We're then comparing the new password against the old one with Strapi's built-in password validation method.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If the new password is the same as the old one, we're raising a validation error.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Finally, we execute the original resetPassword function, allowing Strapi to perform its usual magic.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;By extending the resetPassword method this way, we add our custom behaviour while maintaining the core Strapi functionality intact. It's akin to a skillful remix of a classic song - you maintain the original melody while adding your unique spin! 🎵&lt;/p&gt;

&lt;p&gt;That's all, folks! Get out there and make Strapi work for you. As always, remember to test your code thoroughly to ensure it behaves as expected. Happy coding! 👨‍💻👩‍💻&lt;/p&gt;

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

</description>
      <category>strapi</category>
      <category>webdev</category>
      <category>plugin</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
