Skip to content

Instantly share code, notes, and snippets.


Brian Emory thebrianemory

View GitHub Profile
View _add_token_to_users.exs
defmodule Catcasts.Repo.Migrations.AddTokenToUsers do
use Ecto.Migration
def change do
alter table("users") do
add(:token, :string)
View .formatter.exs
inputs: ["mix.exs", "{config,lib,test}/**/*.{ex,exs}"]
View terminal
* test GET /auth/google/callback with hashrocket email (16.0ms)
1) test GET /auth/google/callback with hashrocket email (Tilex.AuthControllerTest)
Assertion with == failed
code: assert get_flash(conn, :info) == "Signed in with"
left: " is not a valid email address"
right: "Signed in with"
View test.exs
# Configure your database
config :tilex, Tilex.Repo,
adapter: Ecto.Adapters.Postgres,
database: "tilex_test",
hostname: "localhost",
username: "postgres", # Change this line
pool: Ecto.Adapters.SQL.Sandbox
View terminal
** (Mix) The database for Tilex.Repo couldn't be created: FATAL 28000 (invalid_authorization_specification): role "postgres" does not exist
08:18:21.521 [error] GenServer #PID<0.612.0> terminating
** (Postgrex.Error) FATAL 28000 (invalid_authorization_specification): role "postgres" does not exist
(db_connection) lib/db_connection/connection.ex:148: DBConnection.Connection.connect/2
(connection) lib/connection.ex:622: Connection.enter_connect/5
(stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: nil
View mix.exs
build_path: "../../_build",
config_path: "../../config/config.exs",
deps_path: "../../deps",
lockfile: "../../mix.lock"
View prod.exs
config :tilex, TilexWeb.Endpoint,
load_from_system_env: true,
url: [scheme: "https", host: "", port: 443],
force_ssl: [rewrite_on: [:x_forwarded_proto]],
cache_static_manifest: "priv/static/cache_manifest.json",
secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE")
View mix.exs
def project do
[app: :tilex,
version: "0.0.1",
elixir: "~> 1.5",
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
aliases: aliases(),
deps: deps(),
View auth_controller.ex
defp authenticate(%{info: info, uid: uid}) do
email = Map.get(info, :email)
name = Developer.format_username(Map.get(info, :name))
case String.match?(email, ~r/$/) do # Add your domain on this line
true ->
attrs = %{
email: email,
username: name,
google_id: uid
View prod.exs
config :tilex, TilexWeb.Endpoint,
http: [port: {:system, "PORT"}],
url: [host: System.get_env("HOST"), port: 80],
cache_static_manifest: "priv/static/manifest.json",
secret_key_base: System.get_env("SECRET_KEY_BASE")