Welcome to ElixirDrops!

Hello there and welcome to the ultimate hub for the Elixir community! Whether you're a seasoned developer or just starting your journey, ElixirDrops is the perfect place to discover, share, and discuss the best tips and tricks for mastering Elixir. Sign in to explore, learn and become a contributor on this platform.

Pattern matching on Bitstrings

Assume that you have a long string of text that you want to display to the user. You want to display a maximum of 60 characters and add an ellipsis if...
Deankinyua

Deankinyua

16 hours ago

Fixing Wallaby's "Invalid Session ID" Error

When running Wallaby integration tests in your Phoenix application, you might encounter this cryptic error:...
almirsarajcic

almirsarajcic

2 days ago

Using the "Use" Elixir Macro

Suppose you have the following module directives in your current module:...
Deankinyua

Deankinyua

3 days ago

Offset-based pagination in Elixir

Pagination is a technique used to break a large dataset into manageable “pages” (chunks) of results. It’s essential for: + UI rendering (e.g., showin...
Deankinyua

Deankinyua

3 days ago

Testing Oban Workers

Background processing refers to the execution of tasks as separate, detached processes. Oban is a robust background job framework that is widely used ...
Deankinyua

Deankinyua

8 days ago

Reproducing failed CI tests locally with seeds

When tests fail in CI, you can use the test seed to reproduce the exact same test run locally. This is especially useful for debugging flaky tests or ...
almirsarajcic

almirsarajcic

9 days ago

Creating and hosting sitemaps in Elixir/Phoenix

Recently, we implemented sitemap generation for ElixirDrops, so I thought I'd share our approach. Since we don't store sitemaps in git and hosting pr...
almirsarajcic

almirsarajcic

16 days ago

Ecto fragments for complex queries

Sometimes when writing Ecto queries, you might discover that the conventional approach doesn't quite cut it. This is where fragments come in, which ar...
Deankinyua

Deankinyua

17 days ago

Capturing Logs in Tests

Sometimes when you writing functions that may produce errors, you might want to log the error in the terminal :...
Deankinyua

Deankinyua

22 days ago

Temporarily changing app config in tests

When testing functionality that depends on application configuration, you can temporarily set specific config values and ensure they're restored after...
almirsarajcic

almirsarajcic

23 days ago

Multi-process collaboration in Mox

Mox enforces process-based verification, meaning only the process that defines expectations is allowed to call the mock by default. This can prove pro...
Deankinyua

Deankinyua

25 days ago

Gracefully handle 404s and other errors in Phoenix using Plug.ErrorHandler

Instead of letting your Phoenix app crash with ugly errors, add this clean error handler:...
amos-kibet

amos-kibet

28 days ago

Cleaning up after tests (on_exit)

When your tests create files, database records, or other side effects, you need to clean them up regardless of whether the test passes or fails. Data...
almirsarajcic

almirsarajcic

1 month ago

Auto-disappearing flash messages in Phoenix LiveView

Use this LiveView hook to make flash messages automatically disappear after 5 seconds in your Phoenix app. Create the JavaScript hook file:...
almirsarajcic

almirsarajcic

1 month ago

Enhanced missing gettext translations check in CI

Earlier I wrote about a check for strings that haven't been extracted yet to .pot and .po gettext files (link). Still, extracting them is not enough....
almirsarajcic

almirsarajcic

1 month ago