Elixir Blog Posts

A list of things a newcomer could skip vs things they need to start immediately.

2 Likes

I wrote a blog post for creating a simple infinitescroll page using LiveView, Intersection Observer API and JS interop using phx-hook.

2 Likes

“I am the classic example - my background is mainly Ruby” - he said. Why Michał changed his programming road?

Meet Michał Buszkiewicz - a Senior Elixir Dev himself! He’ll give us his insights on what it means to be a SENIOR Elixir programmer, share some of their favourite features, and talk through how he developed over time (and how you can develop yourself!)

https://curiosum.com/blog/junior-to-senior-who-is-senior-elixir-dev-interview-michal-buszkiewicz

Elixir is a hot topic in programming right now. I could tell you about its benefits, but why don’t we just go ahead and ask this guy who knows everything there’s to know?

Learn more from the interview!

1 Like

Elixir code style, a brief example

The other day I wrote

  def build_string(a, b, ops, sep) do
    Enum.reduce(ops, "", fn op, acc ->
      acc <> sep <> Integer.to_string(calculate(a, b, op))
    end)
    |> String.trim_leading(sep)
  end

For a function, and was annoyed by how ugly it was. Improved version is

  def build_string(a, b, ops, sep) do
    ops
    |> Enum.map(&calculate(a, b, &1))
    |> Enum.join(sep)
  end

The real point of the blog post is to avoid introducing cases like the first function, which requires a call to String.trim_leading.

Also can use Enum.map_join/3 like:

def build_string(a, b, ops, sep) do
  Enum.map_join(ops, sep, &calculate(a, b, &1))
end

Good to see blog posts like this too!

3 Likes

Elixir 1.14.0 added Kernel.dbg/2 to improve developer experience. I spent some time playing around with dbg as a replacement for IO.inspect. Here is a post with some examples of debugging a Phoenix app.

Learn how dbg can replace IO.inspect to enhance your debugging workflow.

3 Likes

Elixir is gaining in popularity and as a result many SaaS companies are now using Elixir and Phoenix as the basis of their technology stack. Here are some of the most interesting examples.

8 SaaS Using Elixir and Phoenix in Production

A quick dive into ExUnit’s @tag-attributes and how to use them for clean and explicit test configuration

3 Likes

Many consider Elixir to be Ruby’s successor, so we decided to settle that. Together with CTO, Michał Buszkiewicz and experienced Elixir & React Developer, Krzysztof Janiec, we decided to compare the two programming languages.
Elixir vs Ruby in Depth Comparison

I wrote a blog post about how we have been using Ecto Queries for search / filter forms in web applications. It aims at the same problem as the ransack gem in the rails world, but with less magic.

9 Likes

Thanks for sharing! Great post and I love the accompanying Livebook as a means of extending the content without adding too much bloat to the post itself. That’s a great pattern for future content like that.

1 Like

I took a deep-dive into Upserts with Ecto and investigated odd behaviors like:

  • Why does Ecto return a new binary_id every time I upsert a schema?
  • Why do upserts introduce gaps in the IDs of schemas?

This and more is all answered here now:

4 Likes

haha two butts and kills people, anyways great content!

1 Like

And another one. This time I explore using placeholders in Repo.insert_all/3. If you ever used insert_all/3 you probably sent waaaaaaaay more data than you had to. I explain how to never ever do this terrible mistake again, here:

7 Likes

I wrote a blog post for creating a simple infinitescroll page using LiveView, Intersection Observer API and JS interop using phx-hook.

Here’s the working/canonical link for building simple infinite scroll using LiveView (and in less than 30 lines of JS).

I wrote a blog post on how we used the Observer to debug some weird memory spikes in our Elixir gateway app. It includes some pretty interesting learnings about how SSL certs are handled in processes. It was a fun debug adventure :smiley:

6 Likes

Wrote a blog post on SQL injection in Phoenix. Covers how Ecto really discourages you from writing insecure code, what a vulnerable function looks like, and using Sobelow to detect this.

Detecting SQL Injection in Phoenix with Sobelow

1 Like

In this post, I will introduce you to the world of cybersecurity and tell you how Elixir programming language works in this environment.
Elixir vs Cybersecurity - is Elixir Language a Safe Technology?

2 Likes

Today’s blog post is about exclusion constraints in Postgres and how to prevent double-bookings of appointments with them. It’s a nice dive into how to execute custom SQL code in your migrations and how timestamp ranges work in Posgres.

You can use this if you want to prevent any double-bookings of e.g. appointments, schedules, meetings, etc.

3 Likes

New post describing how to implement a scrolling data table without running out of memory in Phoenix LiveView