« Back to channel list

#elixir-lang - 28 May 2019

« Back 1 day Forward 1 day »
[00:02:38] netrino: has joined #elixir-lang
[00:08:17] mdbm: has joined #elixir-lang
[00:08:43] lauromoura: has joined #elixir-lang
[00:24:43] orbyt_: has joined #elixir-lang
[00:40:09] Adkron: has joined #elixir-lang
[00:41:38] netrino: has joined #elixir-lang
[00:44:50] ariedler: has joined #elixir-lang
[00:45:14] tomku: has joined #elixir-lang
[00:45:49] kapilp: has joined #elixir-lang
[00:50:44] orbyt_: has joined #elixir-lang
[00:55:05] sevenseacat: has joined #elixir-lang
[01:14:48] lauromoura: has joined #elixir-lang
[01:17:26] Adkron: has joined #elixir-lang
[01:20:39] netrino: has joined #elixir-lang
[01:31:36] tomterl: has joined #elixir-lang
[01:35:57] drincruz: has joined #elixir-lang
[01:45:02] ryotsu: has joined #elixir-lang
[01:48:34] theWhisper__: has joined #elixir-lang
[01:54:54] jeffro: has joined #elixir-lang
[01:58:04] Adkron: has joined #elixir-lang
[01:59:39] netrino: has joined #elixir-lang
[02:01:56] ryotsu: has joined #elixir-lang
[02:01:59] jeffro: has joined #elixir-lang
[02:04:43] thomasross: has joined #elixir-lang
[02:06:56] oneark: has joined #elixir-lang
[02:09:37] praveenperera: has joined #elixir-lang
[02:19:42] heimann: has joined #elixir-lang
[02:20:41] ur5us: has joined #elixir-lang
[02:31:49] jeffro: has joined #elixir-lang
[02:37:17] griffinbyatt: has joined #elixir-lang
[02:38:41] netrino: has joined #elixir-lang
[02:38:45] praveenperera: has joined #elixir-lang
[02:39:51] Adkron: has joined #elixir-lang
[02:46:05] ariedler: has joined #elixir-lang
[02:48:13] nageV: does string concatenation with an empty string cause a brand new binary to be created? for example: foo = String.duplicate("x", 65); bar = foo <> ""; # now do both foo and bar should point to the same RefC binary on the shared binary heap, correct?
[02:49:22] nageV: i'm worried that String.trim_trailing(some_line, "\n") is causing unnecessary copying of RefC binaries :/
[02:50:33] Saukk: has joined #elixir-lang
[03:07:09] griffinbyatt: has joined #elixir-lang
[03:13:50] jimmyrcom: has joined #elixir-lang
[03:17:27] Adkron: has joined #elixir-lang
[03:17:42] netrino: has joined #elixir-lang
[03:51:25] blahdodo: has joined #elixir-lang
[03:53:51] ur5us_: has joined #elixir-lang
[03:55:14] Adkron: has joined #elixir-lang
[03:56:43] netrino: has joined #elixir-lang
[04:21:10] drincruz: has joined #elixir-lang
[04:32:06] mbuf: has joined #elixir-lang
[04:35:25] Adkron: has joined #elixir-lang
[04:35:41] netrino: has joined #elixir-lang
[04:46:49] ariedler: has joined #elixir-lang
[04:57:06] gvaughn: has joined #elixir-lang
[04:57:46] drincruz: has joined #elixir-lang
[05:08:50] orbyt_: has joined #elixir-lang
[05:09:25] gde33: has joined #elixir-lang
[05:14:46] netrino: has joined #elixir-lang
[05:18:36] Adkron: has joined #elixir-lang
[05:22:09] kyrylo: has joined #elixir-lang
[05:31:36] Mieserkadser: has joined #elixir-lang
[05:34:57] gvaughn: has joined #elixir-lang
[05:35:53] kdisneur: has joined #elixir-lang
[05:47:00] Jetimon: has joined #elixir-lang
[05:48:05] drincruz: has joined #elixir-lang
[05:48:13] jsehop98: has joined #elixir-lang
[05:50:13] serafeim: has joined #elixir-lang
[05:52:55] Adkron: has joined #elixir-lang
[05:53:46] netrino: has joined #elixir-lang
[06:11:16] kdisneur: has joined #elixir-lang
[06:17:11] Cloudflare: has joined #elixir-lang
[06:21:54] tuacker: has joined #elixir-lang
[06:22:19] serafeim: here's a thing that almost drove me crazy today
[06:22:37] serafeim: take a look at this simple function call: <%= text_input f, :username, placeholder: gettext "Username", autofocus: true, autocomplete: "username" %>
[06:22:54] serafeim: do you see any shoot-yourself-in-the-foot bug ?
[06:23:03] Nicd-: missing parentheses after gettext
[06:23:14] serafeim: Nicd-: ha ha you are much more experienced than me
[06:23:21] Nicd-: here's a protip: don't skip on parentheses
[06:23:36] serafeim: yes i lost like half an hour trying to understand why autofocus wasn't working :(
[06:23:44] Nicd-: I would write that as `<%= text_input(f, :username, placeholder: gettext("Username"), autofocus: true, autocomplete: "username") %>`
[06:24:02] Nicd-: the autoformatter adds parentheses to regular code too
[06:24:03] serafeim: Nicd-: 100% agreed ; i think it'd be best to make parameters erquired in elixir
[06:24:12] serafeim: Nicd-: yes unfortunately this is template code
[06:24:22] Nicd-: the reason for them not being required is technical
[06:24:41] serafeim: Nicd-: i'll try to keep your advice from now on but it's too much work to refactor my code right now :(
[06:25:01] proteusguy: has joined #elixir-lang
[06:25:01] serafeim: Nicd-: care to explain why they are required ?
[06:25:05] Nicd-: otherwise you would have to write things like `if(..., do: 1, else: 2)` and `defmodule(Foo, ...)`
[06:25:28] Nicd-: (unsure to what extent, but many Elixir constructs are just macros/functions in disguise)
[06:25:29] serafeim: Nicd-: maybe make them optional in macros and required in function calls ?
[06:26:26] serafeim: also i am not sure why this: text_input f, :username, placeholder: gettext "Username", autofocus: true, autocomplete: "username" didn't throw an error
[06:27:17] serafeim: i presume that all other parameters were consumed by gettext but why ?
[06:28:14] Nicd-: it was parsed as `<%= text_input(f, :username, placeholder: gettext("Username", autofocus: true, autocomplete: "username")) %>`
[06:29:15] Nicd-: if gettext takes in a list of options, then that won't crash (the unknown options will just be ignored)
[06:29:32] serafeim: yes i see this gettext(backend, msgid, bindings \\ %{})
[06:30:10] serafeim: so all other parameters were parsed as keyword pairs for the bindings
[06:30:27] Adkron: has joined #elixir-lang
[06:32:47] netrino: has joined #elixir-lang
[06:34:01] serafeim: another question
[06:34:26] serafeim: i want to split my router.ex file using something like this: forward "/admin", AdminRouter
[06:34:40] serafeim: so i have a AppWeb.Router and an AppWeb.AdminRouter
[06:35:42] serafeim: i've added some aliases for my AdminRouter helpers in the view and controller macros and used the AdminRoutes in my controllers / templates where needed
[06:35:47] serafeim: it seems to be working fine
[06:35:57] serafeim: however when I try to run my tests I get an error
[06:36:14] serafeim: although I think i've done everything needed :|
[06:36:32] sevenseacat: whats the error?
[06:36:40] Nicd-: no let me mind read it
[06:36:50] Nicd-: damn sorry I'm out of mana
[06:37:20] serafeim: for example in this test: conn = get(conn |> fake_sign_in, AdminRoutes.authority_path(conn, :index))
[06:37:32] serafeim: i get this error ** (Phoenix.Router.NoRouteError) no route found for GET /authorities (PhxcrdWeb.Router)
[06:37:39] netrino_: has joined #elixir-lang
[06:38:20] serafeim: however when i visit AdminRoutes.authority_path(conn, :index)) from my browser I `correctly` go to http://127.0.0.1:4000/admin/authorities
[06:38:47] serafeim: i can't really understand why this tries to go to /authoritiesa nd not /admin/authorities
[06:39:19] serafeim: I've added the following to my conn_case.ex `using`: alias PhxcrdWeb.AdminRouter.Helpers, as: AdminRoutes
[06:39:34] serafeim: right under `alias PhxcrdWeb.Router.Helpers, as: Routes`alias PhxcrdWeb.Router.Helpers, as: Routes
[06:39:45] Nicd-: I don't use forward so I can't help with that
[06:40:50] sevenseacat: I don't know what that test is doing so
[06:41:03] kdisneur: has joined #elixir-lang
[06:41:06] serafeim: there's no real test
[06:41:12] serafeim: i just want it to visit the page
[06:41:26] serafeim: this isn't working: get(conn, AdminRoutes.authority_path(conn, :index))
[06:41:38] serafeim: because it tried to visit /authorities instead of /admin/authorities
[06:41:53] sirn_: has joined #elixir-lang
[06:42:17] serafeim: i guess AdminRoutes, if used by itself *will* return /authorities/ because the /admin partt is set in the normal Routes
[06:42:27] serafeim: but why is it working from the browser ?
[06:42:34] sevenseacat: sounds reasonable
[06:42:54] sevenseacat: why is what working from the browser
[06:44:31] blahdodo: has joined #elixir-lang
[06:47:07] sirn_: has joined #elixir-lang
[06:47:43] ariedler: has joined #elixir-lang
[06:48:02] serafeim: could this be a bug ?
[06:48:29] serafeim: this is really strange for me. it should either work in both browser and test or not work
[06:48:36] sevenseacat: why is what working from the browser?
[06:50:07] serafeim: the thing i described before
[06:50:19] serafeim: the forwardss
[06:50:21] serafeim: the forward
[06:50:47] sevenseacat: so you can go to /admin/authorities in a browser. can you go to /admin/authorities in a test?
[06:52:38] Nicd-: serafeim: have you tested that the path helper gives the correct path when using it normally in a view (with browser)?
[06:53:01] Nicd-: you can just put `<%= AdminRoutes.authority_path(conn, :index) %>` in a template to see what it prints
[06:53:02] serafeim: Nicd-: that's what i said before. it works fine through the browser :(
[06:54:03] serafeim: here's my router: https://github.com/spapas/phxcrd/blob/master/lib/phxcrd_web/router.ex
[06:54:05] sevenseacat: that's... not whaty ou said before
[06:54:22] snapet: has joined #elixir-lang
[06:54:37] Nicd-: serafeim: how did you test it?
[06:54:42] Nicd-: that it works in browser
[06:54:51] serafeim: i run the project ?
[06:55:05] Nicd-: and then what?
[06:55:06] sevenseacat: AdminRoutes.authority_path(conn, :index) isn't defined by that code
[06:55:17] serafeim: and here's the adminroutes https://github.com/spapas/phxcrd/blob/master/lib/phxcrd_web/admin_router.ex
[06:55:55] sevenseacat: so if you put that in a template, it will error
[06:56:30] Nicd-: I don't think it will error, it will produce `/authorities`
[06:56:35] serafeim: sevenseacat: no it won't because it is here https://github.com/spapas/phxcrd/blob/master/lib/phxcrd_web.ex#L46
[06:56:51] sevenseacat: ok you didn't say that before either
[06:56:59] serafeim: Nicd-: actually what is *crazy* is that it *it is not producing authorities*. it produces /admin/authorities
[06:57:07] Nicd-: in template?
[06:57:09] sevenseacat: its fun trying to extract the entire issue, piece by frustrating piece
[06:57:13] serafeim: Nicd-: get the project and run it
[06:57:35] Nicd-: sevenseacat: they did though 09:38:16 <serafeim> I've added the following to my conn_case.ex `using`: alias PhxcrdWeb.AdminRouter.Helpers, as: AdminRoutes
[06:57:44] sevenseacat: thats conn_case, not web.ex
[06:57:53] Nicd-: I assumed :D
[06:58:11] serafeim: sevenseacat: yes i've added it also to the web ex ; i mentioned that somewhere before
[06:59:56] serafeim: i find it strange that when i use this `<%= link gettext("Authorities"), to: AdminRoutes.authority_path(@conn, :index)%>` in my templates it works and outputs /admin/authorities
[07:00:35] serafeim: but when I use this conn = get(conn |> fake_sign_in, AdminRoutes.permission_path(conn, :index)) in my test case i tries to visit /authorities
[07:02:38] Adkron: has joined #elixir-lang
[07:06:03] Nicd-: in your github code you have `conn = get(conn |> fake_sign_in, Routes.authority_path(conn, :index))` (not AdminRoutes)
[07:06:04] drincruz: has joined #elixir-lang
[07:06:39] serafeim: Nicd-: yes yes this is before i started fixing the tests
[07:06:44] serafeim: let me push the new ver
[07:10:09] serafeim: also i'm not sure i've fixed all tests; i am testing now with authority_controller_test.exs:46
[07:11:37] serafeim: also please notice that if i changed line 48 from `conn = get(conn |> fake_sign_in, AdminRoutes.authority_path(conn, :index))` to `conn = get(conn |> fake_sign_in, "/admin/authorities")` the test passes
[07:14:18] gvaughn: has joined #elixir-lang
[07:18:10] serafeim: so even though my AdminRoutes helper is not working properly the routes *are* working
[07:21:40] serafeim: could this be a bug in phoenix?
[07:22:04] serafeim: because i've seen that `forward` is not used that much especially for forwarding to other routers
[07:22:16] serafeim: so I may be stumbled upon a corner case :(
[07:27:13] kdisneur: has joined #elixir-lang
[07:30:17] serafeim: also notice that if i use `mix phx.routes PhxcrdWeb.AdminRouter` I also get the wrong thing, for example: ` authority_path GET /authorities PhxcrdWeb.AuthorityController :index`
[07:32:17] lexmag: has joined #elixir-lang
[07:43:38] serafeim: ok it *definitely* is a bug with how forward works
[07:44:07] serafeim: i've changed my routes to `match :*, "/admin/*path", AdminRouter, :any` and it works excellent now !
[07:44:09] tcit: has left #elixir-lang: ("User left")
[07:44:23] serafeim: i just had to properly put the /admin/ in my AdminRouter scope
[07:44:51] Adkron: has joined #elixir-lang
[07:44:58] Nicd-: maybe it would be good to write a post on the forum about this
[07:45:02] Nicd-: just include enough details
[07:45:47] serafeim: Nicd-: i'll try but the details needed for this to be reproduced are too much :|
[07:46:07] Nicd-: make a new tiny app that reproduces it :)
[07:46:16] drincruz: has joined #elixir-lang
[07:48:26] kapilp: has joined #elixir-lang
[08:00:12] serafeim: i've got the following can? test: http://dpaste.com/3YVAVG9
[08:00:32] serafeim: is this possible for this to be written in a more idiomatic way? could I use a guard in the function for example ?
[08:01:33] Nicd-: well you can just return `Enum.member?(permissions"superuser")` instead of the whole if
[08:02:09] Nicd-: `def can?(%User{permissions: permissions}, :index, Permission), do: Enum.member?(permissions, "superuser")`
[08:02:39] serafeim: thnanks Nicd- you are right
[08:03:03] serafeim: i guess i can't use a guard because permissions is a viariable
[08:04:34] squall: has joined #elixir-lang
[08:08:06] serafeim: what's the difference between or and || ?
[08:08:32] serafeim: i.e I see that somewhere I've got this expression: `permissions |> Enum.any?(&(&1 == "superuser" || &1 == "admin")) or (authority_id && authority_id > 0)` and it actually works
[08:11:27] gvaughn: has joined #elixir-lang
[08:14:01] Gazler: serafeim: https://hexdocs.pm/elixir/Kernel.html#%7C%7C/2 explains it at the bottom
[08:14:12] kdisneur: has joined #elixir-lang
[08:14:34] Gazler: or requires left to be a boolean and can be used in guards.
[08:15:00] serafeim: gazler: excellent thanks
[08:16:02] netrino_: has joined #elixir-lang
[08:18:59] Adkron: has joined #elixir-lang
[08:21:55] KeyJoo: has joined #elixir-lang
[08:25:16] netrino_: has joined #elixir-lang
[08:27:36] kdisneur: has joined #elixir-lang
[08:30:41] netrino_: has joined #elixir-lang
[08:38:31] netrino__: has joined #elixir-lang
[08:39:09] ur5us: has joined #elixir-lang
[08:39:29] jkva: has joined #elixir-lang
[08:48:32] ariedler: has joined #elixir-lang
[08:52:52] gvaughn: has joined #elixir-lang
[08:53:26] mdbm: has joined #elixir-lang
[09:03:37] Adkron: has joined #elixir-lang
[09:12:13] serafeim: the docs have the following example: `from c in Comment, join: p in Post, on: p.id == c.post_id`. what is the proper syntax so I could join with more tables ?
[09:13:00] Nicd-: just add another join
[09:13:32] serafeim: like this: `from c in Comment, join: p in Post, on: p.id == c.post_id, join: z in Zoo, on z.id == p.zoo_id` ?
[09:13:38] Nicd-: example: https://gitlab.com/code-stats/code-stats/blob/master/lib/code_stats/profile/queries.ex#L55-68
[09:13:45] netrino__: has joined #elixir-lang
[09:14:09] serafeim: Nicd-: thanks i was afraid it would result to a syntax error
[09:14:30] Nicd-: it's a keyword list technically
[09:14:37] Nicd-: and keyword lists can have many of the same key
[09:14:47] Nicd-: `[a: 1, a: 2]` is valid for example
[09:15:07] serafeim: i understand thanks
[09:16:02] ur5us: has joined #elixir-lang
[09:18:15] wonko7: has joined #elixir-lang
[09:23:01] netrino__: has joined #elixir-lang
[09:41:41] Adkron: has joined #elixir-lang
[09:49:21] drincruz: has joined #elixir-lang
[10:06:46] netrino__: has joined #elixir-lang
[10:18:11] m1dnight_: has joined #elixir-lang
[10:21:41] Adkron: has joined #elixir-lang
[10:32:20] gvaughn: has joined #elixir-lang
[10:33:50] griffinbyatt: has joined #elixir-lang
[10:36:23] evax: has joined #elixir-lang
[10:44:02] fastfresh: has joined #elixir-lang
[10:45:52] netrino__: has joined #elixir-lang
[10:46:16] rawtaz: peeps. how well does phoenix and its channels etc work in mobile devices - is it heavy on resources?
[10:46:22] rawtaz: and what about liveview?
[10:46:57] Nicd-: the channels are just websockets, it totally depends on what you do with it
[10:47:10] Nicd-: a single message's overhead is not big
[10:47:28] rawtaz: yeah, makes sense.
[10:48:36] rawtaz: im thinking of using elixir and phoenix to build a pretty simple webapp that will run on mobile phones as well (as an embedded webpage, nothing specifically appy). any suggestions on what frontend framework to use with phoenix? it's basically just going to display some lists of data and items on a map (travel plans for aircrafts)
[10:48:55] rawtaz: just looking for what people like and think works nicely with phoenix, basically.
[10:49:01] Nicd-: what about rendering on the server? :P
[10:49:16] ariedler: has joined #elixir-lang
[10:49:26] rawtaz: hehe yeah but that will mean quite a lot more data transfer than doing it on the client i think
[10:53:13] Nicd-: not really
[10:53:36] Nicd-: with gzip the payload is really small
[10:54:08] rawtaz: you think liveview is pretty much production ready for small and non-critical projects?
[10:54:32] Adkron: has joined #elixir-lang
[10:54:56] Nicd-: my profile page on my website is 2.9 KiB gzipped
[10:54:58] drincruz: has joined #elixir-lang
[10:55:08] Nicd-: the HTML that is
[10:55:10] ariedler: has joined #elixir-lang
[10:55:29] Nicd-: I don't know liveview, haven't used it
[10:57:09] lexmag: has joined #elixir-lang
[11:13:49] serafeim: hey Nicd- nice site! have you developed this all alone ?
[11:19:53] Mieserkadser: When i want to nest live views they are separated in dom tree. Any idea? I used container flag but it wont work.
[11:21:33] Mieserkadser: So a live view which should rendered inside oder html tags is rendered outside of the tags
[11:23:08] PragTob: has joined #elixir-lang
[11:24:52] netrino__: has joined #elixir-lang
[11:26:53] serafeim: Nicd-: also i am trying to install the vs code plugin for code::stats and it doesn't find it :(
[11:27:43] Nicd-: Try searching for codestats
[11:28:09] Nicd-: Yes I've made most of it and the plugins for ST3, Atom, JetBrains
[11:28:16] gvaughn: has joined #elixir-lang
[11:31:30] Adkron: has joined #elixir-lang
[11:43:55] drincruz: has joined #elixir-lang
[11:45:47] Nicd-: serafeim: lemme know what you think :)
[11:48:53] serafeim: Nicd-: great!
[11:55:09] mdbm: has joined #elixir-lang
[11:56:29] mdbm_: has joined #elixir-lang
[12:00:40] drincruz: has joined #elixir-lang
[12:01:17] gvaughn: has joined #elixir-lang
[12:01:27] tnez: has joined #elixir-lang
[12:03:54] netrino__: has joined #elixir-lang
[12:04:01] mdbm: has joined #elixir-lang
[12:11:25] Adkron: has joined #elixir-lang
[12:14:45] Gika: has joined #elixir-lang
[12:19:37] Gika: hi, i'm trying to sort a list of structs based on their attributes. the structs are all formed like %{ score: s, cards: [ %{n: 1}, %{n: 2}, %{n: 3}, %{n: 4}, %{n: 5} ] }. i'd like the list to be ordered based on the score attribute first, then if still ambiguous by the value of the first card, then second card etc. I tried something like Enum.sort_by(list, &{&1.score, &1.cards |> Enum.at(0) |> Map.fetch("n"), &1.cards |> Enum.at(1)
[12:19:37] Gika: |> Map.fetch("n") ... }) but it doesn't seem to work. any tips?
[12:21:36] benwilson512: Gika: Map.fetch returns a tuple
[12:22:00] benwilson512: you probably want Map.get, and pattern matching would make all of this a bit easier
[12:22:23] Gika: ...i always confuse get and fetch
[12:23:09] benwilson512: Gika: oh also are you doing "n" or :n ?
[12:23:21] benwilson512: `Enum.sort_by(list, &{&1.score, Enum.map(&1.cards, fn %{n: n} -> n end)})`
[12:24:15] Gika: yeah it was "n", forgot it was an atom
[12:24:46] benwilson512: that'll be the issue, it would have returned :error for all of them
[12:24:50] benwilson512: which will compare equal
[12:24:58] Gika: yeah, rookie mistake :)
[12:25:11] benwilson512: no worries! If you look at the code bit I posted, you can see how you can just turn the cards into a list of `n`
[12:25:20] benwilson512: and not need to do index based calls yourself
[12:26:12] Gika: `Enum.sort_by(list, &{&1.score, Enum.map(&1.cards, fn %{n: n} -> n end)})` <- so how does this work? I thought the mapper function had to return a tuple of values which are then compared, but the second value in the tuple is a list?
[12:30:02] benwilson512: Gika: the mapper function returns any elixir term
[12:30:11] benwilson512: and then those elixir terms are compared with what is called "term order"
[12:30:30] benwilson512: Gika: https://hexdocs.pm/elixir/operators.html#term-ordering
[12:30:59] Gika: Lists are compared element by element. <- oh OKAY! that was the missing link
[12:31:05] Gika: would've saved me some time :)
[12:31:16] benwilson512: Gika: right. so my mapper function returns a tuple which ensures that it is first compared by score, then by its second value
[12:31:22] Gika: i thought you couldn't just do list > list
[12:31:22] benwilson512: and then the second value is a list, which will be compared item by item
[12:31:30] benwilson512: term order is great like that :)
[12:31:44] Gika: that's really useful
[12:38:19] lexmag: has joined #elixir-lang
[12:42:54] netrino__: has joined #elixir-lang
[12:46:15] inoas: has joined #elixir-lang
[12:49:58] lexmag: has joined #elixir-lang
[12:52:57] KeyJoo: has joined #elixir-lang
[12:53:16] paxis: has joined #elixir-lang
[12:55:00] paxis: has joined #elixir-lang
[12:56:01] zigpaw: has joined #elixir-lang
[12:56:26] Adkron: has joined #elixir-lang
[12:59:24] lexmag: has joined #elixir-lang
[13:01:01] jeffro: has joined #elixir-lang
[13:01:05] jeffro: has joined #elixir-lang
[13:05:19] feld: has joined #elixir-lang
[13:07:51] praveenperera: has joined #elixir-lang
[13:21:55] netrino__: has joined #elixir-lang
[13:24:18] lpvb: has joined #elixir-lang
[13:27:15] drincruz: has joined #elixir-lang
[13:31:27] Adkron: has joined #elixir-lang
[13:41:03] m1dnight_: Where is the implementation for reduce for streams?
[13:42:31] Nicd-: Enum.reduce?
[13:47:17] benwilson512: m1dnight_: it'll be in the defimpl for whatever the type is
[13:48:11] gvaughn: has joined #elixir-lang
[13:55:51] gvaughn: has joined #elixir-lang
[14:00:56] netrino__: has joined #elixir-lang
[14:05:49] Adkron: has joined #elixir-lang
[14:07:28] m1dnight_: I found most of them here: https://github.com/elixir-lang/elixir/blob/v1.0.5/lib/elixir/lib/enum.ex#L2230 so I expected them to be there too. I'll look in the streams module perhaps
[14:07:58] m1dnight_: https://github.com/elixir-lang/elixir/blob/v1.8.2/lib/elixir/lib/stream.ex#L1559 got it.
[14:08:14] m1dnight_: Given that there is a List and a Map module, why are the defimpl Enumerable not there then?
[14:08:29] m1dnight_: (I'm just curious, not critisizing)
[14:15:15] PragTob: has joined #elixir-lang
[14:26:42] ankhers: I have a struct I am trying to make an assertion on. One of this fields has a string field. I am currently just doing `assert %MyStruct{foo: "some field"} = reply'. This field has a "long" in it. I want to check that number against the one that I have to make sure they match up. What are my options here? I know I can just put the :foo field in a variable and do another assertion, but is that the best way?
[14:27:53] wsieroci: has joined #elixir-lang
[14:27:57] Nicd-: it's a string that contains a number?
[14:28:37] ankhers: It has a format, but yes. "some text: $number not found" -- basically that.
[14:29:15] Nicd-: is "some text: " static in length?
[14:29:25] ankhers: Should be.
[14:30:02] Nicd-: then you can match with `%MyStruct{foo: "some text: 235235" <> _rest}`
[14:31:04] ankhers: The number isn't really a static length though. It can be any long value, ranging from min to max.
[14:32:30] Nicd-: wondering if you can assert with `%MyStruct{foo: "some text: #{your_number}" <> _rest}`
[14:33:58] ankhers: illegal pattern compile error.
[14:35:03] Nicd-: well we tried. easiest to make a separate assert
[14:35:39] mdbm: has joined #elixir-lang
[14:38:27] ankhers: Thanks for the help.
[14:39:56] netrino__: has joined #elixir-lang
[14:52:04] jkva: Is it common to use type specifications outside of behaviours?
[14:54:10] dimitarvp: has joined #elixir-lang
[14:54:31] ankhers: jkva: I do for my own work. dialyzer isn't a perfect replacement for a type system, but it helps.
[14:55:32] jkva: Ankhers: Thanks. I want to start using Mox, but annotations seem a useful addition in themselves outside of behaviours, hence the q
[14:59:17] ankhers: Nicd-: <<"some text: ", foo :: binary - size(size), " rest" >>, I have to convert the number I currently have into a string, and use `byte_size/1' to get the number of bytes though. I'm hoping there is a better way of doing this.
[14:59:30] qgnox: has joined #elixir-lang
[15:01:17] Nicd-: Odd that it can do that but not what I posted earlier
[15:03:59] Gazler: Ankhers: I'd match it out and do a separate assertion. %{foo: "some text: " <> num}; assert {^my_known_num, _} = Integer.parse(num)
[15:04:07] kapilp: has joined #elixir-lang
[15:08:04] ankhers: gazler: If I do that, I may as well just do `%{foo: message}; assert ^message = "some text: #{my_num} rest"'.
[15:08:23] kansi: has joined #elixir-lang
[15:08:32] ankhers: %{foo: message} = reply
[15:08:35] ankhers: That rather.
[15:09:07] Gazler: You can do that the other way round.
[15:09:21] Gazler: message = "some text: #{my_num} rest"; assert %{foo: ^message} = reply
[15:11:53] ankhers: Right. Thank you. I don't know why that didn't cross my mind.
[15:16:51] gvaughn: has joined #elixir-lang
[15:18:56] netrino__: has joined #elixir-lang
[15:20:04] m1dnight_: Fieuw, I was going through the implementation of Streams. What a complex piece of code.
[15:20:27] m1dnight_: This is where a step-through debugger might help grasping the code.
[15:26:44] ankhers: How can I use a variable in a regex?
[15:27:21] ankhers: Turns out there are different messages based on the version of mongo being used. So I'm just going to match that the number is there.
[15:31:11] benwilson512: Ankhers: regex supports #{} interpolation like a string does
[15:32:01] ankhers: benwilson512: Thanks. Did I miss that somewhere in the documentation? If not, I will throw up a PR for that soon.
[15:32:41] benwilson512: Ankhers: I don't see any examples of #{} in https://hexdocs.pm/elixir/Regex.html so a PR is probably a good idea
[15:34:15] Gazler: m1dnight_: Something like this might help `Task.async(fn -> :dbg.tracer(); :dbg.p(self(), :c); :dbg.tpl(Stream, :_, []); Stream.cycle([1, 2, 3]) |> Enum.take(10) end)`
[15:34:18] gvaughn_: has joined #elixir-lang
[15:39:19] tuacker: has joined #elixir-lang
[15:40:30] drincruz: has joined #elixir-lang
[15:47:38] Gika: has joined #elixir-lang
[15:48:02] pera: has joined #elixir-lang
[15:57:58] netrino__: has joined #elixir-lang
[15:59:42] jasonr: has joined #elixir-lang
[15:59:42] blahdodo: has joined #elixir-lang
[16:09:06] drrty: has joined #elixir-lang
[16:23:25] aalmazan: has joined #elixir-lang
[16:36:58] netrino__: has joined #elixir-lang
[16:44:01] kyrylo: has joined #elixir-lang
[16:45:15] wonko7: has joined #elixir-lang
[16:46:17] kyrylo: has joined #elixir-lang
[16:46:29] lauromoura: has joined #elixir-lang
[16:46:30] icecreamcohen: has joined #elixir-lang
[16:54:13] jnoon2: has joined #elixir-lang
[17:04:20] Phylock: has joined #elixir-lang
[17:04:48] netrino: has joined #elixir-lang
[17:05:59] tomterl: has joined #elixir-lang
[17:06:27] praveenperera: has joined #elixir-lang
[17:22:56] njoseph: has joined #elixir-lang
[17:26:41] icecreamcohen: has joined #elixir-lang
[17:28:31] ankhers: For Phoenix Channels, is there some way to make a plug that runs BEFORE each handle_in callback?
[17:29:46] benwilson512: Ankhers: plug only operates on HTTP connections
[17:30:07] benwilson512: or rather, the channel abstraction is different from the plug abstraction
[17:30:20] wsieroci: has joined #elixir-lang
[17:30:30] ankhers: Fair enough. Do you know if that is possible still? Run some function before the handle_in callback?
[17:30:47] benwilson512: no, although you can basically construct this yourself with regular functions, IE
[17:31:18] benwilson512: https://www.irccloud.com/pastebin/DuewYLQc/
[17:31:35] ankhers: Yeah. I was just wondering if there was a different way.
[17:34:40] netrino_: has joined #elixir-lang
[18:34:25] nageV: has joined #elixir-lang
[18:38:01] proteusguy: has joined #elixir-lang
[18:43:45] squall: has joined #elixir-lang
[18:46:23] netrino__: has joined #elixir-lang
[18:49:16] _barcode_: has joined #elixir-lang
[18:49:32] pera: has joined #elixir-lang
[18:53:01] blahdodo: has joined #elixir-lang
[18:54:20] mahmudov: has joined #elixir-lang
[18:58:40] icecreamcohen: has joined #elixir-lang
[19:00:14] icecreamcohen: has joined #elixir-lang
[19:01:52] praveenperera: has joined #elixir-lang
[19:07:27] lexmag: has joined #elixir-lang
[19:12:04] sparogy: has joined #elixir-lang
[19:19:09] thurloat: has joined #elixir-lang
[19:23:10] thurloat2: has joined #elixir-lang
[19:30:47] icecreamcohen: has joined #elixir-lang
[19:46:50] knack: has joined #elixir-lang
[19:47:00] nickjj: what is the best way to filter a preloaded association? basically wanting to attach a "where" clause to the preloaded association
[19:47:34] benwilson512: nickjj: join that association, then do your where
[19:48:13] nickjj: is a join the only way to do that?
[19:48:29] orbyt_: has joined #elixir-lang
[19:48:33] benwilson512: if you want to do it at the actual SQL level, you need to write the requisite SQL
[19:49:43] lauromoura_: has joined #elixir-lang
[19:53:42] nickjj: benwilson512, is joining it going to be better than passing in a query filter to the preload itself?
[19:54:16] nickjj: because after monkeying around for a while, ecto is accepting this syntax and it seems to work (ignore the hard coded values for now, just playing around) https://gist.github.com/nickjj/a46a8b8f475a99d2884da5ef9c26685e
[19:54:53] nickjj: this produces 2 queries without a join
[19:57:20] benwilson512: nickjj: it depends on whether you're trying to filter the parent by the child or not
[19:57:41] benwilson512: if you're just trying to filter the child, then preload query is perfect
[19:58:24] nickjj: the parent (discountpackages) has a package_id , it can either match that passed in package_id or the package_id can be nil to be a "first pass match"
[19:58:42] nickjj: the child (discount) is the gory details of the discount , it has things like the actual discount code, expiration times, etc.
[19:59:21] nickjj: so i wanted to first see "is a discount even capable of being accepted at the package_id level? ok it is? nice, let's make sure the discount code matches (the 2nd query)"
[19:59:46] nickjj: is that the use case where a preload query is perfect?
[20:00:28] benwilson512: sorta seems like you should just do that in one query
[20:00:37] benwilson512: I'm a bit fuzzy on the logic, and have to run
[20:05:57] drrrty: has joined #elixir-lang
[20:22:27] blahdodo: has joined #elixir-lang
[20:24:06] icecreamcohen: has joined #elixir-lang
[20:49:07] gvaughn: has joined #elixir-lang
[20:53:28] praveenperera: has joined #elixir-lang
[20:55:02] praveenperera: has joined #elixir-lang
[20:56:46] praveenperera: has joined #elixir-lang
[21:15:31] praveenperera: has joined #elixir-lang
[21:17:12] praveenperera: has joined #elixir-lang
[21:18:16] praveenperera: has joined #elixir-lang
[21:29:01] drrty: has joined #elixir-lang
[21:38:37] nickjj: i spewed a bunch of syntactically valid ecto queries that i'm pretty sure work, but looking at this function makes me want to throw up -- any advice on how i can refactor this to not suck? https://gist.github.com/nickjj/eea4a535856b67e73563331d145cfc6b
[21:52:36] __charly__: has joined #elixir-lang
[22:02:09] blahdodo: has joined #elixir-lang
[22:28:53] Sgeo: has joined #elixir-lang
[22:29:30] kapilp: has joined #elixir-lang
[22:43:27] drincruz: has joined #elixir-lang
[22:44:31] NightMonkey_: has joined #elixir-lang
[22:50:47] praveenperera: has joined #elixir-lang
[23:00:12] praveenperera: has joined #elixir-lang
[23:06:22] drincruz: has joined #elixir-lang
[23:13:23] Sgeo_: has joined #elixir-lang
[23:14:43] Exuma: has joined #elixir-lang
[23:37:02] sparogy: has joined #elixir-lang
[23:52:05] netrino__: has joined #elixir-lang
[23:58:21] __charly__: has joined #elixir-lang
[23:58:58] orbyt_: has joined #elixir-lang