# https://gist.github.com/Gazler/b4e92e9ab7527c7e326f19856f8a974a
Application.put_env(:phoenix, :json_library, Jason)
Application.put_env(:sample, SamplePhoenix.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 5001],
server: true,
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 Macro do | |
@doc """ | |
Copy of `Macro.prewalk/2` w/ a branch accumulator | |
""" | |
def prewalk(ast, fun) when is_function(fun, 1) do | |
elem(prewalk(ast, nil, nil, fn x, nil, nil -> {fun.(x), nil} end), 0) | |
end | |
@doc """ | |
Copy of `Macro.prewalk/3` w/ a branch accumulator |
- To provide resources for library and framework authors to ensure that BEAM languages have a rich, vibrant ecosystem with a high degree of developer experience. Main Objectives
- Provide and maintain best practices on library and framework standardization, documentation, code, and distribution. Collaborate to work on and make proposals for underlying tooling that improve the experience for library/framework authors and users.
- Provide more visibility into the library ecosystem of Elixir on behalf of both authors and users.
- (if Build and Packaging want to move this here, we could also take this over) Improve the user experience in generating and accessing documentation from the shell, IDEs, web pages, and more.
There are more than a few different ways you could do that. The simplest one would be to modify the actions that are created, by defining them yourself or adding behavior to them.
- creating them yourself, if you do this, AshAuthentication will just validate that the action contains the correct elements:
read :sign_in_with_password do
...
# can also put it in a module: prepare RequireGoogleSignInForFoo
prepare fn query, result ->
if is_foo(Ash.Changeset.get_argument(query, :email)) do
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 Mochi.Deck do | |
use Ash.Resource, | |
data_layer: AshJsonApiWrapper.DataLayer | |
actions do | |
defaults [:read] | |
end | |
json_api_wrapper do | |
finch Mochi.Finch |
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
// This heavily borrows (and is essentialy just a port) of https://andrew.gibiansky.com/blog/verification/writing-a-sat-solver/ | |
import gleam/io | |
import gleam/list | |
import gleam/int | |
import gleam/option.{None, Option, Some} | |
type Expr { | |
Var(Int) | |
And(Expr, Expr) | |
Or(Expr, Expr) |
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 BetterComponent do | |
defmodule Live do | |
defmacro __using__(opts) do | |
quote do | |
import BetterComponent | |
use Surface.LiveComponent | |
def update(assigns, socket) do | |
case assigns[:__event__] do |
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 BetterComponent do | |
defmodule Live do | |
defmacro __using__(opts) do | |
quote do | |
import BetterComponent | |
use Surface.LiveComponent | |
def update(assigns, socket) do | |
case assigns[:__event__] do |
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 Helpdesk.Tickets.Ticket.Relationships.TicketsAboveThreshold do | |
use Ash.Resource.ManualRelationship | |
use AshPostgres.ManualRelationship | |
require Ash.Query | |
require Ecto.Query | |
def load(records, _opts, %{query: query, actor: actor, authorize?: authorize?}) do | |
rep_ids = Enum.map(records, & &1.id) | |
{:ok, |
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 Mix.Tasks.DumpHackerNews do | |
@moduledoc "Grabs the current first few pages of hackernews and saves them to a json file" | |
use Mix.Task | |
defmodule TopStory do | |
@moduledoc false | |
use Ash.Resource, | |
data_layer: AshJsonApiWrapper.DataLayer | |
json_api_wrapper do |