This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~r/^[A-Za-z0-9]+$/ | |
~r/^[A-Za-z0-9]{6}$/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule AppNameWeb.LvLiveTest do | |
use UrlshortenerWeb.ConnCase, async: true | |
import Phoenix.LiveViewTest | |
describe "LV test" do | |
test "we can render the view", %{conn: conn} do | |
{:ok, _lv, html} = live(conn, ~p"/") | |
# open_browser(lv) |
mix phx.new --binary-id budgie
# add docker-compose.yml below
mix setup
mix phx.gen.auth Accounts User users --hashing-lib argon2
Edit mix.ex
defp deps do
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule MyApp.Guards do | |
defguard is_uuid(value) | |
when is_binary(value) and byte_size(value) == 36 and | |
binary_part(value, 1, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and | |
binary_part(value, 2, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and | |
binary_part(value, 3, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and | |
binary_part(value, 4, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and | |
binary_part(value, 5, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and | |
binary_part(value, 6, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and | |
binary_part(value, 7, 1) in ~w|0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F| and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config diff.sopsdiffer.textconv "sops --decrypt --config /dev/null" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- v5 | |
----------------------------------------------------------- basic instance info | |
-- show db version | |
SELECT version(); | |
-- uptime | |
SELECT pg_postmaster_start_time(); | |
-- show connections |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"data": {"values": | |
[ | |
{"_submitted_by": "dalli", | |
"INTRO_DISTRICT": [ | |
"Afgooye" | |
], | |
"count": 1 | |
}, | |
{"_submitted_by": "dalli", |
Generators are implemented with syntax very similar to functions, but instead of returning values, a yield statement is executed to indicate each element in the series
Consider the goal of computing all factors of a positive integer. A traditional function might return a list contating all factors, implemeted as follows:
def factors(n): # traditional function that computes factors
results = [] # store factors in a new list
for k in range(1, n+1):
if n % k == 0: # divides evenly, thus k is a factor
results.append(k) # add k to the list of factors