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 |
# TODO: Extract into it's own library | |
defmodule AbsintheSocket do | |
require Logger | |
alias Phoenix.Channels.GenSocketClient | |
@behaviour GenSocketClient | |
@control_topic "__absinthe__:control" | |
defdelegate fetch(term, key), to: Map | |
defdelegate get(term, key, default), to: Map |
import "../css/app.scss" | |
import "phoenix_html" | |
import {Socket} from "phoenix" | |
import topbar from "topbar" | |
import {LiveSocket} from "phoenix_live_view" | |
import Alpine from 'alpinejs' | |
window.Alpine = Alpine | |
Alpine.start() | |
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content") |
defmodule MyApp.Foo do | |
@on_definition MyApp.SpecToCallback | |
@spec bar(String.t()) :: String.t() | |
def bar(foobar) do | |
impl().bar(foobar) | |
end | |
defp impl, do: Application.get_env(:my_app, :my_app_foo_impl, __MODULE__.DefaultImpl) | |
end |
# Step 1 | |
def create_subscription(email, plan_id, payment_method_id) do | |
with %User{customer_id: nil, name: name} = user <- | |
Repo.get_by(User, email: email), | |
{:ok, %Stripe.Customer{id: customer_id}} <- | |
Stripe.Customer.create(%{ | |
name: name, | |
email: email, | |
payment_method: payment_method_id, |
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
# This is just a cheat sheet: | |
# On production | |
sudo -u postgres pg_dump database | gzip -9 > database.sql.gz | |
# On local | |
scp -C production:~/database.sql.gz | |
dropdb database && createdb database | |
gunzip < database.sql.gz | psql database |
If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.
Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.
If in doubt about what git is doing when you run these commands, just