« Back to channel list

#elixir-lang - 23 May 2019

« Back 1 day Forward 1 day »
[00:04:10] netrino_: has joined #elixir-lang
[00:28:41] FancyEagle: has joined #elixir-lang
[00:30:07] Adkron: has joined #elixir-lang
[00:33:25] nisstyre: has joined #elixir-lang
[00:38:20] oneark: has joined #elixir-lang
[00:43:12] netrino_: has joined #elixir-lang
[00:54:21] jnoon2: has joined #elixir-lang
[01:06:54] laut: has joined #elixir-lang
[01:11:00] orbyt_: has joined #elixir-lang
[01:22:12] netrino_: has joined #elixir-lang
[01:26:00] __charly__: has joined #elixir-lang
[01:37:48] tomterl: has joined #elixir-lang
[02:01:17] netrino_: has joined #elixir-lang
[02:10:29] Adkron: has joined #elixir-lang
[02:31:12] Sgeo: has joined #elixir-lang
[02:40:17] netrino_: has joined #elixir-lang
[03:00:55] nageV: nickjj: if condition, do: nil, else: something # the "do" portion is now documented: `nil` behaves like Python's `pass`
[03:01:49] nageV: better yet, use `unless` for such cases to avoid the need for an empty thing that warrants documentation
[03:02:22] nageV: unless condition, do: something
[03:04:23] FancyEagle: has joined #elixir-lang
[03:17:42] netrino_: has joined #elixir-lang
[03:20:58] notzmv: has joined #elixir-lang
[03:26:47] netrino_: has joined #elixir-lang
[03:30:44] nikhilmore54: has joined #elixir-lang
[03:33:33] Avinash: has joined #elixir-lang
[03:40:59] praveenperera: has joined #elixir-lang
[03:46:20] pera: has joined #elixir-lang
[03:57:10] mbuf: has joined #elixir-lang
[04:05:46] netrino_: has joined #elixir-lang
[04:21:26] Notimik: has joined #elixir-lang
[04:39:10] blahdodo: has joined #elixir-lang
[04:44:51] netrino_: has joined #elixir-lang
[05:10:06] lmarks: has joined #elixir-lang
[05:11:18] lmarks: Looking for a way to get the time taken to complete a request from inside a Phoenix end-point instrumenter module callback - any ideas?
[05:14:08] lauromoura: has joined #elixir-lang
[05:17:23] sms: Well that's strange
[05:17:57] sms: Any idea why locally my code is fine but when I have it deployed I get (UndefinedFunctionError) function DateTime.now/1 is undefined or private
[05:18:33] sms: Running the same branch
[05:24:21] lauromoura: has joined #elixir-lang
[05:31:14] praveenperera: has joined #elixir-lang
[05:49:35] lmarks: Never mind - just realized its in the docs:
[05:49:38] lmarks: event_callback(:stop, time_diff, result_of_before_callback)
[05:51:32] voltone: has joined #elixir-lang
[05:52:52] lauromoura: has joined #elixir-lang
[05:55:55] sms: DateTime.now since v1.8.0
[05:55:58] sms: Of course
[05:56:14] sms: Why wouldn't it be
[06:03:00] praveenperera: has joined #elixir-lang
[06:06:26] kdisneur: has joined #elixir-lang
[06:11:42] lauromoura_: has joined #elixir-lang
[06:19:17] netrino_: has joined #elixir-lang
[06:20:50] fastfresh: has joined #elixir-lang
[06:22:42] Sgeo_: has joined #elixir-lang
[06:27:01] netrino__: has joined #elixir-lang
[06:31:58] gvaughn: has joined #elixir-lang
[06:40:34] jimmyrcom: has joined #elixir-lang
[06:43:16] serafeim_: has joined #elixir-lang
[06:44:48] serafeim: hello, is there a way to configure my `iex -S mix` to auto-alias some stuff when I start it? I've grown tired to always run `alias Project.Auth.User` :(
[06:45:12] serafeim: notice that I'm aware that I can leave it open and use `recompile`.
[06:45:24] Nicd-: there is a .iex.exs file that is run first I think
[06:45:39] Nicd-: https://hexdocs.pm/iex/IEx.html#module-the-iex-exs-file
[06:45:47] serafeim: Nicd-: hm interesting thanks
[06:45:55] Nicd-: put your aliases there
[06:46:50] serafeim: excellent it works great !
[06:46:59] serafeim: even on windows
[06:47:43] kapilp: has joined #elixir-lang
[06:56:20] Sgeo: has joined #elixir-lang
[06:58:52] Adkron: has joined #elixir-lang
[07:00:47] Sgeo_: has joined #elixir-lang
[07:19:20] hmans: has joined #elixir-lang
[07:19:39] hypercore: guys what's the best way of managing subscriptions and notifications, a la youtube? (i.e. users can subscribe to channels, and get notifications when new videos come out)
[07:20:16] hypercore: the subscription part obvious to me, just create a many-to-many subscriptions table, with user_id and channel_id
[07:20:37] hypercore: but the notification system i'm less sure about
[07:22:02] hypercore: would a simple notifications table work? (e.g. {id: int, video_id: references(Video), user_id:references(User), seen: bool})
[07:22:42] hypercore: issue i see with this method is that if i have thousands of users, then the number of notifications could grow far too quickly
[07:23:06] DeadTrickster__: has joined #elixir-lang
[07:23:34] hypercore: e.g. 10 notifications per user per day * 10,000 users = 100,000 new inserts into my notifications table each day
[07:24:52] lpil52: has joined #elixir-lang
[07:25:51] raindrop: has joined #elixir-lang
[07:27:06] jsehop98: has joined #elixir-lang
[07:28:05] serafeim: hypercore: i think that's the correct way to do it if you use an SQL database; 100k inserts per day isn't that much
[07:28:18] gvaughn: has joined #elixir-lang
[07:28:38] serafeim: also this is the kind of data that you can delete after a while since after the users sees the notification is not relative anymore
[07:30:39] hypercore: serafeim: good point, should be able to run a cleaning script deleting old notifications. is 100k inserts per day really not that much?
[07:31:50] serafeim: hypercore: no its not that much a simple database should be able to handle it easily
[07:32:25] serafeim: it's like 1-2 inserts per second
[07:33:00] michael_mbp: has joined #elixir-lang
[07:33:13] hypercore: serafeim: what is considered a lot? 10 inserts per second?
[07:33:23] hypercore: (for a small $5 VPS)
[07:34:31] hypercore: good morning
[07:34:33] serafeim: hmmm i'm not sure about what are the capabilities of an $5 vps...
[07:34:41] Nicd-: I've had a database with 10+ million inserts every night
[07:34:56] hypercore: wow, that's a lot
[07:35:03] hypercore: what hardware was it running on?
[07:35:05] serafeim: however an insert should take like 1 ms ? so 1000 inserts per s ?
[07:35:24] hypercore: serafeim: oh ok that's quite a lot then
[07:35:28] serafeim: this also depends on your indeces
[07:35:55] serafeim: i guess you can measure it to find out
[07:36:10] jkva: For my daily "What's the proper method to do this in Elixir" question... :) I have a number of structs that are structurally 90% similar. I use structs so I can have runtime key checks and pattern matching on struct name. When it comes to drying up code, can I derive specific structs from a common struct, possibly by dynamically setting the `__struct__`m or is there a better way to begin with to achieve such?
[07:36:14] hypercore: for some reason i have it in my head that i should be as conservative with my database as possible (i.e. as few columns in a table as possible, and as few create/read/update/deletes as possbile)
[07:36:30] hypercore: e.g. is 10 columns a lot for a table?
[07:36:45] hypercore: (i feel like it is)
[07:36:47] serafeim: hypercore: no this is a wrong rationality and will lead to non-normalized designs which will lead to great problems after a little while
[07:36:53] serafeim: hypercore: no it definitely is not
[07:37:25] serafeim: hypercore: a table must have as many columns as it is needed to be properly normalzied
[07:37:26] hypercore: serafeim: so i should err on the side of creating as many columns as i think i *might* need (and then removing them eventually if i don't)?
[07:37:35] Nicd-: a lot of columns sounds like a design problem but only if they contain non-normalized data. you don't normalize based on column count
[07:37:48] hypercore: what does normalize mean in this context?
[07:37:53] blahdodo: has joined #elixir-lang
[07:38:00] serafeim: hypercore: you need to read some RDBMS theory :)
[07:38:10] Nicd-: https://en.wikipedia.org/wiki/Database_normalization
[07:38:28] Nicd-: you should really learn that so you can effectively design databases
[07:38:43] serafeim: try to find out what 3NF means
[07:39:04] serafeim: usually it is enough to achive this and it's rather easy to understand it
[07:39:04] Nicd-: you add exactly the columns you need and no more and no less. not because of "I might need this" or "11 is too many"
[07:39:27] serafeim: Nicd-: also each column must contain a single thing
[07:39:32] jkva: https://www.amazon.com/Database-Design-Relational-Theory-Normal/dp/1449328016/ this one is good
[07:39:40] Nicd-: (usually)
[07:40:48] Sgeo__: has joined #elixir-lang
[07:41:38] hypercore: thanks for the tip guys, i'll read up on db theory
[07:42:34] serafeim: no problem... these are things that you can learn on university but also by experience and by following some common sense
[07:43:17] hypercore: is it difficult to restructure table schemas later?
[07:43:34] serafeim: hypercore: yes it is especially if you need to move data
[07:44:05] Nicd-: you will always need to do it in some way due to the software evolving
[07:44:10] Nicd-: so don't fear it too much
[07:44:24] serafeim: i remember that when I was learning about DB theory most of the things about normalization seemed strange; however after i had some experience in creating my own database and *especially* after needing to query for statistics i understood why all these requirements were in place
[07:44:56] Nicd-: and then sometimes you deliberately denormalize things when you know the tradeoffs :)
[07:45:00] Adkron: has joined #elixir-lang
[07:45:08] serafeim: Nicd-: definitely
[07:45:55] Nicd-: the jsonb blob in my users table for every user is definitely not normalized :P
[07:46:51] hypercore: i guess i'm asking if i should ship my app or get a good understanding of RDBMS theory, possibly rewrite a lot of my schemas, and then ship in god knows when
[07:48:18] serafeim: hypercore: <HN>just ship</HN>
[07:48:40] Nicd-: depends on what it is :P
[07:48:47] Nicd-: and if your future depends on it
[07:49:12] hypercore: i mean in a sense my future does depend on it, might save me from wage slavery
[07:50:35] serafeim: I think that if it "just works" for now then just ship it. the problems you'll have from bad database design are *good problems* in the sense that if you have them it means that your project has attracted a lot of users so ti will be worth it to research it more (or ask for hired help)
[07:50:54] sms: How do I inspect a task running in production
[07:51:56] hypercore: serafeim: i think you might be right, otherwise i'm going to keep delay shipping it until it's Perfect™
[07:52:23] Nicd-: yes a lot of popular services have and do run on awful piles of poop :D
[07:53:58] hypercore: Nicd-: better a popular service running on a pile of poo than a dead service running on a pile of gold
[07:54:17] Nicd-: how about a dead service running on a pile of poop
[07:54:21] Nicd-: my specialty
[07:54:45] hypercore: with enough popularity, poo can be transmuted to gold
[07:55:46] sms: Will the observer work on my running prod app?
[07:55:56] hypercore: do you also recommended using a managed DB solution to begin with? going to cost an extra $15 per month, but maybe it's worth it?
[07:56:26] Nicd-: sms: you can start observer on your local machine and connect to your prod machine if you can get erlang distribution started between them (via SSH tunnel for example). but it's a bit finicky
[07:56:42] serafeim: hypercore: this depends on your experience with managing databases
[07:56:46] sms: So is there an easy way to inspect my tasks in production?
[07:56:46] Nicd-: sms: there's also :observer_cli but it's a separate package that needs to be installed for CLI observing
[07:56:57] sms: Well it's currently in a container to
[07:57:02] sms: So I don't know
[07:57:05] sms: A little difficult
[07:57:20] hypercore: serafeim: very little
[07:57:35] serafeim: well thn probably its worth it
[07:57:41] sms: Is there a simple way to just
[07:57:45] sms: Run commands
[07:57:47] hypercore: i mean i can do backups, restores, but my db knowledge is very small
[07:57:50] sms: In the running prod app
[07:58:02] Nicd-: is it a distillery release?
[07:58:06] serafeim: the problem i've seen with managed database solutions is that for non-hobby databases the prices are really high
[07:58:48] hypercore: serafeim: yeah agreed
[07:59:35] serafeim: but once again that's a *good problem*; if you have so much data that you need non-hobby pricing then you are good
[08:00:36] sms: Nicd-: No it's just running in a container regularly
[08:00:45] hypercore: serafeim: also, how do you recommend deploying phoenix apps?
[08:00:48] Nicd-: sms: did you set a node name for it?
[08:00:50] nikhilmore54: has joined #elixir-lang
[08:00:52] Nicd-: and a cookie
[08:00:59] hypercore: still struggling with this a bit, doesn't seem so simple
[08:01:10] sms: Nicd-: I have bash in the container right now, and I'm not sure actually
[08:01:11] hypercore: (trying to get deploy-on-push type of setup going)
[08:01:17] Nicd-: if not, then unfortunately I don't think you can connect to it
[08:01:18] sms: I don't remember setting anything manually
[08:01:41] Nicd-: if you did set, you can --remsh into it from a shell in the same container using the same cookie and a different name
[08:01:50] Nicd-: distillery makes this easier
[08:02:02] inhortte: has joined #elixir-lang
[08:02:26] sms: Ahh I didn't realize, I figured it'd be easier
[08:02:31] sms: That's useful to know though
[08:02:50] serafeim: hypercore: well I've ended up using a simple fabric script to deploy; the common way is to use distillery but it seems too complex for my needs
[08:03:24] netrino__: has joined #elixir-lang
[08:03:39] serafeim: hypercore: TL;DR i just install erlang+elixir on my prod server and then run `MIX_ENV=prod mix phx.server` from supervisord
[08:03:52] hypercore: serafeim: is that basically using your app repo, copying it to the server and running it?
[08:04:07] serafeim: hypercore: yes cloning it at first and then pulling the changes
[08:04:23] serafeim: i've all the required scripts here in case anybody needs it https://github.com/spapas/phxcrd
[08:04:54] gvaughn: has joined #elixir-lang
[08:05:00] hypercore: serafeim: yeah this is a lot easier than releases (which i still don't fully understand). Does it have any downsides compared to using releases?
[08:05:21] serafeim: check out fabric.py and etc/supervisord.conf
[08:06:11] serafeim: hypercore: i guess you'll need to have the same erlang / elixir version in your dev and prod server. also you can't do rolling releases; the prod needs to be restarted
[08:06:38] serafeim: hmmm i can't think of anything else but i haven't used distillery at all so maybe there are others :)
[08:11:39] serafeim: i'll also have to note that i'm using the same more or less method for Django for like 7 years without any problems ever
[08:12:29] netrino__: has joined #elixir-lang
[08:13:02] hypercore: serafeim: lol maybe this is the way to go then?
[08:14:45] serafeim: hypercore: for me definitely
[08:17:23] Niamkik: has joined #elixir-lang
[08:18:37] nikhilmore54: has joined #elixir-lang
[08:21:37] netrino__: has joined #elixir-lang
[08:23:39] eudocimus_r1: has joined #elixir-lang
[08:24:02] serafeim: I've used a `date_select` in my phoenix form. this renders three selects for year / month / day. Is there a way to localize the name of the months ?
[08:24:19] serafeim: I now see January, February etc.
[08:28:12] serafeim: ok this is actually mentioned in te docs !
[08:30:43] netrino__: has joined #elixir-lang
[08:37:55] sevenseacat: has joined #elixir-lang
[08:43:09] wonko7: has joined #elixir-lang
[08:44:17] PragTob: has joined #elixir-lang
[08:50:17] nikhilmore54: has joined #elixir-lang
[09:01:27] netrino: has joined #elixir-lang
[09:01:49] nikhilmore54: has joined #elixir-lang
[09:12:18] nikhilmore54: has joined #elixir-lang
[09:18:41] lexmag: has joined #elixir-lang
[09:37:52] lexmag: has joined #elixir-lang
[09:42:26] celyr: is there a way to do pattern matching on function arguments with string regex ?
[09:45:10] rawtaz: interesting question
[09:45:12] rawtaz: ACTION watches
[09:45:42] Adkron: has joined #elixir-lang
[09:46:11] gvaughn: has joined #elixir-lang
[09:48:59] dysfun: closest you can get is binary match
[09:49:28] celyr: can you give an example so I can understand ?
[09:49:40] celyr: oh I got it treating it like a list
[09:52:07] celyr: I'll use an if it sounds easier and more readable
[09:53:54] dysfun: but you can't do nearly as much with that as a regex
[09:54:07] dysfun: just use an if
[09:54:50] dysfun: in general, if the questions starts "can i" and ends "in pattern matches?", the answer is no, use an if or a case
[09:56:28] celyr: it's just that elixir pushes so hard you against using ifs
[09:56:40] celyr: at least the way I use it
[10:00:10] jkva: dysfun: do you perhaps have any advice regarding my earlier q about structs from a few hours ago?
[10:00:33] celyr: jkva, i don't see it
[10:00:51] jkva: I'll repost it :)
[10:00:55] jkva: For my daily "What's the proper method to do this in Elixir" question... :) I have a number of structs that are structurally 90% similar. I use structs so I can have runtime key checks and pattern matching on struct name. When it comes to drying up code, can I derive specific structs from a common struct, possibly by dynamically setting the `__struct__`m or is there a better way to begin with to achieve such?
[10:02:54] dysfun: jkva: just write them out
[10:03:37] jkva: dysfun: right, you wouldn't make a macro or generator function for those, is what you're saying
[10:04:07] jkva: I mean, I'm talking about ±15 of them, so I wondered if that was a candidate for drying up
[10:04:39] dysfun: we like code that is really easy to understand
[10:05:13] jkva: Works for me :)
[10:06:17] celyr: I honestly I'm on the same opinion of dysfun but was kinda afraid to say :P
[10:07:32] dysfun: just try not to hide things away
[10:07:41] dysfun: i like my code where i can see it
[10:07:53] dysfun: or at least properly abstracted
[10:08:28] jkva: Right, cool. Like Python's explicitness over magic
[10:08:45] blahdodo: has joined #elixir-lang
[10:08:58] dysfun: yeah, but with less mutability
[10:20:06] lexmag: has joined #elixir-lang
[10:21:34] njichev: has joined #elixir-lang
[10:22:55] Adkron: has joined #elixir-lang
[10:26:38] kapilp: has joined #elixir-lang
[10:34:33] voltone: has joined #elixir-lang
[10:53:17] voltone: has joined #elixir-lang
[11:06:37] lexmag: has joined #elixir-lang
[11:08:55] Avinash: has joined #elixir-lang
[11:14:19] hypercore: has joined #elixir-lang
[11:17:12] griffinbyatt: has joined #elixir-lang
[11:33:57] gvaughn: has joined #elixir-lang
[11:35:44] fastfresh: has joined #elixir-lang
[11:40:18] drincruz: has joined #elixir-lang
[11:46:55] tnez: has joined #elixir-lang
[11:50:38] Avinash: has joined #elixir-lang
[11:56:39] netrino_: has joined #elixir-lang
[12:05:32] PragTob: has joined #elixir-lang
[12:10:15] netrino__: has joined #elixir-lang
[12:13:32] drincruz: has joined #elixir-lang
[12:15:56] netrino: has joined #elixir-lang
[12:20:24] bingobingolotto: has joined #elixir-lang
[12:29:19] Adkron: has joined #elixir-lang
[12:42:00] praveenperera: has joined #elixir-lang
[13:03:49] Sgeo_: has joined #elixir-lang
[13:07:16] Adkron: has joined #elixir-lang
[13:19:35] nickjj: action_fallback is still the right abstraction for wanting to do custom things if a record doesn't exist for a specific controller/resource right? the docs show just rendering a generic 404 page
[13:20:51] nickjj: but what if you wanted to say "if blog post doesn't exist, then redirect user to some page" -- suddenly the fallback controller is now specific to blog posts, but what happens if you also have another resource that you want the same behavior but a different redirect?
[13:20:59] Gazler: nickjj: I wouldn't start with action fallback.
[13:21:25] Gazler: I'd use a plug in this instance.
[13:21:32] nickjj: right now i'm finding myself using get_by (without !) and then wrapping every single show action with "if record exists? cool, else redirect to index page of resource"
[13:22:02] nickjj: because i never want to throw a 500 if the page doesn't exist and i never want to show a generic 404 -- i want to do user friendly things specific to that resource / controller
[13:22:52] Gazler: plug :find_blog_post! when action in [:show, :update, :edit, :delete]... defp find_blog_post!(conn, _), do: (if Blog.find_post(conn.params["id"]), do: assign(conn, :post, post), else: redirect(conn, to: ...))
[13:23:56] nickjj: but then you'd end up writing that code for every controller you have right?
[13:25:04] gvaughn: has joined #elixir-lang
[13:26:00] nickjj: thanks, i suppose that'll do
[13:26:14] Gazler: If you want to use action_fallback you can look up the controller from the conn and handle it appropriately.
[13:26:22] Gazler: use https://hexdocs.pm/phoenix/Phoenix.Controller.html#controller_module/1
[13:26:48] nickjj: but what if you do want a 404 to be rendered? is there a more clean way than just modifying that plug example to render the error view like the action_fallback docs?
[13:27:18] Gazler: The example renders a 404 https://hexdocs.pm/phoenix/Phoenix.Controller.html#action_fallback/1-examples
[13:27:31] nickjj: right, that's the docs i was looking at
[13:27:57] nickjj: so that is the right pattern to render a generic 404 for any controllers that use the fallback?
[13:28:05] Gazler: If you want to render a 404 in a plug you can do: conn |> put_status(:not_found) |> put_view(MyErrorView) |> render(:"404") |> halt()
[13:28:11] nickjj: and as long as you get_by without !, a 404 would be thrown?
[13:28:55] Gazler: A 404 would be rendered, yeah.
[13:29:05] nickjj: i definitely will have a few controllers that will 404 if the id isn't matched (that's a reasonable default behavior for the web in general, since the resource doesn't exist)
[13:29:46] __charly__: has joined #elixir-lang
[13:30:14] nickjj: cool thanks, sounds like fallback is the way to go for that, but then use your plug example for situational redirects
[13:31:04] Gazler: I like using plugs because they exit earl and reduces duplication in the functions.
[13:31:24] svennidal: has joined #elixir-lang
[13:31:39] Gazler: You don't have to keep doing `with %Post{} = post <- Blog.find_post(id)`...
[13:32:06] Gazler: All of the paths lead to the same point though.
[13:32:30] nickjj: what makes action_fallback less efficient? just goes through more work before it can do something?
[13:32:51] nickjj: the plug approach sounds like you would still need to write a plug specific for each controller (since it's not always an id you're looking for)
[13:33:50] Gazler: action_fallback happens after your controller function executes, whereas a plug halts execution before getting to the function. It's not going to be the bottleneck in your application though.
[13:35:20] Gazler: Honestly though, I think it is mostly personal preference. Use what you think reads best.
[13:35:49] nickjj: yeah, i'm not sure what looks best yet, was just combing through the docs to try and solve the problem, but didn't find anything conclusive
[13:37:04] nickjj: then i looked at source code examples where they are using get_by! without action fallback but still somehow show a 404 page when the record doesn't exist, but how that happens is still a mystery since nothing is imported and i see no plugs in each controller
[13:37:15] Gazler: Oh, so there is a third way.
[13:37:44] Gazler: https://github.com/phoenixframework/phoenix_ecto/blob/master/lib/phoenix_ecto/plug.ex
[13:38:39] Gazler: https://hexdocs.pm/plug/Plug.Exception.html
[13:38:46] celyr: what I really don't like about elixir is when you get something lie this:
[13:39:15] celyr: str = Agent.get(:FWDADD, fn map -> map end)
[13:39:15] celyr: |> get_string()
[13:39:26] celyr: Because it really messes up what str is
[13:39:33] celyr: what do you think ?
[13:39:33] nickjj: gazler, so you just add this plug to your router.ex and things 404 even using get_by!?
[13:39:45] Gazler: nickjj: You don't need to.
[13:39:50] Gazler: It happens by default.
[13:40:47] nickjj: ah, so don't worry about then -- but in the cases where i want a custom redirect, use your plug example from before?
[13:41:33] Gazler: celyr: What don't you like about it?
[13:41:59] celyr: that at first sight you may not get that str is the return value of get_string()
[13:42:08] nickjj: that threw me off is when you use get_by! and goto an invalid record, you get an Ecto.NoResultsError exception
[13:42:24] Gazler: celyr: If you use the formatter, it moves the Agent line down
[13:42:47] nickjj: i should have looked at the status code of the response, it is a 404 -- it just doesn't hint that it's a 404 in the phoenix stack trace in development
[13:43:03] benwilson512: celyr: one line pipes like that aren't really considered good practice either
[13:43:29] celyr: best to get_string(...) ?
[13:43:44] benwilson512: or two named variables
[13:43:48] benwilson512: one for the value, one for the string
[13:44:22] Gazler: get_string(Agent.get(:FWDADD, fn map -> map end)) don't @ me
[13:45:02] __charly__: has joined #elixir-lang
[13:45:21] nickjj: gazler, do you think i should open a PR in the docs to remove that confusion?
[13:45:38] Adkron: has joined #elixir-lang
[13:46:12] nickjj: because the docs say get_by! will throw Ecto.NoResultsError , however right above that the get_by docs doesn't mention anything about Ecto.NoResultsError -- however in practice, both of them produce the same Ecto.NoResultsError (and give drastically different data about the error in the phoenix dev 404 page)
[13:46:36] nickjj: and both even throw a proper 404 status code
[13:47:14] Gazler: get_by doesn't throw a NoResultsError
[13:47:16] Gazler: Only get_by!
[13:47:20] Gazler: get_by will return nil
[13:47:39] Gazler: s/throw/raise
[13:48:10] nickjj: i see a noresultserror when using get instead of get!
[13:48:31] Gazler: https://hexdocs.pm/phoenix/errors.html#content explains the custom errors btw.
[13:49:12] nickjj: nevermind, really need to buy a new keyboard -- thanks
[13:51:35] benwilson512: aha! for some reason it took me this long to recognize that the live view websocket connection is a 100% different thing from the initial page render, it could even go to a different backend server
[13:51:59] benwilson512: which is why assigns aren't magically transfered
[13:52:09] benwilson512: and stuff in the session can be
[13:54:44] benwilson512: although... how are assigns that are passed in to the `live_render` call transferred? back to the code.
[13:55:28] josevalim: We don’t pass assigns ever
[13:56:31] josevalim: Only from child to child I think
[13:56:51] benwilson512: ok that makes sense and jives with what I'm reading in the code base
[13:57:21] benwilson512: I _think_ then the only way to get page url parameters into a live view at the moment then is `let liveSocket = new LiveSocket("/live", {params: parseURLParams})`
[13:57:36] benwilson512: and fork the socket code to put those params as an assign
[13:58:48] benwilson512: I guess I could render them into a form and have the socket get the contents of the form?
[13:59:51] benwilson512: or I give up on making this URL based for now
[14:00:00] benwilson512: and make the search button a live view event
[14:01:20] gvaughn: has joined #elixir-lang
[14:06:09] benwilson512: ah, that won't actually work cause it's part of the nav header which is outside the live view dom element
[14:08:42] drincruz: has joined #elixir-lang
[14:15:51] benwilson512: ok, the JS based thing worked
[14:28:43] sirn_: has joined #elixir-lang
[14:35:21] garazdawi: has joined #elixir-lang
[15:00:54] samgaw: has joined #elixir-lang
[15:05:05] bingobingolotto: has joined #elixir-lang
[15:08:27] mvdw: has joined #elixir-lang
[15:12:18] samgaw: Can anyone offer any advice regarding Postgrex types? I'm trying to run a fairly simple query as a fragment against a `cidr` column.
[15:12:18] samgaw: e.g. `where(query, [e], fragment("value >>= ?", ^value))`
[15:12:20] samgaw: But I'm getting the error back `Postgrex expected %Postgrex.INET{}, got "192.168.0.1". Please make sure the value you are passing matches the definition in your table or in your query or convert the value accordingly.`
[15:12:33] wsieroci: has joined #elixir-lang
[15:16:17] orbyt_: has joined #elixir-lang
[15:21:10] dimitarvp: has joined #elixir-lang
[15:23:40] gamache: is it possible to specify a minimum OTP version in mix.exs?
[15:30:13] aalmazan: has joined #elixir-lang
[15:33:40] orbyt_: has joined #elixir-lang
[15:36:35] wsieroci: has joined #elixir-lang
[15:48:42] dimitarvp: has joined #elixir-lang
[16:09:15] wonko7: has joined #elixir-lang
[16:16:38] icecreamcohen: has joined #elixir-lang
[16:17:55] icecreamcohen: From my cursory checks, it looks like DBConnection and Mint are incompatible, correct? Or, more specifically, you can’t make a client process a process that receives mint messages.
[16:35:20] pera: has joined #elixir-lang
[16:35:39] medzin: has joined #elixir-lang
[16:38:16] medzin: has joined #elixir-lang
[16:39:39] medzin: has joined #elixir-lang
[16:48:40] Phylock: has joined #elixir-lang
[16:51:59] gamache: icecreamcohen: what do you mean by "Mint messages"? The messages that get sent to the caller during a Mint request are from the :gen_tcp or :ssl modules
[16:52:07] icecreamcohen: that’s right
[16:52:25] icecreamcohen: but from what I can tell, a db_connection connection process can’t override handle_info
[16:53:17] icecreamcohen: now, it can spawn another process that’s the recipient of the gen_tcp messages, but I think that gets away from the idea of db_connection
[16:53:24] gamache: interesting. I see that they can and do handle messages directly as a way to flush the mailbox, but I think you might be right
[16:53:57] icecreamcohen: yeah, I could put a receive block in there, but i’ll invariably miss some messages.
[16:54:24] gamache: If you're just looking for Mint plus a pool, I wrote this thing Mojito that is that https://github.com/appcues/mojito
[16:54:57] icecreamcohen: lol, great name
[16:55:01] gamache: the pooling is just Poolboy right now but soon that will be replaced with a dispcount/shackle-ish solution
[16:55:07] gamache: it's mint you can enjoy by a pool :D
[16:55:57] icecreamcohen: it looks like that could be a great alternative to hackney
[16:56:06] icecreamcohen: and mint reminds me a lot of gun
[16:56:40] icecreamcohen: but I’m actually connecting to a database that uses HTTP as its transport
[17:03:56] jnoon2: has joined #elixir-lang
[17:05:29] squalloster: has joined #elixir-lang
[17:05:57] icecreamcohen: has joined #elixir-lang
[17:10:39] Sentreen: has joined #elixir-lang
[17:10:51] eudocimus_r: has joined #elixir-lang
[17:29:28] ericmj: icecreamcohen: is the database using HTTP/1 or HTTP/2?
[17:30:55] ericmj: mojito can be a good use case when you send requests to a single host like a database
[17:31:37] ericmj: you can also write a custom connection pool around mint that handles your needs specifically
[17:32:37] micmus: i guess the disconnect is with db_connection expecting sockets to work in passive mode, while mint is active-mode only
[17:32:42] icecreamcohen: actually, I don’t think I need a pool at all. Since the HTTP connections are 1:1 with db_connections, and db_connections are often pooled.
[17:32:48] micmus: Would it be hard to add passive mode to mint?
[17:32:57] icecreamcohen: that’s precisely it.
[17:33:13] icecreamcohen: db_connection _used_ to do active mode, but it was removed.
[17:34:02] ericmj: if you support active mode it is easy to support passive mode
[17:34:19] ericmj: remove the calls to setopts and wrap the recv in {:tcp, ...}
[17:34:30] micmus: Another similar situation I saw recently was broadway that does not allow you to maintain state and mint that requires you to maintain state... So it forces adding another process in there. I guess it's not worse than other http libs, just a bit disappointing
[17:35:32] icecreamcohen: that’s the workaround that I had to implement as well
[17:35:56] ericmj: I think broadway assumes you write the mint handling parts with gen_stage?
[17:36:09] icecreamcohen: I wanted to see if I could eke out more performance over hackney, but no.
[17:36:39] micmus: ericmj: if it's a source. But if you want mint as part of your sink, you have to add another pool & all of that
[17:38:05] micmus: You can't maintain state in the sink and you can't replace the sinks with gen stage
[17:39:51] ericmj: if the socket mode is the only thing that limits mint to be used with dbconn then I think we can fix that
[17:40:19] ericmj: was a long time since I used dbconn though
[17:40:25] ericmj: fishcakez: are you around?
[17:40:28] micmus: I'm not sure it's the only thing, but I think it's the biggest one
[17:41:40] pera: has joined #elixir-lang
[17:42:03] icecreamcohen: from what I can tell, that was the only thing
[17:43:00] ericmj: please open an issue on mint about passive mode
[17:43:18] josevalim: but on broadway + mint, you can just do blocking requests (which is how all other clients work anyway)
[17:45:30] micmus: josevalim: yes, but I can't hold the mint struct in the broadway consumer process. I have to artificially introduce another process to hold the connection and check it in/out for every message
[17:46:48] micmus: Similar if I need other processes for the consumer - I can't just create them when the consumer starts - I have to do some weird lazy-initialization dance and maintain a registry. Lots of unnecessary dance
[17:47:17] lauromoura__: has joined #elixir-lang
[17:47:24] ericmj: isn't this what gen_stage is for?
[17:48:32] micmus: ericmj: sure, I can do all of that with raw gen_stage, but then I have to reimplement all of the things broadway provides. You could argue you could do the same with raw processes ;)
[17:49:06] micmus: ericmj: broadway allows you to inject custom stages as sources, but not as sinks. It forces you to build stateless sinks
[17:49:25] ericmj: they are all abstractions providing benefits and drawbacks from each other
[17:49:42] icecreamcohen: ericmj: Issue opened, but I don’t think it’s a huge deal for me. Just something I noticed and wanted to make sure I wasn’t doing anything wrong
[17:50:35] micmus: Sure. I agree. It's just this seems like a weird limitation. I'm not involved with the project so there might be a technical reason this is not allowed, but it's quite limiting in what you can use broadway for
[17:51:19] lauromoura_: has joined #elixir-lang
[17:52:42] icecreamcohen: Correct me if I’m wrong, but the usage of mint would vary pretty wildly depending on if you use active or passive mode
[17:53:10] ericmj: not really, in one you call :gen_tcp.recv in the other you don't
[17:53:21] ericmj: in passive mode you would still own the socket
[17:54:38] icecreamcohen: but clients of mint currently use receive blocks to get messages that mint processes
[17:54:44] icecreamcohen: that would change, no?
[17:54:57] icecreamcohen: I mean, for my use case that would absolutely have to change
[17:55:04] ericmj: yes, that would change, you would call :gen_tcp.recv instead of receive
[17:56:36] micmus: ericmj: what if there was an API like `Mint.recv(conn)` that would call the correct recv underneath for you?
[17:56:40] icecreamcohen: That’s not too bad, of course, just two interfaces… but gen_tcp has two interfaces and that’s fine.
[17:58:16] ericmj: right, you can't support both active and passive without two interfaces
[17:58:29] Adkron: has joined #elixir-lang
[17:58:29] ericmj: in the same way gen_tcp has two interfaces for active and passive
[17:59:07] ericmj: micmus: I prefer if the user still sources the data, gives more flexibility, specially with the new sockets API
[17:59:28] ericmj: the new sockets API might give us non-blocking passive mode
[18:00:16] micmus: Right, that makes sense. Though, I think mint internally still calls gen_tcp/ssl, doesn't it? So it would just remove it from one place but not others
[18:00:47] fishcakez: ericmj: dbconnection only works on passive mode
[18:01:02] fishcakez: Design is to be simple for drivers
[18:01:32] icecreamcohen: has joined #elixir-lang
[18:01:37] ericmj: mint calls gen_tcp/ssl directly but the underlying transport is flexible
[18:02:08] ericmj: we had a transport behavior before 0.1.0 but it was not needed so we scrapped it, but we can easily add it back
[18:02:50] ericmj: fishcakez: if mint supported passove mode could it work with dbconn, or would it require any other changes?
[18:03:18] josevalim: the reason broadway is stateless is because error handling is much simpler. if you have state, any failure in the tree kinda has to shut the whole tree down because the state may have been corrupted
[18:03:58] fishcakez: ericmj: it could work for http1, h2 it doesn't make sense imo
[18:04:45] ericmj: right, dbconn doesn't support concurrent requests for a single connection
[18:05:53] micmus: josevalim: not sure I understand. If the state is for the sink, why do you need to shut down other sinks or producers?
[18:06:07] josevalim: the sink is the only exception to what i said
[18:06:33] josevalim: but if we said "you can only have state in the sink", then people would move stuff they should not to the sink
[18:06:37] josevalim: only to leverage the state
[18:06:47] micmus: and the only place where I want to have state :P
[18:07:43] josevalim: but a db_connection like pool for mint would solve most of those concerns anyway
[18:07:56] fishcakez: micmus: state lives outside, before Broadway in your tree
[18:08:49] fishcakez: It's really nice design for Broadway to have for fault tolerance without making it too complex or fragile to use I think
[18:09:19] fishcakez: Building gen stage pipelines with optimal faul tolerance is not something easy to do
[18:09:31] fishcakez: And you probably don't want to configure it
[18:10:47] micmus: You're most probably right. I was just very surprised by this API. It seems like a perfect and natural concurrency boundary, but requires me to split it up again and not leverage it
[18:14:09] wsieroci: has joined #elixir-lang
[18:15:07] fishcakez: If you don't build the supervision tree yourself it's very hard to understand the failure unless the library has very simple failure handling. If there was state this would happen I think, and be harder to test in user application.
[18:16:14] sebboh: has joined #elixir-lang
[18:24:34] sebboh: hi all. Is there an andrewek present? I came across his github and noticed he uses elixir and lives in the same city as I do, so I thought I'd drop by and say hi.
[18:31:46] lexmag: has joined #elixir-lang
[18:32:07] icecreamcohen: has joined #elixir-lang
[18:37:28] Kerem: has joined #elixir-lang
[18:38:28] Kerem: Any one that has experience with jason and encoding structs to json? I am having a bit of trouble locating how to change the way json keys are represented (Default seems to be strings)
[18:39:14] sebboh: Doesn't json require strings for keys? Oh, you're probably talking about the representation on the other end..
[18:40:34] Kerem: never mind i think seems to be an other issue
[18:46:06] nageV: josevalim: speaking of Broadway, I love Flow because makes it really easy to scale horizontally (e.g. Flow.partition(stages: N) |> Flow.map(...) gives you N instances of GenStages that perform mapping), but it's not obvious how to do the same kind of scaling with GenStage/Broadway because you have to set up the topology by yourself: how do you perform "stages: 32" with GenStage/Broadway? (i.e.
[18:46:12] nageV: replicating a stage 32 times and connecting all the instances up to the same upstream & downstream GenStages in the topology)
[18:47:41] icecreamcohen: has joined #elixir-lang
[18:50:37] nageV: Kerem: the library probably doesn't default to using atoms to avoid DoS attacks (atoms are never garbage collected in Erlang VM so if you dynamically create atoms from strings, such as from arbitrary JSON you read in, then you might use up all available memory and crash the Erlang VM)
[18:51:25] nickjj: does anyone know why 2 unique_constraints that each use 2 different sets of keys don't work together to block both combinations of inserts?
[18:57:17] nickjj: it's like ecto always tries to run the validation against 1 of the constraints first, regardless of how they are ordered in the changeset
[18:58:45] micmus: nickjj: the database does the validations, the constraint calls in changeset just inform ecto to transform the database errors into nice changeset errors
[18:59:22] nickjj: micmus, is there something i can do on the ecto side of things to tell it to try unique_constraint #1 first before it attempts to try unique_constraint #2?
[18:59:49] micmus: if anything you'd do that on the db side
[19:00:02] micmus: no idea how, though
[19:00:07] nickjj: because right now unique constraint #2 is never being ran, even though from my POV it's the more important / strict one
[19:03:40] wsieroci: has joined #elixir-lang
[19:04:52] mahmudov: has joined #elixir-lang
[19:06:14] __charly__: has joined #elixir-lang
[19:07:07] pera_: has joined #elixir-lang
[19:18:28] joshproehl: has joined #elixir-lang
[19:22:46] warmwaffles: has joined #elixir-lang
[19:24:36] icecreamcohen: has joined #elixir-lang
[19:25:25] Bounga: has joined #elixir-lang
[19:26:41] nickjj: micmus, seems like it might be semi-related to ecto in the end
[19:31:29] bingobingolotto: has joined #elixir-lang
[19:34:10] serafeim: hello, is there a way to somehow denote a "required" field in an phoenix form ?
[19:34:32] pera_: has joined #elixir-lang
[19:34:33] serafeim: or i'll just have to add a * by hand ?
[19:44:36] netrino: has joined #elixir-lang
[19:58:52] Sgeo__: has joined #elixir-lang
[20:01:24] josevalim: nageV: broadway has the same option. stages: 32
[20:07:28] tomku: has joined #elixir-lang
[20:08:51] gvaughn: has joined #elixir-lang
[20:16:52] Sgeo__: has joined #elixir-lang
[20:48:51] Sgeo_: has joined #elixir-lang
[20:55:22] Sgeo__: has joined #elixir-lang
[21:09:51] paxis: has joined #elixir-lang
[21:12:51] nikhilmore54: has joined #elixir-lang
[21:23:30] _barcode_: has joined #elixir-lang
[21:41:15] w09x: has joined #elixir-lang
[21:42:10] pera: has joined #elixir-lang
[21:42:10] w09x: How should I be thinking about an api controller that receives a phone number which then triggers an SMS using an external service like Twillio?
[21:42:19] w09x: No table is needed...
[21:43:04] w09x: Actually, this is a Phoenix related question, am I in the wrong channel?
[21:43:19] Nicd-: this is the only channel
[21:44:06] icecreamcohen: has joined #elixir-lang
[21:44:17] OliverMT: you've spent your question now though
[21:44:23] OliverMT: on asking if this is the right channel
[21:44:26] OliverMT: please hold for 10 minutes
[21:44:32] Nicd-: ACTION plays hold music
[21:44:50] OliverMT: ...i came in like a wreeeecking baaaaalll....
[21:45:12] OliverMT: this is also the comedic relief channel, when we made one, there was only me and Nicd- in there :(
[21:45:26] w09x: I'm here for the comedy only
[21:45:27] Nicd-: don't forget nox
[21:45:43] Nicd-: I should probably go to bed already
[21:45:46] OliverMT: josevalim lights up some jokes now and then too!
[21:45:53] OliverMT: same here, so if you want answers, ask quickly w09x !
[21:46:25] Nicd-: started a new project with Raxx and frontend is going to be a TypeScript/lit-html PWA
[21:46:27] Nicd-: so hipster
[21:47:27] Nicd-: sorry LitElement, it's so hipster I forgot the name
[21:47:57] icecreamcohen: has joined #elixir-lang
[21:58:37] Exuma: has joined #elixir-lang
[22:03:49] gvaughn_: has joined #elixir-lang
[22:08:03] icecreamcohen: has joined #elixir-lang
[22:14:44] blahdodo: has joined #elixir-lang
[22:27:46] blahdodo: has joined #elixir-lang
[22:49:40] thurloat: has joined #elixir-lang
[22:51:16] BitBot: has joined #elixir-lang
[22:56:34] jeffro_: has joined #elixir-lang
[23:12:26] __charly__: has joined #elixir-lang
[23:13:53] netrino: has joined #elixir-lang
[23:22:59] netrino: has joined #elixir-lang
[23:32:05] netrino: has joined #elixir-lang
[23:33:44] blahdodo: has joined #elixir-lang
[23:38:37] jeffro_: has joined #elixir-lang