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 GOL do | |
def encode(list) do | |
encode(nil, list) | |
end | |
# Figure out the starting condition, whether we start "on" or "blank" | |
def encode(nil, [1 | rest]), do: encode({:on, 1, 1}, rest) | |
def encode(nil, rest), do: encode({:blank, 1}, rest) | |
# If we have a sequence of "on" cells we need to know when it started and whether we are consecutive | |
# with the last cell |
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 UserController do | |
def create(params) do | |
changeset = params | |
|> cast([:name, :email]) | |
|> validate_required([:email]) | |
|> validate_other_stuff() | |
WithSideEffects.create(changeset) | |
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
# from https://github.com/Shopify/graphql-batch/blob/c84a5236ecb1c38fa275c76ee38017f30b7074be/examples/association_loader.rb | |
# This handles creating generic association loaders (see team_member_graph.rb for an example) | |
class AssociationLoader < GraphQL::Batch::Loader | |
def self.validate(model, association_name) | |
new(model, association_name) | |
nil | |
end | |
def initialize(model, association_name) | |
@model = model |
OlderNewer