mix ecto.drop && mix ecto.setup
iex -S mix phx.server
{:ok, user, pid} = Les.UserEntity.create(%{username: "u1", name: "n1"})
user
pid
CREATE ROLE <user_name> WITH LOGIN PASSWORD '<password>' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION; | |
GRANT CONNECT ON DATABASE <db> TO <user_name>; | |
\c <db> | |
GRANT USAGE ON SCHEMA public TO <user_name>; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO <user_name>; | |
GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO <user_name>; | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO <user_name>; |
defmodule GPad do | |
def get_base() do | |
try do | |
get_base(System.get_env("MIX_ENV")) |> Path.join("lib") | |
catch | |
e -> IO.puts("Error: #{inspect(e)}") | |
end | |
end | |
def get_base(nil) do |
defmodule NoSlides.Service do | |
def ping(v\\1) do | |
idx = :riak_core_util.chash_key({"noslides", "ping#{v}"}) | |
pref_list = :riak_core_apl.get_primary_apl(idx, 1, NoSlides.Service) | |
[{index_node, _type}] = pref_list | |
:riak_core_vnode_master.sync_command(index_node, {:ping, v}, NoSlides.VNode_master) | |
end |
1) test Aggregate and publish internal temperature base on same minute on receipt (BackendOneTest)
test/backend_one_test.exs:86
No message matching {:test_consumer, %{"type" => "stats", "seller_id" => 42, "payload" => %{"receipt" => %{"date" => receipt_dt, "id" => 666}, "internal_avg_temperature" => 23.0, "external_avg_temperature" => 13.0, "people" => 1}}} after 5000ms.
Process mailbox:
{:test_consumer, %{"payload" => %{"external_avg_temperature" => 13.0, "internal_avg_temperature" => 23.0, "people" => 1, "receipt" => %{"date" => "2016-01-01T15:42:18Z", "id" => 666, "sellerId" => 42}}, "type" => "stats"}}
stacktrace:
test/backend_one_test.exs:111: (test)
#--- | |
# Excerpted from "Programming Elixir", | |
# published by The Pragmatic Bookshelf. | |
# Copyrights apply to this code. It may not be used to create training material, | |
# courses, books, articles, and the like. Contact us if you are in doubt. | |
# We make no guarantees that this code is fit for any purpose. | |
# Visit http://www.pragmaticprogrammer.com/titles/elixir for more book information. | |
#--- | |
defmodule FibSolver do |
defmodule Fibonacci do | |
def fib(0), do: 0 | |
def fib(1), do: 1 | |
def fib(n), do: fib(n-1) + fib(n-2) | |
end | |
defmodule Fibonacci.Parallel do | |
def fib(n, processes) do | |
(1..processes) |> Enum.map(fn id -> | |
srv = self() |
defmodule QSv1 do | |
def sort([]), do: [] | |
def sort([pivot | rest]) do | |
{smaller, bigger} = Enum.partition(rest, &(&1 < pivot)) | |
sort(smaller) ++ [pivot] ++ sort(bigger) | |
end | |
end | |
defmodule QSv2 do | |
def sort([]), do: [] |
require 'net/http' | |
require 'net/https' | |
require 'uri' | |
require 'base64' | |
class HeyWeb | |
BASE_URL = "https://secure.apisms.it/http/" | |
ID_API = 5 | |
REPORT_TYPE = 'P' |
#include "StdAfx.h" | |
#include "GPadAssert.h" | |
template<typename MyRand> | |
class MyRandomObject | |
{ | |
int _sum; | |
MyRand rand; | |
public: | |
MyRandomObject() |