Giter Site home page Giter Site logo

the-little-elixir-otp-guidebook-code's Introduction

Code for The Little Elixir & OTP Guidebook

Welcome! This is the source code for "The Little Elixir & OTP Guidebook".

Running the code

For programs that are not created by mix, can be run as such:

% iex length_converter.ex

Larger programs such as metex in Chapter 3, can be run with the following command:

% iex -S mix

These larger programs will contain their own READMEs and more detailed instructions on running the program.

Enjoy!

the-little-elixir-otp-guidebook-code's People

Contributors

benjamintanweihao avatar chenyuxyz avatar cinderella-man avatar guypeer8 avatar ilasorsa avatar wulymammoth avatar zeroasterisk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

the-little-elixir-otp-guidebook-code's Issues

Answers to exercises?

I'm working through the book, great job by the way, and am stuck on one of the exercises. Are you planning on posting solutions to them anywhere?

Listing 2.5 ID3Parser

Tried to run ID3Parser.parse "/Users/riza/Downloads/Barn_Owl-The_Long_Shadow.mp3". Got the following result:

Barn Owl^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ - The Long Shadow^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@ (V^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@, 2013)

Music took from http://www.epitonic.com/#/genres/blues/.

Just wondering it's because of the mp3 file or the code. Because I tried 3 mp3s the results are similar.

Chapter 8 - Blitzy implementation is different from the repo?

Hello, Blitzy's implementation from the book seems different from the repo. The version in the book has a start/2 function because Blitzy.Caller passes its PID in order to get the results back to it.

Which version is the correct one? Maybe the chapter 8 in the book still hasn't been finalized?

Thanks

Proposed change

I was looking through the pooly source and had a couple of questions in handle_info/2 (https://github.com/benjamintanweihao/the-little-elixir-otp-guidebook-code/blob/master/chapter_7/pooly/version-3/lib/pooly/pool_server.ex#L109-L114)

  1. Don't we want to move new_state = %{state | workers: [new_worker(pool_sup)|workers]} above case :ets.lookup(monitors, pid) do, so that workers are restarted even if they aren't checked out into ets?
  2. Don't we want to use new_worker(worker_sup) instead of new_worker(pool_sup), because the workers should be children of the worker_sup, right? This is consistent with prepopulate(size, worker_sup) ( ) which is the only other place where new_worker gets called.

Why the use of SampleWorker mfa to start WorkerSupervisor in version 1 of Pooly?

A bit confused about the use of the SampleWorker mfa which is passed from Pooly to the top-level Supervisor, who then passes it to Server to use to start up WorkerSupervisor in version 1 of Pooly.

Since the init between SampleWorker and WorkerSupervisor (default init vs implemented) is so different, shouldn't the mfa for WorkerSupervisor be used instead? Or, will I see this changed in later iterations of Pooly?

Thanks

terminating children in thy_supervisor.ex

I am reading through the book and I am confused on pages 102 - 103. for the following handle_call cb we delete the child from the state (HashDict).

def handle_call({ :terminate, pid }, _from, state) do
case terminate_child(pid) do
:ok ->
new_state = state |> HashDict.delete(pid)
{ :reply, :ok, new_state }
:error ->
{ :reply, { :error, "error terminating child" }, state }
end
end

defp terminate_child(pid) do
Process.exit(pid, :kill)
:ok
end

Benjamin then goes to explain that we must provide the following handle info cb to terminate the child process, since we used Process.exit(pid, :kill)

def handle_info({ :EXIT, from, :killed }, state) do
new_state = state |> HashDict.delete(from)
{ :noreply, new_state }
end

To me it seems you are deleting the child process twice since the following line

new_state = state |> HashDict.delete(from)

is in both the handle_call and handle_info callbacks. What is going on here?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.