nelsonic / practice

Practice makes ...
11 stars 4 forks source link

Elixir School #10

Open nelsonic opened 7 years ago

nelsonic commented 7 years ago

My plan is go through all of the Elixir School Lessons and log my progress! ๐Ÿค“

https://elixirschool.com/lessons/basics/basics/ image

https://elixirschool.com/lessons/basics/collections/ image image

https://elixirschool.com/lessons/basics/enum/ image image image

image image

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/pattern-matching/ image image

https://elixirschool.com/lessons/basics/control-structures/#if-and-unless image

https://elixirschool.com/lessons/basics/control-structures/#case image

https://elixirschool.com/lessons/basics/control-structures/#cond image

https://elixirschool.com/lessons/basics/control-structures/#with image

https://elixirschool.com/lessons/basics/functions/ image

https://elixirschool.com/lessons/basics/functions/#function-naming-and-arity image

https://elixirschool.com/lessons/basics/functions/#private-functions image

https://elixirschool.com/lessons/basics/functions/#guards image

https://elixirschool.com/lessons/basics/functions/#default-arguments image

image image

https://elixirschool.com/lessons/basics/pipe-operator/ image There are much better pipe operator examples on: https://stackoverflow.com/questions/41584737/how-does-pipe-operator-in-elixir-work

https://elixirschool.com/lessons/basics/modules/ image

https://elixirschool.com/lessons/basics/modules/#structs image

https://elixirschool.com/lessons/basics/modules/#import image

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/mix/ image

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/sigils/ image

https://elixirschool.com/lessons/basics/sigils/#creating-sigils image

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/documentation/ image

Note: Dogbert to the rescue: https://stackoverflow.com/questions/42504226/elixir-module-was-not-compiled-with-docs ... ๐Ÿ˜‰

https://elixirschool.com/lessons/basics/documentation/#documenting-functions image

https://elixirschool.com/lessons/basics/documentation/#exdoc image

https://elixirschool.com/lessons/basics/documentation/#installing image

https://elixirschool.com/lessons/basics/documentation/#generating-documentation image

image image image

Further reading:

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/testing/ image

https://elixirschool.com/lessons/basics/testing/#assert image

https://elixirschool.com/lessons/basics/testing/#assertreceive there's a gap in this section of the tutorial ... it does not explain how to use assert_receive ... but that's OK! because we aren't going to use it for now! ๐Ÿ‘

https://elixirschool.com/lessons/basics/testing/#captureio-and-capturelog image

https://elixirschool.com/lessons/basics/testing/#test-setup image

https://elixirschool.com/lessons/basics/testing/#mocking image AMEN! :shipit:

nelsonic commented 7 years ago

http://blog.plataformatec.com.br/2015/10/mocks-and-explicit-contracts/ good read! ๐Ÿ‘

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/comprehensions/ image

image This is soooooo cool! ๐Ÿ˜ฎ

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/comprehensions/#filters image

https://elixirschool.com/lessons/basics/comprehensions/#using-into image

Nuts! :shipit: ๐ŸŽ‰

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/strings/#strings image

image

https://elixirschool.com/lessons/basics/strings/#exercises image

https://elixirschool.com/lessons/basics/strings/#anagrams image

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/mix-tasks/ image

nelsonic commented 7 years ago

https://elixirschool.com/lessons/basics/iex-helpers https://elixirschool.com/lessons/basics/iex-helpers/#autocomplete image

https://elixirschool.com/lessons/basics/iex-helpers/#iexexs image

https://elixirschool.com/lessons/basics/iex-helpers/#h image image

https://elixirschool.com/lessons/basics/iex-helpers/#i image

https://elixirschool.com/lessons/basics/iex-helpers/#s image

https://elixirschool.com/lessons/basics/iex-helpers/#t image

Totes finished the "basic" level in Elixir School. easy. AMA! ๐Ÿ˜‰

nelsonic commented 7 years ago

https://elixirschool.com/lessons/advanced/erlang/ image

๐Ÿ˜ž

nelsonic commented 7 years ago

goto: https://github.com/doomspork/elixir-school/blob/master/en/lessons/advanced/erlang.md and see: https://github.com/doomspork/elixir-school/issues/1010

nelsonic commented 7 years ago

https://github.com/doomspork/elixir-school/blob/e03066d8a1435f547ffc3f1e9fdc886811035730/en/lessons/advanced/erlang.md#standard-library image

Obviously my laptop is a bit slower than the author's ... ๐Ÿ˜œ But apparently that's not a "bad" thing ... https://twitter.com/dominictarr/status/629992939738005504 image

https://github.com/doomspork/elixir-school/blob/e03066d8a1435f547ffc3f1e9fdc886811035730/en/lessons/advanced/erlang.md#erlang-packages image

Obviously this code will/would work if we use valid filename and palette variables... see: https://github.com/yuce/png

sweet. ๐Ÿญ

nelsonic commented 7 years ago

next: https://elixirschool.com/en/lessons/advanced/error-handling/ https://github.com/doomspork/elixir-school/blob/e03066d8a1435f547ffc3f1e9fdc886811035730/en/lessons/advanced/error-handling.md

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/error-handling/#error-handling image

typed example: image

got error as opts is undefined. (obviously) but unclear from example... (unfriendly to beginners)

https://elixirschool.com/en/lessons/advanced/error-handling/#after image File.open docs: https://elixir-lang.org/getting-started/io-and-the-file-system.html

https://elixirschool.com/en/lessons/advanced/error-handling/#new-errors image

https://elixirschool.com/en/lessons/advanced/error-handling/#throws image

(no longer used in new elixir code, but need to be aware of it...)

https://elixirschool.com/en/lessons/advanced/error-handling/#exiting image

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/escripts/ image

https://elixirschool.com/en/lessons/advanced/escripts/#parsing-args image

https://elixirschool.com/en/lessons/advanced/escripts/#building image

Initially it did not work ... ๐Ÿ˜•

defined as :main_module could not be loaded

found answer: https://elixirforum.com/t/cant-find-the-module-in-the-escript-made-by-one-mix-exs-file-at-runtime/2838/6 updated mix.exs to:

defmodule Example.Mixfile do
  use Mix.Project

  def project do
    [app: :example,
     version: "0.1.0",
     escript: escript(),
     elixirc_paths: ["."],
     elixir: "~> 1.4",
     build_embedded: Mix.env == :prod,
     start_permanent: Mix.env == :prod,
     deps: deps()
    ]
  end

  def escript do
    [main_module: Example.CLI]
  end
end

and cli.ex to:

defmodule Example.CLI do
  def main(args \\ []) do
    args
    |> parse_args
    |> response
    |> IO.puts
  end

  defp parse_args(args) do
    {opts, word, _} =
      args
      |> OptionParser.parse(switches: [upcase: :boolean])

    {opts, List.to_string(word)}
  end

  defp response({opts, word}) do
    if opts[:upcase], do: String.upcase(word), else: word
  end
end

Now builds: image

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/concurrency/ https://elixirschool.com/en/lessons/advanced/concurrency/#processes image

https://elixirschool.com/en/lessons/advanced/concurrency/#message-passing got error: image

Tried again from scratch: image worked. Don't know what was wrong, but re-typing everything carefully worked. ๐Ÿ‘

https://elixirschool.com/en/lessons/advanced/concurrency/#process-linking image

image

https://elixirschool.com/en/lessons/advanced/concurrency/#process-monitoring image

https://elixirschool.com/en/lessons/advanced/concurrency/#agents image

https://elixirschool.com/en/lessons/advanced/concurrency/#tasks image

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/otp-concurrency/#genserver image

https://elixirschool.com/en/lessons/advanced/otp-concurrency/#synchronous-functions image image

https://elixirschool.com/en/lessons/advanced/otp-concurrency/#asynchronous-functions image

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/otp-supervisors/#configuration https://elixirschool.com/en/lessons/advanced/otp-supervisors/#strategies https://elixirschool.com/en/lessons/advanced/otp-supervisors/#nesting https://elixirschool.com/en/lessons/advanced/otp-supervisors/#task-supervisor Examples aren't clear. Will read this in more detail when I need it! ๐Ÿ‘

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/metaprogramming/#quote image image

https://elixirschool.com/en/lessons/advanced/metaprogramming/#unquote image

https://elixirschool.com/en/lessons/advanced/metaprogramming/#macros image image image

The Logger Example is kinda useless (not very beginner friendly...) image

How exactly are we meant to run this example code? ๐Ÿ˜•

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/metaprogramming/#debugging image image

https://elixirschool.com/en/lessons/advanced/metaprogramming/#private-macros no example for private macros (why/when would you need them...?)

https://elixirschool.com/en/lessons/advanced/metaprogramming/#macro-hygiene image

https://elixirschool.com/en/lessons/advanced/metaprogramming/#binding image image

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/umbrella-projects image

https://elixirschool.com/en/lessons/advanced/umbrella-projects/#child-projects image

https://elixirschool.com/en/lessons/advanced/umbrella-projects/#iex image

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/typespec/ image

https://elixirschool.com/en/lessons/advanced/typespec/#specification image

https://elixirschool.com/en/lessons/advanced/typespec/#custom-types (just intro) https://elixirschool.com/en/lessons/advanced/typespec/#defining-custom-type image

image

https://elixirschool.com/en/lessons/advanced/typespec/#documentation-of-types image

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/behaviours/ The example is incomplete. ๐Ÿ˜ข The "advanced" lessons aren't as useful because the examples are isolated and theoretical. Instead it should build up a mini-project that uses the various features similar to how the Elixir book does.

Anyway, for behaviours, see: https://elixir-lang.org/getting-started/typespecs-and-behaviours.html

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/gen-stage/ image

https://elixirschool.com/en/lessons/advanced/gen-stage/#getting-started image image

image

https://elixirschool.com/en/lessons/advanced/gen-stage/#producer image

https://elixirschool.com/en/lessons/advanced/gen-stage/#producer-consumer image

https://elixirschool.com/en/lessons/advanced/gen-stage/#consumer image

https://elixirschool.com/en/lessons/advanced/gen-stage/#putting-it-all-together image

https://elixirschool.com/en/lessons/advanced/gen-stage/#multiple-producers-or-consumers image

https://elixirschool.com/en/lessons/advanced/gen-stage/#use-cases found a better example: https://github.com/pcmarks/genstage_example

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/advanced/protocols/ (just intro/reading) https://elixirschool.com/en/lessons/advanced/protocols/#what-are-protocols image

https://elixirschool.com/en/lessons/advanced/protocols/#implementing-a-protocol image with working to_string(Tuple): image

Implementing a new protocol: image

works: image

and thus concludes the "Advanced" section of Elixir School! image

๐ŸŽ‰ https://vimeo.com/8503138

nelsonic commented 7 years ago

Quick pomodoro break: image https://www.youtube.com/watch?v=RM7lw0Ovzq0&list=PLQw3xggCuGQUdd7reYR1SoUW5SvkQyNEY

"Quick" in the loosest possible sense of the word ... ๐Ÿ˜† I watched a few of Jay-Z's videos ... ๐ŸŽถ ๐ŸŽง
but now I'm $.ready() for plug! ๐Ÿ˜‰

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/specifics/plug/ https://elixirschool.com/en/lessons/specifics/plug/#dependencies image image

https://elixirschool.com/en/lessons/specifics/plug/#the-specification image

https://elixirschool.com/en/lessons/specifics/plug/#configuring-the-projects-application-module image image

Totes Works! image

https://elixirschool.com/en/lessons/specifics/plug/#plugrouter image

Update lib/example.ex to Example.Router: image

Works as expected: image

https://elixirschool.com/en/lessons/specifics/plug/#adding-another-plug image image

https://elixirschool.com/en/lessons/specifics/plug/#making-the-http-port-configurable image

update ./config/config.exs to include config :example, cowboy_port: 8080 image

https://elixirschool.com/en/lessons/specifics/plug/#testing-a-plug image run the test: image

Further reading: https://github.com/elixir-plug/plug#available-plugs

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/specifics/ecto/ https://elixirschool.com/en/lessons/specifics/ecto/#setup

mix new exampleapp --sup

image

https://elixirschool.com/en/lessons/specifics/ecto/#repository missed a step: add ExampleApp.Repo to config.exs:

use Mix.Config
config :exampleapp, ecto_repos: [ExampleApp.Repo]

then run: mix ecto.gen.repo image

https://elixirschool.com/en/lessons/specifics/ecto/#supervisor image

https://elixirschool.com/en/lessons/specifics/ecto/#configuration image

https://elixirschool.com/en/lessons/specifics/ecto/#mix-tasks image

https://elixirschool.com/en/lessons/specifics/ecto/#migrations

mix ecto.gen.migration users

image

mix ecto.migrate

image

https://elixirschool.com/en/lessons/specifics/ecto/#models unclear from the intro to models where we should put our Users model...! ๐Ÿ˜• so putting it in ./models/user.ex: image

https://elixirschool.com/en/lessons/specifics/ecto/#querying again zero indication where we should put the code!! image

https://elixirschool.com/en/lessons/specifics/ecto/#basics just shows some basic ecto queries. useless without any sample data!

https://elixirschool.com/en/lessons/specifics/ecto/#changesets image

There doesn't appear to be any continuity after this ... ๐Ÿ˜• Again, I think we need an "end-to-end" tutorial ...

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/specifics/eex/ image

https://elixirschool.com/en/lessons/specifics/eex/#evaluation image

https://elixirschool.com/en/lessons/specifics/eex/#definitions again totally unclear where I'm meant to put the code ... but here goes: image Worked: image

https://elixirschool.com/en/lessons/specifics/eex/#tags tried it in greeting.eex: image

https://elixirschool.com/en/lessons/specifics/eex/#engine image

done. โœ…

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/specifics/ets/ https://elixirschool.com/en/lessons/specifics/ets/#creating-tables image

https://elixirschool.com/en/lessons/specifics/ets/#table-types image

https://elixirschool.com/en/lessons/specifics/ets/#inserting-data image

https://elixirschool.com/en/lessons/specifics/ets/#data-retrieval image

https://elixirschool.com/en/lessons/specifics/ets/#simple-matches image image

https://elixirschool.com/en/lessons/specifics/ets/#advanced-lookup image image

https://elixirschool.com/en/lessons/specifics/ets/#deleting-data image

https://elixirschool.com/en/lessons/specifics/ets/#removing-tables image

https://elixirschool.com/en/lessons/specifics/ets/#example-ets-usage image

simplecache.ex image

https://elixirschool.com/en/lessons/specifics/ets/#disk-based-ets image

done. sleep time ... ๐Ÿ˜ด ๐Ÿ’ค

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/specifics/mnesia/ finally!!! ๐Ÿ˜ image

https://elixirschool.com/en/lessons/specifics/mnesia/#when-to-use image

https://elixirschool.com/en/lessons/specifics/mnesia/#nodes image

went off on a slight tangent reading: https://dba.stackexchange.com/questions/84/mnesia-advantages-and-differences which took me to many other places! but in the interest of getting back on track (i'm not going to paste lots more links here...) where was I...? ๐Ÿค”

https://elixirschool.com/en/lessons/specifics/mnesia/#starting-mnesia image

https://elixirschool.com/en/lessons/specifics/mnesia/#creating-tables image

https://elixirschool.com/en/lessons/specifics/mnesia/#the-dirty-way image

https://elixirschool.com/en/lessons/specifics/mnesia/#transactions image and image

https://elixirschool.com/en/lessons/specifics/mnesia/#using-indices image Retrieving based on :job index: image

https://elixirschool.com/en/lessons/specifics/mnesia/#match-and-select image Mnesia.select/2: http://erlang.org/doc/man/mnesia.html#select-2 image

https://elixirschool.com/en/lessons/specifics/mnesia/#data-initialization-and-migration image code: image

done. (barely scratch the surface, but at least we know the super-basics!)

nelsonic commented 7 years ago

https://elixirschool.com/en/lessons/specifics/debugging/ image image Took absolute ages to check 380 on my "crappy ol' laptop" and didn't output time taken ...!

https://elixirschool.com/en/lessons/specifics/debugging/#static-analysis-of-code image

https://elixirschool.com/en/lessons/specifics/debugging/#debugging image image image

https://elixirschool.com/en/lessons/specifics/debugging/#creating-breakpoints image image

Disable / Delete a breakpoint: image image

onto Guardian ...?

nelsonic commented 7 years ago

pretty close to finishing (all of) Elixir School, why not do the Guardian lesson...? ๐Ÿ˜‰ https://elixirschool.com/en/lessons/libraries/guardian/ image

https://elixirschool.com/en/lessons/libraries/guardian/#jwts image I'm quite familiar with JWTs ... ๐Ÿ˜‰ image

https://elixirschool.com/en/lessons/libraries/guardian/#setup

mix new MyApp
cd MyApp

image

https://elixirschool.com/en/lessons/libraries/guardian/#minimal-setup image config/config.ex: image

lib/my_app/guardian_serializer.ex >> lib/guardian_example/guardian_serializer.ex image

https://elixirschool.com/en/lessons/libraries/guardian/#http-requests image

"Guardian doesnโ€™t require Phoenix, but using Phoenix in the following examples will be easiest" right... ๐Ÿ™„

The guardian example is incomplete and thus confusing to beginners. I'm disappointed. We can/will do better. see: https://github.com/dwyl/learn-phoenix-framework/issues/93

nelsonic commented 7 years ago

The Last Lesson in Elixir School!! ๐Ÿ˜ฎ https://youtu.be/GVUTiuPuxMc

https://elixirschool.com/en/lessons/libraries/poolboy/ image

https://elixirschool.com/en/lessons/libraries/poolboy/#installation image image

https://elixirschool.com/en/lessons/libraries/poolboy/#the-configuration-options image

Note: actual configuration below.

https://elixirschool.com/en/lessons/libraries/poolboy/#configuring-poolboy image

https://elixirschool.com/en/lessons/libraries/poolboy/#creating-worker image

https://elixirschool.com/en/lessons/libraries/poolboy/#using-poolboy image

Ok. this is a joke. it would have been trivially easy to make this lesson good. instead it assumes that people magically know where to put the code! Utterly useless! I'm exceedingly disappointed with these lass two lessons. They should have a massive "Work In Progress" label on them cause they aren't finished!! I'm going to FIX this!!