Mix.install([
{:phoenix_live_view, "~> 0.20.1"},
{:phoenix_ecto, "~> 4.4"}
])
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
# A proc is just a block of code that can be called later: | |
say_hello = -> { 2 + 2 } | |
say_hello.call # => 4 | |
# Procs can take parameters: | |
double = ->(x) { x * 2 } |
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
#!/usr/bin/env elixir | |
Mix.install([ | |
{:httpoison, "~> 1.8"}, | |
{:jason, "~> 1.3"} | |
]) | |
defmodule Space do | |
def run do | |
fetch_data() |
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
text | |
|> String.split("\n") | |
|> Enum.reduce({["{"], " "}, fn line, {output, current_indent} -> | |
case Regex.run(~r/^( +)(.*): ?(.*)/, line, capture: :all_but_first) do | |
[indent, key, ""] -> | |
close_braces = | |
if indent < current_indent do | |
Enum.map_join( | |
(String.length(current_indent) - 4)..String.length(indent)//-4, | |
"", |
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
class Stack | |
class Empty < RuntimeError; end | |
def initialize | |
@items = [] | |
end | |
def empty? | |
@items.count == 0 |
OlderNewer