<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>elixir on Poeticoding</title><link>https://www.poeticoding.com/tag/elixir/</link><description>Recent content in elixir on Poeticoding</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 20 Jul 2025 15:06:39 +0000</lastBuildDate><atom:link href="https://www.poeticoding.com/tag/elixir/index.xml" rel="self" type="application/rss+xml"/><item><title>Fine-Tuning YOLO to Watch Soccer Matches</title><link>https://www.poeticoding.com/fine-tuning-yolo-to-watch-soccer-matches/</link><pubDate>Thu, 17 Jul 2025 15:14:24 +0000</pubDate><guid>https://www.poeticoding.com/fine-tuning-yolo-to-watch-soccer-matches/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/m7nO5jtpc_w" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;p>Today we&amp;rsquo;re diving into something really cool: fine-tuning YOLO models for soccer detection. We&amp;rsquo;re going to detect &lt;code>ball&lt;/code>s, &lt;code>referee&lt;/code>s, &lt;code>player&lt;/code>s, and &lt;code>goalkeeper&lt;/code>s in soccer matches using &lt;a href="https://docs.ultralytics.com/modes/train/" target="_blank" rel="noopener">Ultralytics&amp;rsquo; fine-tuning tools&lt;/a>.&lt;/p>
&lt;p>The popular YOLO models you&amp;rsquo;ll find out there, like &lt;a href="https://docs.ultralytics.com/models/yolo11/" target="_blank" rel="noopener">Ultralytics YOLOv11&lt;/a>, and &lt;a href="https://github.com/Megvii-BaseDetection/YOLOX" target="_blank" rel="noopener">YOLOX&lt;/a> in different sizes, are mostly pre-trained on something called the &lt;a href="https://cocodataset.org/" target="_blank" rel="noopener">COCO dataset&lt;/a>.&lt;/p></description></item><item><title>Effortless Video Sharing with Phoenix LiveView and FLAME</title><link>https://www.poeticoding.com/effortless-video-sharing-with-phoenix-liveview-and-flame/</link><pubDate>Thu, 28 Nov 2024 18:09:06 +0000</pubDate><guid>https://www.poeticoding.com/effortless-video-sharing-with-phoenix-liveview-and-flame/</guid><description>&lt;p>As someone who loves experimenting with new technologies, I recently got the Vision Pro (I’m a big fan of VR and the idea of working in mixed reality). What excites me the most is sharing the cool stuff I discover, with my friends and colleagues, like how amazing it is to have a floating 3D model in mixed reality, built with just a few lines of Swift code.&lt;/p></description></item><item><title>Layouts and LiveEEx templates</title><link>https://www.poeticoding.com/layouts-and-liveeex-templates/</link><pubDate>Tue, 25 May 2021 11:14:16 +0000</pubDate><guid>https://www.poeticoding.com/layouts-and-liveeex-templates/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/2Sc0eOauH2k" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;p>&lt;a href="https://www.poeticoding.com/introductory-phoenix-liveview-course/">Course Index page&lt;/a>&lt;/p>
&lt;h1 id="code">Code&lt;/h1>
&lt;ul>
&lt;li>&lt;a href="https://github.com/poeticoding/poeticoins/tree/lv-first-view" target="_blank" rel="noopener">&lt;code>lv-first-view&lt;/code> branch&lt;/a>&lt;/li>
&lt;/ul>
&lt;h1 id="links">Links&lt;/h1>
&lt;ul>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix/views.html#layouts" target="_blank" rel="noopener">Phoenix Layouts&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/live-layouts.html" target="_blank" rel="noopener">Live Layouts&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/live-layouts.html" target="_blank" rel="noopener">Assigns and LiveEEx templates&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/assigns-eex.html#liveeex-pitfalls" target="_blank" rel="noopener">Updating the HTML document title&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;p>&lt;a href="https://www.poeticoding.com/how-phoenix-liveview-works/">We&amp;rsquo;ve previously seen in detail how Phoenix LiveView works&lt;/a>. In this lesson we are going to see:&lt;/p></description></item><item><title>How Phoenix LiveView works</title><link>https://www.poeticoding.com/how-phoenix-liveview-works/</link><pubDate>Tue, 27 Apr 2021 11:20:08 +0000</pubDate><guid>https://www.poeticoding.com/how-phoenix-liveview-works/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/pq5eOJRCkow" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;hr>
&lt;p>&lt;a href="https://www.poeticoding.com/introductory-phoenix-liveview-course/">Course Index page&lt;/a>&lt;/p>
&lt;h2 id="code">Code&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://github.com/poeticoding/poeticoins/tree/how-lv-works" target="_blank" rel="noopener">GitHub: how-lv-works&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/poeticoding/poeticoins/blob/how-lv-works/lib/poeticoins_web/live/crypto_dashboard_live.ex" target="_blank" rel="noopener">crypto_dashboard_live.ex&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/poeticoding/poeticoins/blob/how-lv-works/assets/js/app.js" target="_blank" rel="noopener">&lt;code>app.js&lt;/code>&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="links">Links&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#module-life-cycle" target="_blank" rel="noopener">Life-cycle&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#connected?/1" target="_blank" rel="noopener">&lt;code>socket.connected?&lt;/code>&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/patrick-steele-idem/morphdom" target="_blank" rel="noopener">morphdom&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="how-does-liveview-work">How does LiveView work?&lt;/h2>
&lt;p>In the &lt;a href="https://www.poeticoding.com/first-contact-with-phoenix-liveview/">previous lesson&lt;/a> we got a taste of the LiveView&amp;rsquo;s magic! In this lesson we are going to see how LiveView really works and what happens behind the scenes when a user connects.&lt;/p></description></item><item><title>First contact with Phoenix LiveView</title><link>https://www.poeticoding.com/first-contact-with-phoenix-liveview/</link><pubDate>Tue, 13 Apr 2021 18:46:05 +0000</pubDate><guid>https://www.poeticoding.com/first-contact-with-phoenix-liveview/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/9ZTm0R5YU64" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;p>&lt;a href="https://www.poeticoding.com/introductory-phoenix-liveview-course/">&lt;strong>Course Index page&lt;/strong>&lt;/a>&lt;/p>
&lt;h2 id="code">Code&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://github.com/poeticoding/poeticoins/tree/lv-first-view" target="_blank" rel="noopener">&lt;code>lv-first-view&lt;/code> branch&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/poeticoding/poeticoins/pull/15" target="_blank" rel="noopener">Lesson&amp;rsquo;s PR&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://github.com/poeticoding/poeticoins/blob/lv-first-view/lib/poeticoins_web/live/crypto_dashboard_live.ex" target="_blank" rel="noopener">&lt;code>PoeticoinsWeb.CryptoDashboardLive&lt;/code>&lt;/a>&lt;/li>
&lt;/ul>
&lt;h2 id="links">Links&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#c:mount/3" target="_blank" rel="noopener">mount/3&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#c:render/1" target="_blank" rel="noopener">ren&lt;/a>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#c:render/1" target="_blank" rel="noopener">d&lt;/a>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#c:render/1" target="_blank" rel="noopener">er/1&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#assign/3" target="_blank" rel="noopener">assign/3&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#update/3" target="_blank" rel="noopener">update/3&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.Helpers.html#sigil_L/2" target="_blank" rel="noopener">~L&lt;/a>&lt;/li>
&lt;/ul>
&lt;hr>
&lt;h2 id="our-first-live-view">Our first Live View&lt;/h2>
&lt;p>In this lesson we&amp;rsquo;ll introduce LiveView and get a sense of how powerful it can be. In the next lesson we&amp;rsquo;ll see better how LiveView works under the hood.&lt;/p></description></item><item><title>The Primitives of Phoenix LiveView</title><link>https://www.poeticoding.com/the-primitives-of-phoenix-liveview/</link><pubDate>Tue, 12 Nov 2019 16:30:21 +0000</pubDate><guid>https://www.poeticoding.com/the-primitives-of-phoenix-liveview/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/gPSXxtgmyB8" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;p>&lt;strong>Understanding Phoenix LiveView&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://www.poeticoding.com/how-to-setup-phoenix-liveview/">Setup&lt;/a>&lt;/li>
&lt;li>The Primitives (this article)&lt;/li>
&lt;li>&lt;a href="https://www.poeticoding.com/understanding-liveview-build-a-gallery-app/">Building a Gallery app&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>In the previous article we saw &lt;a href="https://www.poeticoding.com/how-to-setup-phoenix-liveview/">how to setup Phoenix LiveView&lt;/a>, in order to have everything we need to build a simple LiveView &lt;em>gallery app&lt;/em>.&lt;/p></description></item><item><title>How to Setup Phoenix LiveView</title><link>https://www.poeticoding.com/how-to-setup-phoenix-liveview/</link><pubDate>Tue, 29 Oct 2019 17:18:48 +0000</pubDate><guid>https://www.poeticoding.com/how-to-setup-phoenix-liveview/</guid><description>&lt;p>&lt;em>Updated for LiveView &lt;strong>0.11.0 - 7th April 2020&lt;/strong>&lt;/em>&lt;/p>
&lt;p>&lt;strong>Understanding Phoenix LiveView&lt;/strong>&lt;/p>
&lt;ul>
&lt;li>Setup &lt;em>(this)&lt;/em>&lt;/li>
&lt;li>&lt;a href="https://www.poeticoding.com/the-primitives-of-phoenix-liveview/">The Primitives&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.poeticoding.com/understanding-liveview-build-a-gallery-app/">Build a Gallery app&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>&lt;a href="https://github.com/phoenixframework/phoenix_live_view" target="_blank" rel="noopener">Phoenix LiveView&lt;/a> has been released on &lt;a href="https://hex.pm/packages/phoenix_live_view" target="_blank" rel="noopener">Hex&lt;/a>! Although it&amp;rsquo;s still not a stable release (at the time of writing &lt;strong>0.11.0&lt;/strong>), it works really well and it&amp;rsquo;s packed of cool features.&lt;/p></description></item><item><title>Phoenix LiveView - Change the URL without refreshing the page</title><link>https://www.poeticoding.com/phoenix-liveview-change-the-url-without-refreshing-the-page/</link><pubDate>Wed, 19 Jun 2019 16:11:17 +0000</pubDate><guid>https://www.poeticoding.com/phoenix-liveview-change-the-url-without-refreshing-the-page/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/Dad1mKexvu8" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;p>It&amp;rsquo;s now possible to try the &lt;em>pushState&lt;/em> support available in Phoenix LiveView (which, remember, is still in beta)&lt;/p>
&lt;figure>&lt;img src="https://www.poeticoding.com/phoenix-liveview-change-the-url-without-refreshing-the-page/liveview_pushstate_github_commit.png" alt="Add live_link and live_redirect for push state support" loading="lazy" width="700" height="200">&lt;figcaption>Add live_link and live_redirect for push state support&lt;/figcaption>&lt;/figure>&lt;h4 id="what-is-pushstate-and-why-can-be-useful">What is &lt;em>pushState&lt;/em> and why can be useful?&lt;/h4>
&lt;p>With Phoenix LiveView we can easily update parts of the page without having to change the location, refreshing the page or directly use JavaScript.&lt;/p></description></item><item><title>Step-by-Step Tutorial to Build a Phoenix App that Supports User Upload</title><link>https://www.poeticoding.com/step-by-step-tutorial-to-build-a-phoenix-app-that-supports-user-uploads/</link><pubDate>Wed, 17 Apr 2019 15:00:23 +0000</pubDate><guid>https://www.poeticoding.com/step-by-step-tutorial-to-build-a-phoenix-app-that-supports-user-uploads/</guid><description>&lt;ul>
&lt;li>Part 1: this article&lt;/li>
&lt;li>Part 2: &lt;a href="https://www.poeticoding.com/creating-thumbnails-of-uploaded-images-and-pdf-in-phoenix/">Creating Thumbnails of uploaded Images and PDF in Phoenix&lt;/a>&lt;/li>
&lt;li>Part 3: &lt;a href="https://www.poeticoding.com/add-a-progress-bar-in-the-phoenix-file-upload-app/">Add a Progress Bar in the Phoenix File Upload app&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>There are many ways to let users upload their files to our Phoenix app, including reliable libraries that manage the uploads for us, saving the files securely on cloud storage.&lt;/p></description></item><item><title>Hashing a File in Elixir</title><link>https://www.poeticoding.com/hashing-a-file-in-elixir/</link><pubDate>Wed, 10 Apr 2019 15:47:11 +0000</pubDate><guid>https://www.poeticoding.com/hashing-a-file-in-elixir/</guid><description>&lt;p>A &lt;strong>hash function&lt;/strong> is a function that converts a variable size sequence of bytes (a string, a file content etc.) to a fixed size sequence of bytes, called &lt;strong>digest&lt;/strong>. This means that hashing a file of any length, the hash function will always return the same unique sequence of bytes for that file. It&amp;rsquo;s a sort of digital fingerprint, usually represented by an hexadecimal string of length between 32 and 128 characters.&lt;/p></description></item><item><title>Elixir Stream and large HTTP responses: processing text</title><link>https://www.poeticoding.com/elixir-stream-and-large-http-responses-processing-text/</link><pubDate>Wed, 03 Apr 2019 16:02:19 +0000</pubDate><guid>https://www.poeticoding.com/elixir-stream-and-large-http-responses-processing-text/</guid><description>&lt;ul>
&lt;li>Part 1 - &lt;a href="https://www.poeticoding.com/elixir-streams-to-process-large-http-responses-on-the-fly/">Elixir Stream to process large HTTP responses on the fly&lt;/a>&lt;/li>
&lt;li>Part 2 - &lt;em>this article&lt;/em>&lt;/li>
&lt;/ul>
&lt;p>You find the code, of this and the previous article, on &lt;a href="https://github.com/poeticoding/httpstream_articles" target="_blank" rel="noopener">poeticoding/httpstream_articles&lt;/a> GitHub repo. The code at this repo is not meant for production use, is just part of the examples of these articles.&lt;/p></description></item><item><title>Elixir Streams to process large HTTP responses on the fly</title><link>https://www.poeticoding.com/elixir-streams-to-process-large-http-responses-on-the-fly/</link><pubDate>Wed, 27 Mar 2019 16:48:21 +0000</pubDate><guid>https://www.poeticoding.com/elixir-streams-to-process-large-http-responses-on-the-fly/</guid><description>&lt;ul>
&lt;li>Part 1 - &lt;em>this article&lt;/em>&lt;/li>
&lt;li>Part 2 - &lt;a href="https://www.poeticoding.com/elixir-stream-and-large-http-responses-processing-text/">Elixir Stream and large HTTP responses: processing text&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>This is the first of a two-part article where we see a handy way of handling async HTTP responses.\&lt;/p>
&lt;ul>
&lt;li>In &lt;strong>this&lt;/strong> &lt;strong>first part&lt;/strong> we see how make an Elixir Stream out of a large HTTP response.&lt;/li>
&lt;li>In the &lt;strong>second part&lt;/strong> we will extend the implementation so we can download a large text file, processing lines on the fly.&lt;/li>
&lt;/ul>
&lt;h2 id="first-and-foremost--why">First and foremost &amp;hellip; WHY?&lt;/h2>
&lt;p>Why should we handle HTTP responses with Streams, when we can just simply use something like &lt;code>HTTPoison.get&lt;/code> to receive a response with the data we need?&lt;/p></description></item><item><title>The Primitives of Elixir Concurrency: a Full Example</title><link>https://www.poeticoding.com/the-primitives-of-elixir-concurrency-full-example/</link><pubDate>Tue, 19 Mar 2019 15:39:08 +0000</pubDate><guid>https://www.poeticoding.com/the-primitives-of-elixir-concurrency-full-example/</guid><description>&lt;p>Previous articles about Concurrency in Elixir:\&lt;/p>
&lt;ul>
&lt;li>&lt;a href="https://www.poeticoding.com/spawning-processes-in-elixir-a-gentle-introduction-to-concurrency/">How to spawn an Elixir process&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.poeticoding.com/hey-process-there-is-a-message-for-you/">How to send and receive messages between processes&lt;/a>&lt;/li>
&lt;/ul>
&lt;p>Let’s put in practice what we’ve seen in the last few articles about concurrency. In this article we see how to fully make our &lt;a href="https://www.poeticoding.com/spawning-processes-in-elixir-a-gentle-introduction-to-concurrency/#http_api_requests">initial cryptocurrency example&lt;/a>, using just &lt;a href="https://github.com/edgurgel/httpoison" target="_blank" rel="noopener">HTTPoison&lt;/a> module and &lt;code>spawn&lt;/code>, &lt;a href="https://hexdocs.pm/elixir/Kernel.html#send/2" target="_blank" rel="noopener">send&lt;/a> and &lt;code>receive&lt;/code> to handle concurrency. At the end we will refactor it using &lt;a href="https://hexdocs.pm/elixir/Task.html" target="_blank" rel="noopener">Task&lt;/a>, which makes everything far easier!&lt;/p></description></item><item><title>Hey Process, there is a Message for you!</title><link>https://www.poeticoding.com/hey-process-there-is-a-message-for-you/</link><pubDate>Wed, 13 Mar 2019 16:21:23 +0000</pubDate><guid>https://www.poeticoding.com/hey-process-there-is-a-message-for-you/</guid><description>&lt;p>&lt;a href="https://www.poeticoding.com/spawning-processes-in-elixir-a-gentle-introduction-to-concurrency/">We already saw how to spawn new processes&lt;/a> to run our code concurrently, doing multiple HTTP requests at the same time, getting cryptocurrency prices.&lt;/p>
&lt;p>Without messages and coordination between processes, the only way to see the results was to let each process printing each price once finished.&lt;/p></description></item><item><title>Spawning processes in Elixir, a gentle introduction to concurrency</title><link>https://www.poeticoding.com/spawning-processes-in-elixir-a-gentle-introduction-to-concurrency/</link><pubDate>Wed, 06 Mar 2019 12:35:26 +0000</pubDate><guid>https://www.poeticoding.com/spawning-processes-in-elixir-a-gentle-introduction-to-concurrency/</guid><description>&lt;p>Along with &lt;a href="https://www.poeticoding.com/the-beauty-of-pattern-matching-in-elixir/">pattern matching&lt;/a>, one of the coolest things in Erlang and Elixir is &lt;a href="https://en.wikipedia.org/wiki/Actor_model" target="_blank" rel="noopener">their concurrency implementation based on Actor model&lt;/a>. In this article I introduce concurrency and show how we can start making our code concurrent in Elixir, using processes.&lt;/p>
&lt;h2 id="concurrency">Concurrency&lt;/h2>
&lt;p>We can think of concurrency as dealing with multiple things happening, and progressing, at the same time.&lt;/p></description></item><item><title>The Beauty of Pattern Matching in Elixir</title><link>https://www.poeticoding.com/the-beauty-of-pattern-matching-in-elixir/</link><pubDate>Tue, 19 Feb 2019 12:01:31 +0000</pubDate><guid>https://www.poeticoding.com/the-beauty-of-pattern-matching-in-elixir/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/jbuSdZH-14w" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;h2 id="transcript">Transcript&lt;/h2>
&lt;p>One of the reasons I fell in love with Elixir is pattern matching and how it can be extensively used all over the code.&lt;/p>
&lt;h2 id="match-operator">Match Operator&lt;/h2>
&lt;p>Let&amp;rsquo;s start the interactive Elixir console, &lt;code>iex&lt;/code> and let&amp;rsquo;s do what is seems to be a normal assignment&lt;/p></description></item><item><title>Download Large Files with HTTPoison Async Requests</title><link>https://www.poeticoding.com/download-large-files-with-httpoison-async-requests/</link><pubDate>Wed, 13 Feb 2019 16:37:55 +0000</pubDate><guid>https://www.poeticoding.com/download-large-files-with-httpoison-async-requests/</guid><description>&lt;p>With &lt;a href="https://github.com/edgurgel/httpoison" target="_blank" rel="noopener">HTTPoison&lt;/a> is really easy to do HTTP requests in Elixir. If we need to get the latest BTC-USD exchange rate from the Coinbase API, we just use the &lt;code>HTTPoison.get!&lt;/code> passing the url and query parameters.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-elixir" data-lang="elixir">&lt;span class="line">&lt;span class="cl">&lt;span class="n">iex&lt;/span>&lt;span class="o">&amp;gt;&lt;/span> &lt;span class="n">url&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="s2">&amp;#34;https://api.coinbase.com/v2/prices/spot&amp;#34;&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">iex&lt;/span>&lt;span class="o">&amp;gt;&lt;/span> &lt;span class="n">resp&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nc">HTTPoison&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">get!&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">url&lt;/span>&lt;span class="p">,&lt;/span> &lt;span class="p">%{},&lt;/span> &lt;span class="ss">params&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="p">[&lt;/span>&lt;span class="ss">currency&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;USD&amp;#34;&lt;/span>&lt;span class="p">])&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">%&lt;/span>&lt;span class="nc">HTTPoison.Response&lt;/span>&lt;span class="p">{&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="ss">body&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="s2">&amp;#34;{\&amp;#34;data\&amp;#34;:{\&amp;#34;amount\&amp;#34;:\&amp;#34;3585.005\&amp;#34; ... }}&amp;#34;&lt;/span>&lt;span class="p">,&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="n">...&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl"> &lt;span class="ss">status_code&lt;/span>&lt;span class="p">:&lt;/span> &lt;span class="mi">200&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="p">}&lt;/span> 
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">iex&lt;/span>&lt;span class="o">&amp;gt;&lt;/span> &lt;span class="p">%{&lt;/span>&lt;span class="s2">&amp;#34;data&amp;#34;&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="p">%{&lt;/span>&lt;span class="s2">&amp;#34;amount&amp;#34;&lt;/span> &lt;span class="o">=&amp;gt;&lt;/span> &lt;span class="n">amount&lt;/span>&lt;span class="p">}}&lt;/span> &lt;span class="o">=&lt;/span> &lt;span class="nc">Jason&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">decode!&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">resp&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">body&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="n">iex&lt;/span>&lt;span class="o">&amp;gt;&lt;/span> &lt;span class="nc">String&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="n">to_float&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">amount&lt;/span>&lt;span class="p">)&lt;/span>
&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="mf">3585.005&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We easily get the response with a JSON body containing the information we need. We then use a library like &lt;a href="https://github.com/michalmuskala/jason" target="_blank" rel="noopener">Jason&lt;/a> to de-serialise the JSON string and then get the amount using pattern matching.&lt;/p></description></item><item><title>Connecting Elixir Nodes with libcluster, locally and on Kubernetes</title><link>https://www.poeticoding.com/connecting-elixir-nodes-with-libcluster-locally-and-on-kubernetes/</link><pubDate>Wed, 06 Feb 2019 12:57:02 +0000</pubDate><guid>https://www.poeticoding.com/connecting-elixir-nodes-with-libcluster-locally-and-on-kubernetes/</guid><description>&lt;div class="video">&lt;iframe src="https://www.youtube-nocookie.com/embed/FARtObrKr5I" title="YouTube video" loading="lazy" allow="accelerometer; encrypted-media; gyroscope; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin">&lt;/iframe>&lt;/div>

&lt;p>In the last few articles we saw how to make our Phoenix chat app distributed; at the beginning with Redis, and after with distributed Elixir connecting the nodes together.&lt;/p>
&lt;p>We had just one problem; we had to manually connect to the nodes in the IEX console. This is an issue in production. In this video we will see how to automatically cluster the Phoenix chat nodes using the libcluster library locally, and on a Kubernetes cluster with a dynamic number of nodes.&lt;/p></description></item><item><title>Distributed Phoenix Chat using Redis PubSub</title><link>https://www.poeticoding.com/distributed-phoenix-chat-using-redis-pubsub/</link><pubDate>Wed, 23 Jan 2019 18:21:34 +0000</pubDate><guid>https://www.poeticoding.com/distributed-phoenix-chat-using-redis-pubsub/</guid><description>&lt;p>In the previous article, &lt;a href="https://www.poeticoding.com/create-a-high-availability-kubernetes-cluster-on-aws-with-kops/">Create a High-Availability Kubernetes Cluster on AWS with Kops&lt;/a>, we have seen how to create a Kubernetes cluster and how to deploy the Phoenix Chat app. The single node configuration worked well, but when we tried to scale out we saw that the messages were not sent to all the browsers.&lt;/p></description></item><item><title>Processing Large CSV files with Elixir Streams</title><link>https://www.poeticoding.com/processing-large-csv-files-with-elixir-streams/</link><pubDate>Thu, 10 Jan 2019 14:21:24 +0000</pubDate><guid>https://www.poeticoding.com/processing-large-csv-files-with-elixir-streams/</guid><description>&lt;p>We need to process a large CSV file of minute by minute volume and prices. Our task is pretty simple: we just want to get the first line of the year 2015, with valid data. At first, this seems an easy task we could tackle with &lt;code>String.split&lt;/code>, &lt;code>Enum.map&lt;/code>/&lt;code>filter&lt;/code>/&lt;code>find&lt;/code>. But what happens when the CSV file is &lt;strong>large&lt;/strong>?&lt;/p></description></item></channel></rss>