Skip to content

Instantly share code, notes, and snippets.

<h2>Listing users</h2>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Password</th>
<th></th>
<h2>Show user</h2>
<ul>
<li>
<strong>Name:</strong>
<%= @user.name %>
</li>
<li>
<%= form_for @changeset, @action, fn f -> %>
<%= if f.errors != [] do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below:</p>
<ul>
<%= for {attr, message} <- f.errors do %>
<li><%= humanize(attr) %> <%= message %></li>
<% end %>
</ul>
</div>
@darui00kara
darui00kara / example.ex
Created December 10, 2016 06:55
Model for many-to-many and follow functions
defmodule SampleApp.User do
use SampleApp.Web, :model
alias SampleApp.Helpers.Encryption
schema "users" do
field :name, :string
field :email, :string
field :password, :string, virtual: true
field :password_digest, :string
@darui00kara
darui00kara / macro_example.ex
Last active April 12, 2017 13:39
[elixir]map and ast toy
defmodule MacroExample do
alias User
alias Post
defmacro get_struct_info(
{:%, _, [{_, _, struct_name}, {:%{}, _, values}]}) do
quote do
{unquote(struct_name), unquote(values)}
end
@darui00kara
darui00kara / Omake.elm
Last active April 10, 2022 13:56
Elm json encode example
-- おまけ用のメモ
> body = Http.jsonBody (UserEncoder.user User.new)
StringBody "application/json" "{\"id\":0,\"name\":\"\",\"email\":\"\"}"
: Http.Body
> import Model.UserDecoder as UserDecoder
> Http.post "http://localhost:4000/exmamples" body UserDecoder.user
Request { method = "POST", headers = [], url = "http://localhost:4000/exmamples", body = StringBody "application/json" "{\"id\":0,\"name\":\"\",\"email\":\"\"}", expect = { responseType = "text", responseToResult = <function> }, timeout = Nothing, withCredentials = False }
: Http.Request Model.User.Schema