Elixir/phoenix Flashcards

1
Q

What is def?

A

def/2. A macro that let’s you define functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do AST tuples contain?

A

function name, metadata, and function arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the output of quote do:42

A

42

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the output of quote do: "Hello"

A

“Hello”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the output of quote do: 1 + 2

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

is quote a macro or a function?

A

macro

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

how do you get the textual code representation from a quoted expression?

A

Macro.to_string(quote do: sum(1, 2 + 3, 4))

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Inner join example

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

left join example

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the most common Webserver used with plug?

A

the Cowboy webservr

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

defp

A

defp/2 is a macro used to define private functions in the module

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

private functions vs regular functions

A

private functions cannot be called from other modules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

how to change the port Phoenix runs on

A

go to config/dev.exs and change the [port: 4000] section to [port: System.get_env("PORT") || 4000] and then boot up program in terminal like PORT=4444 mix phx.server

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how to kill Phoenix process in terminal

A

Ctrl-C a ENTER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

defmodule

A

defmodule/2 a macro that lets you define your own modules

17
Q

use

A

use/2 is a macro

18
Q

what does use translate to?

A

require and ExUnit.Case.\_\_using\_\_

example:

use ExUnit.Case, async: true

—–> =

require ExUnit.Case

ExUnit.Case.\_\_using\_\_(async: true)
19
Q

require

A

require/2 is a macro. Requires a module in order to use its macros.

20
Q

How to use the html generator?

A

$ mix phoenix.gen.html Post posts title:string body:text

21
Q

what does mix phoenix.gen.html create?

A

model, view, controllers, repository, templates, tests

22
Q

What would you have to do after creating a Post object and related items using the html generator?

A

add a new endpoint to resources "/posts", PostController

23
Q

How can you see your routes list?

A

$ mix phoenix.routes

24
Q

where are migration files located?

A

priv/repo/migrations/

25
Q

mix ecto.something is analogous to what in Rails?

A

rake db:something

26
Q

What are the four Phoenix generators?

A

mix mix phoenix.gen.html, mix phoenix.gen.channel, mix phoenix.gen.json, mix phoenix.gen.model