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 ScatterSwap do | |
@moduledoc """ | |
Usage: | |
Pass a number (as an integer) and random spin to the 'hash' function and it will return an obfuscated version of it. | |
ScatterSwap.hash(1, 0) #=> 4517239960 | |
ScatterSwap.hash(2, 0) #=> 7023641925 | |
ScatterSwap.hash(42, 0) #=> 2912536240 |
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 Slugify do | |
@moduledoc """ | |
The main intent of this module is to be used in slug generation for URLs. | |
Supports russian transliteration. | |
""" | |
@char_mappings %{"а" => "a", "б" => "b", "в" => "v", "г" => "g", "д" => "d", "е" => "e", | |
"ё" => "e", "ж" => "j", "з" => "z", "и" => "i", "й" => "i", "к" => "k", "л" => "l", "м" => "m", | |
"н" => "n", "о" => "o", "п" => "p", "р" => "r", "с" => "s", "т" => "t", "у" => "y", "ф" => "f", | |
"х" => "h", "ц" => "ts", "ч" => "ch", "ш" => "sh", "щ" => "sch", "ъ" => "", "ы" => "y", |
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
.App {margin:200px 0;text-align:center;font-size:16px;} | |
.App form input[type="email"] {font-size:16px;padding:7px 10px;border:1px solid #ccc;border-radius:6px;} | |
.App p.success {color:green;} | |
.App p.error {color:red;} |
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
import React, { useState } from 'react'; | |
import axios from 'axios'; | |
import './App.css'; | |
function App() { | |
const [email, setEmail] = useState(''); | |
const [error, setError] = useState(''); | |
const [isSubmitted, setSubmitted] = useState(false); | |
const [isProcessing, setProcessing] = useState(false); |
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 HealthyskinWeb.Router do | |
use HealthyskinWeb, :router | |
pipeline :api do | |
plug :accepts, ["json"] | |
end | |
scope "/api", HealthyskinWeb do | |
pipe_through :api |
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 HealthyskinWeb.SubscriptionController do | |
use HealthyskinWeb, :controller | |
def create(conn, %{"email" => email}) do | |
IO.inspect(email, label: "Email submitted") | |
send_resp(conn, 200, "") | |
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
# config/prod.exs - Remove cache_manifest | |
config :healthyskin, HealthyskinWeb.Endpoint, url: [host: "example.com", port: 80] | |
# lib/healthyskin_web/endpoint.ex - Instruct Plug.Static how to serve assets | |
plug Plug.Static, | |
at: "/", | |
from: "assets/build", | |
gzip: false, |
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 HealthyskinWeb.PageController do | |
use HealthyskinWeb, :controller | |
plug :put_layout, false | |
def index(conn, _params) do | |
render(conn, "index.html") | |
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
defmodule HealthyskinWeb.PageView do | |
use HealthyskinWeb, :view | |
def render("index.html", _assigns) do | |
{:safe, File.read!("assets/build/index.html")} | |
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
# config/prod.exs - url builder options and `force_ssl` behind Heroku proxy | |
config :healthyskin, HealthyskinWeb.Endpoint, | |
url: [scheme: "https", host: "example.com", port: 443], | |
force_ssl: [rewrite_on: [:x_forwarded_proto]] | |
# config/prod.secret.exs - use secure database connection | |
config :healthyskin, Healthyskin.Repo, | |
ssl: true, |