rd(tst,{name,desc}).
application:stop(mnesia).
mnesia:create_schema([node()]).
application:start(mnesia).
mnesia:create_table(tsts,
[{record_name, tst},
{attributes, record_info(fields, tst)},
{disc_copies, [node()]},
{type, set}]).
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
#!/bin/bash | |
export TKN=$(curl -X POST 'http://localhost:8080/auth/realms/master/protocol/openid-connect/token' \ | |
-H "Content-Type: application/x-www-form-urlencoded" \ | |
-d "username=admin" \ | |
-d 'password=admin' \ | |
-d 'grant_type=password' \ | |
-d 'client_id=admin-cli' | jq -r '.access_token') | |
curl -X GET 'http://localhost:8080/auth/admin/realms' \ |
CREATE DATABASE hello_dev;
CREATE USER devel WITH ENCRYPTED PASSWORD 'devel';
GRANT ALL PRIVILEGES ON DATABASE hello_dev TO devel;
ALTER USER devel CREATEDB;
# Also pg_hba.conf
local all devel md5
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
2> application:ensure_all_started(mongodb). | |
{ok,[bson,poolboy,pbkdf2,mongodb]} | |
3> | |
3> Database = <<"test">>. | |
<<"test">> | |
4> {ok, Connection} = mc_worker_api:connect ([{database, Database},{w_mode, safe}]). | |
{ok,<0.181.0>} | |
5> | |
5> % Drop all the docs | |
5> Collection = <<"test">>. |
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 MapTest do | |
def hmap(%{ :a => "a"} = changeset) do | |
IO.inspect changeset | |
end | |
end | |
MapTest.hmap(%{ :a => "a", :b => "B" }) # matches | |
MapTest.hmap(%{ :a => "A", :b => "B" }) # clause error | |
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
Process.info(self(), :current_stacktrace) |
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 FnEx do | |
def m( %{ :a => a } , a ) do | |
IO.puts "Hello" | |
end | |
end |
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 Excep do | |
def ex() do | |
try do | |
throw("a") | |
catch | |
c -> | |
IO.inspect c # "a" | |
end | |
end |
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
(fn true -> IO.puts("yes its true") end).(true) | |
# Example | |
"hello" |> ( fn msg -> IO.puts(msg) end ).() |
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
if v, do: "v", else: "no_v" |