<?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 Moiz Ali on Medium]]></title>
        <description><![CDATA[Stories by Moiz Ali on Medium]]></description>
        <link>https://medium.com/@moiz1524?source=rss-7ca522b4d72d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6o_mjpjL0R6wWCQeW8B5gw.png</url>
            <title>Stories by Moiz Ali on Medium</title>
            <link>https://medium.com/@moiz1524?source=rss-7ca522b4d72d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 09:11:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@moiz1524/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[Revolutionizing AI: Highlights from OpenAI’s GPT-4 Developer Livestream]]></title>
            <link>https://moiz1524.medium.com/revolutionizing-ai-highlights-from-openais-gpt-4-developer-livestream-e238b2390590?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/e238b2390590</guid>
            <category><![CDATA[gpt-4]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[diversity]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Thu, 23 Mar 2023 18:38:00 GMT</pubDate>
            <atom:updated>2023-03-23T18:38:00.656Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s dive into the cool insights and capabilities that GPT-4 has. An era of productivity and enabling people to become superhuman beings</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vE1P4gw5cdQkQt8KvrxboA.jpeg" /><figcaption>Photo from Unsplash by D koi</figcaption></figure><h3>Flexibility to Content</h3><p>The ability to receive and act upon feedback is an essential component of any learning system, and OpenAI has demonstrated this ability in GPT-4 by showcasing its ability to replace words starting with specific letters in an article and generate new ideas through article comparison.</p><p>During the demonstration, GPT-4 was shown to be able to take feedback from users and use it to improve its performance. For example, if a user wanted to replace certain words in an article, GPT-4 could easily identify the words and replace them with more appropriate alternatives. Given the point, it&#39;s more user-centric.</p><h3>Programming Assistant</h3><p><em>As a programming assistant, GPT-4 shows its ability to turn vague requirements into a functioning Discord chatbot by following pseudocode and real-time implementation.</em></p><p>GPT-4 is poised to be a game-changing language model that can revolutionize the world of programming. One of its most impressive features, showcased, is its ability to act as a programming assistant. By following pseudocode and real-time implementation, GPT-4 turned vague requirements into a functioning Discord chatbot, demonstrating its remarkable problem-solving capabilities.</p><p>As such, GPT-4 represents a major step forward in the field of artificial intelligence, and its potential applications are limitless.</p><h3>Image Analysis</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*By3CZ3RDQOtaX0k_EzjUaQ.png" /></figure><p>OpenAI’s recent showcase of GPT-4’s visual understanding highlights the model’s remarkable ability to interpret and analyze images. During the demonstration, GPT-4 was presented with an image and asked to describe the details and underlying factors of the scene</p><p>Overall, GPT-4’s visual understanding is a significant advancement in the field of artificial intelligence, with the potential to revolutionize how we interact with images and visual data. Its ability to analyze and interpret images could have a profound impact on many aspects of our lives, and we can expect to see many exciting new applications emerge as this technology continues to evolve.</p><h3>Prototype to Minimal Web App</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jjQLKdyn9IurTuMuQ3uyMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tOYUjitdj0Du44t9GZaoeg.png" /></figure><p>This is really insane! Blew me away!</p><p>During the demonstration, a hand-drawn prototype of a simple Jokes website was brought to life with HTML, CSS, and JavaScript, and validated on CodePen, leaving no room for doubt.</p><p>This amazing feat highlights the remarkable capabilities of GPT-4, which can now help web developers to streamline their workflow and reduce the time and resources required to create functional websites. With the ability to turn hand-drawn sketches into functional websites, GPT-4 has the potential to revolutionize how we design and develop web applications, making it easier and more accessible for developers of all skill levels.</p><p>This feature also has significant implications for the field of user experience (UX) design, where it can help designers to rapidly prototype and test new ideas, allowing for more iterative and responsive design processes. Moreover, the ability to validate the code on CodePen demonstrates GPT-4’s commitment to producing high-quality, functional components, ensuring that the resulting website is both aesthetically pleasing and fully functional.</p><h3>A Friendly Tax Assistant</h3><p>GPT-4 to streamline complex financial calculations and make them more accessible to a wider audience. With the ability to handle complex tax calculations with ease, GPT-4 could have significant implications for a wide range of industries, including finance, accounting, and even personal financial management.</p><p>For example, financial advisors and tax professionals could use GPT-4 to quickly and accurately calculate taxes for their clients, providing them with valuable insights and recommendations. Similarly, individuals could use GPT-4 as a personal financial tool, allowing them to calculate their taxes and make more informed decisions about their finances.</p><blockquote><em>But one thing to keep in mind always:</em></blockquote><blockquote><strong>Never trust AIs and untrusted code or solutions</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*wIAFBFxzjI4v7Sk6WwAZrQ.gif" /></figure><blockquote>You can watch the recorded demo here<br><a href="https://www.youtube.com/watch?v=outcGtbnMuQ&amp;ab_channel=OpenAI">https://www.youtube.com/watch?v=outcGtbnMuQ&amp;ab_channel=OpenAI</a></blockquote><p>What are your thoughts on these exciting developments? Let me know in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e238b2390590" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[String Manipulation by a Rubyist]]></title>
            <link>https://moiz1524.medium.com/string-manipulation-by-a-rubyist-8bef735df319?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/8bef735df319</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Wed, 02 Nov 2022 06:00:41 GMT</pubDate>
            <atom:updated>2022-11-02T06:00:41.962Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7QOF4QTWrv_YQ0Uv7DJOaQ.jpeg" /><figcaption>Photo by Sora Shimazaki</figcaption></figure><p>While writing database queries or getting our desired results for some native features, we have to cope with string manipulation. To get most out of the situation here are 3 tips that will boost your daily development drill</p><h3>Character Index</h3><blockquote>Check position of a character in string</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*sjnYBOhLhZNqCvRmKa2blg.png" /></figure><h3>Substrings</h3><blockquote>Extract sub-strings from your string</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*DOJ2dpig_oxuBeOs8oBJFA.png" /></figure><h3>Concatenation</h3><blockquote>3 ways to concatenate strings on the go</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*YhN6ofWFSDJrcDEGYd71pA.png" /></figure><p>Though these are some quick tips to utilize but once you start building on it, you’ll get the taste. Let me know about your thoughts inside comments</p><p>Make sure to Love and follow <a href="https://medium.com/u/7ca522b4d72d">Moiz Ali</a> for more content bites</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8bef735df319" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to initiate Refactoring?]]></title>
            <link>https://moiz1524.medium.com/how-to-initiate-refactoring-42c63c9c9b2a?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/42c63c9c9b2a</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Tue, 24 May 2022 19:33:34 GMT</pubDate>
            <atom:updated>2022-05-24T19:33:34.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Aq_K9xeBLdf9ZdXrDC4XVw.jpeg" /><figcaption>Just Refactor stuff</figcaption></figure><h3>Introduction</h3><p>4 years later, when I started programming I used to write code and just care about the results mainly <strong>It&#39;s working how it’s intended to be stance</strong>. But as time passed I realized that whenever I want to add new functionality within, it becomes nearly impossible for me.</p><p>However Rails defaults enable us to stick with OOP principles and good practices, but as the codebase grows you have to be a champion to hold up things properly!</p><p>So I have to compromise and search for escape routes. My bad. Being proactive and habit of thinking to extend the genre is what I’m missing. By the time I learned from different experiences, features, other people’s code, and mainly from Google (How can I miss this!)</p><h3>Why do we need Refactoring?</h3><blockquote>Its an Art.</blockquote><p>As I described above that it becomes hard to extend features and add new stuff but mainly you lose control of your codebase. You become a slave of an unknown compelling force established within your app. Produced by your bad code and mismanagement.</p><p>Just think about big tech giants and social media apps, and how code is being managed and scaled to reach a bigger audience. You’ll get the answer for sure!</p><h3>Jumping into the Playground</h3><p>Today I’m going to share my initial 5 steps approach to refactor a bad piece of code. It can be a starting point for those who don’t have an idea about <em>Where to start?</em>.</p><p>Let&#39;s start this!</p><p>As an example, we’ll discuss this controller action in Rails which has code smells. It enables the admin to assign user a specific subscription membership group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b30L2S9RHAxlOv1cIket2A.png" /><figcaption>Bad piece</figcaption></figure><h3>Dry run each line of code, understand meanings?</h3><blockquote>I have added comments against each line. See</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0GB0ZCyax8BQn-h7XrwGgA.png" /><figcaption>Code with comments</figcaption></figure><h3>Identify responsibilities with Divide &amp; Conquer rule</h3><ul><li>Authorization check for user’s role</li><li>Query user from db and figure out user old membership and new group for further addition</li><li>Update user with new attrs</li><li>Send membership email</li><li>Perform subscription expiry job</li><li>Handle failure case of #update</li><li>Handle failure case of authorization</li></ul><h3>Extract methods by Single Responsibility Principle</h3><blockquote>The single-responsibility principle (SRP) is a computer-programming principle that states that every module, class or function in a computer program should have responsibility over a single part of that program’s functionality, and it should encapsulate that part.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U76Oj4DCh9uWK8-jIyCfxw.png" /><figcaption>Single Responsibility Principle</figcaption></figure><p>In accordance with responsibilities obtained in Step 2. I’ve added separate methods. Each doing its own thing.</p><p>check_user_role! depicts authorization check, continue only if user is an <em>admin</em> otherwise redirect. The ! at the end describes that it&#39;s going to follow up immediately</p><p>grab_user_and_associated_group find user, get membership names, group, and expiry date. Here I switched local variables with instance variables to manipulate them among micro-actions. Provided the fact we can also use them inside views.</p><p>user_params prepares hash to pass inside update call</p><p>update_user updates user and call forward_emails_then_set_job. It has an else case to describe if something goes wrong.</p><p>forward_email_then_set_job calls mailer and job classes respectively. For sake of simplicity, I&#39;m skipping the discussion for them!</p><p>Notice about usage of redirect_back in this context, instead of using redirect_to with request.referrer You can find it <a href="https://apidock.com/rails/v5.0.0.1/ActionController/Redirecting/redirect_back">here</a></p><h3>Filter out performance gaps and fill them</h3><p>If you notice down, there is a performance gap inside forward_email_then_set_job. The problem is deliver_now and perform_now. When we have a queue backend like Sidekiq in place, it&#39;s essential to configure queues that can hold up jobs to perform one by one. deliver_now halts this priority queue and we can face the situations where jobs received at same time instant would be dropped, thus creating load on queue backend.</p><p>For the solution, I’ve used deliver_later and perform_later which takes care of priority queue. Jobs are processed one by one, providing minimal drop chances and optimized queue backend</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wu3PfU3ty3PXzz8rSfY5wA.png" /><figcaption>Performance gaps</figcaption></figure><h3>Put all pieces and ask yourself Is it improved?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*47g2LQxfYHXzB45JkPa5iA.png" /><figcaption>Put all pieces</figcaption></figure><p>The answer can be Yes or No. But the new version would be better than the worst. A stable form!</p><p>Refactoring is costly if not done from the start. It&#39;s a habit towards self improvisation and a better understanding of code.</p><p>I haven’t come up with a perfect version. There are certain improvements we can do here. I would like to hear from you guys. Do Share and Like if you find it useful ..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=42c63c9c9b2a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you’re not Productive?]]></title>
            <link>https://moiz1524.medium.com/why-youre-not-productive-2d77a9f5ed6a?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d77a9f5ed6a</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[beginners-mind]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Sat, 14 May 2022 19:22:21 GMT</pubDate>
            <atom:updated>2022-05-14T19:22:21.151Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QmDs2Y5UCA_plCs3mItvCw.jpeg" /></figure><h3>Introduction</h3><p>As my software engineering journey progressed, I found mistakes and shortcomings that slowed and lowered my productivity bar. Years before, it seemed no problem until I put myself through a <strong>Self Assessment process</strong>!</p><blockquote><em>Today I would like to share those common Slippery Patches so you can get a feel and prepare yourself against them on the first hand</em></blockquote><h3>False Initialization (Lose the moment)</h3><p>Being a human, we respond to everything that comes in for us. Either its a social interaction or work specific.</p><p>The region of time-lapse must be ideal. As a developer, if a task is assigned to you, there should be a plan to implement and get along to the finish line.</p><p>Time can never be infinite, so if you initiate stuff at the right time the possibility ratio of success broadens itself. You definitely get a chance to submit work at time. Using 8 hrs to complete work daily is an Art. Undoubtedly, you’ll learn this by time and experience.</p><p>If you are unable to do so, time is near when you get stuck in Late night spending for work and get your ass safe! This directly cast a negative impact on your personal life. Either your family, friends, or your own space.</p><h3>Lack of Prioritization</h3><p>Active and Passive are two natures that live inside developers. The person with first always knows what’s ahead, he/she plans and sets up their schedulers while others just procrastinate.</p><p>This practice leads to No Goal Achievement or Low Progress Levels. Also a common problem for those who are struggling to find a better fit between Work and Life.</p><h3>Useless Internet Surfing</h3><p>Developers love to connect with the global world and it&#39;s really awesome. But surf wisely not blindly. If you’re used to scrolling feed of your favorite app, many times in an hour. Chances are there to spoil your productivity bar. By surfing wisely I mean to surf at a specific time to chill and relieve stress. Watch podcasts, read books or watch a movie when you feel tired or frustrated!</p><p>So that&#39;s all for now!!</p><p><strong>Have you faced these issues</strong>? or <strong>struggling to find a better fit</strong>. Let me know inside comments so we can tie threads and learn together!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d77a9f5ed6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Magical Bulk Insertion in Rails 6]]></title>
            <link>https://moiz1524.medium.com/magical-bulk-insertion-in-rails-6-2a9fd078fd23?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2a9fd078fd23</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[rails-6]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Tue, 10 May 2022 04:13:33 GMT</pubDate>
            <atom:updated>2022-05-10T04:13:33.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vU_GXZ6TnYdNuU4NgV7_nw.jpeg" /></figure><h3>Introduction</h3><p>In modern apps, we mostly have a requirement that allows users to perform bulk actions. Like insertion of records is the one.</p><p>On the first take, you would come up with this version</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UuxiBNphBh10hnOH407fMg.png" /></figure><h3>Problematic Region</h3><p>So what is the hack? The above code is a classic situation of multiple SQL insert calls, each for a movie creation. This yields slow performance, and eventually bad code!</p><h3>Workaround in Oldies</h3><p>If you’re running on Rails 5 and older versions, you might face the situation where writing raw customized SQL or using gems like <a href="https://github.com/zdennis/activerecord-import">activerecord-import</a> is the final option you are left with.</p><h3>Magic of Rails 6</h3><p>But once you’re up and running here, there is a method for you, built out of the box namely <strong>insert_all</strong></p><p>Pick your wand and lets get started!</p><p>*We are discussing a Car model here*</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*77PmORiVJKWNLGAWbox1Yw.png" /></figure><p>Documentation here: <a href="https://apidock.com/rails/v6.0.0/ActiveRecord/Persistence/ClassMethods/insert_all">https://apidock.com/rails/v6.0.0/ActiveRecord/Persistence/ClassMethods/insert_all</a></p><p>Do you find it useful? Let me know inside comments!<br>Follow me for more interesting snacks. <br>Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2a9fd078fd23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Surprising Ways to use Rails Console]]></title>
            <link>https://moiz1524.medium.com/5-surprising-ways-to-use-rails-console-fa7880807979?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/fa7880807979</guid>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[tricks]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Sat, 07 May 2022 20:31:06 GMT</pubDate>
            <atom:updated>2022-05-27T09:00:36.360Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ifYb3jjDhDWXvfDS5zO5AQ.jpeg" /></figure><p>While running on Rails, there’s been hardly a day when you don’t pull up the rails console. Having basic mode and usage is fine but to spice up things a little bit I would like to share some tricks in this regard.</p><h3>View Tables</h3><p>Just run this command and get a glimpse of database tables!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QVYLNzcMXs_xQkTFsg9OwA.png" /><figcaption>Tables on the Fly</figcaption></figure><h3>Sandbox Mode</h3><p>You can enable sandbox mode, so that commands are rolled back once you exit. No fear to manipulate real objects but still it&#39;s not recommended to use in a production environment</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_qaW6V4vQr2yyjYOZXtZw.png" /><figcaption>Sandbox Mode</figcaption></figure><h3>Make HTTP Requests</h3><p>Being lazy to hit a route through chrome or any other browser, just play with <strong>app</strong> object’s methods!</p><blockquote><a href="https://apidock.com/rails/Object/app"><strong><em>app</em></strong></a><strong><em> </em></strong>is globally available when you are accessing rails console of your application</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bNNQy0UdVSBn_14_S7jt3w.png" /><figcaption>Make HTTP Requests</figcaption></figure><h3>Locate Method Source</h3><p>Its a kind of search feature that a code editor also offers, but helpful one for the Rubyists</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HZchMuUJQApSebMZqtcL-w.png" /><figcaption>Locate Method Source</figcaption></figure><h3>Block Returned Output</h3><p>If you’re annoyed by the return value of iterators and other structures, this will let you cool down!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6iLMd8z_tSaXj6BmcxKcaQ.png" /><figcaption>Block Returned Output</figcaption></figure><p>Does it worth time-saving? Let me know inside comments.<br>Make sure to Love and follow <a href="https://medium.com/u/7ca522b4d72d">Moiz Ali</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fa7880807979" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should write good commit messages?]]></title>
            <link>https://moiz1524.medium.com/why-you-should-write-good-commit-messages-1870dcb18366?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1870dcb18366</guid>
            <category><![CDATA[git]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Thu, 14 Apr 2022 00:14:45 GMT</pubDate>
            <atom:updated>2022-04-14T00:14:45.998Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V1TvkkVD8rMTiDWsctz55w.jpeg" /><figcaption>Commit messages on Fly</figcaption></figure><p>I read a lot of posts that describe <em>how to write awesome commit messages?. </em>This is an undeniable fact that every developer needs to do it for some or more reasons. It’s a habit, hard to adopt but once gained, it returns a fruitful response. On professional grounds, I have sensed my top 3 reasons for this:</p><h3><strong>Codebase Versioning</strong></h3><p>Your commit resolves to a particular version of the codebase. It can include a bug fix or a new feature or an enhancement. All this means that a change has been introduced. To identify this, there must be a meaningful one-liner sentence without digging into details. Viewing and reading code snippets within a bunch of files is not cool at first! Think about the scenario when you are chasing a buggy commit to extract out.</p><h3>Back &amp; Forth Tracking</h3><p>When a team collaborates on a project, they have assigned their specific branches. One’s scope of work will decide how many features are required? Lines of code and actions they need to integrate? During work if a bad commit is introduced and being pushed to the stack by upcoming ones, it becomes hard to trace the buggy part if you don’t have a relevant trail commit message. Always Remember! Healthy and appropriate commit history for each iteration provide a backtrace, resolution in relevance to bug!</p><h3>Seamless PR reviews</h3><p>PR helps to understand the state in which code has been built, changes integration and avoids code smells. PR Review is a challenging task. You have to analyze code and report smells when they exist. Having a low discouraged commit history results in poor state lookup for a module or piece of code. As PRs are a way of getting response</p><p>Hungry to learn about writing commit messages? Check this <a href="https://www.freecodecamp.org/news/how-to-write-better-git-commit-messages/">link</a> from freeCodeCamp</p><p>Happy committing !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1870dcb18366" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Deletion Request Callback, Rails]]></title>
            <link>https://moiz1524.medium.com/data-deletion-request-callback-rails-424319bbb144?source=rss-7ca522b4d72d------2</link>
            <guid isPermaLink="false">https://medium.com/p/424319bbb144</guid>
            <category><![CDATA[callback]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[deletion]]></category>
            <dc:creator><![CDATA[Moiz Ali]]></dc:creator>
            <pubDate>Wed, 10 Feb 2021 21:35:26 GMT</pubDate>
            <atom:updated>2021-02-10T21:38:58.582Z</atom:updated>
            <content:encoded><![CDATA[<h3>Data Deletion Request Callback, Ruby on Rails</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wVXSkvoHNoUIRnKzmRu4zg.jpeg" /></figure><h3>Introduction:</h3><p>In order to provide users with more control over data and to protect data privacy norms, Facebook gives the option to remove all data consumed by the apps and integrations. A common use case scenario is When a user authenticates with Facebook to use the application’s services, his profile details are stored by the app. User can send a request to your app to delete his Facebook consumed data afterwards.</p><p><a href="https://developers.facebook.com/docs/development/create-an-app/app-dashboard/data-deletion-callback/">https://developers.facebook.com/docs/development/create-an-app/app-dashboard/data-deletion-callback/</a></p><p>In this post, we’ll implement this feature in a Rails way</p><h3>Why is it necessary?</h3><p>As a developer, we need to implement a Data Deletion Request callback URL to get our app passed for Facebook compliance when a user request to delete his/her data. This is mandatory as per new data privacy policy, GDPR. Also, we can’t submit our app for Review and switch to Live mode without implementing it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/819/1*5owiv8PCyQODAkEiBNbl5w.png" /></figure><h3>Implement the Callback URL:</h3><p>We have to make a POST web API endpoint on our server, where we’ll receive requests from Facebook. Our endpoint must be <strong>HTTPS</strong> enabled and preserve the functionality to parse signed request token sent by Facebook and take further actions to delete user’s data.</p><h3>Actual Code in Rails:</h3><pre>def facebook_user_deletion<br>  signed_request = params[&#39;signed_request&#39;]<br>  data = parse_fb_signed_request(signed_request)</pre><pre>  # Do data deletion stuff then<br>  user = User.find_by(uid: data[&#39;user_id&#39;])<br>  user.destroy</pre><pre>  # Return tracking url and code to Facebook<br>  data = { url: &quot;#{ENV[&#39;APP_HOST_URL&#39;]}/deletion_status?id=del_#           {user.id}&quot;, confirmation_code: &quot;del_#{user.id}&quot; }</pre><pre>  respond_to do |format|<br>    format.json { render :json =&gt; data }<br>  end<br>end</pre><pre>def parse_fb_signed_request(signed_request)<br>  encoded_sig, payload = signed_request.split(&#39;.&#39;, 2)<br>  secret = ENV[&#39;FACEBOOK_SECRET_ID&#39;]<br><br>  # Decode the data<br>  decoded_sig = Base64.urlsafe_decode64(encoded_sig)<br>  data = JSON.load(Base64.urlsafe_decode64(payload))<br><br>  # Create the HMAC signature<br>  expected_sig = OpenSSL::HMAC.digest(&quot;SHA256&quot;, secret, payload)<br><br>  if decoded_sig != expected_sig<br>    puts &#39;Bad Signed JSON signature!&#39;<br>    return nil<br>  end<br>    data<br>  end<br>end</pre><h3>Explanation:</h3><p>Our facebook_user_deletion method is the endpoint where the request is received. Firstly we are getting signed_request token from the params hash and passing it to our parse_fb_signed_request method as a parameter which will parse it and return the user&#39;s data JSON object like this:</p><pre>{<br>   &quot;algorithm&quot;: &quot;HMAC-SHA256&quot;,<br>   &quot;expires&quot;: 1291840400,<br>   &quot;issued_at&quot;: 1291836800,<br>   &quot;user_id&quot;: &quot;218471&quot;<br>}</pre><p>In this object user_id is our relevant field which we are using to find the user and destroy it.</p><p>After that, we are returning a JSON response object to Facebook, which has url and confirmation code key-value pairs. Basically, this URL exists on our server in the form of a webpage where the user can check status of his request by using his own confirmation code.</p><blockquote>I am using some interpolation inside values to dynamically inject user ids. Also ENV[‘APP_HOST_URL’] is an environment variable which holds my app’s default host url.</blockquote><p>In parse_fb_signed_request method we split the token into two parts with reference to dot(.) to obtain encoded signature and payload.<br>Then we get the app&#39;s Facebook secret id which will be used to construct the expected signature</p><blockquote>You can learn more about Base64 and JSON.load methods here:</blockquote><blockquote><a href="https://ruby-doc.org/stdlib-2.6.3/libdoc/base64/rdoc/Base64.html"><em>Base64</em></a><em><br></em><a href="https://apidock.com/ruby/JSON/load"><em>JSON.load</em></a></blockquote><p>After that, we are creating an HMAC signature using SHA256 algorithm, app’s secret and payload object. Finally, an If conditional block confirms the signature by comparing the decoded and newly created signature, thus returning nil object when block fails otherwise it returns data</p><h3>Add API endpoint as Callback in Facebook Project App:</h3><p>Go to <a href="https://developers.facebook.com/apps/">App Dashboard</a> &gt; Products &gt; Facebook Login &gt; Settings &gt; Data Deletion Requests</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/813/1*e-LACIPyKhWJGTg0HayCGA.png" /></figure><p>Always Love Coding !!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=424319bbb144" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>