Thinking Elixir News 145
Episode 145 of Thinking Elixir. News covers the EEF election results, a new Livebook 0.9 release, Docker reverses directions, how Github spilled the secret beans, full text search with a new Haystack lib, how intentionally vulnerable Phoenix apps are educational, the timescale hex package grows up some more, and more!
Phoenix LiveView's new JS.exec/3 function!
Phoenix 1.7.2 shipped a new JS.exec/3 function.
It allows us to execute JS defined in a different dom element.
Why would we want that?
If we’re repeating the same code in multiple places (e.g. hide modal), even if we’re using a helper function to reduce code duplication, we might still be sending that several times in the payload!
JS.exec/3 allows us to reduce that payload by only including the JS command in a single place!
Here I refactor a modal component 👉 https://youtu.be/fZd58xxY4pU 👀
Elixir Security: Sobelow 0.12.1 Released, Adds LiveView Support
Sobelow version 0.12.1 was released recently, adding support for HEEx templates, which are used in Phoenix LiveView. Sobelow is a static analysis tool for finding security issues in Elixir and Phoenix code. If you’re using Elixir in production, running Sobelow is highly recommended, because it automatically checks for common security issues.
LiveView Streams with Pagination
I’ve run across this several times now.
How do we use LiveView streams with pagination (for example, with infinite scroll) where we want to insert more than one element?
This is what I do 👇
Enum.reduce(elements, socket, fn socket, el ->
stream_insert(socket, :elements, el)
end)
See it in action 👉 https://youtube.com/shorts/oR88yGtw89w 👀
Connect Livebook to a Local Phoenix Server
In this quick video, Amos shows you how to connect your Livebook to a local Phoenix server.
Elixir/Phoenix Security: What is CSRF via Action Reuse?
Misconfiguration of the Phoenix router can lead to CSRF via a GET request to your controller action. Learn more in this article.
Thinking Elixir News 144
Episode 144 of Thinking Elixir. A collection of ML stories, fixing an 8-year old LiveView bug, Docker drama, speeding up Dialyzer in CI, a new Credo release and more!
Debugging Phoenix LiveView with open_browser/2 Tracey Onim
Find out how to debug Phoenix LiveView tests with open_browser/2: https://blog.appsignal.com/2023/03/28/debugging-phoenix-liveview-with-open-browser2.html
Between the Ctrl-C's
Have you ever noticed the little menu that shows up after you press Ctrl-C
the first time in IEx and just before you press it again? What is that menu for? What can you do with it?
https://blog.sequin.io/between-the-ctrl-cs/
Syncing SQLite and Postgres using Elixir and Erlang
I had a load of fun figuring out everything for making this video on @ElectricSQL. Syncing between SQLite and Postgres. Local first. Active-Active replication.
If you like SQLite AND/OR Postgres. This should be for you. https://www.youtube.com/watch?v=_U5Z8AQy0hc
Using LiveView's New Primitives for Accessibility
Phoenix LiveView 0.18 added new features to manipulate focus and improve accessibility in your Phoenix LiveView apps. In this post, I show you all of these features, and provide real-life examples to demonstrate just how simple it is to use them and enhance your app’s accessibility. https://fly.io/phoenix-files/liveview-accessible-focus/
[Video] Elixir and Phoenix Security, Remote Code Execution (RCE)
Did you miss the webinar on exploiting serialization in Elixir? Don’t worry, the recording is up on the Paraxial.io YouTube channel.
Add full-text search to an Elixir Phoenix application
In this tutorial, we’re going to build a simple Phoenix application based upon NimblePublisher. I will then show you how you can integrate Haystack to add full-text search for your content.
https://culttt.com/2023/03/23/add-full-text-search-to-an-elixir-phoenix-application
Building a Chat App With LiveView Streams
Building a LiveView powered chat app is easier than ever when using Streams! Sophie DeBenedetto shows us how in this article. She createa a Slack-like chat client with infinite scroll back, editing message, deleting messages, and appending new message to the bottom. It’s slick and efficient, not storing any of that data in the LiveView.
https://fly.io/phoenix-files/building-a-chat-app-with-liveview-streams/
Missing the Elixir Slack community? Join the new Elixir Discord!
While we wait for things to get sorted I’ve set up a new discord server for Elixir enthusiasts to gather. Join here! https://discord.gg/HH8Dqbs3
Better function component tests with ~H
There are 2 ways to test Phoenix function components:
- render_component/3
- rendered_to_string/1 + ~H sigil
Use the second one every time!
So much nicer ergonomics ✨and allows us to test more complex components (e.g. with slots). 🎉
Building a full-text search engine in Elixir
This blog post is an overview of how Haystack is built, the motivations for the project, and the design decisions I have made to allow Haystack to be as simple and extendable as possible.
https://culttt.com/2023/03/22/building-a-full-text-search-engine-in-elixir
Dynamic Function Calls
In this episode, we’ll utilize dynamic function calls to build a web-based application that helps people learn Elixir.
Lisbon |> Elixir Meetup 19th Edition
next @LisbonElixir meetup is happening on April 18, 18:30! come join us 🤗 we’d like to thank @bouncemystuff for the meetup space (their office) and @CodeSyncGlobal for the tickets we’ll raffle! 🎟️ 🎫 #elixir #meetup #myelixirstatus @elixirlang @josevalim https://www.meetup.com/lisbon-elixir/events/292379655/