A picture's worth a thousand words. It can be confusing to explain to a LiveView newbie just what the lifecycle of a LiveView process looks like. I made a flow chart to help visualize how an HTTP Request becomes a stateful LiveView
How can I measure the similarity between two images?
I would like to compare a screenshot of one application (could be a Web page) with a previously taken screenshot to determine whether the application is displaying itself correctly. I don't want an...
Given a set of r random values from a large set (of size N), I have been using the formula 1-exp(-r**2/(2N)) to approximate the probability of a collision. It assumes that r is much smaller than N. The formula suggests that if you have hundreds of millions of random 64-bit numbers, you will start getting … Continue reading How accurate is the birthday’s paradox formula?
Building Self-referential Associations in Elixir/Phoenix
Self-referential association is used to associate a model with itself. It's pretty common to have this kind of association to build relationships in today's social media applications - Twitter, Mastodon, Facebook, etc. However, the association model ...
If you take a square and rotate it 90 degrees, you get back an identical square. We say the square is rotationally symmetric. Similarly, if you reflect it...
Coding of domain names to wire format at gigabytes per second
When you enter in your browser the domain name lemire.me, it eventually gets encoded into a so-called wire format. The name lemire.me contains two labels, one of length 6 (lemire) and one of length two (me). The wire format starts with 6lemire2me: that is, imagining that the name starts with an imaginary dot, all dots … Continue reading Coding of domain names to wire format at gigabytes per second
State Machine in Elixir using Erlang’s gen_statem Behaviour
Finite state machine is a common phenomenon in programs that need to maintain multiple states and transition among them based on certain actions. Erlang’s gen_statem provides a generic state machine behaviour. In this article, I will implement a simp...
How To Add Magic Link Login to a Phoenix LiveView App
Magic link authentication has become an increasingly common way to sign in to web applications. Magic link authentication is where one receives a link in their email to sign in to a web application rather than enter their email and password (Slack is a popular example of this sign in flow)
Let's look at how we can use `:noreply` and `GenServer.reply` to allow a GenServer to continue working even while its `call`ers wait for the result of long-running operations.
Tools to visualize an HTML document tree (DOM tree)
I want to visualize the document structure of a HTML website.
What I would like to have is something like this:
Are there any known tools that do this and where the results can be saved as a bit...
A visualizer to help you learn how the DOM Event system works through exploration. Explore event phases, stopping events, canceling events, passive events and more. Explore DOM Events →
In this post, we delve headfirst into the BitTorrent protocol, understanding the process of downloading a torrent by building a minimal torrent client from scratch.