Skip to content

Instantly share code, notes, and snippets.

View Devalo's full-sized avatar
💭
:D

Stephan Bakkelund Valois Devalo

💭
:D
  • Tønsberg, Norway
View GitHub Profile
exports.config = {
// See http://brunch.io/#documentation for docs.
files: {
javascripts: {
joinTo: "js/app.js"
// To use a separate vendor.js bundle, specify two files path
// http://brunch.io/docs/config#-files-
// joinTo: {
// "js/app.js": /^js/,
def handle_info(:after_join, socket) do
user = Repo.get(User, socket.assigns.user_id)
{:ok, _} = Presence.track(socket, user.email, %{
online_at: inspect(System.system_time(:seconds))
})
push socket, "presence_state", Presence.list(socket)
{:noreply, socket}
end
# http://imgur.com/a/Bp59w <- Images are stacked on top of each other in the first image.
# Images are properly positioned in the last image.
# Template
<div class="portfolio-wrapper" >
<div class="col-md-12">
<h3 class="text-center">Sjekk ut noen av nettsidene vi tidligere har levert</h3>
</div>
%{"34425" => %{"extract" => "Z (named zed /ˈzɛd/' or zee /ˈziː/) is the 26th and final letter of the modern English alphabet and the ISO basic Latin alphabet.\n\n",
"ns" => 0, "pageid" => 34425, "title" => "Z"}}
%{"batchcomplete" => "",
"query" => %{"normalized" => [%{"from" => "test", "to" => "Test"}],
"pages" => %{"11089416" => %{"extract" => "Test, TEST or Tester may refer to:\nTest (assessment), an assessment intended to measure the respondents' knowledge or other abilities\nMedical test, to detect, diagnose, or monitor diseases",
"ns" => 0, "pageid" => 11089416, "title" => "Test"}}}}
Prefix Verb URI Pattern Controller#Action
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Hello Cvapp!</title>
@Devalo
Devalo / auth.ex
Created May 24, 2016 20:09
Auth. When registering a new user, it checks if password and email is correct, and invoke login/2 which assigns :current_user and pipes through Guardian.Plug.sign_in. It raises error when using @current_user in views, saying assign @current_user not available in eex template.
defmodule Cvapp.Auth do
import Comeonin.Bcrypt, only: [checkpw: 2, dummy_checkpw: 0]
import Plug.Conn
def login(conn, user) do
conn
|> assign(:current_user, user)
|> Guardian.Plug.sign_in(user)
end
defmodule NaturalNums do
def print(1), do: IO.puts(1)
def print(n) do
print(n - 1)
IO.puts(n)
end
end
def index(conn, _params) do
case authenticate(conn) do
%Plug.Conn{halted: true} = conn ->
conn
conn ->
users = Repo.all(User)
render conn, "index.html", users: users
end
end