Skip to content

Instantly share code, notes, and snippets.

View EssenceOfChaos's full-sized avatar

Frederick John EssenceOfChaos

View GitHub Profile
@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_step2.ex
Created January 3, 2018 00:02
Example pipeline - step 2
# step 2
iex> "freddy" |> String.capitalize() |> String.reverse()
"ydderF"
@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_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 / 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 / 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 / css-specificity-example.css
Created November 30, 2018 07:58
The all powerful !important clause
.heading {
color: blue;
}
h1 {
color: green !important;
}
#witty {