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 CouchQuery do | |
| use GenServer.Behaviour | |
| def start_link() do | |
| :gen_server.start_link(__MODULE__, [], []) | |
| end | |
| def set_timeout(pid, timeout) do | |
| :gen_server.call(pid, {:set_timeout, timeout}) | |
| 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
| puts "foo" |
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
| # Shameless copy from http://learnyousomeerlang.com/buckets-of-sockets | |
| defmodule SimpleTcp do | |
| def start_server(port) do | |
| pid = spawn fn -> | |
| {:ok, listen} = :gen_tcp.listen(port, [:binary, {:active, false}]) | |
| spawn fn -> acceptor(listen) end | |
| :timer.sleep(:infinity) | |
| end | |
| {:ok, pid} |
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 PhoenixUeberauthComeonin.Repo.Migrations.CreateUsers do | |
| use Ecto.Migration | |
| def change do | |
| create table(:users) do | |
| add :name, :string | |
| add :email, :string | |
| add :password, :string | |
| timestamps() | |
| 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
| defp deps do | |
| [... | |
| {:ueberauth, "~> 0.4"}, | |
| {:ueberauth_identity, "~> 0.2"}, | |
| ...] |
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
| def application do | |
| [mod: {PhoenixUeberauthComeonin, []}, | |
| applications: [ | |
| ... | |
| ueberauth, | |
| ueberauth_identity, | |
| ... |
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
| config :ueberauth, Ueberauth, | |
| providers: [ | |
| identity: { Ueberauth.Strategy.Identity, [ | |
| callback_methods: ["POST"], | |
| uid_field: :email, | |
| nickname_field: :email, | |
| request_path: "/sessions/new", | |
| callback_path: "/sessions/identity/callback", | |
| ]} | |
| ] |
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
| scope "/sessions", PhoenixUeberauthComeonin do | |
| pipe_through [:browser] | |
| get "/new", SessionsController, :new | |
| post "/identity/callback", SessionsController, | |
| :identity_callback | |
| 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 PhoenixUeberauthComeonin.SessionsController do | |
| use PhoenixUeberauthComeonin.Web, :controller | |
| alias Ueberauth.Strategy.Helpers | |
| plug Ueberauth | |
| def new(conn, _params) do | |
| render conn, "new.html", callback_url: Helpers.callback_url(conn) | |
| 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 PhoenixUeberauthComeonin.SessionsView do | |
| use PhoenixUeberauthComeonin.Web, :view | |
| end |