This file contains 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.User do | |
def changeset(model, params \\ :empty) do | |
model | |
|> cast(params, @required_fields, @optional_fields) | |
|> validate_format(:email, ~r/@/) | |
|> validate_length(:password, min: 8) | |
|> validate_format(:password, ~r/[0-9]+/, message: "Password must contain a number") # has a number | |
|> validate_format(:password, ~r/[A-Z]+/, message: "Password must contain an upper-case letter") # has an upper case letter | |
|> validate_format(:password, ~r/[a-z]+/, message: "Password must contain a lower-case letter") # has a lower case letter | |
|> validate_format(:password, ~r/[#\!\?&@\$%^&*\(\)]+/, message: "Password must contain a symbol") # Has a symbol |
This file contains 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 Game do | |
use GenServer | |
def init(game_id) do | |
{:ok, %{game_id: game_id}} | |
end | |
def start_link(game_id) do | |
GenServer.start_link(__MODULE__, game_id, name: {:global, "game:#{game_id}"}) | |
end |
This file contains 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
// Construct Single Node | |
class Node { | |
constructor(data, next = null) { | |
this.data = data; | |
this.next = next; | |
} | |
} | |
// Create/Get/Remove Nodes From Linked List | |
class LinkedList { |
This file contains 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
using UnityEngine; | |
/// <summary> | |
/// A class that allows to visualize the Physics2D.BoxCast() method. | |
/// </summary> | |
/// <remarks> | |
/// Use Draw() to visualize an already cast box, | |
/// and BoxCastAndDraw() to cast a box AND visualize it at the same time. | |
/// </remarks> |