Skip to content

Instantly share code, notes, and snippets.

View nallwhy's full-sized avatar

Jinkyou Son nallwhy

View GitHub Profile
@nallwhy
nallwhy / server.exs
Created June 19, 2024 01:48
manage_relationship treat create before destroy
Mix.install(
[
{:plug_cowboy, "~> 2.7"},
{:jason, "~> 1.0"},
{:phoenix, "1.7.12"},
{:phoenix_live_view, "0.20.14"},
{:ash, "3.0.13"},
{:ash_phoenix, "2.0.4"}
],
config: [
@nallwhy
nallwhy / server.exs
Created April 30, 2024 08:07
embedded in union type
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.7"},
{:jason, "~> 1.0"},
@nallwhy
nallwhy / server.exs
Created April 30, 2024 01:04
union type not loaded
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.7"},
{:jason, "~> 1.0"},
@nallwhy
nallwhy / server.exs
Created April 29, 2024 08:21
error with not public union type
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.7"},
{:jason, "~> 1.0"},
@nallwhy
nallwhy / server_ash.exs
Created April 17, 2024 07:25
inputs_for with union type not working with update action
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.7"},
{:jason, "~> 1.0"},
@nallwhy
nallwhy / server.exs
Created March 11, 2024 08:27
LiveView Form with phx-hook input example
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.7"},
{:jason, "~> 1.0"},
@nallwhy
nallwhy / server.exs
Last active March 5, 2024 23:50
AshPhoenix Form is not valid
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
live_view: [signing_salt: "aaaaaaaa"],
secret_key_base: String.duplicate("a", 64)
)
Mix.install([
{:plug_cowboy, "~> 2.7"},
{:jason, "~> 1.0"},
@nallwhy
nallwhy / gist:0ddb3a32f9ccc502ecc06e991ca104a4
Created January 19, 2024 05:08
IsNil Ash validation (validate the fields are nil)
defmodule MyApp.Validation.IsNil do
use Ash.Resource.Validation
alias Ash.Error.Changes.{NoSuchAttribute, InvalidAttribute}
@impl true
def init(opts) do
{:ok, opts}
end
@impl true
[
{
"date": "2023-02-11",
"report_coount": 7
},
{
"date": "2023-02-10",
"report_coount": 11
},
{
@nallwhy
nallwhy / gist:3858c75f89b5266ad3239d14213f09a5
Last active August 21, 2022 14:36
Definject with no do case
defmodule DefinjectPlayground do
import Definject
# definject hello(who, opts \\ [])
# definject hello(name_list, _opts) when is_list(name_list), do: name_list |> Enum.map(& "Hello, #{&1}")
# definject hello(name, _opts) when is_binary(name), do: "Hello, #{name}"
def hello(who, opts \\ [])
def hello(name_list, _opts) when is_list(name_list), do: name_list |> Enum.map(& "Hello, #{&1}")
def hello(name, _opts) when is_binary(name), do: "Hello, #{name}"