A Pen by Benjamin Milde on CodePen.
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
# How to use it: | |
# | |
# Plug it at the end of your :browser pipeline in your Phoenix app router.ex | |
# Make sure it is plugged before your session-based authentication and authorization Plugs. | |
# | |
# pipeline :browser do | |
# plug :accepts, ["html"] | |
# plug :fetch_session | |
# plug :fetch_flash | |
# plug :put_secure_browser_headers |
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 App.RegistrationController do | |
use App.Web, :controller | |
alias App.{Registration, Repo} | |
def new(conn, _params) do | |
changeset = Registration.changeset(%Registration{}) | |
render conn, :new, changeset: changeset | |
end | |
def create(conn, %{"registration" => registration_params}) 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 DateTimeGenerators do | |
use ExUnitProperties | |
@time_zones ["Etc/UTC"] | |
def date do | |
gen all year <- integer(1970..2050), | |
month <- integer(1..12), | |
day <- integer(1..31), | |
match?({:ok, _}, Date.from_erl({year, month, day})) do |
Laravel-Mix is "an elegant wrapper around Webpack for the 80% use case". It has nothing to do with Elixir's Mix and does not require Laravel to work!
Create a new phoenix application with mix phx.new
. You may choose to add the --no-brunch
flag to stop brunch from being intiailized, but I personally prefer leaving that in and replacing brunch so that the folder structure is set up for me.
$ mix phx.new demo
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 MyApp.Factory do | |
alias MyApp.Repo | |
# Factories | |
def build(:name, :default) do | |
%MyApp.Struct{ | |
} | |
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
# Basic user with just name, email, password | |
user = Repo.get User, 1 | |
# Load profile | |
user = Repo.preload(user, :profile) | |
profile = user.profile |
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
server { | |
## [Default Nginx Configuration] | |
# .htaccess 8.1 | |
charset utf-8; | |
# .htaccess 3. | |
location = /favicon.ico { log_not_found off; access_log off; } | |
location = /robots.txt { log_not_found off; access_log off; } | |
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
<?php namespace LostKobrakai; | |
class WireUploadChunked extends \ProcessWire\WireUpload { | |
/** | |
* @var bool $uploadingChunkFile | |
*/ | |
protected $uploadingChunkFile = false; | |
/** |