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 GoogleStorage.Application do | |
# ... | |
@impl true | |
def start(_type, _args) do | |
producer_module = Application.get_env(:google_storage, :producer_module) | |
children = [ | |
{GoogleStorage.Pipeline, [producer_module: producer_module]} |
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 GoogleStorage.Pipeline do | |
use Broadway | |
require Logger | |
alias Broadway.Message | |
def start_link(opts) do | |
producer_module = Keyword.fetch!(opts, :producer_module) | |
Broadway.start_link(__MODULE__, |
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
# config/config.exs | |
import Config | |
config :goth, json: File.read!("priv/creds.json") | |
subscription = "projects/gcs-pubsub-1/subscriptions/api-subscription" | |
config :google_storage, | |
producer_module: {BroadwayCloudPubSub.Producer, subscription: subscription} |
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 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 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 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 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 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 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 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 |
NewerOlder