« Back to channel list

#elixir-lang - 23 June 2019

« Back 1 day Forward 1 day »
[00:01:59] adonis: Hi all, I have a simple question. In this example child_spec "%{id: Todo.Cache, start: {Todo.Cache, :start_link, [nil]}}", why does start_map take a list (the third argument) if the Supervisor that uses it will simply pass nil to start_link in this example?
[00:02:19] adonis: the start key*
[00:03:57] adonis: so Todo.Cache.start_link(nil) will be called instead of Todo.Cache.start_link([nil])
[00:07:06] ankhers: adonis: Todo.Cache.start_link(nil) still gets called. That format is known as MFA or Module, Function, Arguments. The list is used for arguments so that you can pass a variable number of arguments to a given function. If we did not use the list, you would have to use some other format (maybe a loarger tuple?) But then there could possibly be limitations on the number of arguments you could pass to the function.
[00:08:06] ankhers: For what it's worth, since you are passing nil, you could just not pass anything (i.e., use an empty list for that third argument).
[00:08:25] ankhers: Unless nil is somehow important to the initialization function?
[00:09:02] adonis: Ok, so its to support MFA so a list makes sense, but in this case even though it’s a list how come the list is not passed to Todo.Cache.start_link() ?
[00:09:05] rere: has joined #elixir-lang
[00:09:25] adonis: Todo.Cache.start_link receives nil (the first element of the list only)
[00:11:41] ankhers: Yes, again, we use lists so that we can technically pass an infinite amount of values to a given function. So if you did {Todo.Cache, :start_link, [:foo, :bar]}, it would pass two arguments, :foo as the first and :bar as the second, to the start_link function.
[00:12:14] adonis: so in that case start_link([:foo, :bar]) would be called..
[00:12:42] ankhers: {Todo.Cache, :start_link, [[:foo, :bar]]} would call start_link([:foo, :bar])
[00:12:54] ankhers: It takes a bit to get used to.
[00:13:07] ankhers: I know I stumbled on this more than a few times when starting.
[00:14:05] adonis: What does {Todo.Cache, :start_link, [:foo, :bar]} call?
[00:14:13] ankhers: start_link(:foo, :bar)
[00:14:17] adonis: start_link/2
[00:14:19] adonis: aha.. ok.
[00:14:30] adonis: That’s what I was trying to understand.
[00:14:31] ankhers: Each element in the list becomes an argument to the function.
[00:14:46] ankhers: https://hexdocs.pm/elixir/Kernel.html#apply/3 -- If it makes a difference, this is what is being called underneath.
[00:15:20] adonis: It makes sense to me now :)
[00:16:03] ankhers: You are welcome! Glad I could help. If there is anything else you come across that is confusing, just ask.
[00:18:36] adonis: Sounds good! By the way loving elixir right now. I'm a iOS dev who usually has done the backends for my apps. Initially I was using Go but Elixir/Erlang caught my eyes for what it could do with Supervisors, etc etc..
[00:19:35] adonis: Lol, I'm in the middle of trying to finish up Elixir in Action. Pretty good book.
[00:30:22] InternetFriend: has joined #elixir-lang
[00:33:57] __charly__: has joined #elixir-lang
[00:34:59] jeffro: has joined #elixir-lang
[00:45:34] Exuma: has joined #elixir-lang
[00:48:05] InternetFriend: has joined #elixir-lang
[00:57:49] dsr: has joined #elixir-lang
[01:02:50] dsr: has joined #elixir-lang
[01:12:31] cschneid_: has joined #elixir-lang
[01:15:18] praveenperera: has joined #elixir-lang
[01:16:52] elixir-logger: has joined #elixir-lang
[01:17:08] praveenperera: has left #elixir-lang: ()
[01:17:58] SirFunk: has joined #elixir-lang
[01:20:13] dsr: has joined #elixir-lang
[01:26:34] dsr: has joined #elixir-lang
[01:29:46] tomterl: has joined #elixir-lang
[01:29:48] pera: has joined #elixir-lang
[01:31:18] dsr: has joined #elixir-lang
[01:35:29] dsr: has joined #elixir-lang
[01:41:27] dsr: has joined #elixir-lang
[01:49:17] InternetFriend: has joined #elixir-lang
[01:49:49] mahmudov: has joined #elixir-lang
[02:02:32] praveenperera: has joined #elixir-lang
[02:02:37] praveenperera: has left #elixir-lang: ()
[02:03:25] ariedler: has joined #elixir-lang
[02:07:02] jeffweiss: has joined #elixir-lang
[02:10:21] praveenperera: has joined #elixir-lang
[02:18:57] InternetFriend: has joined #elixir-lang
[02:19:27] cschneid_: has joined #elixir-lang
[02:21:21] iamvery: has joined #elixir-lang
[02:27:53] jmcgnh: has joined #elixir-lang
[02:35:51] jeffro: has joined #elixir-lang
[02:52:32] InternetFriend: has joined #elixir-lang
[03:18:08] jeffweiss: has joined #elixir-lang
[03:18:26] Guest73854: has joined #elixir-lang
[03:22:03] ariedler: has joined #elixir-lang
[03:29:09] cschneid_: has joined #elixir-lang
[03:31:54] praveenperera: has joined #elixir-lang
[03:36:46] jeffro: has joined #elixir-lang
[03:42:45] deesar: has joined #elixir-lang
[03:47:57] jeffweiss: has joined #elixir-lang
[04:08:33] jeffweiss: has joined #elixir-lang
[04:12:58] cschneid_: has joined #elixir-lang
[04:16:04] ariedler: has joined #elixir-lang
[04:19:54] mdbm: has joined #elixir-lang
[04:26:48] cschneid_: has joined #elixir-lang
[04:31:58] Disorganized: has joined #elixir-lang
[04:33:51] Saukk: has joined #elixir-lang
[04:43:31] jeffweiss: has joined #elixir-lang
[04:46:27] foggyboi: has joined #elixir-lang
[04:53:47] jeffweiss: has joined #elixir-lang
[04:56:46] jeffro: has joined #elixir-lang
[05:02:15] notzmv: has joined #elixir-lang
[05:03:32] iamvery: has joined #elixir-lang
[05:04:42] voltone: has joined #elixir-lang
[05:06:41] wsieroci: has joined #elixir-lang
[05:07:38] cschneid_: has joined #elixir-lang
[05:14:18] gvaughn: has joined #elixir-lang
[05:57:27] jeffweiss: has joined #elixir-lang
[06:05:16] zigpaw: has joined #elixir-lang
[06:08:22] cschneid_: has joined #elixir-lang
[06:20:29] gvaughn: has joined #elixir-lang
[06:21:37] mdbm_: has joined #elixir-lang
[06:28:12] tuacker: has joined #elixir-lang
[06:33:14] jeffro: has joined #elixir-lang
[06:43:53] dsr: has joined #elixir-lang
[06:54:26] notzmv: has joined #elixir-lang
[07:00:26] dsr: has joined #elixir-lang
[07:02:19] elixir-lang234: has joined #elixir-lang
[07:03:15] iamvery: has joined #elixir-lang
[07:33:59] InternetFriend: has joined #elixir-lang
[07:38:02] cschneid_: has joined #elixir-lang
[07:46:46] gde33: has joined #elixir-lang
[07:46:58] absolutejam: has joined #elixir-lang
[08:09:41] lexmag: has joined #elixir-lang
[08:14:27] InternetFriend: has joined #elixir-lang
[08:17:48] ariedler: has joined #elixir-lang
[08:34:56] jeffro: has joined #elixir-lang
[08:48:01] wsieroci: has joined #elixir-lang
[08:53:30] mahmudov: has joined #elixir-lang
[09:03:00] gvaughn: has joined #elixir-lang
[09:05:24] iamvery: has joined #elixir-lang
[09:07:08] ephemera_: has joined #elixir-lang
[09:08:32] cschneid_: has joined #elixir-lang
[09:11:50] Sgeo_: has joined #elixir-lang
[09:14:43] sangoma: has joined #elixir-lang
[09:18:11] sangoma: has joined #elixir-lang
[09:30:03] lexmag_: has joined #elixir-lang
[09:55:39] Sgeo_: has joined #elixir-lang
[10:18:27] ariedler: has joined #elixir-lang
[10:22:05] Randyr: has joined #elixir-lang
[10:25:28] jeffro: has joined #elixir-lang
[10:38:10] cschneid_: has joined #elixir-lang
[10:51:13] gvaughn: has joined #elixir-lang
[10:53:57] squalloster: has joined #elixir-lang
[10:54:20] iamvery: has joined #elixir-lang
[10:55:07] ariedler: has joined #elixir-lang
[10:55:44] jeffweiss: has joined #elixir-lang
[11:04:07] iamvery: has joined #elixir-lang
[11:18:13] InternetFriend: has joined #elixir-lang
[11:20:48] absolutejam: has joined #elixir-lang
[11:21:39] jeffweiss: has joined #elixir-lang
[11:45:29] dsr[m]: has joined #elixir-lang
[11:46:56] m1dnight1: has joined #elixir-lang
[11:52:29] netrino__: has joined #elixir-lang
[11:59:51] InternetFriend: has joined #elixir-lang
[12:00:34] Phylock: has joined #elixir-lang
[12:07:47] sangoma: has joined #elixir-lang
[12:09:55] cschneid_: has joined #elixir-lang
[12:12:46] wsieroci: has joined #elixir-lang
[12:23:05] mdbm__: has joined #elixir-lang
[12:26:21] jeffro: has joined #elixir-lang
[12:35:09] jeffro: has joined #elixir-lang
[12:36:40] mdbm_: has joined #elixir-lang
[12:39:33] gvaughn: has joined #elixir-lang
[12:42:36] wsieroci: has joined #elixir-lang
[12:43:25] sangoma: has joined #elixir-lang
[13:02:13] gvaughn: has joined #elixir-lang
[13:03:18] voltone: has joined #elixir-lang
[13:26:22] mdbm_: how do you manage to stay connected forever?
[13:27:12] edwinbalani: To IRC? I use a bouncer
[13:27:37] ankhers: Specifically, I use https://wiki.znc.in/ZNC
[13:27:59] ankhers: I have a small server setup that I use for various things and I threw ZNC on that.
[13:28:36] ankhers: I think some web based IRC clients will also act as a bouncer for you.
[13:31:28] edwinbalani: ^ ZNC in much the same environment for me
[13:32:09] edwinbalani: In theory you could run a ZNC for yourself *and* others; it's not too difficult to maintain and is built for multiple users
[13:32:30] edwinbalani: (conversely, you may find someone running a ZNC who could give you an account)
[13:33:08] ankhers: Just be careful with that though. Your passwords are stored in plaintext with ZNC. So make sure it is something you trust.
[13:33:57] ankhers: someone you trust rather.
[13:35:20] edwinbalani: The communications in general are also going through their bouncer, so you should trust them for that reason as well
[13:36:02] edwinbalani: ZNC has lots of plugins like channel logging (which I use)
[14:01:47] deesar: has joined #elixir-lang
[14:10:35] sangoma: has joined #elixir-lang
[14:30:34] cschneid_: has joined #elixir-lang
[14:36:00] jeffro: has joined #elixir-lang
[14:45:39] dsr[m]: There’s also riot.im that can bridge to IRC which acts as a bouncer.
[14:47:26] mdbm_: has joined #elixir-lang
[14:47:34] Disorganized: has joined #elixir-lang
[14:56:03] Disorganized: has joined #elixir-lang
[15:00:57] __charly__: has joined #elixir-lang
[15:01:00] andersju: mdbm_: tmux+weechat-or-irssi on a server somewhere (e.g. a vps for a few dollars a month) is another popular alternative
[15:01:43] mdbm_: andersju, actually i nhave a VPS server
[15:10:04] __charly__: has joined #elixir-lang
[15:16:08] InternetFriend: has joined #elixir-lang
[15:16:35] tuacker: has joined #elixir-lang
[15:23:08] jeffweiss: has joined #elixir-lang
[15:23:37] cschneid_: has joined #elixir-lang
[15:38:49] gvaughn: has joined #elixir-lang
[15:46:13] jeffro: has joined #elixir-lang
[15:53:09] Disorganized: has joined #elixir-lang
[15:55:30] nickjj: does anyone know when the programming phoenix 1.4 book wrote the section on associating data between echo schemas?
[15:57:01] nickjj: just asking because the book says to use put_assoc when dealing with associated records across 2 contexts , but the documentation on contexts says not to do that but to use ecto multi instead
[15:58:56] nickjj: which one should we use, and if it's ecto multi, will the book be amended for that before it's finalized?
[16:15:43] gvaughn: has joined #elixir-lang
[16:34:42] cschneid_: has joined #elixir-lang
[16:41:14] __charly__: has joined #elixir-lang
[16:43:28] orbyt_: has joined #elixir-lang
[16:56:50] jeffro: has joined #elixir-lang
[17:00:25] InternetFriend: has joined #elixir-lang
[17:02:47] praveenperera: has joined #elixir-lang
[17:15:03] Disorganized: has joined #elixir-lang
[17:15:51] praveenperera: has joined #elixir-lang
[17:18:40] hypercore: guys what function do i give to put_assoc? (when i want to create a bunch of has_many models for my parent model?
[17:23:46] hypercore: or should i not be using put_assoc?
[17:24:06] wonko7: has joined #elixir-lang
[17:48:04] __charly__: has joined #elixir-lang
[17:48:22] josevalim: nickjj: i honestly think both are fine
[17:49:08] josevalim: the guide may have decided to not do associations across 2 contexts though
[17:49:17] josevalim: so then you have to resort to multis?
[17:49:48] nickjj: the guide (docs) only talks about it at the very end in the " Strategies for cross-context workflows
[17:49:48] nickjj: " section
[17:50:41] jmiven: has joined #elixir-lang
[17:50:42] nickjj: oh, it supports direct linking: https://hexdocs.pm/phoenix/contexts.html#strategies-for-cross-context-workflows
[17:51:53] DTZUZO: has joined #elixir-lang
[17:51:56] josevalim: nickjj: and where in the book does it use put_assoc?
[17:53:48] josevalim: i assume in the relationships chapteer, is it the video <-> user relationship?
[17:54:02] nickjj: josevalim, chapter 6 under "managing related data". it's where we do create_video that takes a user and then we put_assoc(:user, user)
[17:54:11] josevalim: yes, that's totally fine
[17:54:17] josevalim: because you have the video building on top of users
[17:54:30] josevalim: you want to avoid the other way around (users knowing about everything in the system)
[17:54:38] InternetFriend: has joined #elixir-lang
[17:54:50] josevalim: the rule is to avoid cycles in how your contexts depend on each other
[17:55:18] nickjj: ah i see, so multimedia deals with videos and videos have a user_id , so put_assoc on the user is cool because we need to know about it anyways?
[17:55:29] josevalim: yes, exactly
[17:56:05] josevalim: going with the phoenix guide, it is ok for for CMS to depend on Accounts, because you need accounts to make it tick, but you want to avoid accounts knowing about everything in the system
[17:56:15] nickjj: i don't want to bug you with my suggestions (you're the boss!) but would a "jose says" aside be worth it there to talk about multi and why it's not a good fit?
[17:56:30] nickjj: and when multi would be a good fit potentially
[17:57:43] josevalim: we don't mention multi anywhere in the book
[17:57:50] josevalim: so we can't just drop it out of nowher
[17:57:58] josevalim: it will be more confusing than helpful
[17:58:16] nickjj: ok, thanks
[17:58:25] josevalim: but we can add more nuance to the guides
[17:58:30] josevalim: thanks for the suggestions!
[18:01:50] absolutejam: has joined #elixir-lang
[18:04:30] cschneid_: has joined #elixir-lang
[18:07:22] hypercore: if i have a parent has_many children relationship, how do i get the parent_id to use in the children models if i haven't created the parent model yet?
[18:08:19] hypercore: e.g. Shop has_many Products, but i want to create a new shop, and at the same time create several products, how would i do this in my changeset so that Product{shop_id: Shop.id}?
[18:09:01] josevalim: ah, the guide is actually commenting on this already
[18:09:04] josevalim: > If we require a `CMS.Author` to exist every time an `Accounts.User` is created, we have to think carefully where to place this dependency. We know our `CMS` context depends on the `Accounts` context, but it's important to avoid cyclic dependencies across our contexts
[18:17:56] hypercore: was that aimed at nickjj?
[18:24:06] hypercore: just wanted to make sure :P
[18:30:24] jeffro: has joined #elixir-lang
[18:31:32] nickjj: for some reason the way the guide worded it wasn't as clear as what you wrote -- at least not to me
[18:36:08] squalloster: has joined #elixir-lang
[18:37:45] sillyotter: has joined #elixir-lang
[18:38:35] nickjj: hypercore, i do something like this https://gist.github.com/nickjj/775c9adf79af8e01916f3c08dfcb5fb7 , no idea if it's the best way, but it does work (the child record gets created from the parent)
[18:41:16] cschneid_: has joined #elixir-lang
[18:43:15] micmus: has joined #elixir-lang
[18:49:58] hypercore: nickjj: cool thanks, think i got that part working. Only problem is now i'm getting this error -> https://paste.ubuntu.com/p/MQDRVvrZrv/
[18:51:15] hypercore: not sure what the problem is exactly, could it be that my Image model has a filed called :filename, and somehow this is a problem for Arc?
[18:51:38] nickjj: you might want to comb through https://github.com/thechangelog/changelog.com/tree/master/lib/changelog/files , it has a working example of using arc (it's what i used as a guide to get arc fully working)
[18:51:58] nickjj: i don't know enough about arc to know what went wrong with your gist
[18:52:33] nickjj: if you look at changelog's person schema, it has an arc ecto field too (for profiles)
[18:57:57] hypercore: nickjj: i've got it working for a User's avatar, but now im trying to use it to allow users to upload a bunch of Images (i.e. a has_many relationship), which seems to be different somehow
[18:58:14] hypercore: although it shouldn't be
[18:59:34] nickjj: i never tried multiple images, but there's this in arc_ecto's repo https://github.com/stavro/arc_ecto/pull/91/commits/cb961a63fb1b325def1ade7548dd0e1d08a460c3
[19:00:29] InternetFriend: has joined #elixir-lang
[19:00:45] hypercore: nickjj: great thanks, i'll see if i can get it working after looking at that repo
[19:01:25] dsr: has joined #elixir-lang
[19:40:53] boeg: has left #elixir-lang: ("ERC (IRC client for Emacs 26.2)")
[19:41:22] hypercore: lol this issue has been open for 3 years -> https://github.com/stavro/arc/issues/52
[19:42:05] hypercore: oh no it was closed
[19:47:08] Sgeo_: has joined #elixir-lang
[19:48:53] gde33: has joined #elixir-lang
[19:49:59] cschneid_: has joined #elixir-lang
[19:54:55] awl: has joined #elixir-lang
[20:03:58] boeg: has joined #elixir-lang
[20:23:03] infowolfe: has joined #elixir-lang
[20:23:37] praveenperera: has joined #elixir-lang
[20:40:20] boeg: has left #elixir-lang: ("ERC (IRC client for Emacs 26.2)")
[20:49:27] praveenperera: has joined #elixir-lang
[20:57:48] tuacker: has joined #elixir-lang
[21:01:27] boeg: has joined #elixir-lang
[21:26:33] cschneid_: has joined #elixir-lang
[21:29:53] ur5us: has joined #elixir-lang
[21:30:32] jeffro: has joined #elixir-lang
[21:32:23] jeffweiss: has joined #elixir-lang
[21:56:14] griffinbyatt: has joined #elixir-lang
[22:04:05] phinas: has joined #elixir-lang
[22:07:13] __charly__: has joined #elixir-lang
[22:57:17] cschneid_: has joined #elixir-lang
[23:01:38] deesar: has joined #elixir-lang
[23:01:47] Disorganized: has joined #elixir-lang
[23:26:02] icecreamcohen: has joined #elixir-lang
[23:31:20] jeffro: has joined #elixir-lang
[23:37:30] Disorganized: has joined #elixir-lang