Skip to content

Instantly share code, notes, and snippets.

@Maikon
Maikon / page.index.html.heex
Created November 10, 2022 13:24
Phoenix whitelabel app (html changes)
<!-- change this -->
<h1><%= gettext "Welcome to %{name}!", name: "Phoenix" %></h1>
<!-- to this -->
<h1><%= gettext "Welcome to %{name}!", name: Map.get(@conn.private, :subdomain, "fresco") %></h1>
@Maikon
Maikon / endpoint.ex
Created November 10, 2022 13:21
Phoenix whitelabel app (endpoint changes)
plug Plug.Session, @session_options
plug FrescoWeb.Plugs.Subdomain # <----
plug FrescoWeb.Router
@Maikon
Maikon / subdomain.ex
Created November 10, 2022 13:20
Phoenix whitelabel app (subdomain plug)
defmodule FrescoWeb.Plugs.Subdomain do
@behaviour Plug # see this for more on behaviours: https://elixir-lang.org/getting-started/typespecs-and-behaviours.html#behaviours
import Plug.Conn, only: [put_private: 3]
def init(_opts) do
%{ root_host: FrescoWeb.Endpoint.config(:url)[:host] }
end
def call(%Plug.Conn{host: host} = conn, %{root_host: root_host} = _opts) do
@Maikon
Maikon / config.exs
Last active November 10, 2022 13:19
Phoenix whitelabel app tutorial (config)
config :fresco, FrescoWeb.Endpoint,
url: [host: "fresco.com"], # <----
render_errors: [view: FrescoWeb.ErrorView, accepts: ~w(html json), layout: false],
@Maikon
Maikon / docker-compose.yml
Created September 19, 2022 08:19 — forked from onjin/docker-compose.yml
example docker compose for postgresql with db init script
postgres:
image: postgres:9.4
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
@Maikon
Maikon / live_saas_kit_deploy.md
Created June 9, 2022 14:37 — forked from staknine/live_saas_kit_deploy.md
Steps to deploy LiveSaaS Kit on Fly with Phoenix 1.6.9

Here are the steps to update Phoenix Live SaaS Kit for Fly and Phoenix 1.6.9:

Initial Deployment

  1. git init, git add ., git commit -m "init repo"
  2. Remove generated docker & deploy script files
  • build.sh
  • docker-entrypoint.sh
  • .dockerignore
  • Dockerfile

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@Maikon
Maikon / Genomics_A_Programmers_Guide.md
Created May 17, 2019 16:01 — forked from andy-thomason/Genomics_A_Programmers_Guide.md
Genomics a programmers introduction

Genomics - A programmer's guide.

Andy Thomason is a Senior Programmer at Genomics PLC. He has been witing graphics systems, games and compilers since the '70s and specialises in code performance.

https://www.genomicsplc.com

@Maikon
Maikon / keybindings.json
Last active April 4, 2019 14:50
VS Code custom keybindings
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "ctrl+cmd+r",
"command": "editor.action.startFindReplaceAction"
},
{
"key": "alt+cmd+f",
"command": "-editor.action.startFindReplaceAction"
},
@Maikon
Maikon / HOWTO.md
Created February 7, 2019 08:46 — forked from cvan/HOWTO.md
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you