<?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>Forem: Bikash Mishra</title>
    <description>The latest articles on Forem by Bikash Mishra (@forkbikash).</description>
    <link>https://forem.com/forkbikash</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%2F655288%2F0f433d93-0a44-447e-bb05-714f28a7b27a.jpeg</url>
      <title>Forem: Bikash Mishra</title>
      <link>https://forem.com/forkbikash</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/forkbikash"/>
    <language>en</language>
    <item>
      <title>Introducing encache: A Powerful Caching Library for Go</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Sun, 12 May 2024 03:39:59 +0000</pubDate>
      <link>https://forem.com/forkbikash/introducing-encache-a-powerful-caching-library-for-go-2jdp</link>
      <guid>https://forem.com/forkbikash/introducing-encache-a-powerful-caching-library-for-go-2jdp</guid>
      <description>&lt;p&gt;In the world of software development, performance is king. One effective way to boost your application's performance is by caching expensive function calls. This is where the &lt;a href="https://github.com/forkbikash/encache"&gt;&lt;code&gt;encache&lt;/code&gt;&lt;/a&gt; package comes into play. &lt;a href="https://github.com/forkbikash/encache"&gt;&lt;code&gt;encache&lt;/code&gt;&lt;/a&gt; is a Go library that provides a caching mechanism for function calls, allowing you to cache the results of computationally intensive or I/O-bound operations, and retrieve them from the cache instead of recomputing them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features Galore
&lt;/h3&gt;

&lt;p&gt;The encache package is packed with features that make caching a breeze:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Support for in-memory and Redis caching: Choose between caching in memory or using Redis, depending on your project's requirements.&lt;/li&gt;
&lt;li&gt;Automatic cache expiration and periodic expiration of stale entries: Never worry about stale data clogging up your cache.&lt;/li&gt;
&lt;li&gt;Locking mechanisms for thread-safety: Ensures your cached data remains consistent, even in concurrent scenarios.&lt;/li&gt;
&lt;li&gt;Customizable cache key generation: Fine-tune how your cache keys are generated to suit your needs.&lt;/li&gt;
&lt;li&gt;Option to cache function results even when errors occur: Errors won't halt the caching process, ensuring you always have data available.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;p&gt;Installing encache is a breeze, thanks to Go's built-in package management system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go get github.com/forkbikash/encache
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once installed, using encache is incredibly straightforward. Here's a simple example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"fmt"&lt;/span&gt;
    &lt;span class="s"&gt;"time"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/forkbikash/encache"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;expensiveOperation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Simulate an expensive operation&lt;/span&gt;
    &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Sleep&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Second&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Create a new in-memory cache implementation&lt;/span&gt;
    &lt;span class="n"&gt;mapCache&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;encache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewMapCacheImpl&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;cacheKeyImpl&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;encache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewDefaultCacheKeyImpl&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;lockImpl&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;encache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewMuLockImpl&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

    &lt;span class="c"&gt;// Create a new encache instance&lt;/span&gt;
    &lt;span class="n"&gt;encache&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;encache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewEncache&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lockImpl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;mapCache&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cacheKeyImpl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Minute&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// Wrap the expensive function with caching&lt;/span&gt;
    &lt;span class="n"&gt;cachedExpensiveOperation&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;encache&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CachedFunc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;expensiveOperation&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;encache&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Minute&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// Call the cached function&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;cachedExpensiveOperation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Result:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c"&gt;// Subsequent calls will retrieve the result from the cache&lt;/span&gt;
    &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cachedExpensiveOperation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Error:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Result (cached):"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&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;In this example, we create a new encache instance with an in-memory cache implementation (MapCacheImpl), a default cache key implementation (DefaultCacheKeyImpl), and a mutex-based lock implementation (MuLockImpl). We then wrap the expensiveOperation function with the CachedFunc function, which returns a new function that will cache the results of expensiveOperation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Contributing
&lt;/h3&gt;

&lt;p&gt;Contributions are what keep the open-source community vibrant and growing. If you have any improvements, bug fixes, or new features to propose, please open an issue or submit a pull request. We welcome all contributions!&lt;/p&gt;

&lt;h3&gt;
  
  
  Future Developments
&lt;/h3&gt;

&lt;p&gt;The encache package is constantly evolving, and we have exciting plans for future developments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cache invalidation strategies: Aside from the simple expiration-based cache invalidation, we plan to add support for other strategies like manual invalidation, LRU (Least Recently Used) eviction, or event-based invalidation (e.g., invalidating the cache when the underlying data changes).&lt;/li&gt;
&lt;li&gt;Monitoring and metrics: We aim to provide metrics and monitoring capabilities to help users understand the cache's performance, hit/miss rates, and other relevant statistics.&lt;/li&gt;
&lt;li&gt;Adaptive caching: Implement an adaptive caching mechanism that can automatically adjust the cache size, eviction policy, or other parameters based on the workload and usage patterns.&lt;/li&gt;
&lt;li&gt;Asynchronous cache updates: Provide an asynchronous cache update mechanism to allow for non-blocking cache population and update operations.&lt;/li&gt;
&lt;li&gt;Change package structure: Reorganize the package structure to improve maintainability and extensibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned for more updates and enhancements to the encache package!&lt;/p&gt;

&lt;p&gt;I hope this article helps someone out there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked the post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on gitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on dev.to: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/introducing-encache-a-powerful-caching-library-for-go-2jdp"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>backend</category>
      <category>backenddevelopment</category>
    </item>
    <item>
      <title>Unleash the Power of Rate-Limiting with Limitless</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Sun, 12 May 2024 03:29:17 +0000</pubDate>
      <link>https://forem.com/forkbikash/unleash-the-power-of-rate-limiting-with-limitless-ich</link>
      <guid>https://forem.com/forkbikash/unleash-the-power-of-rate-limiting-with-limitless-ich</guid>
      <description>&lt;p&gt;In today's fast-paced world of web applications, rate-limiting has become an indispensable tool for maintaining system stability and protecting against abuse or overload. That's where the &lt;a href="https://github.com/forkbikash/limitless"&gt;&lt;code&gt;limitless&lt;/code&gt;&lt;/a&gt; package for Golang comes into play, offering a powerful and flexible rate-limiting solution that harnesses the power of the token bucket algorithm.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Rate-Limiting
&lt;/h2&gt;

&lt;p&gt;Before we dive into the &lt;code&gt;limitless&lt;/code&gt; package, let's briefly explore what rate-limiting is and why it's so important. Rate-limiting is a technique used to control the rate at which requests or operations are processed by an application. By limiting the number of requests that can be processed within a given time window, you can prevent system overload, protect against denial-of-service (DoS) attacks, and ensure fair usage of shared resources.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing Limitless
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;limitless&lt;/code&gt; package is a robust and highly configurable rate-limiting solution that provides both in-memory and Redis-based implementations of the token bucket algorithm. With its wide range of features, &lt;code&gt;limitless&lt;/code&gt; empowers you to tailor rate-limiting to your application's specific needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Features Galore
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;In-Memory Token Bucket&lt;/strong&gt;: For applications that don't require distributed rate-limiting, &lt;code&gt;limitless&lt;/code&gt; offers an in-memory implementation of the token bucket algorithm.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Redis Token Bucket&lt;/strong&gt;: If you're dealing with horizontally scaled applications, the Redis-based implementation of the token bucket algorithm provides a distributed rate-limiting solution.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Configurable Rate and Capacity&lt;/strong&gt;: Customize the rate (requests/operations per second) and capacity (maximum burst size) of the token bucket to suit your application's demands.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Concurrent Access&lt;/strong&gt;: With proper locking mechanisms, &lt;code&gt;limitless&lt;/code&gt; ensures thread-safety and supports concurrent access to the rate limiter.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Extensibility&lt;/strong&gt;: The package provides a &lt;code&gt;RateLimiter&lt;/code&gt; interface, allowing you to implement custom rate-limiting strategies if needed.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Getting Started
&lt;/h3&gt;

&lt;p&gt;Installing the &lt;code&gt;limitless&lt;/code&gt; package is a breeze:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go get github.com/forkbikash/limitless
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="s"&gt;"github.com/forkbikash/limitless"&lt;/span&gt;

&lt;span class="c"&gt;// Create a new in-memory token bucket&lt;/span&gt;
&lt;span class="n"&gt;tb&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;limitless&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewInMemoryTokenBucket&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c"&gt;// capacity: 10, rate: 2 requests/second&lt;/span&gt;

&lt;span class="c"&gt;// Check if a request is allowed&lt;/span&gt;
&lt;span class="n"&gt;allowed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;limitless&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Allow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tb&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Handle error&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;allowed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c"&gt;// Process the request&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="c"&gt;// Request is rate-limited&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Contributing to Limitless
&lt;/h3&gt;

&lt;p&gt;Contributions to the limitless package are always welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the GitHub repository.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Glimpse into the Future
&lt;/h3&gt;

&lt;p&gt;The limitless package has an exciting roadmap ahead, with plans for numerous enhancements and new features. Here's a sneak peek at what's in store:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Middleware Integration: Develop a middleware component that can be easily integrated into popular Golang web frameworks (e.g., Gin, Echo, Fiber) to streamline the application of rate limiting functionality.&lt;/li&gt;
&lt;li&gt;Metrics and Reporting: Include options to expose metrics related to rate limiting, such as the number of requests processed, rejected requests, and the current rate limiting state.&lt;/li&gt;
&lt;li&gt;Burst Capacity: Allow users to configure a burst capacity, enabling a maximum number of requests to be processed immediately, even if it exceeds the rate limit. This can be invaluable for handling sudden traffic spikes.&lt;/li&gt;
&lt;li&gt;Adaptive Rate Limiting: Implement an adaptive rate limiting algorithm that can dynamically adjust the rate limit based on factors like current load, resource utilization, or custom metrics.&lt;/li&gt;
&lt;li&gt;Multi-Dimensional Rate Limiting: Provide the ability to apply rate limiting based on multiple dimensions, such as client IP, user identity, API endpoint, or a combination thereof, enabling granular control over rate limiting policies.&lt;/li&gt;
&lt;li&gt;Contextual Information: Pass contextual information (e.g., request metadata, user identity) through the rate limiting system, empowering users to make informed decisions or apply custom rate limiting rules.&lt;/li&gt;
&lt;li&gt;Fallback Behavior: Define fallback behaviors for when the rate limiting storage (e.g., Redis, Memcached) becomes unavailable, such as allowing a default number of requests or completely blocking further requests.&lt;/li&gt;
&lt;li&gt;Webhooks and Notifications: Allow users to configure webhooks or other notification mechanisms to be triggered when certain rate limiting thresholds are reached or exceeded, enabling timely action.&lt;/li&gt;
&lt;li&gt;Grouping and Inheritance: Implement a mechanism for grouping rate limiting policies and allowing inheritance, making it easier to define common rules and apply them across multiple endpoints or clients.&lt;/li&gt;
&lt;li&gt;Logging and Debugging: Provide robust logging and debugging capabilities, including detailed information about rate limiting events, applied limits, and rejection reasons.&lt;/li&gt;
&lt;li&gt;HTTP/gRPC Integrations: Offer seamless integration with both HTTP-based and gRPC-based services, enabling rate limiting across your entire application stack.&lt;/li&gt;
&lt;li&gt;Observability and Monitoring: Integrate with popular observability and monitoring tools (e.g., Prometheus, Grafana) to provide detailed metrics and dashboards for monitoring the rate limiting system's performance and health.&lt;/li&gt;
&lt;li&gt;Backpressure Management: Implement mechanisms to handle backpressure, such as queuing and throttling, ensuring that the rate limiting system can gracefully handle sudden traffic spikes without causing cascading failures.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Stay tuned for more updates and join the limitless community to be part of this exciting journey towards robust and efficient rate-limiting solutions!&lt;/p&gt;

&lt;p&gt;I hope this article helps someone out there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked the post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on gitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on dev.to: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/unleash-the-power-of-rate-limiting-with-limitless-ich"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>backend</category>
      <category>backenddevelopment</category>
    </item>
    <item>
      <title>The Actor Model in Go: Simplifying Concurrent Programming</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Sun, 12 May 2024 03:14:17 +0000</pubDate>
      <link>https://forem.com/forkbikash/the-actor-model-in-go-simplifying-concurrent-programming-1j9d</link>
      <guid>https://forem.com/forkbikash/the-actor-model-in-go-simplifying-concurrent-programming-1j9d</guid>
      <description>&lt;p&gt;In the world of modern software development, concurrency is a necessity. With the rise of multi-core processors and distributed systems, applications need to be able to execute multiple tasks simultaneously to take full advantage of available hardware resources and ensure optimal performance.&lt;/p&gt;

&lt;p&gt;One elegant solution to tackle concurrency is the Actor Model, a conceptual model for building concurrent and distributed systems. And now, with the power of Go, you can harness the benefits of this model with ease.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Actor Model?
&lt;/h2&gt;

&lt;p&gt;The Actor Model is a mathematical model of concurrent computation that treats actors as the universal primitives of concurrent computation. An actor is a lightweight, independent entity that operates concurrently and communicates with other actors by sending and receiving asynchronous messages.&lt;/p&gt;

&lt;p&gt;In this model, each actor has its own mailbox, a queue where incoming messages are stored. The actor processes messages from its mailbox one by one, performing computations and potentially sending messages to other actors in response.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing the Go Actor System
&lt;/h2&gt;

&lt;p&gt;The Go Actor System is an implementation of the Actor Model in the Go programming language. It provides a framework for building concurrent applications using lightweight actors that communicate via message passing.&lt;/p&gt;

&lt;p&gt;The Actor System consists of the following components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Actor System Interface&lt;/strong&gt;: The entry point for submitting tasks to the Actor System.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Task Queue&lt;/strong&gt;: A queue that holds the tasks submitted by the Actor System Interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assigner Actor&lt;/strong&gt;: Responsible for reading tasks from the Task Queue and assigning them to available Actor instances.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Actors&lt;/strong&gt;: Lightweight entities that execute the assigned tasks concurrently. Each Actor has its own Task Queue.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Auto Scaler&lt;/strong&gt;: Dynamically increases or decreases the number of Actor instances based on the Task Queue size.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Using the Go Actor System
&lt;/h2&gt;

&lt;p&gt;Using the Go Actor System is straightforward. Here's an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"sync"&lt;/span&gt;
    &lt;span class="s"&gt;"time"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/forkbikash/aktor/actor"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/forkbikash/aktor/actor_system"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/forkbikash/aktor/entities"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;task&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;Execute&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;taskFunc&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="n"&gt;entities&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Task&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;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;task&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;actorSystem&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;actor_system&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CreateActorSystem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"actor_system"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Config&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;MinActor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;MaxActor&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;AutoScale&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;actor&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AutoScale&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;UpscaleQueueSize&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;DownscaleQueueSize&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10&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;for&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;actorSystem&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SubmitTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;taskFunc&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="o"&gt;&amp;lt;-&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;After&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Millisecond&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;systems&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;actor_system&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ActorSystem&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;actorSystem&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;wg&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;sync&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WaitGroup&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;systems&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;system&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="k"&gt;range&lt;/span&gt; &lt;span class="n"&gt;systems&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;go&lt;/span&gt; &lt;span class="n"&gt;system&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Shutdown&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;wg&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Wait&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;In this example, we create an Actor System with a minimum of 10 and a maximum of 100 actors. We then submit 1000 tasks to the system, with a short delay between each submission. Finally, we shut down the system and wait for all tasks to complete.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Next?
&lt;/h2&gt;

&lt;p&gt;The Go Actor System is a powerful tool for building concurrent applications, but there's always room for improvement. Some potential future enhancements include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Assigning task IDs to each task and providing functionality to wait for the completion of a specific task.&lt;/li&gt;
&lt;li&gt;Support for distributed environments, allowing actors to communicate across multiple machines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With the Actor Model and the Go Actor System, concurrent programming becomes more accessible and manageable. Embrace the power of concurrency and take your applications to new heights with this elegant and efficient approach.&lt;/p&gt;

&lt;p&gt;I hope this article helps someone out there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked the post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on gitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on dev.to: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/the-actor-model-in-go-simplifying-concurrent-programming-1j9d"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>backend</category>
      <category>programming</category>
    </item>
    <item>
      <title>Last minute guide to React.useEffect()</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Thu, 02 Sep 2021 06:31:39 +0000</pubDate>
      <link>https://forem.com/forkbikash/last-minute-guide-to-react-useeffect-4n1i</link>
      <guid>https://forem.com/forkbikash/last-minute-guide-to-react-useeffect-4n1i</guid>
      <description>&lt;p&gt;React.useEffect() is one of the React hooks that manages side-effects in functional React components. You can do so much by writing so little with the help of this hook.&lt;/p&gt;

&lt;p&gt;useEffect accepts a callback function (also called the 'effect' function), and it runs after every render (by default).&lt;/p&gt;

&lt;p&gt;If you want your effects to run less often, you can provide a second argument – an array of values. Think of them as the dependencies for that effect.&lt;/p&gt;

&lt;p&gt;So, let us look at some examples in which I'll be showing how you can control the behavior of useEffect.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. When no dependencies are provided
&lt;/h2&gt;

&lt;p&gt;The callback function provided as the first argument will run after every rendering.&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&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;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Runs after EVERY rendering&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;
  
  
  2. When an empty dependencies array([]) is provided
&lt;/h2&gt;

&lt;p&gt;The callback function provided as the first argument will run only once after the initial rendering.&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&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;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Runs ONCE after initial rendering&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. When dependencies array provided has props or state values [prop1, prop2, ..., state1, state2]
&lt;/h2&gt;

&lt;p&gt;The callback function provided as the first argument will run only when any dependency value changes.&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt; &lt;span class="p"&gt;}&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;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;MyComponent&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;prop&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="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setState&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Runs ONCE after initial rendering&lt;/span&gt;
    &lt;span class="c1"&gt;// and after every rendering ONLY IF `prop` or `state` changes&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;prop&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;state&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;
  
  
  4. Effect with Cleanup
&lt;/h2&gt;

&lt;p&gt;If the callback of useEffect returns a function, then useEffect() considers this as an effect cleanup.&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="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Side-effect...&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;cleanup&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Side-effect cleanup...&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="nx"&gt;dependencies&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's pretty common to clean up an effect after some time. This is possible by returning a function from within the effect function passed to useEffect. Below's an example with addEventListener.&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="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;clicked&lt;/span&gt; &lt;span class="o"&gt;=&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;window clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;clicked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;// return a clean-up function&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;clicked&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;When&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt; &lt;span class="nx"&gt;click&lt;/span&gt; &lt;span class="nx"&gt;the&lt;/span&gt; &lt;span class="nb"&gt;window&lt;/span&gt; &lt;span class="nx"&gt;you&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ll 
    find a message logged to the console
  &amp;lt;/div&amp;gt;
}
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  5. Multiple Effects
&lt;/h2&gt;

&lt;p&gt;Multiple useEffect calls can happen within a functional component as shown below:&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="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// 🍟&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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;clicked&lt;/span&gt; &lt;span class="o"&gt;=&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;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;window clicked&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;clicked&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;removeEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;clicked&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="c1"&gt;// 🍟 another useEffect hook &lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;another useEffect call&lt;/span&gt;&lt;span class="dl"&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;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;Check&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt; &lt;span class="nx"&gt;logs&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I hope this article helps someone out there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked this post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on Twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on GitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on this beautiful platform: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/last-minute-guide-to-react-useeffect-4n1i"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>react</category>
    </item>
    <item>
      <title>My Learnings in LGMSoC’2021</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Sat, 21 Aug 2021 05:03:03 +0000</pubDate>
      <link>https://forem.com/forkbikash/my-learnings-in-lgmsoc-2021-2hkg</link>
      <guid>https://forem.com/forkbikash/my-learnings-in-lgmsoc-2021-2hkg</guid>
      <description>&lt;h2&gt;
  
  
  WHAT IS &lt;a href="https://letsgrowmore.in/"&gt;LET'SGROWMORE&lt;/a&gt;?
&lt;/h2&gt;

&lt;p&gt;LetsGrowMore is a community of the students, for the students and by the students.&lt;/p&gt;

&lt;h2&gt;
  
  
  WHAT IS LGM-SOC?
&lt;/h2&gt;

&lt;p&gt;LGM – SOC is an online program designed to encourage student participation in open source software development under the guidance of mentors from the open source community. As it’s the present demand and students need, so we come with LGM – SOC.&lt;/p&gt;

&lt;h2&gt;
  
  
  HOW DOES IT WORK?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open source projects apply to be mentor organizations.&lt;/li&gt;
&lt;li&gt;LGM chooses the organization interesting in participating.&lt;/li&gt;
&lt;li&gt;Students submit project proposals to mentor organization.&lt;/li&gt;
&lt;li&gt;Mentor organizations choose the students they’d like to accept.&lt;/li&gt;
&lt;li&gt;Students are paired with a mentor for required guidance.&lt;/li&gt;
&lt;li&gt;Now coding begins! Students work under their mentors over 10 weeks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ELIGIBILITY
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;All you need to be is a student ready to grab learning opportunity.&lt;/li&gt;
&lt;li&gt;Accepted into or enrolled in a graduate program by the students acceptance date.&lt;/li&gt;
&lt;li&gt;Eligible to work in the country you reside.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  MY LEARNINGS
&lt;/h2&gt;

&lt;p&gt;I contributed to one of the open source repositories namely &lt;a href="https://github.com/forkbikash/awesome-portfolio-websites"&gt;awesome-portfolio-websites&lt;/a&gt;. The project is aiming to provide a full-fledged template that anyone can use to build and put out their website within an hour.&lt;br&gt;
I am one of the top contributors of the project. Written modularized code to add some features to the &lt;a href="https://portfolio.smaranjitghose.com/"&gt;website&lt;/a&gt;, fixed bugs and raised some critical issues throughout the journey. Our mentors &lt;a href="https://github.com/smaranjitghose"&gt;@smaranjitghose&lt;/a&gt; and &lt;a href="https://github.com/anushbhatia"&gt;@anushbhatia&lt;/a&gt; helped me a lot in improving the style of coding. I would like to thank them for their contributions in my journey.&lt;/p&gt;

&lt;p&gt;I am glad to be a part of LGMSOC community. Looking forward to more events and learning opportunities like this.&lt;/p&gt;

&lt;p&gt;If you want to know more about the program, head over to their &lt;a href="https://letsgrowmore.in/"&gt;website(letsgrowmore.in)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope this helps someone out there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked this post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on Twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on GitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on this beautiful platform: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/my-learnings-in-lgmsoc-2021-2hkg"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>letsgrowmore</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Closure in JavaScript</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Thu, 19 Aug 2021 19:58:46 +0000</pubDate>
      <link>https://forem.com/forkbikash/closure-in-javascript-3hga</link>
      <guid>https://forem.com/forkbikash/closure-in-javascript-3hga</guid>
      <description>&lt;p&gt;Coding in JavaScript without an understanding of closures is like trying to speak English without an understanding of grammar rules — you might be able to get your ideas across, but probably a bit awkwardly.&lt;/p&gt;

&lt;p&gt;Closure is one of important concepts in JavaScript. It is widely discussed and still confused concept. Let's understand what the closure is.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Closures?
&lt;/h2&gt;

&lt;p&gt;As stated in MDN Web Docs, a closure is the combination of a function bundled together (enclosed) with references to its surrounding state (the lexical environment). In other words, a closure gives you access to an outer function’s scope from an inner function. In JavaScript, closures are created every time a function is created, at function creation time.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Lexical Scope?
&lt;/h2&gt;

&lt;p&gt;Lexical scope is the ability for a function scope to access variables from the parent scope. We call the child function to be lexically bound by that of the parent function.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Simple closure
&lt;/h2&gt;

&lt;p&gt;Let’s look at a simple closure example in JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function OuterFunction() {

    var outerVariable = 1;

    function InnerFunction() {
        alert(outerVariable);
    }

    InnerFunction();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, InnerFunction() can access outerVariable.&lt;/p&gt;

&lt;p&gt;Now, InnerFunction() can access outerVariable even if it will be executed separately. Consider the following example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function OuterFunction() {

    var outerVariable = 100;

    function InnerFunction() {
        alert(outerVariable);
    }

    return InnerFunction;
}
var innerFunc = OuterFunction();

innerFunc(); // 100
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the above example, return InnerFunction; returns InnerFunction from OuterFunction when you call OuterFunction(). A variable innerFunc reference the InnerFunction() only, not the OuterFunction(). So now, when you call innerFunc(), it can still access outerVariable which is declared in OuterFunction(). This is called Closure.&lt;/p&gt;

&lt;p&gt;Above example also shows that the local variables are not copied in the closure: the closure maintains a reference to the original variables themselves. It is as though the stack-frame stays alive in memory even after the outer function exits.&lt;/p&gt;

&lt;h2&gt;
  
  
  Closure Scope Chain
&lt;/h2&gt;

&lt;p&gt;Every closure has three scopes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Local Scope (Own scope)&lt;/li&gt;
&lt;li&gt;Outer Functions Scope&lt;/li&gt;
&lt;li&gt;Global Scope&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  When to use Closure?
&lt;/h2&gt;

&lt;p&gt;Closures are useful whenever you need a private state associated with a function. This is a very common scenario - and remember: JavaScript did not have a class syntax until 2015, and it still does not have a private field syntax. Closures meet this need.&lt;/p&gt;

&lt;h2&gt;
  
  
  Performance considerations
&lt;/h2&gt;

&lt;p&gt;It is unwise to unnecessarily create functions within other functions if closures are not needed for a particular task, as it will negatively affect script performance both in terms of processing speed and memory consumption.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final points:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Whenever a function is declared in JavaScript closure is created.&lt;/li&gt;
&lt;li&gt;Returning a function from inside another function is the classic example of closure, because the state inside the outer function is implicitly available to the returned inner function, even after the outer function has completed execution.&lt;/li&gt;
&lt;li&gt;A closure in JavaScript is like keeping a reference (NOT a copy) to the scope at the point of function declaration, which in turn keeps a reference to its outer scope, and so on, all the way to the global object at the top of the scope chain.&lt;/li&gt;
&lt;li&gt;A new set of local variables is created every time a function is called.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this helps someone out there.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked this post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on Twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on GitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on this beautiful platform: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/closure-in-javascript-3hga"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>tutorial</category>
      <category>webdev</category>
      <category>codequality</category>
    </item>
    <item>
      <title>9 Best Free Resources for learning HTML and CSS</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Sat, 03 Jul 2021 07:29:45 +0000</pubDate>
      <link>https://forem.com/forkbikash/9-best-free-resources-for-learning-html-and-css-9f4</link>
      <guid>https://forem.com/forkbikash/9-best-free-resources-for-learning-html-and-css-9f4</guid>
      <description>&lt;p&gt;Looking for the best free resources to get you going in your journey towards learning HTML and CSS?&lt;br&gt;
Looking to quickly brush up on your concepts of HTML and CSS?&lt;br&gt;
Want some cheat sheets of HTML and CSS?&lt;/p&gt;

&lt;p&gt;If any of the above questions' answer is yes for you, you are in the right place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check out the list of resources given below:&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  01. &lt;a href="https://digital.com/tools/html-cheatsheet/"&gt;HTML Cheat Sheet&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This HTML cheat sheet has a full list of all HTML elements, including descriptions, code examples, and live previews.&lt;/p&gt;

&lt;h3&gt;
  
  
  02. &lt;a href="https://www.onblastblog.com/css3-cheat-sheet/"&gt;CSS Cheat Sheet&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;This cheat sheet will be ready and waiting for you in your bookmarks for those times when you need a reminder.&lt;/p&gt;

&lt;h3&gt;
  
  
  03. &lt;a href="https://css-tricks.com/"&gt;CSS-Tricks&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;For daily articles about CSS, HTML, JavaScript, and all things related to web design and development.&lt;/p&gt;

&lt;h3&gt;
  
  
  04. &lt;a href="https://csswizardry.com/"&gt;CSS Wizardry&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you want to write scalable and maintainable CSS, like the BEM methodology and refactoring, you should check out this site.&lt;/p&gt;

&lt;h3&gt;
  
  
  05. &lt;a href="https://codepen.io/2016/popular/pens/"&gt;CodePen's Yearly Top Pens&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;If you want to have a look at some of the best live demos of things build using HTML and CSS, then this site is for you.&lt;br&gt;
&lt;a href="https://codepen.io/"&gt;CodePen&lt;/a&gt; is also one of the best places to build, test, and discover front-end code.&lt;/p&gt;

&lt;h3&gt;
  
  
  06. &lt;a href="https://labs.jensimmons.com/"&gt;Jen Simmons Lab&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;In this Experimental Layout Lab of Jen Simmons, he uses CSS to implement practical scenarios.&lt;/p&gt;

&lt;h3&gt;
  
  
  07. &lt;a href="https://www.youtube.com/user/KepowOb"&gt;Kevin Powell&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Kevin Powell is a great YouTuber who loves to simplify CSS.&lt;/p&gt;

&lt;h3&gt;
  
  
  08. &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Front-end_web_developer"&gt;MDN Web Docs&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;I personally like MDN for its up-to-date, clear and briefly defined content for each technology, which is required for starting your career as a web developer.&lt;/p&gt;

&lt;h3&gt;
  
  
  09. &lt;a href="https://www.freecodecamp.org/"&gt;freeCodeCamp&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;freeCodeCamp has a step-by-step process to it where you don’t just watch, there are tasks for you to complete.&lt;/p&gt;

&lt;p&gt;I hope this helps someone out there.&lt;/p&gt;

&lt;p&gt;Don't forget to mention what resources you use in the comments below!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked this post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on Twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on GitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on this amazing platform: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/9-best-free-resources-for-learning-html-and-css-9f4"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Best Browser(chrome or firefox) extensions for students and professionals</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Tue, 29 Jun 2021 10:18:53 +0000</pubDate>
      <link>https://forem.com/forkbikash/best-browser-chrome-or-firefox-extensions-for-students-and-professionals-1h59</link>
      <guid>https://forem.com/forkbikash/best-browser-chrome-or-firefox-extensions-for-students-and-professionals-1h59</guid>
      <description>&lt;p&gt;The browser(chrome or firefox) extensions listed below are the ones that I use for my productivity and convenience. And I am sure that some of you are already using these extensions or will start using them immediately after reading this post.&lt;/p&gt;

&lt;p&gt;Some of these extensions are for developers only and the rest are for everyone including developers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So, here is the list of browser extensions that I use daily:&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  AdBlocker Ultimate
&lt;/h3&gt;

&lt;p&gt;AdBlocker Ultimate is a free extension that blocks ads and malicious domains known to spread malware. It also disables sneaky tracking.&lt;/p&gt;

&lt;p&gt;Check out the extension:&lt;br&gt;
&lt;a href="https://chrome.google.com/webstore/detail/adblocker-ultimate/ohahllgiabjaoigichmmfljhkcfikeof?utm_source=chrome-ntp-icon"&gt;For chrome&lt;/a&gt;&lt;br&gt;
&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/adblocker-ultimate/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search"&gt;For firefox&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  I don't care about cookies
&lt;/h3&gt;

&lt;p&gt;Remove cookie warnings from almost all websites!&lt;/p&gt;

&lt;p&gt;The EU regulations require that any website using tracking cookies must get user's permission before installing them. Imagine how irritating that becomes when you surf anonymously or if you delete cookies automatically every time you close the browser.&lt;/p&gt;

&lt;p&gt;Check out the extension:&lt;br&gt;
&lt;a href="https://chrome.google.com/webstore/detail/i-dont-care-about-cookies/fihnjjcciajhdojfnbdddfaoknhalnja/related"&gt;For chrome&lt;/a&gt;&lt;br&gt;
&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/i-dont-care-about-cookies/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search"&gt;For firefox&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Hide YouTube Fullscreen Controls
&lt;/h3&gt;

&lt;p&gt;Hide the YouTube fullscreen controls when you move the cursor to the display border.&lt;/p&gt;

&lt;p&gt;Check out the extension:&lt;br&gt;
&lt;a href="https://chrome.google.com/webstore/detail/hide-youtube-fullscreen-c/akkdefghgcakdgkmakeajmijjhlcofmk?utm_source=chrome-ntp-icon"&gt;For chrome&lt;/a&gt;&lt;br&gt;
&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/hide-youtube-controls/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search"&gt;For firefox&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Video Speed Controller
&lt;/h3&gt;

&lt;p&gt;Speed up, slow down, advance and rewind HTML5 audio/video with shortcuts.&lt;/p&gt;

&lt;p&gt;Check out the extension:&lt;br&gt;
&lt;a href="https://chrome.google.com/webstore/detail/video-speed-controller/nffaoalbilbmmfgbnbgppjihopabppdk"&gt;For chrome&lt;/a&gt;&lt;br&gt;
&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/videospeed/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search"&gt;For firefox&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Octotree - GitHub code tree (for developers only)
&lt;/h3&gt;

&lt;p&gt;Browser extension that enhances GitHub code review and exploration.&lt;/p&gt;

&lt;p&gt;Features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fast IDE-like code tree&lt;/li&gt;
&lt;li&gt;Quick file search &lt;/li&gt;
&lt;li&gt;Support GitHub themes&lt;/li&gt;
&lt;li&gt;Support private repositories&lt;/li&gt;
&lt;li&gt;Omni bookmarking&lt;/li&gt;
&lt;li&gt;High performance, working with repositories of any size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The extension is free but you can also opt for pro.&lt;/p&gt;

&lt;p&gt;Check out the extension:&lt;br&gt;
&lt;a href="https://chrome.google.com/webstore/detail/octotree-github-code-tree/bkhaagjahfmjljalopjnoealnfndnagc?utm_source=chrome-ntp-icon"&gt;For chrome&lt;/a&gt;&lt;br&gt;
&lt;a href="https://addons.mozilla.org/en-US/firefox/addon/octotree/?utm_source=addons.mozilla.org&amp;amp;utm_medium=referral&amp;amp;utm_content=search"&gt;For firefox&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you use browser other than chrome or firefox, search for these types of extensions on the internet.&lt;/p&gt;

&lt;p&gt;I hope this helps someone out there.&lt;/p&gt;

&lt;p&gt;Don't forget to mention what extensions you use in the comments below!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked this post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on Twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on GitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on this beautiful platform: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/best-browser-chrome-or-firefox-extensions-for-students-and-professionals-4p4d-temp-slug-2135274"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>chromeextension</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Run Scripts on websites using this simple technique</title>
      <dc:creator>Bikash Mishra</dc:creator>
      <pubDate>Thu, 24 Jun 2021 18:12:58 +0000</pubDate>
      <link>https://forem.com/forkbikash/run-scripts-on-websites-using-this-simple-technique-lpn</link>
      <guid>https://forem.com/forkbikash/run-scripts-on-websites-using-this-simple-technique-lpn</guid>
      <description>&lt;h2&gt;
  
  
  What are bookmarklets?
&lt;/h2&gt;

&lt;p&gt;A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser.&lt;/p&gt;

&lt;p&gt;Developing a bookmarklet is simple and easy to use.&lt;/p&gt;

&lt;p&gt;They can even make a post request with the fetch API.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to develop one
&lt;/h2&gt;

&lt;p&gt;Use javascript in &lt;code&gt;href&lt;/code&gt; attribute of &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tags in HTML.&lt;br&gt;
An example would be&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="javascript: alert('hello world');"&amp;gt;click me&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make that in HTML and drag it into your bookmarks bar, you have just added a bookmarklet to your browser. Isn't it simple?&lt;/p&gt;

&lt;p&gt;All the javascript in your bookmarklet has to be minified.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="javascript: fetch('https://api.website.com/endpoint').then((data) =&amp;gt; { alert('data'); })"&amp;gt;&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bookmarklet can be used to modify(or filter) the content of a website.&lt;br&gt;
Below is an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="javascript: document.body.innerHTML = '&amp;lt;h1&amp;gt;yeah!&amp;lt;/h1&amp;gt;' })"&amp;gt;&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The main reason you should consider developing or using a bookmarklet is for productivity.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to install a bookmarklet?
&lt;/h2&gt;

&lt;p&gt;There are many ways to install a bookmarklet. I will show one of them which is probably the simplest one.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for bookmarklets you want to install on the internet.&lt;/li&gt;
&lt;li&gt;Drag the bookmarklet from the page to your Bookmarks Toolbar. It should show on the toolbar now.&lt;/li&gt;
&lt;li&gt;If the Bookmarks Toolbar is not visible then you first have to show the Bookmarks Toolbar by right-clicking on an empty section of the Tab Strip and checking the Bookmarks Toolbar in the pop-up menu. Now repeat the above step.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to use the installed bookmarklet?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Go on a website where you want to use your bookmarklet.&lt;/li&gt;
&lt;li&gt;Click the bookmarklet on your Bookmarks Toolbar. You will see the magic happening.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find many more pre-built bookmarklets on the internet.&lt;/p&gt;

&lt;p&gt;I hope this helps someone out there.&lt;/p&gt;

&lt;p&gt;Don't forget to mention what you've made in the comments below!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;If you liked this post, you can find more by:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following me on Twitter: &lt;a href="https://twitter.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on GitHub: &lt;a href="https://github.com/forkbikash"&gt;@forkbikash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Following me on this beautiful platform: &lt;a class="mentioned-user" href="https://dev.to/forkbikash"&gt;@forkbikash&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://twitter.com/share?url=https://dev.to/forkbikash/run-scripts-on-websites-using-this-simple-technique-lpn"&gt;&lt;strong&gt;Tweet this post&lt;/strong&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://twitter.com/forkbikash?ref_src=twsrc%5Etfw"&gt;&lt;strong&gt;Follow me on Twitter @forkbikash&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bookmarklet</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>html</category>
    </item>
  </channel>
</rss>
