Fixing `Ecto.StaleEntryError` with optimistic locking patterns

Race conditions in concurrent updates cause cryptic Ecto.StaleEntryError crashes in production. The error happens when multiple processes try to updat...
almirsarajcic

almirsarajcic

23 hours ago

Phoenix application configuration

The config folder plays a pivotal role in any phoenix application. Its constituents are normally config.exs, dev.exs, prod.exs, runtime.exs and test.e...
Deankinyua

Deankinyua

yesterday

Hunting down flaky tests with `--repeat-until-failure`

Nothing destroys developer confidence like tests that randomly fail in CI. One day your build is green, the next it's red with the exact same code. Th...
almirsarajcic

almirsarajcic

7 days ago

Impelementing Infinite Scroll in Phoenix

Infinite scroll is a listing-page design approach seen a lot on widely used apps such as TikTok and Instagram to keep the user engaged, loading additi...
Deankinyua

Deankinyua

9 days ago

Preventing atom exhaustion attacks with `String.to_existing_atom`

Using String.to_atom/1 on user input is a critical security vulnerability that can crash your entire BEAM VM through atom exhaustion. Here are two app...
almirsarajcic

almirsarajcic

14 days ago

Executing OS processes using Elixir Ports

Ports in Elixir provide us an interface for communicating with external processes by sending and receiving messages. They make it easy to start and ma...
Deankinyua

Deankinyua

19 days ago

Speed up Phoenix with ETS content caching and TTL expiration

Database queries for content-heavy pages become performance bottlenecks fast. Redis adds infrastructure complexity. ETS gives you microsecond lookups ...
almirsarajcic

almirsarajcic

21 days ago

Fine tuning routing for a better UX

Phoenix gives you a very cool and easier way to fine tune your routing and be able to effectively handle cases where, say a user has a typo in the url...
jrowah

jrowah

21 days ago

Verifying Replicate Signatures

Replicate is a platform for running AI models without having to worry about setting up infrastructure. A more simple definition would be "The Cloud bu...
Deankinyua

Deankinyua

27 days ago

Using `@impl Phoenix.LiveView` instead of `@impl true` for clear callback contracts

Stop using @impl true in your Phoenix modules. The Elixir compiler provides much better safety and clarity when you specify the exact behaviour module...
almirsarajcic

almirsarajcic

29 days ago

Sandbox modes in Ecto Testing

A sandbox is an isolated testing environment that enables users to run programs or open files without affecting the application, system or platform on...
Deankinyua

Deankinyua

1 month ago

Pass arguments to Mix aliases with anonymous functions

Need to pass command-line arguments to your Mix aliases? Use anonymous functions instead of strings to capture and forward arguments....
almirsarajcic

almirsarajcic

1 month ago

Extracting repeated type specs to module-level `@type` declarations

Tired of Dialyzer warnings and repetitive type declarations? Clean up your specs by extracting repeated types to the module level. Your code becomes m...
almirsarajcic

almirsarajcic

1 month ago

Debugging GenServer state with `:sys.get_state`

Ever wondered what's actually inside your GenServer's state when things go wrong? Instead of adding debug prints or crashing the process, you can peek...
almirsarajcic

almirsarajcic

1 month ago

Asynchronous operations in Phoenix LiveView

What do you understand by the term "Expensive Computations"? Theoretical computer science defines them as the ones taking the most memory and time to ...
Deankinyua

Deankinyua

1 month ago