<?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 Amir on Medium]]></title>
        <description><![CDATA[Stories by Amir on Medium]]></description>
        <link>https://medium.com/@azolf?source=rss-c8d0db910a7a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*IsML60BK0IP3GxRnyYeEHg@2x.jpeg</url>
            <title>Stories by Amir on Medium</title>
            <link>https://medium.com/@azolf?source=rss-c8d0db910a7a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 01:22:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@azolf/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[AI Replacing Me? Please Do!]]></title>
            <link>https://azolf.medium.com/ai-replacing-me-please-do-e353ac6a4bc1?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/e353ac6a4bc1</guid>
            <category><![CDATA[software-enginnering]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Sat, 26 Sep 2026 18:49:10 GMT</pubDate>
            <atom:updated>2026-09-26T18:49:10.414Z</atom:updated>
            <content:encoded><![CDATA[<p>Is this article just more AI slop? <strong>Maybe!</strong> It’s more of a heartfelt reflection, corrected and polished with AI.</p><figure><img alt="Engineer holds glowing threads linking a teal system map while cyan AI light traces type on a keyboard below." src="https://cdn-images-1.medium.com/max/1024/1*Je2mQjILKmZ1RDVbuQsyTw.png" /></figure><p>For a couple of years now, one question has been everywhere: what will happen with AI? How will it affect our day-to-day work? In software engineering especially, AI is taking over work that people used to do. Does that worry me? Absolutely not!</p><h3>AI Is Already Better at Writing Code</h3><p>I’ve joked that for years, engineers built software, frameworks, and new programming languages, and attached piles of documentation to them, mostly because we didn’t want to talk to each other and preferred to just point to the docs!</p><p>Now AI reads those docs and understands them better than we do, because it can see the bigger picture. It writes in a couple of minutes code that took us weeks to develop.</p><p>There are plenty of questions about the quality of that code and whether you can trust it, and it has turned into a rivalry between software engineers and everyone else.</p><p>I believe AI is much better than me at writing code. It’s faster, more accurate, and more readable.</p><h3>Where Humans Still Win</h3><p>I’m much better than AI (for now, at least) at critical thinking, spotting common mistakes, and finding ways to break things. I can attach things together and build something new! I have a gut feeling for things that doesn’t seem to be successfull but they will be.</p><ul><li><strong>Taste and judgment.</strong> Knowing when something is good enough to ship, what to cut, and when a technically correct solution is the wrong one. AI gives you options, and you pick the one that’s right for the situation.</li><li><strong>Context AI doesn’t have.</strong> Company politics, what a customer said in a hallway, why a past decision was made, what burned the team last year. None of that is in the prompt unless you put it there.</li><li><strong>Asking the right question.</strong> AI answers the question it’s given, but humans decide which problem is worth solving. A perfect solution to the wrong problem has no value.</li><li><strong>Knowing what not to build.</strong> Saying no to features, avoiding complexity, and deleting code. AI tends to add; engineers need to subtract.</li><li><strong>Owning the risk.</strong> Deciding under uncertainty with incomplete data, and living with the result.</li></ul><h3>Coding Skill Is Being Commoditized</h3><p>If you’re a software engineer, or you want to enter this industry, you should know that writing code or being an expert in a specific programming language or framework is worth very little now, unless you’re exceptionally good, and even then it will only pay off in specific use cases. Let’s face it: we’re not all exceptionally good.</p><h3>From Developer to Engineer</h3><p>Be an engineer! Thanks to AI, the time-consuming part of building a valuable new product has been removed or drastically reduced. Use your engineering mindset to build new products. The era of being just a developer is over. You need to see patterns, understand your customers, and create new value.</p><p>None of today’s big tech companies are valued for their codebase. They’re worth the value they build and deliver to their end users.</p><h3>Don’t Blindfold Yourself</h3><p>Should we just blindfold ourselves and let AI write software? Absolutely not! Building a technology product involves many steps and layers, with countless details and invisible threads holding the product software together. AI is reducing the effort needed to build the pieces, but connecting them is still our job. An LLM doesn’t understand what value means. It can’t create new value (at least not yet), and it can’t understand what will make you happy unless you tell it.</p><h3>Accountability</h3><p>For decades, good engineers have been the ones who take responsibility and accountability. Own the piece in your hands, whether it’s a single script, a whole codebase, or an entire product.</p><p>This doesn’t mean being afraid to take risks. It means that if you take a risk and it doesn’t work out, you have a plan, act on it, and fix the problem. Even if you let AI dig into the details and suggest a fix, make sure you understand what’s happening and own the result.</p><p>A simple rule of thumb: never merge code you couldn’t explain in a code review.</p><h3>Raise the Bar</h3><p>Accept it, move on, raise the bar for yourself, and stop thinking of your job as writing code behind a keyboard. Change has been constant in the tech industry since day one, and it will stay that way.</p><p><strong><em>Be creative and stay curious</em></strong>. Let AI take the keyboard; the thinking is yours, and nobody can replace the engineer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e353ac6a4bc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Technitium DNS Server, Setup And Maintain Records Using Ansible]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/technitium-dns-server-setup-and-maintain-records-using-ansible-ed88ba911743?source=rss-c8d0db910a7a------2"><img src="https://cdn-images-1.medium.com/max/729/1*A2YOKTVUlG9_ZoKc0O7vFw.png" width="729"></a></p><p class="medium-feed-snippet">Technitium DNS Server is an open source authoritative as well as recursive DNS server that can be used for self hosting a DNS server for&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/codex/technitium-dns-server-setup-and-maintain-records-using-ansible-ed88ba911743?source=rss-c8d0db910a7a------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/technitium-dns-server-setup-and-maintain-records-using-ansible-ed88ba911743?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed88ba911743</guid>
            <category><![CDATA[ansible]]></category>
            <category><![CDATA[technitium]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Fri, 28 Jul 2023 16:05:01 GMT</pubDate>
            <atom:updated>2024-07-04T11:50:01.474Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Transforming Your Bootstrap Tech Team Into An Efficient Organization]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://faun.pub/transforming-your-bootstrap-tech-team-into-an-efficient-organization-6d50c1cf0532?source=rss-c8d0db910a7a------2"><img src="https://cdn-images-1.medium.com/max/1900/1*V6tujCY7AyAEWLhl2t3g9Q.png" width="1900"></a></p><p class="medium-feed-snippet">let&#x2019;s delve into the challenge of transforming a tech bootstrap team into a highly efficient and effective organization&#xA0;&#x2026;</p><p class="medium-feed-link"><a href="https://faun.pub/transforming-your-bootstrap-tech-team-into-an-efficient-organization-6d50c1cf0532?source=rss-c8d0db910a7a------2">Continue reading on FAUN.dev()  »</a></p></div>]]></description>
            <link>https://faun.pub/transforming-your-bootstrap-tech-team-into-an-efficient-organization-6d50c1cf0532?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d50c1cf0532</guid>
            <category><![CDATA[management]]></category>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[agile]]></category>
            <category><![CDATA[tech-leadership]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Wed, 24 May 2023 07:47:24 GMT</pubDate>
            <atom:updated>2023-05-24T21:18:33.061Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to use Sidekiq Cron and Web in Plain Ruby?]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/how-yo-use-sidekiq-cron-and-web-in-plain-ruby-7e4824e6a9b?source=rss-c8d0db910a7a------2"><img src="https://cdn-images-1.medium.com/max/2600/1*M6Ziqy8670x1bX6XXkrxdg.png" width="3018"></a></p><p class="medium-feed-snippet">Sidekiq is a simple, efficient background processing for Ruby. It is completely integrated with Rails and is super easy to use. Have you&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/codex/how-yo-use-sidekiq-cron-and-web-in-plain-ruby-7e4824e6a9b?source=rss-c8d0db910a7a------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/how-yo-use-sidekiq-cron-and-web-in-plain-ruby-7e4824e6a9b?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/7e4824e6a9b</guid>
            <category><![CDATA[sidekiq]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Thu, 30 Mar 2023 22:34:06 GMT</pubDate>
            <atom:updated>2023-09-09T12:05:21.786Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Spotify Authentication Flow Example With Ruby Webrick Webserver]]></title>
            <link>https://medium.com/codex/spotify-authentication-flow-example-with-ruby-webrick-webserver-3beb267d6685?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3beb267d6685</guid>
            <category><![CDATA[spotify]]></category>
            <category><![CDATA[multi-provider-auth]]></category>
            <category><![CDATA[spotify-web-api]]></category>
            <category><![CDATA[webric]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Sun, 15 Jan 2023 15:49:53 GMT</pubDate>
            <atom:updated>2023-01-23T16:55:59.237Z</atom:updated>
            <content:encoded><![CDATA[<p>This tutorial will replace Node.js with Ruby in the <a href="https://github.com/spotify/web-api-auth-examples">Authentication Flow example app</a> for Spotify <a href="https://developer.spotify.com/documentation/web-api/">Web API</a>.</p><blockquote>This flow first gets a code from the Spotify Accounts Service, then exchanges that code for an access token. The code-to-token exchange requires a secret key, and for security is done through direct server-to-server communication.</blockquote><blockquote>In this example we retrieve data from the Web API /me endpoint, that includes information about the current user.</blockquote><p>Here we will use Ruby for server-side applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*re6AnhTGQBtiufbZ1ItqQg.png" /></figure><h3>Setup Webserver</h3><p>Many web server gems could accept and process requests. In this tutorial, I tried using <a href="https://github.com/ruby/webrick">Webrick</a>.</p><blockquote>WEBrick is an HTTP server toolkit that can be configured as an HTTPS server, a proxy server, and a virtual-host server.</blockquote><p>First, you need to initialize the Gemfile and add webrick gem.</p><pre>$ bundle init</pre><p>Then add gem &#39;webrick&#39; to your Gemfile and run bundle install to install the gem. Your Gemfile should look like this.</p><pre># frozen_string_literal: true<br><br>source &#39;https://rubygems.org&#39;<br><br>gem &#39;webrick&#39;</pre><p>Then you should create a server.rb file so we can start building the web server.</p><pre># server.rb<br><br>require &#39;webrick&#39;<br><br>port = 8000<br>server = WEBrick::HTTPServer.new Port: port</pre><p>We are going to add a RequestHandler class to our web server and kill the server with crtl+c .</p><pre># server.rb<br>...<br><br>server.mount &#39;/&#39;, RequestHandler<br><br>trap &#39;INT&#39; do server.shutdown end<br><br>server.start</pre><h3>RequestHandler</h3><pre># request_handler.rb<br><br><br># frozen_string_literal: true<br><br># Handle the incoming requests<br>class RequestHandler &lt; WEBrick::HTTPServlet::AbstractServlet<br>  def do_GET(request, response)<br>    method_name = &quot;process_#{request.path.delete_prefix(&#39;/&#39;)}&quot;.to_sym<br>    send(method_name, request, response)<br>  rescue NoMethodError<br>    raise &#39;Not Found&#39;<br>  end<br>end</pre><p>We added a simple web servlet that will process the requests. This will send the request and response objects to a method; otherwise, raise an error which means that the route doesn’t exist. Also, we need to require this file in our server file.</p><pre>#server.rb<br>require &#39;webrick&#39;<br><br>require_relative &#39;request_handler&#39;<br><br><br>port = 8000<br><br>server = WEBrick::HTTPServer.new Port: port<br><br>server.mount &#39;/&#39;, RequestHandler<br><br>trap &#39;INT&#39; do server.shutdown end<br><br>server.start</pre><h3>Adding Actions</h3><p>We will add basic actions so the user can see a Login With Spotify button, click on it, and be redirected to Spotify to grant access to our application and return. I’m using the OAuth examples on the Spotify Web API document page for the HTML pages.</p><h4>Index</h4><p>First, create a templates directory and add an index.html to it with the content below.</p><pre>&lt;!-- templates/index.html --&gt;<br>&lt;!doctype html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Example of the Authorization Code flow with Spotify&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css&quot;&gt;<br>    &lt;style type=&quot;text/css&quot;&gt;<br>      .text-overflow {<br>        overflow: hidden;<br>        text-overflow: ellipsis;<br>        white-space: nowrap;<br>        width: 500px;<br>      }<br>    &lt;/style&gt;<br>  &lt;/head&gt;<br><br>  &lt;body&gt;<br>    &lt;div class=&quot;container&quot;&gt;<br>      &lt;div id=&quot;login&quot;&gt;<br>        &lt;h1&gt;This is an example of the Authorization Code flow&lt;/h1&gt;<br>        &lt;a href=&quot;/login&quot; class=&quot;btn btn-primary&quot;&gt;Log in with Spotify&lt;/a&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>Now we will add the request handler for this. Create a request_handlers directory and add index.rb file. With the logic we had in request_handler.rb file, we need a method called process_ACTION-NAME to handle the request, which in this case, will be process_ and the action name will be empty.</p><pre># request_handlers/index.rb<br><br># frozen_string_literal: true<br><br>def process_(_, response)<br>  result = File.read(&#39;templates/index.html&#39;)<br>  response.status = 200<br>  response[&#39;Content-Type&#39;] = &#39;text/html&#39;<br>  response.body = body<br>end</pre><p>After this, we need to modify our server.rb file and require this new ruby file.</p><pre>#server.rb<br>...<br><br>require_relative &#39;request_handler&#39;<br>require_relative &#39;request_handlers/index&#39;<br><br>...</pre><p>Also, I moved a couple of lines to a helper called response.rb for rendering HTML pages.</p><pre># helpers/response.rb<br><br># frozen_string_literal: true<br><br>def render_html(body, response)<br>  response.status = 200<br>  response[&#39;Content-Type&#39;] = &#39;text/html&#39;<br>  response.body = body<br>end</pre><pre># request_handlers/index.rb<br><br># frozen_string_literal: true<br><br>def process_(_, response)<br>  result = File.read(&#39;templates/index.html&#39;)<br>  render_html(result, response)<br>end</pre><pre># server.rb<br>...<br>require_relative &#39;helpers/response&#39;<br>...</pre><p>Now, if everything is fine you could start the web server with $ ruby server.rb command and in your browser http://localhost:8000 should serve something like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZI_5ST0RyBwAAJDvbdcp2w.png" /></figure><p>Now, this button will send the user to localhost:8000/login which will redirect the user to the Spotify website. Now let’s add the logic for /login .</p><h4>Login Action</h4><p>We have followed the details mentioned in <a href="https://developer.spotify.com/documentation/general/guides/authorization/code-flow/">Spotify Authorization Code Flow</a> documentation.</p><pre># request_handlers/login.rb<br><br># frozen_string_literal: true<br><br>def process_login(_, response)<br>  random_string = SecureRandom.hex<br>  response.cookies.push WEBrick::Cookie.new(&#39;spotify_auth_state&#39;, random_string)<br><br>  params = {<br>    response_type: &#39;code&#39;,<br>    client_id: $client_id,<br>    scope: $scopes,<br>    redirect_uri: $callback_url,<br>    state: random_string<br>  }<br>  uri = URI(&#39;https://accounts.spotify.com/authorize&#39;)<br>  uri.query = URI.encode_www_form(params)<br><br>  response.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, uri.to_s)<br>end</pre><pre># server.rb<br><br>...<br>require &#39;securerandom&#39;<br>require_relative &#39;request_handlers/login&#39;<br>...<br>$scopes = %w[ user-read-private<br>              playlist-read-private<br>              playlist-modify-private].join(&#39; &#39;)<br><br>$client_id = &#39;YOUR_APP_CLIENT_ID&#39;<br>$client_secret = &#39;YOUR_APP_CLIENT_SECRET<br>$callback_url = &quot;http://localhost:#{port}/callback&quot;<br></pre><p>You need to add your app client id and client secret here. Also, change the required scopes based on <a href="https://developer.spotify.com/documentation/general/guides/authorization/scopes/">Spotify Authorization Scopes</a>.</p><p>Now you need to restart the webserver and now click on Login with Spotify button and should be redirected to the Spotify website for login and granting access.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nCLo8nFyomGQR2UB2e6XVA.png" /></figure><p>When you finish, you’ll be redirected back to http://localhost:8000/callback which we are going to add next.</p><h4>Callback Action</h4><p>Whenever the user returns to the callback action, we need to obtain a token with the given code in the query params.</p><blockquote>If the user accepted your request, then your app is ready to exchange the authorization code for an Access Token. It can do this by making a POST request to the /api/token endpoint.</blockquote><pre># request_handlers/callback.rb<br><br># frozen_string_literal: true<br><br>def process_callback(request, response)<br>  state_cookie = request.cookies.select { |c| c.name == &#39;spotify_auth_state&#39; }.first<br>  raise &#39;error&#39; unless state_cookie.value == request.query[&#39;state&#39;]<br><br>  data = {<br>    code: request.query[&#39;code&#39;],<br>    grant_type: &#39;authorization_code&#39;,<br>    redirect_uri: $callback_url<br>  }<br><br>  res = RestClient.post(<br>    &#39;https://accounts.spotify.com/api/token&#39;,<br>    data,<br>    {<br>      Authorization: &quot;Basic #{Base64.strict_encode64($client_id + &#39;:&#39; + $client_secret)}&quot;<br>    }<br>  )<br><br>  result = JSON.parse(res.body)<br><br>  params = {<br>    access_token: result[&#39;access_token&#39;],<br>    refresh_token: result[&#39;refresh_token&#39;]<br>  }<br>  uri = URI(&#39;/me&#39;)<br>  uri.query = URI.encode_www_form(params)<br><br>  response.set_redirect(WEBrick::HTTPStatus::TemporaryRedirect, uri.to_s)<br>end</pre><p>Also, we need to modify our server.rb file to require more items.</p><pre># server.rb<br><br>...<br>require &#39;rest-client&#39;<br>require &#39;json&#39;<br>require &#39;base64&#39;<br>...<br>require_relative &#39;request_handlers/callback&#39;<br>...</pre><p>Firstly, we check the given state with the spotify_auth_statecookie to ensure the user is the same; otherwise, it’s an error, and we should not proceed. Then we need to get the token from Spotify API and redirect the user to a profile page called /me .</p><h4>me Action</h4><p>First, we added the HTML page from <a href="https://github.com/spotify/web-api-auth-examples">OAuth examples</a> on the <a href="https://developer.spotify.com/documentation/web-api/quick-start/">Spotify Web API</a> documentation page.</p><pre>&lt;!-- templates/me.html --&gt;<br>&lt;!doctype html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Example of the Authorization Code flow with Spotify&lt;/title&gt;<br>    &lt;link rel=&quot;stylesheet&quot; href=&quot;//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css&quot;&gt;<br>    &lt;style type=&quot;text/css&quot;&gt;<br>      #login, #loggedin {<br>        display: none;<br>      }<br>      .text-overflow {<br>        overflow: hidden;<br>        text-overflow: ellipsis;<br>        white-space: nowrap;<br>        width: 500px;<br>      }<br>    &lt;/style&gt;<br>  &lt;/head&gt;<br><br>  &lt;body&gt;<br>    &lt;div class=&quot;container&quot;&gt;<br>      &lt;div id=&quot;loggedin&quot;&gt;<br>        &lt;div id=&quot;user-profile&quot;&gt;<br>        &lt;/div&gt;<br>        &lt;div id=&quot;oauth&quot;&gt;<br>        &lt;/div&gt;<br>        &lt;button class=&quot;btn btn-default&quot; id=&quot;obtain-new-token&quot;&gt;Obtain new token using the refresh token&lt;/button&gt;<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br><br>    &lt;script id=&quot;user-profile-template&quot; type=&quot;text/x-handlebars-template&quot;&gt;<br>      &lt;h1&gt;Logged in as {{display_name}}&lt;/h1&gt;<br>      &lt;div class=&quot;media&quot;&gt;<br>        &lt;div class=&quot;pull-left&quot;&gt;<br>          &lt;img class=&quot;media-object&quot; width=&quot;150&quot; src=&quot;{{images.0.url}}&quot; /&gt;<br>        &lt;/div&gt;<br>        &lt;div class=&quot;media-body&quot;&gt;<br>          &lt;dl class=&quot;dl-horizontal&quot;&gt;<br>            &lt;dt&gt;Display name&lt;/dt&gt;&lt;dd class=&quot;clearfix&quot;&gt;{{display_name}}&lt;/dd&gt;<br>            &lt;dt&gt;Id&lt;/dt&gt;&lt;dd&gt;{{id}}&lt;/dd&gt;<br>            &lt;dt&gt;Email&lt;/dt&gt;&lt;dd&gt;{{email}}&lt;/dd&gt;<br>            &lt;dt&gt;Spotify URI&lt;/dt&gt;&lt;dd&gt;&lt;a href=&quot;{{external_urls.spotify}}&quot;&gt;{{external_urls.spotify}}&lt;/a&gt;&lt;/dd&gt;<br>            &lt;dt&gt;Link&lt;/dt&gt;&lt;dd&gt;&lt;a href=&quot;{{href}}&quot;&gt;{{href}}&lt;/a&gt;&lt;/dd&gt;<br>            &lt;dt&gt;Profile Image&lt;/dt&gt;&lt;dd class=&quot;clearfix&quot;&gt;&lt;a href=&quot;{{images.0.url}}&quot;&gt;{{images.0.url}}&lt;/a&gt;&lt;/dd&gt;<br>            &lt;dt&gt;Country&lt;/dt&gt;&lt;dd&gt;{{country}}&lt;/dd&gt;<br>          &lt;/dl&gt;<br>        &lt;/div&gt;<br>      &lt;/div&gt;<br>    &lt;/script&gt;<br><br>    &lt;script id=&quot;oauth-template&quot; type=&quot;text/x-handlebars-template&quot;&gt;<br>      &lt;h2&gt;oAuth info&lt;/h2&gt;<br>      &lt;dl class=&quot;dl-horizontal&quot;&gt;<br>        &lt;dt&gt;Access token&lt;/dt&gt;&lt;dd class=&quot;&quot;&gt;{{access_token}}&lt;/dd&gt;<br>        &lt;dt&gt;Refresh token&lt;/dt&gt;&lt;dd class=&quot;&quot;&gt;{{refresh_token}}&lt;/dd&gt;<br>      &lt;/dl&gt;<br>    &lt;/script&gt;<br><br>    &lt;script src=&quot;//cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0-alpha.1/handlebars.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script src=&quot;http://code.jquery.com/jquery-1.10.1.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script&gt;<br>      (function() {<br><br>        /**<br>         * Obtains parameters from the hash of the URL<br>         * @return Object<br>         */<br>        function getHashParams() {<br>          var params = new URLSearchParams(window.location.search);<br><br>          return params;<br>        }<br><br>        var userProfileSource = document.getElementById(&#39;user-profile-template&#39;).innerHTML,<br>            userProfileTemplate = Handlebars.compile(userProfileSource),<br>            userProfilePlaceholder = document.getElementById(&#39;user-profile&#39;);<br><br>        var oauthSource = document.getElementById(&#39;oauth-template&#39;).innerHTML,<br>            oauthTemplate = Handlebars.compile(oauthSource),<br>            oauthPlaceholder = document.getElementById(&#39;oauth&#39;);<br><br>        var params = getHashParams();<br><br>        var access_token = params.get(&#39;access_token&#39;),<br>            refresh_token = params.get(&#39;refresh_token&#39;),<br>            error = params.get(&#39;error&#39;);<br><br>        if (error) {<br>          alert(&#39;There was an error during the authentication&#39;);<br>        } else {<br>          if (access_token) {<br>            // render oauth info<br>            oauthPlaceholder.innerHTML = oauthTemplate({<br>              access_token: access_token,<br>              refresh_token: refresh_token<br>            });<br><br>            $.ajax({<br>                url: &#39;https://api.spotify.com/v1/me&#39;,<br>                headers: {<br>                  &#39;Authorization&#39;: &#39;Bearer &#39; + access_token<br>                },<br>                success: function(response) {<br>                  userProfilePlaceholder.innerHTML = userProfileTemplate(response);<br><br>                  $(&#39;#login&#39;).hide();<br>                  $(&#39;#loggedin&#39;).show();<br>                }<br>            });<br>          } else {<br>              // render initial screen<br>              $(&#39;#login&#39;).show();<br>              $(&#39;#loggedin&#39;).hide();<br>          }<br><br>          document.getElementById(&#39;obtain-new-token&#39;).addEventListener(&#39;click&#39;, function() {<br>            $.ajax({<br>              url: &#39;/refresh_token&#39;,<br>              data: {<br>                &#39;refresh_token&#39;: refresh_token<br>              }<br>            }).done(function(data) {<br>              access_token = data.access_token;<br>              oauthPlaceholder.innerHTML = oauthTemplate({<br>                access_token: access_token,<br>                refresh_token: refresh_token<br>              });<br>            });<br>          }, false);<br>        }<br>      })();<br>    &lt;/script&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;<br></pre><p>Now we need an action to render this page.</p><pre># request_handlers/me.rb<br><br># frozen_string_literal: true<br><br>def process_me(_, response)<br>  result = File.read(&#39;templates/me.html&#39;)<br>  render_html(result, response)<br>end</pre><pre># server.rb<br>...<br>require_relative &#39;request_handlers/me&#39;<br>...</pre><p>Now, if you restart your web server and grant access to the application with your Spotify account, in the end, you should see a page like this.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d-cI-Hr8pACSM-Mupltc2g.png" /></figure><h4>Refresh Token Action</h4><p>Each Access Token is valid for 1 hour, and you need to obtain a new access token with your refresh token. On this page, there is a Obtain new token using the refresh token button, which will make a request to our web server and ask for a new access token. The action is called /refresh_token and need to return the response with application/json Content-Type header.</p><p>First, we are going to add render_json method to our helper.</p><pre># helpers/response.rb<br>...<br><br>def render_json(body, response)<br>  response.status = 200<br>  response[&#39;Content-Type&#39;] = &#39;application/json&#39;<br>  response.body = body<br>end</pre><p>Now we are going to add the refresh_token action and modify our server.rb file as well.</p><pre># request_handlers/refresh_token.rb<br><br><br>def process_refresh_token(request, response)<br>  url = &#39;https://accounts.spotify.com/api/token&#39;<br>  data = {<br>    refresh_token: request.query[&#39;refresh_token&#39;],<br>    grant_type: &#39;refresh_token&#39;<br>  }<br>  res = RestClient.post url,<br>    data,<br>    {<br>      Authorization: &quot;Basic #{Base64.strict_encode64($client_id + &#39;:&#39; + $client_secret)}&quot;<br>    }<br><br>  render_json(res.body, response)<br>end</pre><pre># server.rb<br><br>...<br>require_relative &#39;request_handlers/refresh_token&#39;<br>...</pre><p>You can finally clone all the files from <a href="https://github.com/azolf/spotify-web-api-auth-examples-ruby/tree/medium">azolf/spotify-web-api-auth-examples-ruby</a> repository on Github.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3beb267d6685" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/spotify-authentication-flow-example-with-ruby-webrick-webserver-3beb267d6685">Spotify Authentication Flow Example With Ruby Webrick Webserver</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Process PostgreSQL Changes With Logical Replication And Ruby]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/process-postgresql-changes-with-logical-replication-and-ruby-a4454cac529a?source=rss-c8d0db910a7a------2"><img src="https://cdn-images-1.medium.com/max/1141/1*evR-oQgQBw9_2mfcK_I4nA.png" width="1141"></a></p><p class="medium-feed-snippet">Have you ever tried to send your database activity logs to an event system?</p><p class="medium-feed-link"><a href="https://medium.com/codex/process-postgresql-changes-with-logical-replication-and-ruby-a4454cac529a?source=rss-c8d0db910a7a------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/process-postgresql-changes-with-logical-replication-and-ruby-a4454cac529a?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4454cac529a</guid>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[postgresql-replication]]></category>
            <category><![CDATA[logical-replication]]></category>
            <category><![CDATA[ruby]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Mon, 02 May 2022 09:17:47 GMT</pubDate>
            <atom:updated>2022-05-02T11:57:45.366Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Tmuxinator Config File Generator]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/codex/tmuxinator-config-file-generator-41b93fa03728?source=rss-c8d0db910a7a------2"><img src="https://cdn-images-1.medium.com/max/1913/1*ZNYLOsS8v_3xyQV4ywW0ow.png" width="1913"></a></p><p class="medium-feed-snippet">Have you ever worked with tmux using tmuxinator? You have to write your own configuration files for each session you want.</p><p class="medium-feed-link"><a href="https://medium.com/codex/tmuxinator-config-file-generator-41b93fa03728?source=rss-c8d0db910a7a------2">Continue reading on CodeX »</a></p></div>]]></description>
            <link>https://medium.com/codex/tmuxinator-config-file-generator-41b93fa03728?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/41b93fa03728</guid>
            <category><![CDATA[tmuxinator]]></category>
            <category><![CDATA[tmux]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Fri, 15 Apr 2022 13:40:32 GMT</pubDate>
            <atom:updated>2022-04-16T04:36:18.557Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[How to debug a production issue?]]></title>
            <link>https://medium.com/codex/how-to-debug-a-production-issue-755700207801?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/755700207801</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Sat, 28 Aug 2021 10:20:23 GMT</pubDate>
            <atom:updated>2021-08-29T17:07:31.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*Zex9j421WrJy86xWPqIpYg.png" /></figure><p>Every developer and manager who worked in tech face an issue that only is happening in a production environment. This type of issue is the hardest one to debug cause you can’t easily check the log or do some regular testing.</p><p>In the past couple of years, I was responsible for delivering different products in production and face this type of issue multiple times. In this article, I’m trying to share my experience on how to fix them.</p><h3>Find the scope</h3><p>First, take a look at the bug report and try to make some guess about the issue. Is it because of the code or could be something related to the server? Could it be related to the data on the live system?</p><p>Try to find the lines of code that are affecting these requests and also wrote down the path that requests go through step by step.</p><h3>Make Sure</h3><p>The next step is to make sure that the issue is happening only on the live system. There was a couple of times I got a report for a live issue but it was also happening on staging servers. In these scenarios, you could easily debug the staging server and do not take any risks on the live system.</p><h3>Check the diff</h3><p>I always check the latest release or find the release which causes the issue. Review the whole code and take notes for suspicious lines of codes. Sometimes you could find a rookie mistake that nobody paid attention to.</p><h3>Staging vs. Production</h3><p>Make sure about the difference between staging and production setup. In production, you might have scaled your project, have different configurations, multiple databases, different caching strategies, etc. Take a note of the differences to have a better overview.</p><h3>The life cycle</h3><p>There is always a request or couple of requests which create the bug, wrote them down, check the life cycle for each of them. Make sure the requests are going through the way that you think. It could waste your time because the request is going through some other lines of code.<br>For instance, we had a release on the live system and some requests were failing because of naming. The developer added a function with the same name and there was a conflict. We changed the function name and everything goes back to normal.</p><h3>Minimize the scope</h3><p>Test and debug everything one by one to minimize the scope for yourself. If you change multiple things together, it’s harder to find out which one was the issue.</p><h4>Caching</h4><p>Sometimes the caching configurations on the live system create the issue. Make sure the required caches have been updated.</p><h4>Load Balancing</h4><p>In a large-scale project in which you load balance the requests between multiple servers, you might have a broken node. Make sure all the nodes are updated and getting the request properly.</p><h3>Everything is possible</h3><p>The problem is not always the hardest one and anything is possible. Just remember to create different test cases to cover every possibility. Go through your test cases one by one and try to create the smallest scope for it.</p><h3>Meaningful log messages</h3><p>When you are adding logs to debug, remember to have a clear message in your logs. It’s easier to find them and also you don’t need to check the code again to see where was that log.</p><p>This is an index action for categories. Some categories are not shown here and we want to find out why.</p><pre>def index<br>      city_id = params[:city_id]<br>      city = Category.city(city_id)&amp;.first<br>      return head 400 unless city.present?<br>      <br>      cache_key = &quot;categories_#{city_id}&quot;<br>      expires_in = Rails.application.config.api_cache_lengths.soon</pre><pre>      <br>      cats = Rails.cache.fetch(cache_key, expires_in: expires_in) do<br>        global_cats = Category.get_global_categories<br>        cats = []<br>        if city.present?<br>          city_cats = Category.get_categories(city) || []<br>        end<br>        cats += city_cats<br>        cats += global_cats<br>      end <br>      cats = Category.remove_no_deals(cats)<br>      cats = Category.categories_sort_by_position(cats)</pre><pre>      categories_serializer = CategorySerializer.new(cats)</pre><pre>      render json: categories_serializer.serializable_hash<br>    end</pre><p>Now I’m going to add some logs to see how the code is working and understand which line of the code is creating the issue.</p><pre>def index<br>      Rails.logger.info &quot;Index action started ..&quot;<br>      city_id = params[:city_id]<br>      Rails.logger.info &quot;City id: #{city_id}&quot;<br>      city = Category.city(city_id)&amp;.first<br>      return head 400 unless city.present?<br>      Rails.logger.info &quot;The city was present&quot;<br>      <br>      cache_key = &quot;categories_#{city_id}&quot;<br>      expires_in = Rails.application.config.api_cache_lengths.soon</pre><pre>Rails.logger.info &quot;Cache Key: #{cache_key}&quot;<br>      <br>      cats = Rails.cache.fetch(cache_key, expires_in: expires_in) do<br>        global_cats = Category.get_global_categories<br>        Rails.logger.info &quot;Global categories count: #{global_cats.count}&quot;<br>        cats = []<br>        if city.present?<br>          city_cats = Category.get_categories(city) || []<br>        end<br>        cats += city_cats<br>        cats += global_cats<br>        Rails.logger.info &quot;Final cached categories count: #{cats.count}&quot;<br>      end <br>      cats = Category.remove_no_deals(cats)<br>      Rails.logger.info &quot;Categories after removing no deals count: #{cats.count}&quot;<br>      cats = Category.categories_sort_by_position(cats)<br>      Rails.logger.info &quot;Categories after sorting: #{cats.count}&quot;</pre><pre>categories_serializer = CategorySerializer.new(cats)<br>      Rails.logger.info &quot;Response should be: #{categories_serializer.serializable_hash}&quot;<br>      <br>      render json: categories_serializer.serializable_hash<br>    end</pre><p>Now you could see where the categories are getting removed from the list and find out why., go and check that line of code.</p><p>You should know that there is not the correct answer for these types of issues. Always share your experience with others and also get help from colleagues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=755700207801" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/how-to-debug-a-production-issue-755700207801">How to debug a production issue?</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Simple To-do App With Gitlab Pages]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://faun.pub/a-simple-to-do-app-with-gitlab-pages-8c56c7c1c762?source=rss-c8d0db910a7a------2"><img src="https://cdn-images-1.medium.com/max/1647/1*Xixhoq-4SEovLqcB3j1wBw.png" width="1647"></a></p><p class="medium-feed-snippet">In this article, I&#x2019;m going to describe how you could set up a static website with GitLab pages and also using your domain for it. For this&#x2026;</p><p class="medium-feed-link"><a href="https://faun.pub/a-simple-to-do-app-with-gitlab-pages-8c56c7c1c762?source=rss-c8d0db910a7a------2">Continue reading on FAUN.dev()  »</a></p></div>]]></description>
            <link>https://faun.pub/a-simple-to-do-app-with-gitlab-pages-8c56c7c1c762?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c56c7c1c762</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[gitlab-page]]></category>
            <category><![CDATA[gitlab-ci]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Fri, 25 Jun 2021 18:42:09 GMT</pubDate>
            <atom:updated>2021-07-27T15:01:10.249Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Dynamic Filters With Laravel Eloquent]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://faun.pub/dynamic-filters-with-laravel-eloquent-2dad9d9ff7c2?source=rss-c8d0db910a7a------2"><img src="https://cdn-images-1.medium.com/max/2600/1*arVBTnvKfhnsTcA3i4E2ow.png" width="4846"></a></p><p class="medium-feed-snippet">Did you ever had a Laravel application and needs filters over your API? You might have tried GraphQL, however, you could write a simple&#x2026;</p><p class="medium-feed-link"><a href="https://faun.pub/dynamic-filters-with-laravel-eloquent-2dad9d9ff7c2?source=rss-c8d0db910a7a------2">Continue reading on FAUN.dev()  »</a></p></div>]]></description>
            <link>https://faun.pub/dynamic-filters-with-laravel-eloquent-2dad9d9ff7c2?source=rss-c8d0db910a7a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dad9d9ff7c2</guid>
            <category><![CDATA[laravel]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Amir]]></dc:creator>
            <pubDate>Tue, 23 Feb 2021 21:37:15 GMT</pubDate>
            <atom:updated>2021-07-26T19:58:51.747Z</atom:updated>
        </item>
    </channel>
</rss>