<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Azeem Akhter on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Azeem Akhter on Medium]]></description>
        <link>https://medium.com/@muhammad-azeem-akhter?source=rss-3f4129de168a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LRA4i0RFVNXvR6ymdJ5juQ.jpeg</url>
            <title>Stories by Muhammad Azeem Akhter on Medium</title>
            <link>https://medium.com/@muhammad-azeem-akhter?source=rss-3f4129de168a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:49:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muhammad-azeem-akhter/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building and Dockerizing a Standalone Celery Application: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@muhammad-azeem-akhter/building-and-dockerizing-a-standalone-celery-application-a-step-by-step-guide-9ffc48baa37e?source=rss-3f4129de168a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ffc48baa37e</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[celery-docker]]></category>
            <category><![CDATA[celery]]></category>
            <category><![CDATA[standalone-celery]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Muhammad Azeem Akhter]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 07:50:35 GMT</pubDate>
            <atom:updated>2023-07-18T07:50:35.146Z</atom:updated>
            <content:encoded><![CDATA[<p>In the world of distributed task queues, Celery stands out as a powerful and versatile tool. With its ability to handle complex task management and distributed processing, Celery is widely used in various application scenarios.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*5Gwa_vnOXkt1ufwHwvDluA.png" /></figure><p>In this article, we will walk through the process of setting up a standalone Celery application and then containerizing it with Docker. Whether you are new to Celery or looking to enhance your knowledge, this step-by-step guide will help you get started on building and deploying your Celery-powered application.</p><p>Let’s start with setting up a standalone Celery application. To begin, ensure that you have Python and pip installed on your system.</p><p>Follow these steps:</p><p>Create a new project directory: Start by creating a new directory for your Celery application.</p><pre>$ mkdir my-celery-app<br>$ cd my-celery-app</pre><p>Create a virtual environment: It’s always a good practice to work within a virtual environment to manage dependencies</p><pre>$ python -m venv venv<br>$ source venv/bin/activate</pre><p>Create a requirements.txt file and add your dependencies there</p><pre>celery==5.3.1<br>kombu===5.3.1</pre><p>Let’s install them using the following command pip install -r requirements.txt</p><p>Create a file called app.pyand start adding celery configuration in the file</p><pre>from celery import Celery<br><br>app = Celery(<br>  &#39;my_celery_app&#39;,<br>  broker=&#39;amqp://guest:guest@localhost:5672/&#39;<br>)</pre><p>In this tutorial we are using Rabbitmq as a broker, you can see a list of brokers that can be configured with celery <a href="https://docs.celeryq.dev/en/stable/getting-started/backends-and-brokers/index.html#backends-and-brokers">here</a>.</p><p>Let’s add default exchange and queues in our celery app.</p><pre>from celery import Celery<br>from kombu import Exchange, Queue <br><br>app = Celery(<br>  &#39;my_celery_app&#39;,<br>  broker=&#39;amqp://guest:guest@localhost:5672/&#39;<br>)<br><br># Registering an exchange and two queues<br>default_exchange = Exchange(&#39;default&#39;, type=&#39;topic&#39;)<br><br>app.conf.task_queues = (<br>    Queue(&#39;default&#39;, default_exchange, routing_key=&#39;default.#&#39;),<br>    Queue(&#39;periodic&#39;, default_exchange, routing_key=&#39;periodic.#&#39;),<br>)</pre><p>In this code block, we have added one exchange and two queues, one to handle normal tasks and the other for periodic tasks. The routing key helps Celery identify which tasks belong to which queue and # in the routing key specify that all tasks in this queue will have default. a prefix in the task name.</p><pre>from celery import Celery<br>from kombu import Exchange, Queue <br><br>app = Celery(<br>  &#39;my_celery_app&#39;,<br>  broker=&#39;amqp://guest:guest@localhost:5672/&#39;<br>)<br><br># Registering an exchange and two queues<br>default_exchange = Exchange(&#39;default&#39;, type=&#39;topic&#39;)<br><br>app.conf.task_queues = (<br>    Queue(&#39;default&#39;, default_exchange, routing_key=&#39;default.#&#39;),<br>    Queue(&#39;periodic&#39;, default_exchange, routing_key=&#39;periodic.#&#39;),<br>)<br><br># ----------<br><br># Configuring default queue, exchange and routing key<br>app.conf.task_default_queue = &#39;default&#39;<br>app.conf.task_default_exchange = &#39;default&#39;<br>app.conf.task_default_routing_key = &#39;default&#39;<br><br># Configuring tasks routes<br>CELERY_TASK_ROUTES = {<br>    &#39;default.*&#39;: {<br>        &#39;queue&#39;: &#39;default&#39;,<br>        &#39;routing_key&#39;: &#39;default.#&#39;,<br>    },<br>    &#39;periodic.*&#39;: {<br>        &#39;queue&#39;: &#39;periodic&#39;,<br>        &#39;routing_key&#39;: &#39;periodic.#&#39;,<br>    }<br>}<br></pre><p>Now we are letting Celery know which queue, exchange, and routing key is going to be used as a default for this app and have also configured routes of tasks manually, all tasks having names starting with defult. will be directed toward default queue and default.#will be used as a routing key for these tasks. You can read further about exchange and queue <a href="https://docs.celeryq.dev/en/stable/userguide/routing.html#exchanges-queues-and-routing-keys">here</a></p><p>Let’s add tasks to our celery app</p><pre>from celery import Celery<br>from kombu import Exchange, Queue <br><br>app = Celery(<br>    &#39;my_celery_app&#39;,<br>    broker=&#39;amqp://guest:guest@localhost:5672/&#39;<br>)<br><br># Registering an exchange and two queues<br>default_exchange = Exchange(&#39;default&#39;, type=&#39;topic&#39;)<br><br>app.conf.task_queues = (<br>    Queue(&#39;default&#39;, default_exchange, routing_key=&#39;default.#&#39;),<br>    Queue(&#39;periodic&#39;, default_exchange, routing_key=&#39;periodic.#&#39;),<br>)<br><br># Configuring default queue, exchange and routing key<br>app.conf.task_default_queue = &#39;default&#39;<br>app.conf.task_default_exchange = &#39;default&#39;<br>app.conf.task_default_routing_key = &#39;default&#39;<br><br>app.autodiscover_tasks()<br><br># Configuring tasks routes<br>CELERY_TASK_ROUTES = {<br>    &#39;default.*&#39;: {<br>        &#39;queue&#39;: &#39;default&#39;,<br>        &#39;routing_key&#39;: &#39;default.#&#39;,<br>    },<br>    &#39;periodic.*&#39;: {<br>        &#39;queue&#39;: &#39;periodic&#39;,<br>        &#39;routing_key&#39;: &#39;periodic.#&#39;,<br>    }<br>}<br><br># ----------<br><br># Tasks<br>@app.task(name=&quot;default.add&quot;, bind=True)<br>def add(self, x, y)<br>    return x + y</pre><p>Since we have added tasks in the same file Celery will pick them up automatically but if we have tasks in a separate file then will have to manually register them with our app as mentioned below.</p><pre>from .tasks import add<br><br>app.register_task(add)</pre><p>Our Celery app has been configured so let’s create a dockerfile to run our Celery app using Docker. Make sure you name it as Dockerfile</p><pre># Dockerfile<br>FROM python:3.9<br><br>RUN mkdir /app<br>WORKDIR /app<br><br>COPY requirements.txt .<br>RUN pip install -r requirements.txt<br><br>COPY . /app<br><br>CMD celery -A app worker --loglevel=info</pre><p>Build the Docker image: Open a terminal window, navigate to your project directory, and build the Docker image using the following command.</p><pre>$ docker build -t my-celery-app .</pre><p>Run the Docker container: Start a new Docker container using the image you built</p><pre>$ docker run -d my-celery-app</pre><p>You have successfully set up a standalone Celery application using RabbitMQ as the message broker and containerized it with Docker. By following this step-by-step guide, you now have the knowledge to leverage the power of Celery for asynchronous task processing and utilize RabbitMQ as a reliable messaging system.</p><p>Remember to explore the Celery and RabbitMQ documentation for further configuration options and advanced features. With Celery and Docker, you can efficiently build scalable and distributed applications. Enjoy harnessing the capabilities of Celery and RabbitMQ to develop robust and responsive systems.</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ffc48baa37e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Flower with Celery in Django Project Using Docker]]></title>
            <link>https://medium.com/@muhammad-azeem-akhter/integrating-flower-with-celery-in-django-project-using-docker-5ba37a8d7dee?source=rss-3f4129de168a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ba37a8d7dee</guid>
            <dc:creator><![CDATA[Muhammad Azeem Akhter]]></dc:creator>
            <pubDate>Mon, 18 Apr 2022 06:15:04 GMT</pubDate>
            <atom:updated>2024-07-04T08:20:54.728Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TLk5Y91kfGi5NsjPY1k9yA.png" /></figure><h4><strong>What is Flower?</strong></h4><p>Flower is a web-based tool for monitoring and administrating Celery clusters.</p><h4>Why Flower?</h4><ul><li>Real-time monitoring using Celery Events<br>- Task progress and history<br>- Ability to show task details (arguments, start time, runtime, and more)<br>- Graphs and statistics</li><li>Remote Control<br>- View worker status and statistics<br>- Shutdown and restart worker instances<br>- Control worker pool size and autoscale settings<br>- View and modify the queues a worker instance consumes from<br>- View currently running tasks<br>- View scheduled tasks (ETA/countdown)<br>- View reserved and revoked tasks<br>- Apply time and rate limits<br>- Configuration viewer<br>- Revoke or terminate tasks</li><li>Broker monitoring<br>- View statistics for all Celery queues<br>- Queue length graphs</li><li>HTTP API</li><li>Basic Auth, GitHub OAuth2, and Google OpenID authentication</li></ul><h4>How?</h4><ol><li>First of all, we need to check available images of flower on <a href="https://hub.docker.com/">docker hub</a>.</li><li>Currently, there isn’t any official image provided by flower so we will use <a href="https://hub.docker.com/r/mher/flower">mher/flower</a> as flower image.</li><li>Let’s update our docker-compose.yml file and add a new service for flower.</li></ol><pre>celery:<br>  image: celery:latest<br>  container_name: celery<br>  command: celery -A &lt;project-name&gt; worker -l INFO&quot;</pre><pre>flower:<br>  image: mher/flower # Image we will use for flower<br>  container_name: flower # Docker conainer name</pre><p>5. Let’s add a command in docker configuration to execute flower.</p><pre>celery:<br>  image: celery:latest<br>  container_name: celery<br>  command: celery -A &lt;project-name&gt; worker -l INFO&quot;</pre><pre>flower:<br>  image: mher/flower<br>  container_name: flower<br>  command: celery flower # This will execute flower.</pre><p>6. Now we need to link flower with our celery broker so that we can get stats of our celery cluster.</p><pre>celery:<br>  image: celery:latest<br>  container_name: celery<br>  command: celery -A &lt;project-name&gt; worker -l INFO&quot;</pre><pre>flower:<br> image: mher/flower<br> container_name: flower<br> command: celery flower # This will execute flower.<br> environment:<br>   - CELERY_BROKER_URL=&lt;broker-url&gt;<br>   - FLOWER_PORT=&lt;port-you-want-to-use-for-flower&gt;<br>ports:<br>- &lt;flower-port&gt;:&lt;flower-port&gt; # docker will expose this ports for flower</pre><p>Flower will communicate with our broker using broker URL and extract all the required information about our celery cluster.</p><p>7. We can also persist our data in flower so that it didn’t go away on every restart of container. In order to do this we have to add a volume and add an argument in the docker command.</p><pre>celery:<br>  image: celery:latest<br>  container_name: celery<br>  command: celery -A &lt;project-name&gt; worker -l INFO&quot;</pre><pre>flower:<br> image: mher/flower<br> container_name: flower<br> command: celery flower <strong>--persisten=True</strong><br> environment:<br>   - CELERY_BROKER_URL=http://my-broker-url<br>   - FLOWER_PORT=8888<br> ports:<br> - 8888:8888 # docker will expose this ports<br> volumes:<br> - flower_data:/data<br>vloumes:<br> flower_data # this will let docker know that we have added a custom volume</pre><p>8. Last but not least, start your docker containers and we are good to experience flower.</p><p>Now visit http://localhost:&lt;flower-port&gt; to experience flower.</p><h4>Related Docs:</h4><ul><li><a href="https://hub.docker.com/r/mher/flower">https://hub.docker.com/r/mher/flower</a></li><li><a href="https://hub.docker.com/_/celery">https://hub.docker.com/_/celery</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ba37a8d7dee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Hoisting in Javascript | M.Azeem Akhter]]></title>
            <link>https://medium.com/@muhammad-azeem-akhter/understanding-hoisting-in-javascript-m-azeem-akhter-ef7d10ed85bd?source=rss-3f4129de168a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef7d10ed85bd</guid>
            <category><![CDATA[variable-hoisting]]></category>
            <category><![CDATA[hoisting]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[javascript-hoisting]]></category>
            <category><![CDATA[function-hoisting]]></category>
            <dc:creator><![CDATA[Muhammad Azeem Akhter]]></dc:creator>
            <pubDate>Wed, 05 Jan 2022 17:43:55 GMT</pubDate>
            <atom:updated>2022-01-05T17:43:55.415Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Hoisting in Javascript</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ffej_miIDZDGPNeq-Gpdlw.png" /></figure><p>Ever wondered what is hoisting and how it works in javascript? Let me help you with this and learn about it together. Let’s start!</p><h3><strong>What is Hoisting?</strong></h3><blockquote>Hoisting in javascript is a process where the interpreter moves the variables, functions and class declaration to the top of their scope, prior to execution of the code.</blockquote><p>Didn’t get it completely? No problem, Let me explain.</p><p>In simple words hoisting allows us to safely use variables/functions in code before their declaration, by moving them at top of their scope but it’s not recommended to use them before their declarations as it may lead to errors.</p><p>Hoisting is done in the creation phase of Global execution context.</p><p>In this article, we will learn about all types of hoisting one by one.</p><h3>Variable Hoisting:</h3><p>An important thing to understand about variable hoisting is that javascript only hoist <strong>declarations, not initialization. </strong>Variables only get initialized when that specific line is executed until that variable has its default initialization as undefined (only for variables declared using var otherwise uninitialized)</p><h4>Variable declaration using var:</h4><p>Let’s figure out how hoisting works when a variable is declared using var with the help of a code block.</p><pre>1. console.log(x)<br>2. var x;<br>3. x = 2;<br>4. console.log(x)</pre><p>Let me explain what will happen when this code block gets executed.</p><p>Before execution of code what interpreter does is scan the code and looks for all the variable declarations available in the file and move them at the top of their scope. In this case interpreter will move line#2 on top of global scope as we are declaring it in main tree.</p><p>This is how javascript will interpret it due to hoisting:</p><pre>1. var x; // Declaration <br>2. console.log(x) // Returns &#39;undefined&#39; instead of 2<br>3. x = 2; // Initialization<br>4. console.log(x) // Returns 2 as x is initialized with 2 now.</pre><p>In line#1 x is declared, in line#2 it will logundefined in console because x is declared using var that’s why it has undefined as its default initialization, in line#3 x is initialized with its actual value 2 and in line#4 it will be logged in console by its actual value 4 .</p><p>Same thing will happen if we declare and initialize a variable at the same time.</p><pre>1. console.log(x) // Returns &#39;undefined&#39; instead of 2<br>2. var x = 2; // Initialization<br>3. console.log(x) // Returns 2 as x is initialized with 2 now.</pre><p><strong>Note:</strong> In case we completely forgot to declare a variable then it will throwReferenceError exception.</p><h4>Variable declaration using let and const:</h4><p>Variables declared using let and const are also hoisted but don’t get initialized with a default value that’s why accessing these variables before declaration will cause ReferenceError exception as the variable is uninitialized.</p><pre>1. console.log(x) // This will throw ReferenceError exception<br>2. let x = 2; // Initialization<br>3. console.log(x) // Returns 2 as x is initialized with 2 now.</pre><h3>Function Hoisting:</h3><p>Hoisting also allows us to use functions before their declarations, let’s understand this with an example</p><pre>1. console.log(sum(2,3));</pre><pre>2. function sum(firstNum, secondNum) {<br>3.   return firstNum + secondNum;<br>4. }<br> // 5 will be the output of this code</pre><p>Without hoisting we have to take care of the order of usage and declaration, thanks to hoisting we can ignore its order.</p><p>Let’s see in another example how <strong>hoisting works with function expressions.</strong></p><pre>1. console.log(getRectArea(2,3));</pre><pre>2. let getRectArea = function(width, height) {<br>3.   return width * height;<br>4. };<br>// This code block will result in ReferenceError exception.</pre><p>It’s time to remind a point we discussed earlier in this article: <strong>javascript hoist only declaration, not initialization.</strong></p><p>Let’s see what happens when interpreter scans the code before execution:</p><p>While scanning when it comes to line#2 it will see a declaration and move it to the top of the scope and in this case it wouldn’t be the whole line moving on top it will just move the declaration part let getRectArea; that’s it. Just to make it clear function assigning to getRectArea variable is part of the initialization process.</p><p>When line#1 is executed interpreter will find a function call although it isn’t aware of any function declaration so it will result in an exception.</p><p>Function and class expression works on almost same pattern so we can say that both <strong>function and class expressions are not hoisted in javascript.</strong></p><h3>Class Hoisting:</h3><p>In javascript we can declare a class by using class keyword along with the name of the class.</p><pre>1. class Student {<br>2.   constructor(id, name, subject) {<br>3.     this.id = id;<br>4.     this.name = name;<br>5.     this.subject = subject;<br>6.   }<br>7. }</pre><p>This method is called <strong>class declaration.</strong></p><p>Classes defined using class declaration are hoisted and interpreter has their references before actual execution happen. But they don’t have default initialization so any code block using a class before its initialization will result in an exception ReferenceError .</p><h3>Conclusion:</h3><p>I’d say in javascript the only thing which matters is the order in which a code block is executed not the order in which it is written.</p><p>We can use variables(only declared using var ) and functions before their declaration but it is not a very good approach so try to declare all your variables and then access them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef7d10ed85bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Medium — Difference between find() and filter() in Javascript]]></title>
            <link>https://medium.com/@muhammad-azeem-akhter/difference-between-find-and-filter-in-javascript-4264abde085?source=rss-3f4129de168a------2</link>
            <guid isPermaLink="false">https://medium.com/p/4264abde085</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[find]]></category>
            <category><![CDATA[filters]]></category>
            <category><![CDATA[comparison]]></category>
            <category><![CDATA[js]]></category>
            <dc:creator><![CDATA[Muhammad Azeem Akhter]]></dc:creator>
            <pubDate>Tue, 04 Jan 2022 06:32:01 GMT</pubDate>
            <atom:updated>2022-01-05T07:55:27.548Z</atom:updated>
            <content:encoded><![CDATA[<p>In this article, we’ll talk about two most commonly used methods available in javascript.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xt8ksjtwYbn2mr1KTrVh0Q.png" /></figure><h3><strong>find():</strong></h3><p>The find method returns the first match in the collection. Once a match is found it stops checking remaining elements in the collection.</p><pre>arr = [&#39;apple&#39;, &#39;banana&#39;, &#39;apple&#39;, &#39;mango&#39;, &#39;pineapple&#39;]<br>arr.find((val) =&gt; val == &#39;apple&#39;)</pre><pre>#OUTPUT<br>apple</pre><h3>filter():</h3><p>The filter method returns all the matches from the collection in the form of another collection.</p><pre>arr = [&#39;apple&#39;, &#39;banana&#39;, &#39;apple&#39;, &#39;mango&#39;, &#39;pineapple&#39;]<br>arr.filter((val) =&gt; val == &#39;apple&#39;)</pre><pre>#OUTPUT<br>[ &#39;apple&#39;, &#39;apple&#39; ]</pre><pre>arr.filter((val) =&gt; val == &#39;mango&#39;)</pre><pre>#OUTPUT<br>[ &#39;mango&#39; ]</pre><p>IF you’re only looking for the first match then find() is a better option in the latest browsers. Mostly when it comes to large arrays then find() is efficient and faster than filter because filter iterate over the whole array whether it finds a match or not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4264abde085" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>