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 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 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. | |
| # Elixir v1.0 | |
| defmodule Rules do | |
| defmacro __using__(_) do | |
| quote do | |
| import unquote(__MODULE__) | |
| @before_compile unquote(__MODULE__) | |
| @rules [] | |
| end | |
| end | |
| # This demonstrates that, when using async/await, a crash in the task will crash the caller | |
| defmodule Tasker do | |
| def good(message) do | |
| IO.puts message | |
| end | |
| def bad(message) do | |
| IO.puts message | |
| raise "I'm BAD!" | |
| end |
| # Aggregates are just collections of command functions, which emit events, | |
| # and event handlers, which mutate state. | |
| # In order to hold state, they should be also structs. | |
| # There is no new() function because aggregates aren't supposed to appear | |
| # out of the blue, they are always the result of a command. | |
| # In this case, %OpenAccount{}. | |
| defmodule Bank.Account do | |
| defstruct [:account_number, :balance] |
| # -*- mode: ruby -*- | |
| # vi: set ft=ruby : | |
| Vagrant.configure(2) do |config| | |
| config.vm.box = "ubuntu/trusty64" | |
| config.vm.network "private_network", ip: "192.168.33.10" | |
| config.vm.provision "shell", inline: <<-SHELL | |
| wget https://packages.erlang-solutions.com/erlang-solutions_1.0_all.deb && sudo dpkg -i erlang-solutions_1.0_all.deb | |
| sudo apt-get update | |
| sudo apt-get install -y nodejs |
| /** | |
| * ## Merging mixin views in backbone.js ## | |
| * | |
| * really just more a test for tumblr gistr | |
| */ | |
| /** | |
| * Merge the mixin (a Backbone.View) into another Backbone.View. Automatically merge events, defaults, and call the parent initializer. | |
| **/ | |
| function mergeMixin(view, mixin) { |