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 event_map do | |
Enum.reduce Repo.all(Event), %{}, fn event, acc -> | |
Map.put(acc, event.id, event.name) | |
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
defmodule MyApp.CommentView do | |
use MyApp.Web, :view | |
@attributes ~W(id name inserted_at) | |
def render("index.json", %{data: comments}) do | |
for comment <- comments, do: render("show.json", %{data: comment}) | |
end | |
def render("show.json", %{data: comment}) do | |
comment |
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
" Rails specific CtrlP mappings | |
map <leader>gs :CtrlP app/assets/stylesheets<cr> | |
map <leader>gv :CtrlP app/views<cr> | |
map <leader>gc :CtrlP app/controllers<cr> | |
map <leader>gm :CtrlP app/models<cr> | |
map <leader>gh :CtrlP app/helpers<cr> | |
map <leader>gt :CtrlP spec<cr> | |
map <leader>gj :CtrlP app/assets/javascripts<cr> | |
map <leader>gjm :CtrlP app/assets/javascripts/models<cr> | |
map <leader>gjc :CtrlP app/assets/javascripts/collections<cr> |
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 Statistik.User do | |
use Statistik.Model | |
schema "users" do | |
field :email, :string | |
field :password, :virtual | |
field :password_confirmation, :virtual | |
field :encrypted_password, :string | |
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
<%= for {notice, msgs} <- Flash.get(@conn) do %> | |
<div class="container"> | |
<div class="row"> | |
<p class="alert alert-<%= notice %>"> | |
<%= safe Enum.map_join(msgs, "<br>", fn msg -> msg end) %> | |
</p> | |
</div> | |
</div> | |
<% 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
# model | |
def field_names do | |
__schema__(:field_names) | |
end | |
# controller | |
def create(conn, params) do | |
Repo.insert struct(Model, permitted_params(params)) | |
redirect conn, Routes.model_path(:index) |
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
augroup elixir | |
au! | |
au BufNewFile,BufRead *.ex,*.exs noremap <buffer> <leader>r :!mix test<cr> | |
au BufNewFile,BufRead *_test.exs noremap <buffer> <leader>r :exe "!mix test %:" . line(".")<cr> | |
au BufNewFile,BufRead *_test.exs noremap <buffer> <leader>R :!mix test %<cr> | |
au BufNewFile,BufRead *_test.exs noremap <buffer> <leader>a :!mix test<cr> | |
au BufNewFile,BufRead *.eex set filetype=eruby.html | |
augroup 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 OAuth2.Strategy.Password do | |
@moduledoc """ | |
The Resource Owner Password Credentials Authorization Strategy. | |
http://tools.ietf.org/html/draft-ietf-oauth-v2-15#section-4.3 | |
""" | |
use OAuth2.Strategy | |
@doc """ | |
Not used for this strategy. |
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
[range_type, range_start, range_end] = | |
case get_req_header(conn, "range") = hdr_range do | |
[] -> ["bytes", "0", "999"] | |
_ -> String.split(List.last(hdr_range), ["=", "-"]) | |
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
defrecord User, name: "", email: "" | |
defmodule Amnesia do | |
@compile {:parse_transform, :qlc} | |
def create_schema do | |
create_table User | |
end |