<?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 Mateusz Jasiński on Medium]]></title>
        <description><![CDATA[Stories by Mateusz Jasiński on Medium]]></description>
        <link>https://medium.com/@mateusz-jasinski?source=rss-808be72490a7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jl63UMFdCD2yFW9rHG5Nqw.jpeg</url>
            <title>Stories by Mateusz Jasiński on Medium</title>
            <link>https://medium.com/@mateusz-jasinski?source=rss-808be72490a7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:17:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mateusz-jasinski/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[5 Backend Interview Questions for Backend Engineer]]></title>
            <link>https://medium.com/@mateusz-jasinski/5-backend-interview-questions-for-backend-engineer-8db7c234d08a?source=rss-808be72490a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8db7c234d08a</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[job-search]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Mateusz Jasiński]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 11:02:06 GMT</pubDate>
            <atom:updated>2024-01-04T11:28:50.577Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 Interview Questions for Backend Engineer</h3><h4>Getting ready for a backend technical interview.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cY8T8hesXEXryUTe" /><figcaption>Photo by <a href="https://unsplash.com/@mkvandergriff?utm_source=medium&amp;utm_medium=referral">Maranda Vandergriff</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Preparing for a backend engineering interview can be a challenging yet rewarding experience. Based on my experience as a technical recruiter I will give you a few tips and, more importantly, tell you what you can expect during a technical interview.</p><h4>How would you implement authentication in web services?</h4><p>To implement authentication in our system, we’ll use <strong>Token-based</strong> authentication. When the user successfully logs in, the system generates a token (for example JWT), the token is securely stored by the client and attached as a header to the request to authenticate the user.</p><p><em>This is only one example of authentication implementation, there are other strategies for example Cookie-Based. Always describe the one that you’re most familiar with.</em></p><h4>What are the pros and cons of using Microservices Architecture?</h4><p>Microservices are small independent components of the application, usually separated based on business/functional parts of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*hV-BngjaRjG92rr4BVO99w.png" /></figure><p><em>You can also mention when it is recommended and when you should avoid using a microservices architecture. If you already worked with microservices, say something about your experience.</em></p><h4>Explain the differences between Relational (SQL) and Non-relational (NoSQL) databases</h4><p><strong>Relational databases</strong> store data in structured tables, and primary keys can identify all records in the databases.</p><p>In <strong>NoSQL databases</strong>, data don&#39;t need to be structured and can be stored as a document, key-value, etc.</p><p><em>You should also mention your experience with both types of databases. Explain real-life scenarios for database type selection.</em></p><h4>Describe the key principles of RESTful API design. Can you walk us through designing and implementing a RESTful API, including considerations for resource naming, HTTP methods, and versioning?</h4><p><strong>Naming</strong></p><ul><li>Use nouns rather than verbs. This ensures that endpoints represent entities or objects.</li><li>Use plural nouns for resource names to maintain consistency. For example, use /comments instead of /comment for the endpoint representing a collection of comments.</li><li>Choose clear and meaningful names for resources, avoiding abbreviations and acronyms.</li></ul><p><strong>HTTP methods</strong></p><ul><li>GET (Read): Use for retrieving resources. The endpoint should be idempotent, meaning repeated requests yield the same result.</li><li>POST (Create): Use for creating new resources. It should not be idempotent, as each request creates a new resource.</li><li>PUT (Update): Use for updating existing resources. The entire resource should be sent in the request payload.</li><li>DELETE (Delete): Use for deleting resources. It should be idempotent.</li><li>PATCH (Partial Update): Use for partial updates to existing resources. It’s more bandwidth-efficient than PUT, as it only sends the modified fields.</li></ul><p><strong>Versioning</strong></p><p>Include version information in the API to handle changes gracefully without breaking existing clients. This can be achieved through URI versioning (/v1/resource) or using custom headers.</p><h4>How would you handle a huge amount of requests?</h4><p>Here are serval strategies to archive high scalability in web services:</p><ul><li><strong>Load balancing </strong>— Distribute incoming traffic across multiple servers to prevent any single server from becoming a bottleneck.</li><li><strong>Horizontal Scaling — </strong>Increase the number of server instances to handle more requests. Utilize cloud services to add or remove instances based on demand dynamically.</li><li><strong>Caching — </strong>Implement caching mechanisms to store and serve frequently requested data without repeatedly processing it. This reduces the load on the backend.</li></ul><p>There are more possibilities like CDNs, asynchronous processing, etc.</p><p>Best of luck in your interviews, and follow for more content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8db7c234d08a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a recommendation system using Neo4j]]></title>
            <link>https://medium.com/@mateusz-jasinski/building-a-recommendation-system-using-neo4j-3baaf349e7?source=rss-808be72490a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3baaf349e7</guid>
            <category><![CDATA[recommendations]]></category>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[graph-database]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[system-architecture]]></category>
            <dc:creator><![CDATA[Mateusz Jasiński]]></dc:creator>
            <pubDate>Fri, 16 Jun 2023 09:03:33 GMT</pubDate>
            <atom:updated>2025-04-01T10:04:00.627Z</atom:updated>
            <content:encoded><![CDATA[<h4>Modern applications now rely on recommendation systems to power personalized suggestions that improve user experiences. In this article, we’ll look at how to use Neo4j to create a simple recommendation system.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nWosNx_Uzt33vx-g" /><figcaption>Photo by <a href="https://unsplash.com/@kierinsightarchives?utm_source=medium&amp;utm_medium=referral">Kier in Sight Archives</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Recommendation system</h3><p>Usually, it’s a system used to filter information and suggest items or content to the end user. The main objective is to offer tailored suggestions based on user preferences, interests, or past behaviors.</p><p>Recommendation systems are widely used in various business domains, such as social media, e-commerce, and entertainment. Recommendation systems play a crucial role in personalizing user experiences and enhancing customer satisfaction.</p><h4>Social Networks</h4><p>In social media, recommendation systems are crucial in enhancing user engagement and content discovery. The system collects information like hashtags, posts, and user relations, and is used to help users find more relevant posts, articles, videos, or new friends.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*7rv5qioLHfKu7rnPy0CevA.png" /><figcaption>Example graph for Social following system</figcaption></figure><p>We are all familiar with features like following or subscribing. On top of that, let’s look at how great of a job Youtube does at finding the best matching content we can spend hours on.</p><h4>E-commerce</h4><p>Systems for making recommendations are essential in e-commerce as they improve customer satisfaction and boost revenue. The system can define highly personalized products based on user preferences, purchase history, and browsing history, encouraging cross-selling, upselling, and ultimately increasing revenue and sales.</p><h3>Understanding Neo4j and Graph Databases</h3><p>Neo4j is a graph database management system designed to store, manage, and analyze highly connected data. It is based on the concept of a graph, where data is represented as nodes, which can be entities such as people or objects, and relationships that define connections between nodes. Neo4j provides a powerful and flexible platform for modeling, querying, and traversing complex relationships in data.</p><h4>Cypher Query Language</h4><p>Cypher is a query language similar to SQL that we can use for creating, browsing, and updating information in the graph database. Using clauses like in SQL we can perform the highly optimal operation on the database.</p><pre># Create Node <br><br>CREATE (node:label{key_1:value, key_2:value ...)<br><br># Matching by nodes<br><br>MATCH (node:label) <br>RETURN node <br><br># Matching by relationship<br> <br>MATCH (node:label)&lt;-[: Relationship]-(n) <br>RETURN n </pre><h3>Building Recommendation System using Neo4j</h3><p>For this article, we will build a movie recommendation system, based on movies watched by followed users.</p><ul><li>System storing information about Users and Movies</li><li>The system will allow the creation of a relationship between the User and the Movie. Also, users should be able to follow other users.</li><li>The goal is to display movies that have been watched by following users.</li></ul><h4>Build Our graph</h4><p>We need to start by adding some data to our database. A few users and a few films ought to be made. Let’s begin with our first query.</p><pre>CREATE (john:User{firstName:&quot;John&quot;}), (tom:User{firstName:&quot;Tom&quot;}),<br>  (mark:User{firstName:&quot;Mark&quot;})<br><br>CREATE (titanic:Movie{title:&quot;Titanic&quot;}),(avatar:Movie{title:&quot;Avatar&quot;}),<br>  (forrest:Movie{title:&quot;Forrest Gump&quot;})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/439/1*znkTjukyOVbROgae00G5zw.png" /><figcaption>Nodes in the initial database</figcaption></figure><p>Now that our initial nodes have been successfully created, let’s examine the graph. We must now add a few node-to-node relations. Start with Tom’s favorite movies and the users that he follows.</p><pre># Create User -&gt; Movie relationship called Watched<br><br>MATCH <br>(avatar:Movie{title: &quot;Avatar&quot;}),<br>(tom:User{firstName:&quot;Tom&quot;}) <br>CREATE (tom)-[:Watched]-&gt;(avatar)<br><br># Create user -&gt; user relationship called Following<br><br>MATCH <br>(tom:User{firstName:&quot;Tom&quot;}),<br>(mark:User{firstName: &quot;Mark&quot;}) <br>CREATE (tom)-[:Following]-&gt;(mark)</pre><p>A few operations later, our final graph will look like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/412/1*XgDFDoqoB4vSCgTnU3Ir-A.png" /></figure><h4>Let’s make some queries</h4><p>When our graph is filled with data, we can start exploring our data, on start let’s take an easy task to find all nodes with label users.</p><pre>MATCH (users:User) <br>return users<br>===================<br>RESULT<br>╒═══════════════════════════╕<br>│users                      │<br>╞═══════════════════════════╡<br>│(:User {firstName: &quot;John&quot;})│<br>├───────────────────────────┤<br>│(:User {firstName: &quot;Tom&quot;}) │<br>├───────────────────────────┤<br>│(:User {firstName: &quot;Mark&quot;})│<br>└───────────────────────────┘</pre><p>Easy, right? So now, let’s try to find all movies, that John watched.</p><pre>MATCH (user:User{firstName:&quot;John&quot;})--(movies:Movie) <br>return movies<br>=========================<br>RESULT<br>╒════════════════════════════════╕<br>│movies                          │<br>╞════════════════════════════════╡<br>│(:Movie {title: &quot;Avatar&quot;})      │<br>├────────────────────────────────┤<br>│(:Movie {title: &quot;Forrest Gump&quot;})│<br>└────────────────────────────────┘</pre><p>Okay, this one was already a little more difficult, because we had to introduce the relation, but have hope that you got the concept and we can move forward.</p><p>Next, let’s try to find all users followed by Tom knowing that Tom&#39;s node is equal to 6.</p><pre>MATCH (user:User)-[:Following]-&gt;(following) <br>WHERE ID(user) = 6 <br>return following<br>==========================<br>╒═══════════════════════════╕<br>│following                  │<br>╞═══════════════════════════╡<br>│(:User {firstName: &quot;John&quot;})│<br>├───────────────────────────┤<br>│(:User {firstName: &quot;Mark&quot;})│<br>└───────────────────────────┘</pre><p>As you can see, using Cypher is very similar to SQL in the case of using clauses. Our final task for today is to build a query for our recommendation system, we want to find all movies watched by users followed by Tom.</p><pre>MATCH (tom:User{firstName: &quot;Tom&quot;})-[:Following]-&gt;(users)-[:Watched]-&gt;(movies) <br>return movies<br>==============================<br>RESULT<br>╒════════════════════════════════╕<br>│movies                          │<br>╞════════════════════════════════╡<br>│(:Movie {title: &quot;Titanic&quot;})     │<br>├────────────────────────────────┤<br>│(:Movie {title: &quot;Avatar&quot;})      │<br>├────────────────────────────────┤<br>│(:Movie {title: &quot;Forrest Gump&quot;})│<br>└────────────────────────────────┘</pre><p>Almost there. One more thing to do, we need to exclude movies already watched by Tom. For that, we’ll use WHERE NOT clause.</p><pre>MATCH <br>(tom:User{firstName: &quot;Tom&quot;}), <br>(tom)-[:Following]-&gt;(users)-[:Watched]-&gt;(otherMovies) <br>WHERE NOT (tom)-[:Watched]-&gt;(otherMovies) <br>return otherMovies<br>=================================<br>RESULT<br>╒════════════════════════════════╕<br>│otherMovies                     │<br>╞════════════════════════════════╡<br>│(:Movie {title: &quot;Titanic&quot;})     │<br>├────────────────────────────────┤<br>│(:Movie {title: &quot;Forrest Gump&quot;})│<br>└────────────────────────────────┘</pre><h3>Next steps</h3><p>Our first recommendation system is ready, now we can extend it more, and play with much more options that Neo4j provides us. Check out their official documentation <a href="https://neo4j.com/docs/">https://neo4j.com/docs/</a> to see more.</p><p>Neo4j provides multiple drivers for the most popular programming languages like Python or Java — <a href="https://neo4j.com/developer/language-guides/">https://neo4j.com/developer/language-guides/</a>.</p><p>I hope you enjoy reading this article. Follow for more content and check my other articles.</p><p><strong>Schedule Cron Jobs With Github Actions</strong> — <a href="https://medium.com/better-programming/schedule-cron-jobs-with-github-actions-d279e8519cec">https://medium.com/better-programming/schedule-cron-jobs-with-github-actions-d279e8519cec</a></p><p><strong>Creating Cron jobs with Django and Kubernetes — </strong><a href="https://medium.com/@mateusz-jasinski/creating-cron-jobs-with-django-and-kubernetes-50f6fc26ca75">https://medium.com/@mateusz-jasinski/creating-cron-jobs-with-django-and-kubernetes-50f6fc26ca75</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3baaf349e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Schedule Cron Jobs With GitHub Actions]]></title>
            <link>https://medium.com/better-programming/schedule-cron-jobs-with-github-actions-d279e8519cec?source=rss-808be72490a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/d279e8519cec</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[scheduled-tasks]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mateusz Jasiński]]></dc:creator>
            <pubDate>Mon, 21 Nov 2022 07:40:04 GMT</pubDate>
            <atom:updated>2023-07-15T08:09:15.187Z</atom:updated>
            <content:encoded><![CDATA[<h4>We used to use tools that we knew well, not looking at disadvantages or cost, but nowadays, we have access to amazing platforms that help us</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*fHk4rZjzm5rWD6FU0yywCA@2x.jpeg" /></figure><p>Often, when I speak with my coworkers about scheduled tasks, the first one that pops up is Celery. I need to agree that it’s a powerful tool, but in many situations, it can be too overwhelming, or too many resources will be needed. That’s why some time ago, I started testing alternatives for standard queues solutions. In my previous article, I showed you how you can use Kubernetes to replace your current configuration, and this time I want to do it again using GitHub Actions.</p><h3>GitHub Action</h3><p>GitHub action is a CI/CD platform created by Microsoft to provide automated pipelines (workflows) to build, test and deploy your application. In this article, I want to show you how to use GHA to replace your current cron configuration. One of the most significant advantages is using actions for free (with limits).</p><h4>Pipeline</h4><p>In simple words, the pipeline is a series of steps that we need to perform to deliver a new version of our application. The pipeline usually contains steps like builds, automated tests, and code analyzers (continuous integration), but also an automated way to deploy our application to servers (continuous deployment).</p><h4>Worker</h4><p>It’s just a machine that will be used to run your workflow. Default GitHub works don’t have persistence memory, and all data is available during running. I will show you how you can deal with it later.</p><h4>Syntax</h4><p>GitHub workflows are created using YAML files. Each workflow defines a few important properties of our pipeline:</p><ul><li>on (triggers)</li><li>jobs (steps — operations of our workflow)</li><li>names, etc.</li></ul><p>The full syntax is available here: <a href="https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions">https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions</a>.</p><h4>Triggers</h4><p>Before we begin, let’s talk about triggers. GitHub provides multiple types of triggers that you can use to start your pipelines. If you are familiar with events, probably you seen triggers like push or commit . To reach our goal, we are going to use schedule —<a href="https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule"> based on the GitHub documentation</a>, using POSIX cron syntax, you can define the time when your cron will be started e.g. */10 * * * * will run your job every ten minutes.</p><p>If you need help with cron extensions, check — <a href="https://crontab.guru/">https://crontab.guru/</a>.</p><p>Okay! Enough theory. Let’s create our first workflow.</p><h3>Hello World</h3><p>Let us start with some basics. We’ll first create a pipeline to display messages to the command line. Here’s what that looks like:</p><pre>---<br>name: &quot;Workflow example&quot;<br>on:<br>  schedule:<br>    - cron: &#39;*/10 * * * *&#39;<br><br>jobs:<br>  hello:<br>    name: &quot;Say hello&quot;<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Display message<br>        run: echo &quot;Hello from GitHub Actions!&quot;</pre><p>Looks easy, right?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_lLynqGL3SPS2zguw_ARGg.png" /></figure><h3>Python</h3><p>Now, we’ll complicate it a little bit. This time we want to run our Python script.</p><pre>from datetime import datetime<br><br>with open(&#39;file.txt&#39;, &#39;w&#39;) as f:<br>    f.write(f&quot;JOB DONE {datetime.now()}&quot;)<br></pre><p>Our workflow will require a couple of additional steps. First of all, we need to clone our repository into our worker. To do that, we can use one of the actions available on <a href="https://github.com/marketplace">GitHub Marketplace</a>.</p><pre>- name: Checkout repository<br>  uses: actions/checkout@v2</pre><p>The next step requires to setup and configuring Python. Using action, we can select the version of Python we’re planning to use. After this step, you can install additional requirements (packages). The final step is to run our script.</p><pre> - name: Setup python<br>   uses: actions/setup-python@v2<br>   with:<br>    python-version: &#39;3.10.6&#39;<br> #Optional, you can also update pip before installing dependencies<br> - name: Install dependencies<br>   run: pip install -r requirements.txt<br> - name: Run python script<br>   run: python job.py</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TxDS7czHDMIzp1VSQL58sA.png" /></figure><p>Awesome! Our pipeline is working, and we can see results in the command line, but something is missing. As a result, we should get a file. How can I get it?</p><p>I’d like to introduce you to artifacts. Those allow you to save the results of your workflow after the job is done. Each workflow (successful or failed) can include artifacts produced during running. You can also use artifacts to share data between jobs, but it’s not needed in our case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RLBT1G6le1C--V789IssPA.png" /><figcaption>You can download your artifacts as a zip file.</figcaption></figure><p>Everything is working as expected, so our final workflow will look like this:</p><pre>---<br>name: &quot;Workflow example&quot;<br>on:<br>  schedule:<br>    - cron: &#39;*/10 * * * *&#39;<br><br>jobs:<br>  python-job:<br>    name: &quot;Python job&quot;<br>    runs-on: ubuntu-latest<br>    steps:<br>      - name: Checkout repository<br>        uses: actions/checkout@v2<br>      - name: Setup python<br>        uses: actions/setup-python@v2<br>        with:<br>          python-version: &#39;3.10.6&#39;<br>#     If you need to install extra packages<br>#     - name: Install dependencies<br>#       run: pip install -r requirements.txt<br>      - name: Run python script<br>        run: python job.py<br>      - name: Upload file as artifact<br>        uses: actions/upload-artifact@v3<br>        with:<br>          name: job-result<br>          path: file.txt</pre><h3>Conclusion</h3><p>As you can see, it is not so difficult. What is most important is that you can test it for free. GitHub allows you to run up to 2,000 minutes of actions with a free account without adding any payment information. So, what are you waiting for?</p><p>Stay tuned for more content. I hope you enjoy my other articles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d279e8519cec" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/schedule-cron-jobs-with-github-actions-d279e8519cec">Schedule Cron Jobs With GitHub Actions</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Cron jobs with Django and Kubernetes]]></title>
            <link>https://medium.com/@mateusz-jasinski/creating-cron-jobs-with-django-and-kubernetes-50f6fc26ca75?source=rss-808be72490a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/50f6fc26ca75</guid>
            <category><![CDATA[celery]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mateusz Jasiński]]></dc:creator>
            <pubDate>Thu, 10 Nov 2022 11:25:49 GMT</pubDate>
            <atom:updated>2022-11-10T11:25:49.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qTwCwGwMV8A1tAhvNcAH0w.png" /></figure><p>Most developers use Celery or RabbitMQ for handling periodic tasks in Django or general python web apps. In this article, I would like to show you, how you can use Kubernetes Cron Job to replace your current scheduler configuration.</p><h3>Celery Config</h3><p>First, I’d like to explain why I think Celery can be an overkill for some of your projects.</p><p>What do you need to start scheduling tasks with Celery?</p><ul><li>First, you’ll need to create a Celery worker. It will be running in the background all the time and consume resources even if it is not used</li><li>In order to schedule tasks, you also need to create a Celery Beater that is going to serve as your timer</li><li>The last needed is a Broker. In most cases, you will use Redis to store a queue of your tasks.</li></ul><p>As you can see, it’s necessary to create three additional services that are running non-stop but will be used only when the task pops up. If your application generates a minor amount of tasks, your Celery configuration will be idle most of the time.</p><h3>Django Commands + Kubernetes Cron Job</h3><p>In this approach, we want to replace our Celery configuration by using Kubernetes Job for the periodical task, e.g., sending daily updates, etc. This solution allows us to start containers on demand, so I will run only when needed and use resources during execution. As soon as your task is completed, Kubernetes will kill your containers, and resources will be released. Let’s jump to an example.</p><h4>Example</h4><p>For the purposes of the article, we want to create a job that will handle the deactivation of auctions if the user didn’t make any offers and the auctions are older than one week.</p><h4>Django command</h4><p>We need to start with creating a custom Django Command that will handle deactivating the actions. Having the command ready we’re able to test it as many times as we need/want to. If you need any help with creating a command check <a href="https://docs.djangoproject.com/en/4.1/howto/custom-management-commands/">https://docs.djangoproject.com/en/4.1/howto/custom-management-commands/</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b51913e018d3c16144a8860e1571facb/href">https://medium.com/media/b51913e018d3c16144a8860e1571facb/href</a></iframe><h4>Kubernetes job</h4><p>The next step is to create a Kubernetes cron job manifest. Below I’ll show you an easy example, for more reference visit <a href="https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/">https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cdbcca1de5e93ce3ad4abb9a2c9b5f56/href">https://medium.com/media/cdbcca1de5e93ce3ad4abb9a2c9b5f56/href</a></iframe><h3>Summary</h3><p>As mentioned, you can painlessly replace your easy Celery Tasks using Django Commands and Kubernetes. Of course, you first need to use Kubernetes in your project, so this solution will not apply to all of your projects, but if you have the option to use this approach, you will be satisfied with the final results.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50f6fc26ca75" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improve your demo and get more for yourself.]]></title>
            <link>https://medium.com/@mateusz-jasinski/improve-your-demo-and-get-more-for-yourself-147793d368f5?source=rss-808be72490a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/147793d368f5</guid>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[presentations]]></category>
            <category><![CDATA[education]]></category>
            <dc:creator><![CDATA[Mateusz Jasiński]]></dc:creator>
            <pubDate>Sat, 05 Nov 2022 09:57:43 GMT</pubDate>
            <atom:updated>2022-11-05T09:57:43.976Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the developer’s responsibilities is to present features and changes to clients and product owners. In this article, I would like to give you a few suggestions on how to can improve your presentations, make a good impression and build your look as an expert.</p><h3>Build a plan</h3><p>The first and most crucial step is preparing your presentation. Some people prefer to go with the flow just checking the list of done stories and showing them one by one. It’s acceptable when giving this kind of presentation to coworkers or friends. Still, you must remember that any mistake or unexpected situation will put you in an uncomfortable position.</p><h4>Prepare yourself</h4><p>Build a plan. Before the demo, go through the changes and the flow you want to show during your presentation. Afterwards, test it a few times, and try to make this process automated. It will allow you to focus more on the changes and potential questions.</p><h4>Pareto principle</h4><p>If you look back at your work before the demo, there is a huge chance that most of the time you spent on things that are not worth showing. This is exactly what Joseph Juran called the Pareto rule. In general, the principle says that 80% of the value is brought by things on which we spend only 20% of our time.</p><p>Knowing that we can select which functionalities are more valuable for the client even if we spent only a few minutes or hours on them.</p><p>Remember that the most important thing is customer satisfaction, so even if your ego says that you should talk more about some challenging items, if they don’t bring much value to your customer, just skip them.</p><h3>Make a good impression</h3><p>Psychologists have already been studying the human brain to discover the mechanism of building options for other people and products for ages. The results of their work are often used in marketing and other industries to increase sales or learn faster and better.</p><h4>Serial-position effect</h4><p>It’s a tendency to recall the first (primary effect) and last item (recency effect) of the series best. You had probably experienced this when you were a student — things that you learn at the beginning and at the end are the ones that you remember best. In the case of demo hosting it can be used to build a positive impression by starting and ending your presentation with well-working functionalities that can satisfy your client.</p><h4>Halo effect</h4><p>The halo effect (sometimes called the halo error) is the tendency for positive impressions of a person, company, brand, or product in one area to positively influence one’s opinion or feelings in other areas. Marketing also uses the halo effect of the image of movie/music stars to influence their advertising brands. The Halo effect is not sustainable, it will disappear after a few days, but still, you can use it to build a good impression. Being positive and enthusiastic can help you to survive your beginnings.</p><h3>Be an expert</h3><p>Of course, clients expect to have things done and this is our goal, but why not use it to build your position? Proving your competence and building trust can help you to get a more prominent position and promote faster.</p><h4>Talk about challenges</h4><p>We are only humans so it’s normal that our work can cause some trouble. During your presentation feel free to talk about challenges that you struggle with during your work. Try to focus on high-level problems and describe the solutions that you provided.</p><p>The majority of your audience will be impressed by your answer if you describe obstacles well because it will sound like something they will need more time to understand.</p><h4>Prepare for questions</h4><p>Depending on your listeners you need to be prepared for answering different types of questions. If your audience works in the same domain, questions can be more precise and you need to check the details of your changes to be able to answer them. If clients/product owners are not so familiar with technologies you need to be able to answer the questions in the simplest way possible, at the same time remembering that the client should not feel offended.</p><h3>Last word</h3><p>Don’t be afraid to present your work, it’s the easiest way to build your brand and expert opinion. Follow these steps and bring your presentations to the new level</p><ul><li>Prepare a plan, make notes and check everything twice</li><li>Use primary and recency effects to make a good impression</li><li>Use your knowledge and skills to build your expert image</li></ul><p>Good luck!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=147793d368f5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Clustering on maps with Elasticsearch]]></title>
            <link>https://medium.com/@mateusz-jasinski/clustering-on-maps-with-elasticsearch-897075a7d1a9?source=rss-808be72490a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/897075a7d1a9</guid>
            <category><![CDATA[geohash]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Mateusz Jasiński]]></dc:creator>
            <pubDate>Sat, 17 Sep 2022 08:06:50 GMT</pubDate>
            <atom:updated>2022-09-17T08:06:50.007Z</atom:updated>
            <content:encoded><![CDATA[<p>This article explains the process of clusterization on the map using Elasticsearch and Python. What is clusterization? Let’s imagine that we have 10 million geo-points of businesses in the United States. It’s impossible to show them all as separated pins on a map, let alone make it readable. Instead, we want to display groups with the number of businesses based on their region.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/0*opUOkajPzwTENw_e.png" /><figcaption>There are too many items🙁</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*R82jQ8Xfj2ed17S6.png" /><figcaption>Now it looks better🤩</figcaption></figure><p>Okay, we know what we want to achieve, but we must face some challenges first.</p><ul><li>How are we going to group the items?</li><li>How can one get details of items within the cluster?</li></ul><h4>Geohash</h4><p>We will use the Geohash system to group items on maps, but how does it work? 🤔<br>Let’s imagine that we are splitting the world map into 16 squares. We will mark them starting from 0 to F (Hexadecimal). Cool! We can assign objects to 16 groups, but it’s not very precise. What can we do with that, then? We can split each square into 16 squares and build hashes 00, 01, 0F … etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/623/0*i4R7rEW9_BkfYs-1.jpeg" /></figure><p>Using this approach, we can go deeper and deeper to build our hash precisely.</p><p>But how to find the best precision?</p><p>The answer is not clear-cut. Everything depends on the goal. I recommend you get your hands on the code and start experimenting. It would be best if you could check different data sets. In my case, it took a few hours to find something that was satisfying.</p><p>To build our application we gonna use Elasticsearch and Python. You don’t need to be an expert, but I’ll show you only the part of the code that refers to our functionality.</p><h4>Elasticsearch</h4><p>To build our clusters we’re gonna use Elasticsearch multi-bucket aggregation <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-geohashgrid-aggregation.html</a>.</p><p>We can generate up to 100 buckets (clusters) using the code below. Each item has a key (hash) and information about the number of elements in a selected bucket. Additionally, we’re building a centroid — the center of the bucket based on the elements’ location using nested aggregation.</p><pre>query[&#39;aggs&#39;] = {<br>    &#39;clustering&#39;: {<br>        &#39;geohash_grid&#39;: {<br>            &#39;field&#39;: &#39;location&#39;,<br>            &#39;precision&#39;: precision,<br>            &#39;size&#39;: 100<br>        },<br>        &quot;aggs&quot;: {<br>            &quot;centroid&quot;: {<br>                &quot;geo_centroid&quot;: {<br>                    &quot;field&quot;: &quot;location&quot;<br>                }<br>            },<br>        }<br>    }<br>}</pre><h4>We need more details</h4><p>So, we have lovely clusters on the map, but I cannot see what is within. Each bucket has an individual hash that we can decode for a set of geo points {’n’: 33.75, ‘s’: 28.125, ‘w’: -123.75, ‘e’: -112.5} .</p><p>Now when we have borders of our square we can use geo-bounding filtering. <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-bounding-box-query.html</a></p><pre>import libgeohash as gh<br>geo_hash_coordinates = gh.bbox(query_params_serializer.validated_data[&#39;geo_hash&#39;])<br><br>filters = {<br>    &quot;filter&quot;: {<br>        &quot;geo_bounding_box&quot;: {<br>            &quot;location&quot;: {<br>                &quot;top_left&quot;: {<br>                    &quot;lat&quot;: geo_hash_coordinates[&#39;n&#39;],<br>                    &quot;lon&quot;: geo_hash_coordinates[&#39;w&#39;],<br>                },<br>                &quot;bottom_right&quot;: {<br>                    &quot;lat&quot;: geo_hash_coordinates[&#39;s&#39;],<br>                    &quot;lon&quot;: geo_hash_coordinates[&#39;e&#39;],<br>                }<br>            }<br>        }<br>    }<br>}</pre><p>As a result of this query, we’ll get all items inside the selected cluster. Cool!</p><h4>The End</h4><p>Now you can experiment with your map by adding new functionalities. For example, you can try to add auto search on zoom or group elements inside the cluster by type.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=897075a7d1a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using MinIO with Django for local development]]></title>
            <link>https://medium.com/@mateusz-jasinski/using-minio-with-django-for-local-development-80bda22927?source=rss-808be72490a7------2</link>
            <guid isPermaLink="false">https://medium.com/p/80bda22927</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[minio]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Mateusz Jasiński]]></dc:creator>
            <pubDate>Fri, 13 May 2022 07:32:55 GMT</pubDate>
            <atom:updated>2022-05-13T07:32:55.488Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5i-i1tdQLwNtnN2XfmI5TQ.png" /></figure><p>Oftentimes we are affected by using different configurations for local and cloud environments as developers. This article aims to give you an easy way to simulate an AWS S3 bucket in your local environment and allow you to reuse your configuration for cloud environments.</p><p>For this article&#39;s purposes, I created a simple blog application that will store statics and uploaded files to the S3 bucket.</p><h3>What is MinIO?</h3><p>MinIO is a service that provides S3 object storage. MinIO allows us to create multiple buckets, upload files using AWS API and browse them using a friendly-looking dashboard.</p><p>From the developers&#39; perspective, we can avoid creating multiple configurations for different environments and make application deployment much smoother — we can test S3 communication and features during development.</p><p>For more details, head over to <a href="https://min.io/">https://min.io/</a>. Below are a few screenshots from the MinIO dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CS0tkXtbIvvfpYhgJNd6dQ.png" /><figcaption>List of buckets in the console dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ALgxXAY4fbTHC8suYIahmA.png" /><figcaption>Bucket file browser</figcaption></figure><h3>Docker configuration</h3><p>To use MinIO we need to configure two additional containers in our docker-compose:</p><ul><li><strong>minio</strong> — the main container that will simulate your S3 service</li><li><strong>minio-client </strong>— the additional container that will create your buckets automatically</li></ul><pre>volumes:<br>  minio-data:</pre><pre>minio:<br>  image: minio/minio:latest<br>  ports:<br>  - 9000:9000<br>  - 9001:9001<br>  environment:<br>    MINIO_ACCESS_KEY: minio<br>    MINIO_SECRET_KEY: minio123<br>  command: server /data --console-address &quot;:9001&quot;<br>  volumes:<br>  - minio-data:/data</pre><pre>minio-client:<br>  image: minio/mc:latest<br>  entrypoint: &gt;<br>    /bin/sh -c &quot;<br>    /usr/bin/mc config host rm expo;<br>    /usr/bin/mc config host add --quiet --api s3v4 local http://minio:9000 minio minio123;<br>    /usr/bin/mc rb --force local/&lt;your-bucket-name&gt;/;<br>    /usr/bin/mc mb --quiet local/&lt;your-bucket-name&gt;/;<br>    /usr/bin/mc policy set public local/&lt;your-bucket-name&gt;;<br>    &quot;<br>  depends_on:<br>    - minio</pre><p>The above configuration is prepared to create a single server running on port 9000. The client will automatically create a single bucket.</p><p>Said configuration uses volumes to keep your objects persistent. If you want to clear your bucket after stopping your containers, remove volumes from minio container configuration.</p><h3>Django configuration</h3><h4>Custom storage</h4><p>Default S3Boto Storage requires some additional changes to work with our setup. Since we’re working with Docker inside the Docker network, the MinIO container is accessible on minio:9000, but outside of the network, we can access MinIO on localhost:9000. To handle returning the proper paths through to the browsers we need to set up a custom domain for our storage.</p><pre>class StaticS3Boto3Storage(S3Boto3Storage):<br>    location = settings.STATICFILES_LOCATION<br><br>    def __init__(self, *args, **kwargs):<br>        if settings.MINIO_ACCESS_URL:<br>            self.secure_urls = False<br>            self.custom_domain = settings.MINIO_ACCESS_URL<br>        super(StaticS3Boto3Storage, self).__init__(*args, **kwargs)<br><br><br>class S3MediaStorage(S3Boto3Storage):<br>    def __init__(self, *args, **kwargs):<br>        if settings.MINIO_ACCESS_URL:<br>            self.secure_urls = False<br>            self.custom_domain = settings.MINIO_ACCESS_URL<br>        super(S3MediaStorage, self).__init__(*args, **kwargs)</pre><h4>Settings file</h4><p>In Django, we need to use a default configuration for using S3. Remember to use custom storage from the previous step.</p><p>settings.py</p><pre>STATIC_URL = &#39;/static/&#39;<br>STATICFILES_LOCATION = &#39;static&#39;<br>STATICFILES_STORAGE = &quot;blogs.storage.StaticS3Boto3Storage&quot;<br><br>MEDIA_URL = &#39;/media/&#39;<br>DEFAULT_FILE_STORAGE = &quot;blogs.storage.S3MediaStorage&quot;<br><br>AWS_ACCESS_KEY_ID = os.getenv(&quot;AWS_ACCESS_KEY_ID&quot;)<br>AWS_SECRET_ACCESS_KEY = os.getenv(&quot;AWS_SECRET_ACCESS_KEY&quot;)<br>AWS_STORAGE_BUCKET_NAME = os.getenv(&quot;AWS_STORAGE_BUCKET_NAME&quot;)<br><br>AWS_S3_ENDPOINT_URL = os.getenv(&quot;AWS_S3_URL&quot;)<br>MINIO_ACCESS_URL = os.getenv(&quot;MINIO_ACCESS_URL&quot;)</pre><p>.env</p><pre>AWS_ACCESS_KEY_ID=minio<br>AWS_SECRET_ACCESS_KEY=minio123<br>AWS_STORAGE_BUCKET_NAME=&lt;your-bucket-name&gt;<br>AWS_S3_URL=http://minio:9000<br>MINIO_ACCESS_URL=localhost:9000/&lt;your-bucket-name&gt;</pre><h3>Summary</h3><p>I hope that this article will make your life easier and allow you to simplify the process of deploying your application. <br>Feel free to check out the example project on Github <a href="https://github.com/mateuszjasinski/Django-MinIO">https://github.com/mateuszjasinski/Django-MinIO</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80bda22927" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>