Skip to content

Instantly share code, notes, and snippets.

View EssenceOfChaos's full-sized avatar

Frederick John EssenceOfChaos

View GitHub Profile
@EssenceOfChaos
EssenceOfChaos / css-specificity-example.css
Created November 30, 2018 07:58
The all powerful !important clause
.heading {
color: blue;
}
h1 {
color: green !important;
}
#witty {
@EssenceOfChaos
EssenceOfChaos / css-specificity-example.html
Created November 30, 2018 06:49
HTML example - part 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CSS Specificity</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<h1 class="heading">Heading tag</h1>
@EssenceOfChaos
EssenceOfChaos / maxchars.exs
Created April 1, 2018 03:40
Maxchars - Given a string, find the character that occurs most frequently.
defmodule Maxchar do
@moduledoc """
Given a string, return the character that occurs most frequently
"""
def main(str) when is_binary(str) do
str
|> count_chars()
|> print()
end
@EssenceOfChaos
EssenceOfChaos / pipelines_final.ex
Created January 3, 2018 00:04
Example pipeline - final
# using pipelines
"freddy"
|> String.capitalize()
|> String.reverse()
|> String.ends_with?("F")
#=> true
# using nested functions
String.ends_with?(String.reverse(String.capitalize("freddy")), "F")
#=> true
@EssenceOfChaos
EssenceOfChaos / pipelines_step3.ex
Created January 3, 2018 00:02
Example pipeline - step 3
# step 3
iex> "freddy" |> String.capitalize() |> String.reverse() |> String.ends_with?("F")
true
@EssenceOfChaos
EssenceOfChaos / pipelines_step2.ex
Created January 3, 2018 00:02
Example pipeline - step 2
# step 2
iex> "freddy" |> String.capitalize() |> String.reverse()
"ydderF"
@EssenceOfChaos
EssenceOfChaos / pipelines_step1.ex
Created January 3, 2018 00:01
Example pipeline - step 1
# step 1
iex> "freddy" |> String.capitalize()
"Freddy"
@EssenceOfChaos
EssenceOfChaos / pipelines_step0.ex
Last active September 27, 2019 14:20
Example pipelines4
# step 0
iex> "freddy"
"freddy"
# shortened for brevity
defp aliases do
[
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
"ecto.reset": ["ecto.drop", "ecto.setup"],
"test": ["ecto.create --quiet", "ecto.migrate", "test"],
"ecto.migrate": ["ecto.migrate", "ecto.dump"]
]
end
# /config/prod.exs on Heroku
use Mix.Config
# Configure for SSL
config :app, AppWeb.Endpoint,
load_from_system_env: true,
url: [scheme: "https", host: "https://app.herokuapp.com", port: 443],
force_ssl: [rewrite_on: [:x_forwarded_proto]],
cache_static_manifest: "priv/static/cache_manifest.json",
secret_key_base: Map.fetch!(System.get_env(), "SECRET_KEY_BASE")