<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Tutorial on Justin B Kay's Blog</title><link>https://blog.jbkconsultingllc.com/tags/tutorial/</link><description>Recent content in Tutorial on Justin B Kay's Blog</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Thu, 04 Jan 2024 14:42:55 -0700</lastBuildDate><atom:link href="https://blog.jbkconsultingllc.com/tags/tutorial/index.xml" rel="self" type="application/rss+xml"/><item><title>Updating deeply nested elixir maps</title><link>https://blog.jbkconsultingllc.com/posts/updating-deeply-nested-elixir-maps/</link><pubDate>Thu, 04 Jan 2024 14:42:55 -0700</pubDate><guid>https://blog.jbkconsultingllc.com/posts/updating-deeply-nested-elixir-maps/</guid><description>&lt;p&gt;In some cases it is necessary to update a deeply nested attribute in a map. I went searching for a way to do this and came across several approaches, the one that worked for me was this, a combination of &lt;a href="https://hexdocs.pm/elixir/Kernel.html#put_in/2"&gt;Kernel.put_in&lt;/a&gt; and &lt;a href="https://hexdocs.pm/elixir/1.12.3/Access.html#key/2"&gt;Access.key&lt;/a&gt;, here I&amp;rsquo;m using it to update a socket struct nested assigns map.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-elixir" data-lang="elixir"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;put_in(socket, &lt;span style="color:#a6e22e"&gt;Enum&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;map([&lt;span style="color:#e6db74"&gt;:assigns&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;:beacon_live_data&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;:form_submitted&lt;/span&gt;], &lt;span style="color:#f92672"&gt;&amp;amp;&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;Access&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;key(&amp;amp;1, %{})), &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The put_in function is pretty easy to understand, it &lt;code&gt;Puts a value in a nested structure via the given path&lt;/code&gt;. The tricky bit is the path.&lt;/p&gt;</description></item><item><title>Running Quantum in an Elixir Cluster</title><link>https://blog.jbkconsultingllc.com/posts/running-quantum-in-elixir-cluster/</link><pubDate>Thu, 17 Feb 2022 14:42:55 -0700</pubDate><guid>https://blog.jbkconsultingllc.com/posts/running-quantum-in-elixir-cluster/</guid><description>&lt;p&gt;In one of the projects that I work on, for the sake of availability and reliability, we are running our Phoenix app in a cluster of 3 servers using libcluster. Initially, it was just running on a single server and I had configured &lt;a href="https://github.com/quantum-elixir/quantum-core"&gt;Quantum&lt;/a&gt; to run our recurring tasks on a cron like schedule. This worked well, and I had no issues with the setup. When we decided to move to a clustered setup, there was a consideration concerning Quantum. I didn&amp;rsquo;t want the jobs to run on multiple servers, I wanted to have a single server responsible for handling all the scheduled jobs so as to keep duplicate jobs from running. I looked around and found someone who had written about using &lt;a href="https://github.com/derekkraan/highlander"&gt;Highlander&lt;/a&gt; to make sure there was only a single instance of Quantum running on the cluster at a time. I decided to try this out.&lt;/p&gt;</description></item><item><title>Add Sass to Phoenix 1.6 with Esbuild</title><link>https://blog.jbkconsultingllc.com/posts/add-sass-to-phoenix-with-esbuild/</link><pubDate>Sun, 12 Sep 2021 20:49:30 -0600</pubDate><guid>https://blog.jbkconsultingllc.com/posts/add-sass-to-phoenix-with-esbuild/</guid><description>&lt;p&gt;If you are starting a new project with The &lt;a href="https://www.phoenixframework.org/"&gt;Phoenix Framework&lt;/a&gt; version 1.6, you&amp;rsquo;ll notice there has been a change with regard to asset handling.
Chris McCord and The Phoenix Team have made the choice to move away from WebPack and start using &lt;a href="https://esbuild.github.io/"&gt;Esbuild&lt;/a&gt; to deal with the Javascript files. One
side effect of this is you lose the ability to use Sass files by default. Have no fear, there&amp;rsquo;s a way to add Sass back into your project.&lt;/p&gt;</description></item></channel></rss>