Skip to content

Instantly share code, notes, and snippets.

View pkoch's full-sized avatar

Paulo Koch pkoch

View GitHub Profile
diff --git a/apps/artbay_api/test/controllers/auth_controller_test.exs b/apps/artbay_api/test/controllers/auth_controller_test.exs
index 9f82660..b39bd1a 100644
--- a/apps/artbay_api/test/controllers/auth_controller_test.exs
+++ b/apps/artbay_api/test/controllers/auth_controller_test.exs
@@ -29,7 +29,7 @@ defmodule ArtbayAPI.AuthControllerTest do
end
test "logins user with valid attributes", %{conn: conn} do
- {:ok, _user} = Hermitage.Services.UserRegistry.register_user(@post_attrs)
+ {:ok, %User{}} = Hermitage.Services.UserRegistry.register_user(@post_attrs)
pkoch  ~  iex
Erlang/OTP 19 [erts-8.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] [dtrace]
Interactive Elixir (1.4.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> defmodule User do
...(1)> defstruct name: "john"
...(1)> end
{:module, User,
<<70, 79, 82, 49, 0, 0, 8, 240, 66, 69, 65, 77, 69, 120, 68, 99, 0, 0, 0, 186,
131, 104, 2, 100, 0, 14, 101, 108, 105, 120, 105, 114, 95, 100, 111, 99, 115,
defmodule Derp do
def project(map, args) do
map
|> Map.take(args)
for k <- args, do: map[k]
end
end
IO.inspect Derp.project(%{a: 1, b: 2}, [:b, :a])
defmodule Derp do
def project(map, args) do
for k <- args, do: map[k]
end
end
IO.inspect Derp.project(%{a: 1, b: 2}, [:b, :a])
1 apt update
2 apt install r-cran-littler
3 R CMD check --as-cran
4 R CMD install.packages(devtools)
5 Rscript 'install.packages(devtools)'
6 Rscript -e 'install.packages(devtools)'
7 Rscript -e 'install.packages("devtools")'
8 Rscript -e 'install.packages()'
9 Rscript -e 'install.packages(c("devtools"))'
10 Rscript -e 'install.packages(c("roxygen2", "jsonlite"), repos="http://cran.us.r-project.org")'
@pkoch
pkoch / -
Created September 1, 2017 18:16
diff --git a/test/controllers/admin/admin_stats_controller_test.exs b/test/controllers/admin/admin_stats_controller_test.exs
index f3cbd21..7f7f79a 100644
--- a/test/controllers/admin/admin_stats_controller_test.exs
+++ b/test/controllers/admin/admin_stats_controller_test.exs
@@ -58,4 +58,4 @@ defmodule Api.AdminStatsControllerTest do
}
}
end
-end
\ No newline at end of file
defmodule Api.PaperVote do
@moduledoc """
TODO: Write.
"""
use Api.Web, :model
alias Api.{Crypto, Team, Category, User}
@required_attrs [
@pkoch
pkoch / derp
Created September 2, 2017 17:53
The database for Api.Repo has been dropped
The database for Api.Repo has been created
......................................
1) test changeset redeem (Api.PaperVoteTest)
test/models/paper_vote_test.exs:28
** (RuntimeError) changing assocs with change/2 or put_change/3 is not supported, please use put_assoc/4 instead
code: assert PaperVote.changeset(%PaperVote{}, Map.merge(base_attrs, %{
stacktrace:
(ecto) lib/ecto/changeset.ex:1011: Ecto.Changeset.put_change/7
defmodule Api.Competition do
@moduledoc """
TODO: Write.
"""
use Api.Web, :model
alias Ecto.{Changeset}
@valid_attrs ~w(
@pkoch
pkoch / 63
Created September 4, 2017 14:35
.......................................................................................................................................
1) test voting_ended_at set twice (Api.CompetitionActionsTest)
test/actions/competition_actions_test.exs:10
** (ArgumentError) Postgrex expected an integer in -2147483648..2147483647, got <<43, 56, 71, 70, 233, 249, 65, 186, 183, 181, 147, 111, 154, 61, 218, 95>>. Please make sure the value you are passing matches the definition in your table or in your query or convert the value accordingly.
code: {:ok, _} = CompetitionActions.open_voting()
stacktrace:
(ecto) /home/pkoch/Desktop/lom/psc-api/deps/postgrex/lib/postgrex/type_module.ex:717: Ecto.Adapters.Postgres.TypeModule.encode_params/3
(postgrex) lib/postgrex/query.ex:45: DBConnection.Query.Postgrex.Query.encode/3
(db_connection) lib/db_connection.ex:1071: DBConnection.describe_run/5