πŸ”— Formatting Phoenix HEEx Templates in VS Code

I'm currently in the thick of a massive update to our Phoenix LiveView course. (It'll be a free update if you already own it! 😉) And yesterday I discovered a better way to auto-format HEEx templates in VS Code. Indeed, formatting .heex files and ~H sigils is fairly straig … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Understanding Policies in Laravel

Laravel Policies are responsible for authorizing an action on a resource in your application. They bundle the authorization logic for a particular model or resource, allowing you to keep your code neat and maintainable. This post will focus more on Laravel Policies, their setup, … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Formatting JSON on save with VS Code

To format JSON on save in VS code, just add ths to your settings.json file: 1{ 2 "[json]": { 3 "editor.formatOnSave": true 4 }, 5 "[jsonc]": { 6 "editor.formatOnSave": true 7 }, 8} | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Get more specific when asserting events dispatched

Laravel offers so many excellent test helpers that let you write expressive tests with minimal effort. For example, you can use Event::assertDispatched in a feature test to assert that a specific event was dispatched. This method allows you to just specify the event name, but you … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— The Science behind Ultra-Wide Rims

When we started riding wide, supple tires more than a decade ago, we wondered about rim width. Do extra-wide tires need extra-wide rims? Figuring this out was part of our research into tire and bicycle performance. Last week, Zipp introduced their new 303 XPLR gravel wheels. Thei … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Free Disk Space (Ubuntu) - GitHub Marketplace

A customizable GitHub Actions to free disk space on Linux GitHub Actions runners. On a typical Ubuntu runner, with all options turned on (or not turned off rather), this can clear up to 31 GB of disk space in about 3 minutes (the longest period is calling apt to uninstall package … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— GitHub - stefanzweifel/laravel-backup-restore

A package to restore database backups made with spatie/laravel-backup. ⚠️ This post links to an external website. ⚠️ | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Alles wat je moet weten over Critical Power

Critical power (CP) is momenteel erg in de mode. Het wordt besproken door coaches, vergeleken door atleten, en eerlijk gezegd klinkt het gewoon een beetje sexyer dan zijn neef, functional threshold power (FTP). Hoewel de metingen qua aard vergelijkbaar zijn, hebben ze enkele subt … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Using a forked package in Laravel

If you want to use a forked package in Laravel, here are the steps you need to follow: Create a fork of the package on GitHub. Create a new branch in the fork which will contain your changes. Make the necessary changes to the package in the new branch. Push the changes to the for … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Stream: Go 10 Week Backend Eng Onboarding

Welcome to Stream. If you're reading the public version of this consider checking out our careers page. We're currently hiring for Go roles of entry to principal/director levels. Stream is an API for building chat, live video and activity feeds. We power thousands of apps and rea … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Laravel TipπŸ’‘: Magic Factories Methods

We use factories a lot. Did you know about the "for[Relation]" and "has[Relation]" magic methods? You just need to make sure you have the relationship set up in your model and you are good to go 🚀 1// You need to have User and Posts factories 2$user = User::factory() 3 … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Security Tip: Stop Using MD5 and SHA-1!

MD5 is like a cockroach - it's persistent and pops up everywhere, but one thing is very clear: you need to stop using it (and SHA-1 too)! ⚠️ This post links to an external website. ⚠️ | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Dispatching a closure after a response in Laravel

Dispatching closure jobs after response can be a really nice way to do some cleanup 💅: 1$pdf->store('file.pdf'); 2 3// Delete the file after the response has been sent 4dispatch(fn () => Storage::delete('file.pdf'))->afterResponse(); 5 6return Zip::download('file.pdf'); … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— The 12,000km Setup

After completing three editions of The Transcontinental Race (TCR), winning two and placing second in another, Christoph Strasser's TCR packs remain unchanged. What can we learn from the packs that have crossed a continent three times? ⚠️ This post links to an external website. ⚠ … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Creating a copy of a database in PostgreSQL

Postgres allows the use of any existing database on the server as a template when creating a new database. I'm not sure whether pgAdmin gives you the option on the create database dialog but you should be able to execute the following in a query window if it doesn't: 1CREATE DATA … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Add columns with custom types in Laravel Migrations

I was certainly surprised when I found out that there is no built-in method to create table columns with custom types in Laravel migrations. The default list of column types available in Laravel may be more than enough for most applications, but, I think there are some valid use … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Installing psql version 16 on Ubuntu

To install the psql client version 16 on Ubuntu, you need perform a couple of steps. First, update the package index and install required packages: 1sudo apt update 2sudo apt install gnupg2 wget nano Add the PostgreSQL 16 repository: 1sudo sh -c 'echo "deb http://apt.postgresql. … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— If you mock, are you even testing?

Have you ever felt like you're making the code harder to read for the sake of testing? Imagine, you have this existing code and it's not tested. It does a bunch of side-effects. People say you should put that code under tests before touching it. So you begin to follow advice like … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Retrieval-Augmented Generation (RAG) with Elixir

This is my initial attempt at implementing RAG in Elixir. My goal is to develop a system similar to PrivateGPT by gaining a deeper understanding of the concepts and improving chunking and metadata techniques. For this project, I intentionally avoided using LangChain or OpenAI to … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Why Mocking Data is a Bad Practice for Testing

Mocking data is a common technique for testing software that depends on external sources of data, such as databases, web services, or APIs. Mocking data means creating fake or simulated data that mimics the real data, but without actually interacting with the external source. Moc … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Render a Phoenix template to a string

Templates in a Phoenix application ultimately get compiled to functions that can be quickly rendered with the necessary data. We can take a look at how a template will be rendered using Phoenix.View.render_to_string/3. First, we need a template: 1# user.html.eex 2

<%= @user.first_name %>

3
<%= @user.username %> (<%= @user.email %>)
... | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Trainen op vermogen

Wielrennen is van oudsher een conservatieve sport. Een sport waar omvang en kwaliteit van de geleverde trainingsarbeid nog steeds niet in de juiste verhouding staan. De hartslagmeter heeft daar weinig of geen verandering in kunnen brengen omdat de vereiste intervalarbeid niet via … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Checking and updating the version of Phoenix

To check the installed version: 1$ mix phx.new -v 2Phoenix installer v1.7.11 To update, you can do this: 1$ mix archive.install hex phx_new 2Resolving Hex dependencies... 3Resolution completed in 0.041s 4New: 5 phx_new 1.7.14 6* Getting phx_new (Hex package) 7All depende … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Zo word je sterker met minder training

'Ik ben niet goed, ik denk dat ik gewoon harder moet trainen.' Dat is zo'n beetje de standaard zin van iedere fietser die niet tevreden is met zijn of haar vorm. Was het inderdaad maar zo simpel dat je gewoon harder moet trainen, want vaak is dat helemaal niet het geval. Veel fie … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Reversing a list using Elixir

To efficiently work with and transform lists in Elixir, you will likely need utilize a list reversing function from time to time. Your best bet is to reach for the Erlang implementation which is available as part of the lists module. Here are a couple examples of how to use it: 1 … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Interview with Jan Heine of RenΓ© Herse: Low Resistance

Inspired by randonneurs of a past era, Jan Heine revived the RenΓ© Herse brand 13 years ago to focus on building tires suitable for his favourite adventures in the Cascade Mountains, while also saying true to the brands nearly century-old legacy. ⚠️ This post links to an external … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Get git details from Elixir

The following snippet allows you to extract the SHA1 of the git commit from within elixir. It is useful to attach the SHA1 to your release or code so that if therea are any issues you can quickly checkout the commit and look into it. You can also get the branch name if required. … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— The RAG Engineer's Guide to Document Parsing

I made a post with my buddy Daniel Warfield breaking down why parsing matters so much for RAG and comparing some of the different approaches based on our experience working with Air France, Dartmouth a big online publisher and dozens of other projects with real data ⚠️ This post … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ One quick way to find out which functions you're executing

When running tests, we sometimes want to know which functions are being executed. You could write custom dbg/1 statements in each of the functions: 1def function_a do 2 dbg(:function_a) 3end 4 5def function_b do 6 dbg(:function_b) 7end 8 9... 10 11def function_z do 12 … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— CSS One-Liners to Improve (Almost) Every Project

A collection of simple one-line CSS solutions to add little improvements to any web page. ⚠️ This post links to an external website. ⚠️ | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Quick Access to Repo Config in Elixir

Sometimes you want to find out information about your Repo configuration. You can dive into the config files and ENV variables to sort out what's being used… or you can take the easier path! In an iex session (that has your Repo available), access the configuration via Repo.confi … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Checking Efx - testable effects for Elixir

Mocking in Elixir is always a hot topic, mainly because of people coming from different other technologies having different expectation. The most "cannonical" solution, Mox, gives a lot of security with regard to what the fake implementation returns, but requires a bit of a cerem … | Continue reading


@yellowduck.be | 3 months ago

πŸ₯ Testing streamed dowloads in Laravel

Imagine you are using streamed downloads in your Laravel controllers like this: 1use App\Services\GitHub; 2 3return response()->streamDownload(function () { 4 echo GitHub::api('repo') 5 ->contents() 6 ->readme('laravel', 'laravel')['contents']; 7} … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Setting up Laravel Valet in 2024 | Undocumented Docs

During my long relationship with PHP I've tried many ways of organizing my local development environment, from Denwer in 2004, WAMP/MAMP/LAMP, to Vagrant and Docker in 2010s. However, for the last few years, I have primarily used the excellent Laravel Valet. But I found that the … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Igniter - Rethinking code generation with project patching

Ash Framework is ~4 years old, and we've only just now introduced the ability to generate resources, or new Elixir projects with Ash installed using a CLI. We've added these thanks to our latest project Igniter. Before I talk about our new generators, however, I'd like to talk ab … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— How to respond to channel broadcasts in a Phoenix LiveView app layout (global broadcasts)

In a project I'm working on, I have a menu in my app layout that displays a number of unread messages. Because this is in the app layout, it does not belong to any one LiveView instance, but to all of them. When a new message comes in, or a message is marked as read, there is a b … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Building Real-Time Features with Phoenix Live View and PubSub

Integrate Phoenix PubSub with LiveView to build real-time features capable of broadcasting updates across a set of clients. ⚠️ This post links to an external website. ⚠️ | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Creating an RSS feed in Elixir and Phoenix

Hand-rolling an RSS feed with Elixir and Phoenix is pretty straightforward. You just need a list of feed items, a controller, a template, and a view. In this article, I'll assume the list of items is a list of blog articles. ⚠️ This post links to an external website. ⚠️ | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Why RSS Content Module is Popular - Including HTML Contents

RSS has long had the element that can be used to include the contents of an . For example, you could use it to include the entire contents of a blog post; or just a summary of it. However, the RSS element is only suppose to be used to include plain text data. This obviously lim … | Continue reading


@yellowduck.be | 3 months ago

πŸ”— Fine Tuning Full Text Search with PostgreSQL 12

Full Text Indexing in PostgreSQL is easy... and it's not. It's not difficult to do simple keyword searches, but fine-tuning your index with weighting and parsing rules takes some effort. ⚠️ This post links to an external website. ⚠️ | Continue reading


@yellowduck.be | 3 months ago

πŸ”— An ORDER BY statement improved our query times by 100x

PostgreSQL queries can be sped up by creating the right indices, and making sure that the indices are being used. It's a tale as old as SQL databases - there's a critical code path being hit many times per second, but its queries are inexplicably slow. ⚠️ This post links to an ex … | Continue reading


@yellowduck.be | 4 months ago

πŸ”— Retrieval Augmented Generation: What It Is and How to Start Using It

If you've spent any time in working with Large Language Models (LLMs) over the past two years, you've almost certainly heard of Retrieval Augmented Generation (RAG). RAG combines the strengths of information retrieval with the language capabilities of LLMs. RAG as a concept is re … | Continue reading


@yellowduck.be | 4 months ago

πŸ”— Dependabot's dependency grouping is awesome

I've been using GitHub's Dependabot since it was released around 4 years ago, and to a large extent, it's been great. Except for one thing: the sheer amount of pull requests Dependabot would open for dependency updates. For some of my repositories it became more of a chore to kee … | Continue reading


@yellowduck.be | 4 months ago

πŸ”— Just Use Postgres for Everything

TLDR; just Postgres for everything. We have invited complexity through the door. But it will not leave as easily. There is Radical Simplicity though. One way to simplify your stack and reduce the moving parts, speed up development, lower the risk and deliver more features in your … | Continue reading


@yellowduck.be | 4 months ago

πŸ”— Serving a billion web requests with boring code

When I worked as a contractor to the US government at ad hoc, I was fortunate enough to get the opportunity to design large parts of a relaunch of medicare plan compare, the US government site through which hundreds of thousands of medicare recipients purchase their health care p … | Continue reading


@yellowduck.be | 4 months ago

πŸ”— TIL: 8 versions of UUID and when to use them

About a month ago1, I was onboarding a friend into one of my side project codebases and she asked me why I was using a particular type of UUID. I'd heard about this type while working on that project, and it's really neat. So instead of hogging that knowledge for just us, here it … | Continue reading


@yellowduck.be | 4 months ago

πŸ”— Erlang | mise-en-place

The following are instructions for using the erlang core plugin. This is used when there isn't a git plugin installed named "erlang". The code for this is inside the mise repository at ./src/plugins/core/erlang.rs. ⚠️ This post links to an external website. ⚠️ | Continue reading


@yellowduck.be | 4 months ago

πŸ”— Installing Elixir and Erlang using Asdf In Ubuntu

During my 13th week of internship , I was assigned the task of cloning a project from GitLab. The project was built using Elixir and ran on a Phoenix server, introducing me to new challenges. To start, I installed Elixir, Erlang, and other essential dependencies on my local machi … | Continue reading


@yellowduck.be | 4 months ago