Map [1]
| Operation | Time Complexity |
|---|---|
| Access | O(log n) |
| Search | O(log n) |
| Insertion | O(n) for < 32 elements, O(log n) for >= 32 elements [2] |
| Deletion | O(n) for < 32 elements, O(log n) for >= 32 elements |
| const Hooks = { ViewportResizeHooks} | |
| const connectLiveSocket = () => { | |
| const csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute('content') | |
| const liveSocket = new LiveSocket('/my_app/live', Socket, { | |
| params: { | |
| _csrf_token: csrfToken, | |
| viewport: { | |
| width: window.innerWidth, | |
| height: window.innerHeight |
| defmodule UniqueUsername do | |
| @behaviour Commanded.Middleware | |
| alias Commanded.Middleware.Pipeline | |
| def before_dispatch(%Pipeline{command: %RegisterUser{} = command} = pipeline) do | |
| %RegisterUser{username: username} = command | |
| case Repo.insert(%Username{username: username}) do | |
| {:ok, _} -> |
| docker pull postgres:12-alpine | |
| docker run --rm \ | |
| --name postgres10 \ | |
| --tmpfs=/pgtmpfs \ | |
| -e PGDATA=/pgtmpfs \ | |
| -e POSTGRES_PASSWORD=postgres \ | |
| -e POSTGRES_USER=postgres \ | |
| -p 5432:5432 \ | |
| postgres:10-alpine |
| def wait_until(timeout \\ 1_000, fun) | |
| def wait_until(0, fun), do: fun.() | |
| def wait_until(timeout, fun) do | |
| fun.() | |
| rescue | |
| ExUnit.AssertionError -> | |
| :timer.sleep(10) | |
| defmodule EventStore.CategoryStreamLinker do | |
| @moduledoc """ | |
| Links streams from aggregate instances to their respective category streams. | |
| example: events from stream_uuid of `contractors_contract-07c52787-da0c-444f-9783-5d380f7093f9` will be | |
| linked to stream_uuid of `contractors_contract`. | |
| """ | |
| use Commanded.Event.Handler, | |
| application: My.App, |
| defmodule InvalidEvent do | |
| @doc """ | |
| Module to be used when an event cannot be deserialized from the event store. | |
| The payload field will be populated with the source event data if | |
| deserialization is possible. | |
| Receiving this event usually indicates an event has been removed or renamed in | |
| the source code between releases. Deserializing to this invalid event module | |
| allows the application to continue running, otherwise it would terminate as |
What I expect from some system managing storage of streams of events, intended to be used in an event-sourced system.
| defmodule Default.Behaviour do | |
| @moduledoc """ | |
| Creates a behaviour that carries its own default implementation. | |
| When used into a behaviour module, when that module in turn is used, all functions | |
| defined on it are given to the using module. | |
| This allows you to have concrete implementations of the behaviour's default functionality | |
| for testing, unlike cramming them all into a __using__ macro. | |