#elixir-lang - 07 March 2019
« Back 1 day Forward 1 day »
[12:00:21] rbino: I've just discovered that iex prompt keeps being usable even if you're spamming the terminal with IO.puts, I never noticed it and that's neat
[12:02:52] rbino: yep, that you can type and stuff it doesn't get broken by the stuff that IO.puts is spitting out
[12:04:45] DanielI: if it keeps asking for more input (unfinished statement), i type "#iex:break" and hit return
[13:30:37] hypercore: would it be implemented as part of mix (i.e. running locally) or on the hex.pm backend?
[13:37:35] hypercore: (that's also why i was asking if mix add an "install" type function, so that i could run it in my CI file)
[13:38:02] dysfun: you can do what you like obviously, but i think it's perhaps better just during dev. particularly because you can ignore it easier that way
[14:24:09] shmink: Maybe off topic but it is an elixir project I’m working with. When it comes to tags on, lets say, news articles. Then if you search for news articles with the tags `"football"` and `"final"`. Should you return all the news articles that have EITHER `"football"` OR `"final"`. _Or_ news articles that have both the tags `"football"` AND `"final"`?
[14:25:34] dysfun: lol, i had a huge fight about that at one job. i arbitrarily chose one and they ended up wanting the other and felt strongly about it
[14:27:39] shmink: I'm tempted to return both the same way I think Google does it. The top results are the ones closest to what you searched for and after that it's anything related.
[14:28:41] zdsmith: Basically when you get more than a little down that rabbit whole you want to be thinking about a boosting-based system like elastic search
[14:30:01] shmink: dysfun: what was the one that "they ended up wanting the other and felt strongly about it"?
[14:31:13] dysfun: the idea was that the content was quite niche so if you added more than one word, you're indicating an intent to narrow down further
[14:31:18] nox: If there is any Italian who fancies Rust here, now that I'll do my first talk ever at RustLab in June.
[14:31:35] dysfun: but the content set wasn't big enough to support more than one term that way at the start, so they were quite upset
[14:32:25] dysfun: and i'd argued against deploying a proper search engine because the project was already well behind schedule when i was parachuted in, so i got quite a lot of anger directed at me
[14:33:57] shmink: dysfun: yeah I've been leaning towards the AND. approach for the same reason. If you just want "football" you would search for that. IF it's both of the words I would assume that they are looking for pieces of content that have both of them. Turns my work into a bigger task though :|
[14:37:48] shmink: yes the data is going to be relatively small. Sites that aren't going to be adding masses of content.
[14:40:21] samrose: hmm actually it looks like it is supported! https://github.com/phoenixframework/phoenix/blob/master/lib/phoenix/router.ex#L191
[14:48:45] dysfun: shmink: no. i found that i emailed it, but i did so as a pastebin link which is now expired :/
[14:52:03] shmink: I'm feeling lucky though. My bluetooth headphones have an aux jack. I decided to just plug my earphones into and now I have wireless wired earphones. My audio set up has evolved.
[14:52:44] samrose: ericmj: I guess I could understand why phoenix team did not make macros for HTTP CONNECT for instance.
[15:35:08] shmink: ericmj: I'm struggling to get it work for my needs. `function_exported?(Profiles.get, :member?, 1)
[15:36:47] shmink: I've also looked at `is_function` with no luck either. I'm surprised it's not actually `is_function?` instead as it returns a boolean.
[15:38:58] shmink: for `function_exported?` from the docs example it looks like it checks if there is ANY function with a certain arity. But the description mentions a function specifically.
[15:39:58] josevalim: Elixir is not assuming anything, there is literally a Profiles.get in your code
[15:44:21] shmink: I think using Profiles.__info__(:functions) will work for me and just check my `get` function is in there will do the trick.
[15:46:44] Gazler: Or I guess a better question is why did you end up where you did with `function_exported?(Profiles.get, :member?, 1)` - maybe there's a documentation PR in there somewhere.
[15:49:27] Gazler: https://github.com/elixir-lang/elixir/blob/master/lib/elixir/pages/Naming%20Conventions.md#is_-prefix-is_foo
[15:54:43] shmink: gazler: aaah now the docs make sense, I thought that atom `:member?` was simply an option that was passed as opposed to an actual function.
[15:55:21] shmink: I don't know how I didn't see it before but I'll do a PR with something perhaps more unique to avoid confusion?
[18:02:37] hypercore: gamache: as in is there a well-known package that people use for this, or do most just build it from scratch?
[18:03:18] gamache: Oh, do you mean like comments on a blog? I assumed you meant code comments, which I implement using trusty ol' #
[18:04:28] mercxry: Yeah Disqus will do it, then if you get pissed at it, you can implement comments by yourself later
[18:06:38] Nicd-: I use Disqus because I don't want to deal with spam. of course my comments are held hostage in their service, but it's a trade off
[18:06:54] hypercore: only problem is i want to be able to make topics/threads, and i can't with disqus
[18:15:25] thurloat: meh since i'm using a single supervisor to parent these genservers i'll just send(modulename, :msg)
[18:17:43] hypercore: Nicd-: hmmm honestly i'm not totally sure on this part, maybe one comment section per topic is enough
[18:24:54] ankhers: There is an ecto function that takes the output of Ecto.Adapters.SQL.query/4 and gives you a list of schemas. What is that function? I can't seem to find it right now.
[18:30:36] hypercore: guys, i'm trying to use an npm package in my app (1.3 w brunch), but the object isn't being defined)
[19:53:43] thurloat: I can't do a send() to a genserver, since it'll use handle_call instead of the receive handling it
[20:15:19] DavidAntaramian: thurloat: A receive block can technically be in any code; it causes the process running that code to check the message box based on the receive block you've given it (possibly preventing the process from moving forward at all).
[20:18:06] DavidAntaramian: Normally, you don't use a receive block in a GenServer, since a GenServer abstracts the process messaging behavior.
[20:19:53] thurloat: i'm finding it hard to think through where the receive block belongs such that it can be `send`'d from another part of the system
[20:21:03] thurloat: could you just supervise a module with a single function with a receive block in it? then send(modulename, :message) and have the receive block find it?
[20:21:26] thurloat: or does it need to be spawned dynamically? the whole picture just isn't super clear for me
[20:25:23] DavidAntaramian: There's a lot to unpack in that question alone, but it might help to step back and recognize that modules and processes are completely separate. A process is an isolated unit of execution that runs the instructions in modules.
[20:27:19] thurloat: DavidAntaramian i completely follow that, what I'm looking to accomplish is have a single process set up (supervised?) that has a function with a receive block in it. used in a similar pattern to Task.await
[20:28:45] DavidAntaramian: If you use a DynamicSupervisor and have the function that your process calls enter a receive block, yes, that should accomplish what you want
[20:29:49] thurloat: the plumbing behind System.do_cmd for example. https://github.com/elixir-lang/elixir/blob/master/lib/elixir/lib/system.ex#L775 is what confuses me, I'm not sure what the plumbing is behind it.
[20:29:50] DavidAntaramian: Although actually a DynamicSupervisor still requires an OTP-compliant process, so even that might be difficult to get what you want. Does it absolutely need to be supervised?
[20:31:42] thurloat: and with my limited experienc,e that usually means using a genserver or something supervised
[20:33:17] DavidAntaramian: do_cmd uses Erlang ports which rely on port drivers. In that case, outputs from the spawned executable are captured and turned into messages which are returned to the process that originally opened the port.
[20:45:26] thurloat: DavidAntaramian maybe what I'm doing can be accomplished without a receive block in the end. I have a genserver that I need to wait until it receives a message. The plan was to have the running genserver do a send() to whatever is running the receive block -- but maybe there's a different approach to blocking using the genserver instead?
[20:49:47] DavidAntaramian: thurloat: Your GenServer isn't going to be doing anything until it receives a message
[20:52:19] DavidAntaramian: I still think you could (and probably should) accomplish it without using an explicit receive block. It depends on the business logic that you are running. It's not common but still possible to enter a receive block inside of a `handle_*` callback.
[20:53:07] DavidAntaramian: You just want to be careful in a situation where the GenServer process messages _itself_
[20:58:58] thurloat: DavidAntaramian I think that last tidbit helped though, going to try and hack it in quick
[21:04:21] thurloat: thanks so much, got it all figured with an inline receive and self() passed to the genesrver on init
[21:21:10] ankhers: What are my options to find out which query/process/function is holding a connection for more than 15 seconds? I'm just getting crash reports, but nothing is really sticking out.
[21:30:30] ankhers: Okay, is there an option I can pass Repo.all to allow owning a connection for longer than 15s?
[21:35:17] ankhers: I also don't understand why this process is holding onto the connection for so long. It is complaining on a simple query that should only return MAYBE a dozen records, simple query too.
[21:41:18] ankhers: Postgrex.Protocol (#PID<0.441.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.443.0> timed out because it owned the connection for longer than 15000ms
[21:51:56] ankhers: If it makes a difference, I am in a couple nested Enum.each. But I don't really think that would matter. No streams, all done with Repo.all.