« Back to channel list

#elixir-lang - 23 April 2019

« Back 1 day Forward 1 day »
[00:06:36] snapet_: has joined #elixir-lang
[00:13:05] gvaughn_: has joined #elixir-lang
[00:19:04] snapet_: has joined #elixir-lang
[00:23:22] orbyt_: has joined #elixir-lang
[00:35:57] Guest5654: has joined #elixir-lang
[00:40:30] iamvery: has joined #elixir-lang
[00:44:23] reda_: has joined #elixir-lang
[01:06:07] carldd: has joined #elixir-lang
[01:14:11] orbyt_: has joined #elixir-lang
[01:21:32] jeffro: has joined #elixir-lang
[01:24:16] iamvery_: has joined #elixir-lang
[01:29:50] zigpaw: has joined #elixir-lang
[01:54:35] Saukk: has joined #elixir-lang
[02:00:13] craigp: has joined #elixir-lang
[02:03:46] tomterl: has joined #elixir-lang
[02:05:39] mdbm: has joined #elixir-lang
[02:12:19] sevenseacat: has joined #elixir-lang
[03:20:06] carldd: has joined #elixir-lang
[03:22:23] jeffro: has joined #elixir-lang
[03:25:22] duaneb: has joined #elixir-lang
[03:56:55] ariedler: has joined #elixir-lang
[04:25:25] wsieroci: has joined #elixir-lang
[04:47:22] Guest97: has joined #elixir-lang
[04:50:06] mbuf: has joined #elixir-lang
[05:00:19] zv: has joined #elixir-lang
[05:07:53] Guest97: has joined #elixir-lang
[05:11:18] gvaughn: has joined #elixir-lang
[05:12:53] kapil____: has joined #elixir-lang
[05:23:12] jeffro: has joined #elixir-lang
[05:57:15] voltone: has joined #elixir-lang
[06:10:13] zakora: has joined #elixir-lang
[06:20:45] serafeim: has joined #elixir-lang
[06:21:06] serafeim: hello I can't understand a small snippet
[06:21:16] serafeim: user = conn.assigns[:current_user] -> assign(conn, :current_user, user)
[06:21:37] serafeim: why user = conn.assigns[:current_user] is there ?
[06:21:51] serafeim: shouldn't that be a boolean ?
[06:25:14] gvaughn: has joined #elixir-lang
[06:32:33] bakedb: has joined #elixir-lang
[06:33:13] Nicd-: it binds the variable `user` to that value so that it can be used in the `assign()` call
[06:33:43] Nicd-: `a = b` returns the value of `b`. so that condition passes if `conn.assigns[:current_user]` is truthy
[06:33:53] serafeim: so it will return true if conn.assigns[:current_user] is no null ?
[06:34:10] Nicd-: yep if it's not `nil` or `false`
[06:34:28] serafeim: but does that code actually do anything ?
[06:34:56] serafeim: if conn.assigns[:current_user] == user then *why* do they assign it again after the -> ?
[06:35:05] Nicd-: looks like a no-op
[06:35:30] serafeim: Nicd-, yes that's what I thought ... I almost got crazy
[06:35:53] serafeim: is there a reason for that to be there ? or they have just forgotten it ? it's from changelog.com
[06:36:34] Nicd-: I don't see a reason for it as it does nothing
[06:36:35] sevenseacat: its a cond - saves typing the conn.assigns part again in the -> part
[06:37:02] Nicd-: sevenseacat: but the whole branch is a no-op
[06:37:03] serafeim: Nicd-, thanks
[06:37:34] Nicd-: looks like badly designed code or it ended up like that after refactoring
[06:37:35] serafeim: here's the whole snippet http://dpaste.com/1BXKQ3P
[06:37:57] serafeim: I understand the 2nd and 3rd line of the cond. but the 1st one probably can be removed
[06:38:21] Nicd-: removing it would change the functionality
[06:38:40] Nicd-: simplest would be to replace it with `conn.assigns[:current_user] -> conn` probably
[06:39:02] serafeim: Nicd-, yes I understand
[06:39:14] serafeim: if you remove it it will make :current_user nil
[06:39:41] serafeim: thanks for clarifying
[06:56:25] zv: has joined #elixir-lang
[06:57:46] Midderna1ht: has left #elixir-lang: ()
[06:58:52] DTZUZO: has joined #elixir-lang
[07:07:02] proteusguy: has joined #elixir-lang
[07:19:52] Guest97: has joined #elixir-lang
[07:24:05] jeffro: has joined #elixir-lang
[07:24:17] PragTob: has joined #elixir-lang
[07:36:33] gvaughn: has joined #elixir-lang
[07:38:48] serafeim_: has joined #elixir-lang
[07:40:28] serafeim_: another question. I see the following function in an ecto schema: def unpublished(query \\ __MODULE__), do: from(q in query, where: not(q.published))
[07:41:07] serafeim_: why query gets a __MODULE__ default value?
[07:41:28] Nicd-: it's a reference to the current module
[07:41:51] kansi: has joined #elixir-lang
[07:41:55] serafeim_: why not just write def unpublished(), do: from(q in Post, where: not(q.published))
[07:42:08] serafeim_: what's the purpose of the query parameter ?
[07:42:21] Nicd-: to give in a query that is already made
[07:42:29] Nicd-: so that you can compose queries to add filters etc
[07:44:09] serafeim_: yes you are right I see it now. thanks
[07:45:11] Guest97: has joined #elixir-lang
[08:01:13] lexmag: has joined #elixir-lang
[08:17:47] kansi: ACTION says hi! Is it possible to skip a `describe` block in tests? I tried doing this `ExUnit.start(capture_log: true, exclude: [:skip])` and using the `@tag :skip` but doesn't seem to work? 
[08:18:57] snapet: has joined #elixir-lang
[08:19:00] PragTob: has joined #elixir-lang
[08:23:17] Gazler: has joined #elixir-lang
[08:23:49] kansi: okay, should have used `@describetag :skip`
[08:26:25] wonko7: has joined #elixir-lang
[08:41:07] kyrylo: has joined #elixir-lang
[08:46:53] gvaughn: has joined #elixir-lang
[08:49:36] josevalim: kansi: i also think skip is skipped by default
[08:49:39] josevalim: so you don't need to exclude it
[08:53:54] kansi: you are right, skip works by default
[08:56:38] za1b1tsu: has joined #elixir-lang
[09:24:49] svennidal: has joined #elixir-lang
[09:24:51] jeffro: has joined #elixir-lang
[09:27:56] voltone: has joined #elixir-lang
[09:41:43] lexmag: has joined #elixir-lang
[09:59:12] ariedler: has joined #elixir-lang
[10:03:48] gvaughn: has joined #elixir-lang
[10:15:23] griffinbyatt: has joined #elixir-lang
[10:43:53] wsieroci: has joined #elixir-lang
[10:46:53] lexmag: has joined #elixir-lang
[10:48:31] lexmag: has joined #elixir-lang
[10:55:08] ariedler: has joined #elixir-lang
[11:07:46] Guest97: has joined #elixir-lang
[11:12:47] lexmag: has joined #elixir-lang
[11:18:25] gvaughn: has joined #elixir-lang
[11:25:41] jeffro: has joined #elixir-lang
[11:27:36] hypercore: has joined #elixir-lang
[11:29:19] voltone: has joined #elixir-lang
[11:37:50] wsieroci: has joined #elixir-lang
[11:40:46] wonko7: has joined #elixir-lang
[11:41:17] mdbm: has joined #elixir-lang
[11:51:51] lexmag: has joined #elixir-lang
[11:54:25] tnez: has joined #elixir-lang
[11:56:48] lexmag: has joined #elixir-lang
[11:58:27] m3lt: has joined #elixir-lang
[12:00:23] DTZUZO: has joined #elixir-lang
[12:01:54] duaneb: has joined #elixir-lang
[12:05:18] marciol: has joined #elixir-lang
[12:13:32] lexmag: has joined #elixir-lang
[12:24:25] blackang: has joined #elixir-lang
[12:24:31] blackang: has left #elixir-lang: ()
[12:27:38] gvaughn: has joined #elixir-lang
[12:44:04] either|or: has joined #elixir-lang
[12:52:51] jmiven: has joined #elixir-lang
[12:53:27] aenglisc: has joined #elixir-lang
[12:57:52] mdbm: has joined #elixir-lang
[13:05:46] lauromoura: has joined #elixir-lang
[13:10:37] _barcode_: has joined #elixir-lang
[13:12:39] _barcode_: Hi, Elixir noob here with a quetion: if I remove dependency, rerun mix deps, how can I safely remove the actual files in the deps folder? Can I just delete them? Thanks
[13:14:56] voltone: has joined #elixir-lang
[13:15:28] dysfun: _barcode_: yes, rm -Rf is fine
[13:15:44] dysfun: you can even just wipe the whole lot and rerun if you want
[13:15:53] dysfun: the process isn't very magical
[13:16:35] _barcode_: dysfun: tyvm!
[13:17:00] dysfun: and if you wipe too many, just rerun mix deps
[13:26:31] jeffro: has joined #elixir-lang
[13:32:01] sparogy: has joined #elixir-lang
[13:32:47] netrino: has joined #elixir-lang
[13:32:52] lexmag: has joined #elixir-lang
[13:44:46] Guest97: has joined #elixir-lang
[13:45:38] gvaughn: has joined #elixir-lang
[13:49:23] celyr: has joined #elixir-lang
[13:52:47] blahdodo: has joined #elixir-lang
[13:56:25] lexmag: has joined #elixir-lang
[13:58:18] gvaughn: has joined #elixir-lang
[13:59:51] Guest97: has joined #elixir-lang
[14:00:43] MissingNoIOI: has joined #elixir-lang
[14:02:06] lexmag: has joined #elixir-lang
[14:08:21] snapet: has joined #elixir-lang
[14:11:14] Guest97: has joined #elixir-lang
[14:42:48] thomasross_: has joined #elixir-lang
[14:49:18] Phylock: has joined #elixir-lang
[14:57:18] Sgeo: has joined #elixir-lang
[15:00:04] Sgeo_: has joined #elixir-lang
[15:02:08] nineczar: has joined #elixir-lang
[15:11:40] mahmudov: has joined #elixir-lang
[15:24:06] jeffro: has joined #elixir-lang
[15:29:52] orbyt_: has joined #elixir-lang
[15:34:24] greengriminal: has joined #elixir-lang
[15:43:12] Guest97: has joined #elixir-lang
[15:47:17] aalmazan: has joined #elixir-lang
[16:05:12] PragTob: has joined #elixir-lang
[16:30:05] tpl_: has joined #elixir-lang
[16:38:06] orbyt_: has joined #elixir-lang
[17:05:34] ctp: Hi folks. When using map as argument for a function, how can I set a specific value within this map to a default value? Concretely:
[17:06:24] ctp: https://www.irccloud.com/pastebin/Vxpty3OO/
[17:06:56] ctp: breaks with "cannot find or invoke local \\/2 inside match. Only macros can be invoked in a match and they must be defined before their invocation. Called as: licenses \\ ['BY-ND', 'BY-SA', 'PDM', 'BY', 'BY-NC-SA', 'BY-NC-ND', 'CC0', 'BY-NC']"
[17:07:54] wsieroci: has joined #elixir-lang
[17:07:58] ctp: same with a simple def search(query, licenses \\ ['BY-ND', 'BY-SA', 'PDM']) do ... ... ... end works fine, but not with a map as argument
[17:09:28] benwilson512: hey ctp, can't be done w/ default values, your best bet is Map.get/3
[17:12:40] ctp: OK, I stripped it down to:
[17:12:43] ctp: defmodule TestA do def foo(a,b,c \\ "bar") do IO.puts "#{a}, #{b}, #{c}" end end
[17:12:52] ctp: defmodule TestB do def foo(%{a: a, b: b, c: c \\ "bar"}) do IO.puts "#{a}, #{b}, #{c}" end end
[17:13:28] ctp: benwilson512: hm, not sure, what you mean ...
[17:13:52] benwilson512: ctp: right, default values are default values to an entire argument to a function
[17:13:56] benwilson512: not some sub part of an argument
[17:14:29] ctp: right, I see the point
[17:14:37] benwilson512: https://www.irccloud.com/pastebin/i8tvT8FI/
[17:15:03] benwilson512: ctp: ^ Map.get/3 takes a last argument which is the value to use if the map does not contain the requested key
[17:15:34] ctp: Aaaah, OK, this makes sense. Thank you!
[17:16:28] mk[]: has joined #elixir-lang
[17:36:45] brandfilt: has joined #elixir-lang
[17:40:12] Guest97: has joined #elixir-lang
[17:44:43] Saukk: has joined #elixir-lang
[17:49:06] pera: has joined #elixir-lang
[17:53:29] wsieroci: has joined #elixir-lang
[18:03:48] thurloat8: has joined #elixir-lang
[18:04:38] wonko7: has joined #elixir-lang
[18:04:43] thurloat: has joined #elixir-lang
[18:13:44] orbyt_: has joined #elixir-lang
[18:14:02] thread: has joined #elixir-lang
[18:14:32] kyrylo: has joined #elixir-lang
[18:15:21] Randyr: has joined #elixir-lang
[18:32:15] l14n: has joined #elixir-lang
[18:33:59] l14n_: has joined #elixir-lang
[18:34:16] l14n_: has joined #elixir-lang
[18:38:05] nate-: has joined #elixir-lang
[18:40:16] duaneb: has joined #elixir-lang
[18:41:33] nate-: has joined #elixir-lang
[18:46:36] firc47689e9e: has joined #elixir-lang
[18:49:16] firc47689e9e: Hi, just wanted to thank everyone for their hard work. Elixir is a great technology and I am very greatful to have discovered it. Thank You!
[18:50:39] fircf35a67: has joined #elixir-lang
[19:03:27] lexmag: has joined #elixir-lang
[19:10:40] orbyt_: has joined #elixir-lang
[19:12:17] squall: has joined #elixir-lang
[19:23:57] lomex: has joined #elixir-lang
[19:48:28] lomex: has left #elixir-lang: ("Textual IRC Client: www.textualapp.com")
[20:21:41] Zarathu: is there still no way to pass named/numbered params into an ecto fragment?
[20:21:50] Zarathu: fragment("$1 + $1", ^n)
[20:24:34] Zarathu: this should definitely be a thing
[20:28:55] manj-budgie: has joined #elixir-lang
[20:29:55] thecatwasnot: has joined #elixir-lang
[20:33:49] Sgeo__: has joined #elixir-lang
[20:35:22] orbyt_: has joined #elixir-lang
[20:40:57] rr_LS: has joined #elixir-lang
[20:52:06] ctp: Hm, somehow struggling with this
[20:52:26] ctp: def search_all(%{q: query_string} = args) when Map.has_key?(args, :page) do ... end
[20:52:51] ctp: how can i define a guard like this?
[20:52:59] ctp: cannot invoke remote function Map.has_key?/2 inside guards
[20:54:33] ctp: concretly:
[20:54:41] ctp: https://www.irccloud.com/pastebin/N457ray3/
[20:58:45] orbyt_: has joined #elixir-lang
[21:01:26] sparogy: has joined #elixir-lang
[21:02:28] ctp: Hm, how can I realize this? Spent a while on it but no idea how to check the map for a key in such a way
[21:06:58] Randyr: Why not define two functions, one in which you pattern match the map for the key you want, and another in which you don't?
[21:07:53] Randyr: Or handle this logic inside the actual function body
[21:17:14] ctp: Randyr: "pattern match the key" is actually what I was thinking of, just wonder how to check the existence of these keys without the has_key? call above
[21:18:44] Randyr: ctp: `def search_all(%{q: query, page: _})` when there is a key and `def search_all(%{q: query})` when there's none.
[21:19:12] Randyr: Make sure the one with the page pattern match comes first.
[21:21:37] ctp: Oh right, ofc
[21:24:13] ctp: OK, it was actually the order that is important.Thanks!
[21:38:56] sparogy: has joined #elixir-lang
[21:53:47] nineczar: has joined #elixir-lang
[21:59:56] infowolfe: does anybody have any ideas for why i might have ~416 threads (via ps -eLf) for beam.smp but only 2 actually active/consuming cpu? git@github.com:kbrw/elixir-sandbox.git <= running that
[22:01:24] kyrylo: has joined #elixir-lang
[22:02:53] infowolfe: it seems that the 'task'-wise methodology is _significantly_ slower than the other methods (stream task_chunk worker worker_chunk) (40m runtime vs <30s for the others)
[22:10:26] rr_LS: has joined #elixir-lang
[22:14:54] dysfun: the BEAM defaults to 1 thread per cpu core
[22:16:10] dysfun: the only reasons i can think that you might have tons of threads are dirty nifs, nifs that spawn threads directly or changing that setting
[22:26:54] benwilson512: infowolfe: yea how many CPU cores do you have
[22:27:03] infowolfe: on this machine? 96.
[22:27:21] benwilson512: infowolfe: ah, so your question is not so much why are there so many threads
[22:27:24] benwilson512: why are only two of them doing work?
[22:28:33] benwilson512: infowolfe: it sort of looks like you're implementing Task.async_stream from the standard library
[22:28:47] infowolfe: i'm not implementing anything, I was looking at it for inspiration
[22:29:13] benwilson512: infowolfe: apologies, what I was getting at is that it's great if what you're doing w/ agents you're doing for educational purposes
[22:29:32] benwilson512: infowolfe: just making sure you knew you could make it simpler if desired
[22:30:31] benwilson512: infowolfe: which mix task were you running?
[22:30:57] infowolfe: `mix task` took 40 minutes on this system with a 19MB input
[22:32:15] infowolfe: with literally ~97% of the machine sitting idle
[22:32:49] benwilson512: infowolfe: that's because each task is completing extremely fast.
[22:33:00] benwilson512: all you're doing is watching 1 CPU read from a file and spawn / kill a bunch of processes in serial
[22:33:23] benwilson512: spawning processes is cheap but
[22:33:46] benwilson512: upcasing 70 characters is also super cheap
[22:34:03] benwilson512: gotta run, consider making a forum post
[22:34:22] orbyt_: has joined #elixir-lang
[22:34:41] infowolfe: 40 minutes to process 19MB of data with "cheap" operations seems... excessive
[22:51:47] ctp: Hm, how can I merge these both maps?
[22:51:51] ctp: foo = %{a: 1, b: 2, c: [%{d: 3, e: 4}, %{d: 5, e: 6}]}
[22:51:58] lao-tzu: has joined #elixir-lang
[22:52:02] ctp: bar = %{a: 1, b: 2, c: [%{d: 7, e: 8}, %{d: 9, e: 0}]}
[22:52:42] ctp: What I want to have is %{a: 1, b: 2, c: [%{d: 3, e: 4}, %{d: 5, e: 6}, %{d: 7, e: 8}, %{d: 9, e: 0}]}
[22:53:44] ctp: Somehow difficult :)
[23:04:42] ctp: Hm, I guess I am too tired. Will check it tomorrow.
[23:05:07] Sgeo: has joined #elixir-lang
[23:14:28] nineczar: has joined #elixir-lang
[23:17:59] greengriminal: has joined #elixir-lang
[23:20:40] ariedler: has joined #elixir-lang
[23:57:34] tomku: has joined #elixir-lang