« Back to channel list

#elixir-lang - 16 May 2019

« Back 1 day Forward 1 day »
[00:01:12] ave_: has joined #elixir-lang
[00:05:05] notzmv: has joined #elixir-lang
[00:11:35] benwilson512: I've gotta get someone to explain how nested live views work
[00:14:25] orbyt_: has joined #elixir-lang
[00:38:58] nageV: wow, OTP 22.0 is a beast!! my program runs 2x faster now (went from 9min 50sec for processing a 21GB file down to just 4min 33sec now) just by upgrading :O
[00:51:52] Adkron: has joined #elixir-lang
[01:00:11] lexmag: has joined #elixir-lang
[01:19:22] sinni800: thank you all for your suggestions
[01:23:46] FancyEagle: has joined #elixir-lang
[01:33:32] orbyt_: has joined #elixir-lang
[01:34:06] icecreamcohen: has joined #elixir-lang
[01:34:58] ur5us: has joined #elixir-lang
[01:45:11] tomterl: has joined #elixir-lang
[01:48:57] praveenperera: has joined #elixir-lang
[01:49:10] blahdodo: has joined #elixir-lang
[01:58:30] Adkron: has joined #elixir-lang
[02:09:55] FancyEagle: has joined #elixir-lang
[02:31:50] greengriminal: has joined #elixir-lang
[02:33:11] Saukk: has joined #elixir-lang
[02:37:32] Adkron: has joined #elixir-lang
[02:38:42] laut: has joined #elixir-lang
[02:59:27] jmiven: has joined #elixir-lang
[03:13:54] Adkron: has joined #elixir-lang
[03:20:42] craigp_: has joined #elixir-lang
[03:25:46] FancyEagle: has joined #elixir-lang
[03:26:53] FancyEagle: has joined #elixir-lang
[03:27:04] icecreamcohen: has joined #elixir-lang
[03:29:52] Nicd-: nageV: nice
[03:30:33] greengriminal: has joined #elixir-lang
[03:36:30] zigpaw: has joined #elixir-lang
[03:51:54] icecreamcohen: has joined #elixir-lang
[03:52:37] Adkron: has joined #elixir-lang
[04:12:06] mbuf: has joined #elixir-lang
[04:17:07] josevalim: nageV: amazing!
[04:17:43] josevalim: Binary handling is one of the things drastically improved in this release
[04:20:24] orbyt_: has joined #elixir-lang
[04:22:09] gvaughn: has joined #elixir-lang
[04:30:35] icecreamcohen: has joined #elixir-lang
[04:34:39] jeffro: has joined #elixir-lang
[04:55:53] gvaughn: has joined #elixir-lang
[05:00:08] voltone: has joined #elixir-lang
[05:01:56] praveenperera: has joined #elixir-lang
[05:12:48] lauromoura__: has joined #elixir-lang
[05:18:42] praveenperera: has joined #elixir-lang
[05:29:32] jeffro: has joined #elixir-lang
[05:31:05] Schmuserkadser: has joined #elixir-lang
[05:33:58] Schmuserkadser: When i want to store form Informations in a Connection instead of Changeset, do i need to create an Empty Connection Struct? As josevalim said it doesn't make any sense to set the own Connection.
[05:49:44] hypercore: has joined #elixir-lang
[05:54:05] gvaughn: has joined #elixir-lang
[05:54:46] Adkron: has joined #elixir-lang
[05:55:08] sevenseacat: has joined #elixir-lang
[05:56:50] bigvig: has joined #elixir-lang
[05:59:10] gvaughn: has joined #elixir-lang
[06:01:54] kyrylo: has joined #elixir-lang
[06:14:16] Guest42: has joined #elixir-lang
[06:15:41] Schmuserkadser: When i want to store form Informations in a Connection instead of Changeset, do i need to create an Empty Connection Struct? As josevalim said it doesn't make any sense to set the own Connection.
[06:25:25] netrino: has joined #elixir-lang
[06:33:54] jeffro: has joined #elixir-lang
[06:46:13] tomaz_b: has joined #elixir-lang
[06:59:37] ur5us: has joined #elixir-lang
[07:06:51] 7ITAAFBPL: has joined #elixir-lang
[07:06:59] gvaughn: has joined #elixir-lang
[07:15:45] jeffro: has joined #elixir-lang
[07:30:48] jeffro: has joined #elixir-lang
[07:51:40] jeffro: has joined #elixir-lang
[07:57:07] Adkron: has joined #elixir-lang
[08:00:36] Guest42: has joined #elixir-lang
[08:01:17] lexmag: has joined #elixir-lang
[08:03:40] Guest42: has joined #elixir-lang
[08:15:52] lexmag_: has joined #elixir-lang
[08:16:59] optikfluffel: has joined #elixir-lang
[08:18:20] gvaughn: has joined #elixir-lang
[08:24:43] Gika: has joined #elixir-lang
[08:38:22] ur5us: has joined #elixir-lang
[08:59:01] lexmag: has joined #elixir-lang
[09:21:47] wonko7: has joined #elixir-lang
[09:22:12] nickjj: has joined #elixir-lang
[09:25:45] vali: has joined #elixir-lang
[09:29:12] lexmag: has joined #elixir-lang
[09:41:10] jeffro: has joined #elixir-lang
[09:51:14] Gika: has joined #elixir-lang
[09:57:45] ur5us: has joined #elixir-lang
[09:58:29] grumble: has joined #elixir-lang
[09:59:10] Adkron: has joined #elixir-lang
[10:02:28] gvaughn: has joined #elixir-lang
[10:12:29] tutti: has joined #elixir-lang
[10:16:45] lexmag: has joined #elixir-lang
[10:16:51] lexmag_: has joined #elixir-lang
[10:20:57] hypercore: has joined #elixir-lang
[10:27:03] voltone: has joined #elixir-lang
[10:51:51] voltone: has joined #elixir-lang
[10:54:28] lexmag: has joined #elixir-lang
[11:01:56] gvaughn: has joined #elixir-lang
[11:11:16] kyrylo: has joined #elixir-lang
[11:26:25] nickjj: if i wanted to match on a controller function where a specific form field has a non-empty string then using `when byte_size(myfield)` is the way to go right?
[11:30:26] wonko7: has joined #elixir-lang
[11:37:28] dysfun: nickjj: yeah, that and is_binary()
[11:37:46] dysfun: but why not is_binary() and /= "" ?
[11:38:01] dysfun: or matching out "" in an earlier case?
[11:38:04] nickjj: is /= "" a valid expression?
[11:39:01] dysfun: def foo(a) when is_binary(a) and a != ""
[11:39:03] dysfun: that's valid
[11:39:27] nickjj: my plan was to have 2 functions , one match for myfield (when it's filled out) and another when myfield is empty (in which case, no guard clause)
[11:39:50] dysfun: well you'd probably still want to check it's a binary
[11:40:00] dysfun: but yeah, having a separate clause for "" is a good way
[11:40:21] nickjj: in this case it's coming from a form field params, wouldn't it always be a string at this point?
[11:40:35] dysfun: oh, probably
[11:41:02] lexmag: has joined #elixir-lang
[11:41:46] nickjj: do you know of any references in the docs that compares things like using byte_size(foo) > 0 vs a != ""
[11:42:33] dysfun: the latter will be cheaper
[11:42:41] gvaughn: has joined #elixir-lang
[11:42:45] dysfun: unless the compiler is smart enough to rewrite the former to the latter these days
[11:43:21] nickjj: cool, thanks
[11:44:08] nickjj: i guess in this case, is it a style preference to use guards vs clauses? i just googled an alternative solution
[11:44:44] dysfun: in general, prefer clauses
[11:44:46] nickjj: for example, in this case the person just matches on myfield's argument being empty or not empty https://stackoverflow.com/a/47099430 (instead of a guard)
[11:44:52] dysfun: there are cases where guards work out better though
[11:45:10] nickjj: ^ in the 2nd code snippet of the answer
[11:45:59] dysfun: that seems to agree with what i said
[11:46:12] nickjj: yep, what type of exception would you choose a guard?
[11:46:45] dysfun: well, i might choose one in the case where i didn't want to match the empty case and i just wanted to let it fall off the match and crash
[11:46:48] nickjj: the guard seemed kind of nice on paper because it means i wouldn't have to modify the "other" non-empty case (which i consider the success case)
[11:47:19] nickjj: because this is a controller function that detects whether or not a honeypot field is submit (basically preventing the form from doing its normal thing if a bot filled it out)
[11:47:36] dysfun: but the point is which comes out cleaner and easier to understand in a given situation
[11:47:48] dysfun: usually ime that's extra clauses
[11:48:58] nickjj: in the clause case, does the ordering matter? for instance, does the empty clause fn need to be written first?
[11:49:29] dysfun: because otherwise the one that comes first which accepts anything will match
[11:51:28] dysfun: matches are top to bottom, only one executed
[11:51:40] dysfun: it would be difficult to read code otherwise
[11:52:33] nickjj: thank you, after seeing both written out, i'm with you in that i prefer the clause -- at least for sure in this use case
[11:52:40] hypercore: has joined #elixir-lang
[11:53:07] dysfun: right. know how to use both techniques and make a decision in each case
[11:54:29] nickjj: in both cases i didn't even have to modify the "other" case either, because in that case the form param doesn't exist at all
[11:59:19] __charly__: has joined #elixir-lang
[12:01:20] Adkron: has joined #elixir-lang
[12:04:41] lexmag: has joined #elixir-lang
[12:07:24] lexmag_: has joined #elixir-lang
[12:08:16] scj: has joined #elixir-lang
[12:10:11] scj: hello, I'm experimenting with the demo app for phoenix liveview, but I can't figure out what message I need to send to be able to change the location from IEx
[12:22:53] lexmag: has joined #elixir-lang
[12:29:39] hypercore: has joined #elixir-lang
[12:32:55] m1dnight_: TIL: https://en.wikipedia.org/wiki/Erlang_(unit)
[12:46:30] tnez: has joined #elixir-lang
[12:46:37] jeffro: has joined #elixir-lang
[12:46:55] voltone: has joined #elixir-lang
[12:55:43] sacredfrog: has joined #elixir-lang
[13:17:49] lexmag_: has joined #elixir-lang
[13:25:04] gvaughn: has joined #elixir-lang
[13:25:24] Sgeo__: has joined #elixir-lang
[13:29:48] sacredfrog: has joined #elixir-lang
[13:31:38] greengriminal: has joined #elixir-lang
[13:32:28] knack: has joined #elixir-lang
[13:42:54] blahdodo: has joined #elixir-lang
[13:49:20] hypercore: has joined #elixir-lang
[13:49:25] drincruz_: has joined #elixir-lang
[14:03:34] Adkron: has joined #elixir-lang
[14:09:42] tutti: has joined #elixir-lang
[14:10:58] gvaughn: has joined #elixir-lang
[14:15:23] Adkron: has joined #elixir-lang
[14:18:48] jeffro: has joined #elixir-lang
[14:23:41] dimitarvp: has joined #elixir-lang
[14:23:53] jeffro: has joined #elixir-lang
[14:24:05] wsieroci: has joined #elixir-lang
[14:29:22] lexmag_: has joined #elixir-lang
[14:30:29] hypercore: has joined #elixir-lang
[14:32:08] drincruz: has joined #elixir-lang
[14:42:47] lauromoura: has joined #elixir-lang
[14:53:18] inoas: has joined #elixir-lang
[14:59:45] jeffro_: has joined #elixir-lang
[15:03:00] lexmag_: has joined #elixir-lang
[15:10:35] Phylock: has joined #elixir-lang
[15:14:26] Guest42: has joined #elixir-lang
[15:18:53] orbyt_: has joined #elixir-lang
[15:18:54] Sgeo: has joined #elixir-lang
[15:28:40] icecreamcohen: has joined #elixir-lang
[15:39:22] Gika: has joined #elixir-lang
[15:46:17] praveenperera: has joined #elixir-lang
[16:00:13] sacredfrog: has joined #elixir-lang
[16:04:18] wonko7: has joined #elixir-lang
[16:13:27] lexmag: has joined #elixir-lang
[16:22:13] Adkron: has joined #elixir-lang
[16:28:42] lexmag: has joined #elixir-lang
[16:34:11] edwinbalani: Is there an elegant way of merging typespec maps?
[16:34:51] edwinbalani: I have a case where some elements in a map are required if the value of another element is 200 (for success)
[16:34:58] edwinbalani: otherwise they are optional
[16:36:12] edwinbalani: It would be clearer to read if I could define a 'common' map of the elements that are required in both, and then Map.merge(common_elements, unique_elements) to form each typespec
[16:36:44] lexmag: has joined #elixir-lang
[16:39:34] pera: has joined #elixir-lang
[17:00:09] greengriminal: has joined #elixir-lang
[17:00:59] KeyJoo: has joined #elixir-lang
[17:16:11] ankhers: edwinbalani: If you require certain keys, why not make a struct?
[17:17:13] ankhers: Then in the documentation for your struct, you can say that keys a, b and c are required, while x, y and z are optional.
[17:17:28] lexmag: has joined #elixir-lang
[17:23:19] lexmag: has joined #elixir-lang
[17:23:49] edwinbalani: Ankhers: I think that might be the best option
[17:24:45] edwinbalani: In reality, the API shouldn't be too complex for this application; the messy bit is the responses fed into it from a remote server
[17:25:07] edwinbalani: and I could just check those constraints with a validation function
[17:25:26] ankhers: Or if you want to not make a struct, you can just say in the documentation that the function(s) they accepted keys in the map or keyword list.
[17:25:51] ankhers: Wow, I englished really bad there.
[17:26:10] ankhers: You can just say in the documentation of the function which keys are accepted and how they interact.
[17:28:03] ankhers: Basically it comes down to a documentation thing, and not really a typespec thing. You can still create a type around a map though if it helps.
[17:58:33] hypercore: has joined #elixir-lang
[18:03:35] netrino: has joined #elixir-lang
[18:04:12] aalmazan: has joined #elixir-lang
[18:09:46] praveenperera: has joined #elixir-lang
[18:14:35] mahmudov: has joined #elixir-lang
[18:20:32] wsieroci: has joined #elixir-lang
[18:21:51] Adkron: has joined #elixir-lang
[18:26:06] sacredfrog: has joined #elixir-lang
[18:31:26] icecreamcohen: has joined #elixir-lang
[18:40:27] Phylock: has joined #elixir-lang
[18:44:11] wsieroci: has joined #elixir-lang
[18:50:15] squall: has joined #elixir-lang
[19:16:42] praveenperera: has joined #elixir-lang
[19:25:36] shiro[cloud]: has joined #elixir-lang
[19:37:38] shiro[cloud]: has left #elixir-lang: ()
[19:38:53] icecreamcohen: has joined #elixir-lang
[19:56:38] sacredfrog: has joined #elixir-lang
[20:06:32] kyrylo: has joined #elixir-lang
[20:07:04] Adkron: has joined #elixir-lang
[20:33:17] praveenperera: has joined #elixir-lang
[20:35:41] benwilson512: chrismccord: if I have live view A and inside I live_render B, should connected?(socket) in B return true when A does?
[20:36:32] chrismccord: benwilson512 err, yes and no
[20:36:47] chrismccord: on the HTTP request, they will all be mounted and connected? false
[20:37:18] chrismccord: on WS connct, the parent will be connected? True, and a shell for the child will be rendered
[20:37:42] chrismccord: so on WS connect, parent child flow happens in serial, not all at once, if that makes sense
[20:38:01] chrismccord: parent is rendered. DOM detects shell for children, joins those
[20:38:19] chrismccord: rinse and repeat
[20:38:21] benwilson512: sure, but I'm trying to understand a situation where the child doesn't mount in a connected way until the parent does a change > 1 min after the initial connection
[20:38:50] benwilson512: the scenario is: I want a tiny live view that you pass a DateTime value to, and it shows "time ago in words" with respect to that value, updating every second
[20:39:41] sacredfrog: has joined #elixir-lang
[20:39:43] benwilson512: what I was experiencing is that it wouldn't start its timer until the container it was in did some sort of change
[20:39:48] benwilson512: I'm trying to create an isolated example
[20:40:31] benwilson512: some of my issues were caused by not realizing that <%= Timex.from_now(@some_fixed_time) %> would never re-render cause the assign there doesn't change
[20:40:47] benwilson512: lesson: don't have code w/ side causes in the render
[20:41:06] benwilson512: but I don't think this was related to that
[20:43:50] voltone: has joined #elixir-lang
[20:44:41] griffinbyatt: has joined #elixir-lang
[20:48:26] benwilson512: chrismccord: reproduced! it happens with for loops
[20:51:10] benwilson512: https://www.irccloud.com/pastebin/m1A3AjV4/
[20:51:12] benwilson512: chrismccord: ^
[20:51:28] benwilson512: the first item in the list counts down properly, the other 2 do nothing
[20:57:53] Gika: has joined #elixir-lang
[21:09:45] lexmag: has joined #elixir-lang
[21:11:41] cjk101010_: has joined #elixir-lang
[21:14:26] sebsel: has joined #elixir-lang
[21:29:41] cbw[m]: has joined #elixir-lang
[21:34:13] ur5us: has joined #elixir-lang
[21:35:11] ur5us: has joined #elixir-lang
[21:36:12] work_: has joined #elixir-lang
[21:38:20] __charly__: has joined #elixir-lang
[21:49:03] tutti: has joined #elixir-lang
[22:11:03] jeffro_: has joined #elixir-lang
[22:18:03] chrismccord: benwilson512 you need to pass a child_id. I chimed in on the issue
[22:18:18] chrismccord: we are supposed to raise, but that check got nuked somewhere recently
[22:18:28] benwilson512: chrismccord: ahhh
[22:23:46] Sgeo: has joined #elixir-lang
[22:27:49] benwilson512: chrismccord: yeah that works great. is this a bad idea in general by the way? Initially I thought this would be important so that I wasn't re-rendering the whole main page but it seems like you already optimize rendering enough that that doesn't happen
[22:29:30] chrismccord: benwilson512 : we don't yet optimize collections, so in this case data wise it's the most efficient. The caveat being you require a process per "ago" view
[22:30:10] chrismccord: so lots of extra processes and timers. Depending on scale, may be totally fine. I would use send_after rather than :timer.send_interval
[22:30:29] benwilson512: chrismccord: yup yeah that trade off is probably fine here
[22:30:41] benwilson512: chrismccord: not a lot of concurrent users, very rich data shown per user
[22:30:53] laut: has joined #elixir-lang
[22:32:40] chrismccord: benwilson512 : 👍🏻 probably scales better than you imagine as well
[22:32:59] benwilson512: chrismccord: subheader for your next book ^
[22:33:26] benwilson512: chrismccord: speaking of scale, we're running ~100 subscriptions per user on the index page
[22:33:45] chrismccord: sounds awesome
[22:34:03] benwilson512: it's really the same subscription but on 100 topics, that's basically the same thing
[22:34:38] benwilson512: anyway, thanks for the child_id pointer
[22:40:00] Sgeo_: has joined #elixir-lang
[22:41:25] slashrsm: has joined #elixir-lang
[22:43:41] benwilson512: blurg, Timex's time ago in words function uses `now()` as a side cause _deep_ in the code
[22:50:25] chrismccord: benwilson512 ?
[22:51:57] lemald: has joined #elixir-lang
[22:52:34] benwilson512: chrismccord: what I'd really like to do is <%= Timex.from_now(@now, point_in_time) %>` and then just update `@now` on whatever timer I want
[22:52:37] benwilson512: and do it all as one page
[22:52:59] benwilson512: doing it in the child is actually super obnoxious because each thing renders at slightly different moments
[22:53:54] benwilson512: but best I can tell there isn't a way to do Timex.time_difference_in_words(t1, t2) because `Timex.from_now` calls `now()` at the formatter level
[22:54:20] benwilson512: https://github.com/bitwalker/timex/blob/3.5.0/lib/format/datetime/formatters/relative.ex#L62
[22:54:35] benwilson512: ah but there is https://github.com/bitwalker/timex/blob/3.5.0/lib/format/datetime/formatters/relative.ex#L83
[22:54:43] hrubi_: has joined #elixir-lang
[22:54:58] benwilson512: I'm just talking out loud, gonna dig in more, don't worry about it
[22:58:44] slashrsm: has joined #elixir-lang
[23:00:19] nageV: what's the best way to force a deep copy of a data structure that contains sub-binaries / refc binaries on shared heap? I'm thinking of doing this: mydata |> :erlang.term_to_binary |> :erlang.binary_to_term
[23:01:02] nageV: I want to essentially disconnect my data structure from the shared heap (so that the refc binaries can be garbage collected) before I send it off to another process for further processing
[23:02:48] nageV: (this is inside a Flow where millions of such data structures need to be "disconnected" in this way)
[23:03:19] benwilson512: nageV: you may be better off just calling :erlang.garbage_collect on your process after you send off the binaries
[23:04:14] nageV: benwilson512: thanks, but wouldn't the sent-off data structures still contain sub-binaries/refc-binaries which still occupy space on the shared heap?
[23:05:02] benwilson512: yes, but running garbage collect would ensure that your intermediary process wasn't holding on to any references itself
[23:05:18] benwilson512: IE you still get the efficiency of not needing to copy the binary when it's sent to the other process
[23:05:26] benwilson512: but you don't have the downside of the dangling reference in the sender
[23:05:42] benwilson512: which can lead to the binary leaks you're presumably doing all of this to avoid
[23:07:50] hrubi: has joined #elixir-lang
[23:08:39] nageV: oh! exactly: i have a many-partitioned Flow that these data structures pass through, and the memory usage (VmHWM: max RSS level) is basically being multiplied as data flows through each partition
[23:16:56] hrubi: has joined #elixir-lang
[23:37:41] craigp_: has joined #elixir-lang
[23:38:01] sacredfrog: has joined #elixir-lang
[23:43:28] Sgeo: has joined #elixir-lang
[23:47:47] griffinbyatt: has joined #elixir-lang
[23:58:17] craigp: has joined #elixir-lang
[23:59:00] orbyt_: has joined #elixir-lang