« Back to channel list

#elixir-lang - 20 May 2019

« Back 1 day Forward 1 day »
[00:00:34] atk: has joined #elixir-lang
[00:07:53] weird_error: has joined #elixir-lang
[00:11:37] miwa: has joined #elixir-lang
[00:11:41] Guest42: has joined #elixir-lang
[00:14:12] craigp: has joined #elixir-lang
[00:19:18] weird_error: has joined #elixir-lang
[00:29:43] FatalNIX: has joined #elixir-lang
[00:32:08] Adkron: has joined #elixir-lang
[00:38:16] weird_error: has joined #elixir-lang
[00:52:04] JeramyRR: has joined #elixir-lang
[00:54:55] orbyt_: has joined #elixir-lang
[01:07:32] orbyt_: has joined #elixir-lang
[01:40:49] tomterl: has joined #elixir-lang
[01:43:53] LnL: has joined #elixir-lang
[02:15:02] harfangk: has joined #elixir-lang
[02:16:11] craigp: has joined #elixir-lang
[02:26:43] Guest42: has joined #elixir-lang
[02:33:24] gvaughn_: has joined #elixir-lang
[02:40:11] Adkron: has joined #elixir-lang
[02:48:00] infowolfe: has joined #elixir-lang
[02:48:00] infowolfe: has joined #elixir-lang
[02:56:52] infowolfe: has joined #elixir-lang
[03:07:07] mahmudov: has joined #elixir-lang
[03:32:59] infowolfe: has joined #elixir-lang
[03:32:59] infowolfe: has joined #elixir-lang
[03:43:33] orbyt_: has joined #elixir-lang
[03:45:30] Adkron: has joined #elixir-lang
[04:36:39] gvaughn: has joined #elixir-lang
[04:39:33] kyrylo: has joined #elixir-lang
[05:10:03] FancyEagle: has joined #elixir-lang
[05:14:27] mbuf: has joined #elixir-lang
[05:15:51] jimmyrcom: has joined #elixir-lang
[05:34:11] voltone: has joined #elixir-lang
[05:48:08] oneark: has joined #elixir-lang
[05:49:34] voltone: has joined #elixir-lang
[05:52:54] gvaughn: has joined #elixir-lang
[05:53:29] Adkron: has joined #elixir-lang
[06:03:32] kdisneur: has joined #elixir-lang
[06:03:41] __charly__: has joined #elixir-lang
[06:32:55] netrino: has joined #elixir-lang
[06:46:27] voltone: has joined #elixir-lang
[06:47:22] FMJz__: has joined #elixir-lang
[06:47:27] avdi: has joined #elixir-lang
[06:47:27] CornishPasty: has joined #elixir-lang
[06:47:28] bytesighs: has joined #elixir-lang
[06:47:28] fishcakez: has joined #elixir-lang
[06:47:30] guan: has joined #elixir-lang
[06:47:30] fertapric: has joined #elixir-lang
[06:47:31] reachfh: has joined #elixir-lang
[06:47:34] zeeshanlakhani: has joined #elixir-lang
[06:47:36] chazlever: has joined #elixir-lang
[06:47:41] RJ2: has joined #elixir-lang
[06:47:41] uranoss: has joined #elixir-lang
[06:47:44] burbas: has joined #elixir-lang
[06:47:45] termos: has joined #elixir-lang
[06:47:49] Brend: has joined #elixir-lang
[06:47:53] whatyouhide: has joined #elixir-lang
[06:47:54] tobias: has joined #elixir-lang
[06:47:56] wizonesolutions_: has joined #elixir-lang
[06:48:02] gmcintire: has joined #elixir-lang
[06:48:02] b-m-f: has joined #elixir-lang
[06:48:02] ericentin: has joined #elixir-lang
[06:48:03] Nicd-: has joined #elixir-lang
[06:48:05] jlpeters: has joined #elixir-lang
[06:48:05] bcavileer: has joined #elixir-lang
[06:48:05] joedevivo: has joined #elixir-lang
[06:48:06] chops: has joined #elixir-lang
[06:48:07] smeevil: has joined #elixir-lang
[06:48:10] m0lok: has joined #elixir-lang
[06:48:10] Liothen: has joined #elixir-lang
[06:48:11] gonz_: has joined #elixir-lang
[06:48:12] HashNuke: has joined #elixir-lang
[06:48:12] hahuang65: has joined #elixir-lang
[06:48:12] JSharp: has joined #elixir-lang
[06:48:13] dignifiedquire: has joined #elixir-lang
[06:48:15] jeregrine: has joined #elixir-lang
[06:48:16] affinespaces: has joined #elixir-lang
[06:48:17] masteinhauser: has joined #elixir-lang
[06:48:17] jetpack_joe: has joined #elixir-lang
[06:48:22] Brenntron_: has joined #elixir-lang
[06:48:22] jhill: has joined #elixir-lang
[06:48:23] manveru: has joined #elixir-lang
[06:48:23] davisp: has joined #elixir-lang
[06:48:25] gen_ale_drinker: has joined #elixir-lang
[06:48:25] zpconn__________: has joined #elixir-lang
[06:48:26] danmcclain_: has joined #elixir-lang
[06:48:29] TechDragon: has joined #elixir-lang
[06:48:29] micmus: has joined #elixir-lang
[06:48:29] benwilson512: has joined #elixir-lang
[06:48:29] ahills: has joined #elixir-lang
[06:48:33] cmeiklejohn: has joined #elixir-lang
[06:48:34] alunduil: has joined #elixir-lang
[06:48:39] bbielsa___: has joined #elixir-lang
[06:48:43] teadrop____: has joined #elixir-lang
[06:50:13] Guest42: has joined #elixir-lang
[06:51:50] zigpaw: has joined #elixir-lang
[06:58:27] blahdodo: has joined #elixir-lang
[07:06:40] DeadTrickster: has joined #elixir-lang
[07:06:48] inoas: has joined #elixir-lang
[07:13:01] nikhilmore54: has joined #elixir-lang
[07:23:26] kyrylo: has joined #elixir-lang
[07:34:57] fastfresh: has joined #elixir-lang
[07:41:58] PragTob: has joined #elixir-lang
[07:42:31] gvaughn: has joined #elixir-lang
[07:52:17] lexmag: has joined #elixir-lang
[07:55:23] Guest46690: has joined #elixir-lang
[08:01:10] nikhilmore54: has joined #elixir-lang
[08:01:55] Adkron: has joined #elixir-lang
[08:12:49] nikhilmore54: has joined #elixir-lang
[08:13:16] Guest42: has joined #elixir-lang
[08:21:50] nikhilmore54: has joined #elixir-lang
[08:29:41] nikhilmore54: has joined #elixir-lang
[08:43:20] jalbert: has joined #elixir-lang
[08:48:15] wonko7: has joined #elixir-lang
[08:59:03] harfangk: has joined #elixir-lang
[09:02:54] hypercore: has joined #elixir-lang
[09:06:14] lexmag: has joined #elixir-lang
[09:11:31] gvaughn: has joined #elixir-lang
[09:19:49] lexmag: has joined #elixir-lang
[09:20:27] snapet: has joined #elixir-lang
[09:27:49] voltone: has joined #elixir-lang
[09:31:53] serafeim: has joined #elixir-lang
[09:32:06] serafeim: good morning
[09:37:44] kdisneur: has joined #elixir-lang
[09:50:48] kyrylo: has joined #elixir-lang
[09:50:53] Gazler: has joined #elixir-lang
[09:55:59] lexmag: has joined #elixir-lang
[09:57:45] serafeim: i see from the docs that the plug Conn struct has a "private" attribute that "is reserver for library use": https://hexdocs.pm/plug/Plug.Conn.html#module-private-fields
[09:58:18] serafeim: is that a problem? can I use this for my controller ? I want to extract the :phoenix_action field from it: pry(27)> conn.private[:phoenix_action]
[09:58:53] serafeim: i want it in order to pass it to an authorization function from a plug
[09:59:00] serafeim: is there a better way ?
[10:05:39] dysfun: assigns ?
[10:07:56] dysfun: https://hexdocs.pm/plug/Plug.Conn.html#assign/3 ?
[10:09:08] hypercore: has joined #elixir-lang
[10:10:45] serafeim: yes i'm aware of assign i use it in other places i can't understand how it can be used to fullfill my requirement :)
[10:11:06] Adkron: has joined #elixir-lang
[10:11:08] dysfun: oh, i see whta you mean
[10:11:21] lexmag: has joined #elixir-lang
[10:11:28] dysfun: yes, you can do that
[10:11:53] dysfun: i mean, if you need something that is already in private
[10:12:02] dysfun: but do you need to be poking around in that?
[10:16:27] serafeim: dysfun well I want to create a plug that will retrieve the current method (:index, :show, :new, :create etc) and authorize (or not) depending on that
[10:16:48] serafeim: and i was only able to find that on conn.private[:phoenix_action]
[10:17:29] serafeim: can i retrieve this somehow without messing with private ?
[10:18:53] serafeim: also i'd like to ask, is it possible to match on multiple keywords on a function ? i.e I have a def foo(:index) and def foo(:create) ... I want both of these to do the same. i.e can I do something like def foo(:index OR :create) do ?
[10:22:48] serafeim: of course a possible solution would be to do something like def foo(:index), do: foo2_index_or_create() and def foo(:create), do: foo2_index_or_create() ... and move the common functionality to the foo2_index_or_create() function. but this is not ideal for me
[10:29:43] dysfun: def foo(x) where x == :index or x == :create
[10:30:02] dysfun: i don't know where phoenix stores its routing information, i haven't needed to play with it
[10:34:03] serafeim: dysfun i've forgotten about guards :)
[10:34:22] dysfun: guards are great
[10:34:24] serafeim: dysfun no problem i'll then use the con.private field as it seems to be working fine
[10:34:32] dysfun: rather specify too many requirements than too few
[10:34:56] dysfun: ("be assertive)
[10:39:11] griffinbyatt: has joined #elixir-lang
[10:49:58] josevalim: serafeim: there is a Phoenix.Controller.action_name
[10:50:17] josevalim: in Phoenix controllers, you can do thiss:
[10:50:26] josevalim: `plug :foo when action_name in [:index, :show]`
[10:52:10] serafeim: josevalim thank you. so i'll have multiple plugs depending on the action_name; yes that can also work
[10:52:39] serafeim: do you feel that using conn.private[:phoenix_action] will be problematic ?
[10:53:05] dysfun: it will be if the implementation changes
[10:55:55] gvaughn: has joined #elixir-lang
[10:57:28] serafeim: i'll refactor it to use the action_name guard as jose proposed thanks
[11:15:24] kyrylo: has joined #elixir-lang
[11:30:57] wonko7: has joined #elixir-lang
[11:31:51] craigp: has joined #elixir-lang
[11:33:28] kdisneur: has joined #elixir-lang
[11:49:27] mdbm: has joined #elixir-lang
[11:53:53] voltone: has joined #elixir-lang
[11:57:29] mdbm_: has joined #elixir-lang
[12:11:00] mdbm: has joined #elixir-lang
[12:13:19] lauromoura_: has joined #elixir-lang
[12:14:21] hypercore: has joined #elixir-lang
[12:18:04] weird_error: has joined #elixir-lang
[12:20:01] Adkron: has joined #elixir-lang
[12:24:58] Gika: has joined #elixir-lang
[12:27:32] wonko7: has joined #elixir-lang
[12:37:21] gvaughn: has joined #elixir-lang
[12:42:17] lexmag: has joined #elixir-lang
[12:51:59] gde33: has joined #elixir-lang
[12:53:42] lexmag: has joined #elixir-lang
[12:57:36] tnez: has joined #elixir-lang
[13:10:12] fastfresh: has joined #elixir-lang
[13:11:20] status402: has joined #elixir-lang
[13:17:07] knack: has joined #elixir-lang
[13:19:37] serafeim: is there a quick way to output a string containining newlines to <br />s in an eex template ?
[13:20:30] serafeim: i.e i've got a\nb\nc and i want to output a<br />b<br />c
[13:21:35] serafeim: i guess i can replace \n with <br /> and mark it as safe, however i don't want to allow any other html elems (only brs)
[13:25:10] lexmag: has joined #elixir-lang
[13:30:28] Adkron: has joined #elixir-lang
[13:31:13] gvaughn: has joined #elixir-lang
[13:36:45] Guest42: has joined #elixir-lang
[13:37:05] dysfun: well you'll have to escape those then
[13:37:45] voltone: has joined #elixir-lang
[13:38:19] elixir-lang951: has joined #elixir-lang
[13:39:38] serafeim: is there a standard way ?
[13:40:01] nikhilmore54: has joined #elixir-lang
[13:40:38] dysfun: escaping the html directly, *then* replacing newlines with <br />, *then* marking it safe?
[13:41:03] micmus: serafeim: is this what you're looking for? https://hexdocs.pm/phoenix_html/Phoenix.HTML.Format.html#text_to_html/2
[13:41:42] dysfun: :insert_brs - hadn't noticed that before
[13:42:08] serafeim: micmus yes! that's what i needed thanks
[14:41:37] kdisneur: has joined #elixir-lang
[14:46:48] _barcode_: has joined #elixir-lang
[14:53:54] lanodan: has joined #elixir-lang
[15:00:53] voltone: has joined #elixir-lang
[15:03:48] dimitarvp: has joined #elixir-lang
[15:16:16] nickjj: when it comes to best practices, if you have a route where you expect an ID to be present and there's only 1 id being passed, do you use :id or :foo_id where foo is the schema name?
[15:19:02] kdisneur: has joined #elixir-lang
[15:22:57] nikhilmore54: has joined #elixir-lang
[15:25:49] aalmazan: has joined #elixir-lang
[15:26:44] nikhilmore54: has joined #elixir-lang
[15:38:18] Saukk: has joined #elixir-lang
[15:39:25] Adkron: has joined #elixir-lang
[15:41:32] icecreamcohen: has joined #elixir-lang
[15:49:32] wsieroci: has joined #elixir-lang
[16:08:13] wonko7: has joined #elixir-lang
[16:09:35] josevalim: The default is :id but a good argument could be made for foo_id
[16:14:55] warmwaffles: has joined #elixir-lang
[16:19:23] Adkron: has joined #elixir-lang
[16:34:21] dsimon: has joined #elixir-lang
[16:37:27] dsimon: hey all, i was wondering about some of the behavior of Streams, specifically about when i can rely on reading a stream to be side-effect-free
[16:37:37] dsimon: e.g. check out this Gist: https://gist.github.com/robmckinnon/7d1a74e979c15e78a812913673f7f8fd#file-elixir_stream-sh
[16:38:22] dsimon: using Enum.at(0) to read from a Stream based on a simple list or from File.stream! seems to have no side effects
[16:39:02] dsimon: but reading from a stream based on IO.stream(:stdio) does seem to permanently advance the "stream source"
[16:39:58] dsimon: I don't see much documentation about this except a warning in a couple spots that "an IO stream has side effects and every time you go over the stream you may get different results"
[16:40:29] dsimon: but can i rely on this always happening (or not happening) in the same circumstances?
[16:40:54] icecreamcohen: has joined #elixir-lang
[16:41:09] dsimon: or should i always use something like https://github.com/tallakt/stream_split just to be safe, if i want to be able to read from a stream and rely on subsequent reads of the same stream returning the same data?
[16:48:59] jnoon2: has joined #elixir-lang
[16:51:19] lauromoura_: has joined #elixir-lang
[17:03:14] BitBot: has joined #elixir-lang
[17:09:49] PragTob: has joined #elixir-lang
[17:10:04] nickjj: josevalim, do you think in phoenix 2.0+ you will rethink making schema_id the new default?
[17:20:31] nickjj: also when you say default, do you mean the generated code, or is there some functionality that works with :id without you having to pass in an argument to some function (i don't know which one off hand)?
[17:33:36] asabil: has joined #elixir-lang
[17:39:26] starbelly: Hmm, trying to understand why an UUID isn't casted in an embedded schema... that is to say, I can pass any string in for the binary id field and the changeset is always valid
[17:40:04] starbelly: of course, I can just validate the field myself, but want to be sure something is not being missed overall
[17:42:22] wsieroci: has joined #elixir-lang
[17:47:17] lexmag: has joined #elixir-lang
[17:49:02] starbelly: Ahh n/m I see what the fix is... must be `belongs_to(:foo, Foo, type: Ecto.UUID)` vs `field(:foo_id, type: :binary_id)`
[17:51:03] josevalim: nickjj: unlikely
[17:51:26] josevalim: I don’t like using 2.0 as an excuse to break APIs
[17:51:40] josevalim: Such a change would make migrating very hard
[17:52:25] nickjj: josevalim, realistically what type of migration process are we talking about? is it all user land code?
[17:52:37] nickjj: going into your router.ex, replacing id with schema_id and adjusting all controller params for that too?
[17:53:33] nickjj: but on the phoenix side of things, there's nothing that would have worked with :id but wouldn't have worked with :schema_id?
[17:54:00] nickjj: aka. on a new project now, argument can be made for schema_id without making things "worse" from a phoenix usability standpoint
[17:54:42] josevalim: Yes, there could be an option that flips the router
[17:54:54] josevalim: But it means you can’t mix old and new
[17:55:16] josevalim: The new generators would be broken for old apps
[17:55:25] josevalim: Maybe there are other consequences
[17:55:56] josevalim: It doesn’t seem to be important enough to be worth it
[17:57:54] pera: has joined #elixir-lang
[18:02:55] lauromoura__: has joined #elixir-lang
[18:06:08] mahmudov: has joined #elixir-lang
[18:09:15] Saukk: has joined #elixir-lang
[18:19:56] Gika: has joined #elixir-lang
[18:28:07] Adkron: has joined #elixir-lang
[18:31:41] netrino: has joined #elixir-lang
[18:39:50] nickjj: does anyone want to help me take a shot at setting up a form that needs to validate things from 2 different schemas and also deals with a transaction? i've been able to hack together a bunch of other things but i can't find a single example of what i'm trying to do online, and i don't know enough about complex phoenix/ecto relations to pull this off alone
[18:40:30] nickjj: this isn't for a paid gig (it's a side project, which i plan to open source) but it might take like 30 minutes for someone experienced to come up with a solution, i'm actually willing to pay someone to help if need be
[18:41:08] nickjj: i wrote up a workflow of what i'm trying to do at https://gist.github.com/nickjj/e31a467f863374228be212dc0475755c
[18:50:08] josevalim: perhaps have a schema meant to model the form and then internally you convert it to the proper schemas?
[18:50:36] josevalim: nickjj: there is an eaxmple here: http://blog.plataformatec.com.br/2016/05/ectos-insert_all-and-schemaless-queries/
[18:52:14] starbelly: I posed this question on erlanger slack... it's dead there right now... Anyone have resources on building a register based VM ala the BEAM in C?
[18:56:30] josevalim: maybe the beam wisdows/internals website?
[18:56:42] josevalim: http://beam-wisdoms.clau.se/en/latest/
[18:58:54] starbelly: josevalim: I do have that book marked, but I suppose the angle I'm coming from... I've never even built a VM, so I suppose I'm looking for some thing of a tutorial in that regard.
[18:59:29] starbelly: that and the beambook ofc... and I could always just rip apart the BEAM... but wanted to try a different approach then my normal M.O.
[19:02:02] starbelly: Hmm to note the goal is build a simple VM that only does a few things the BEAM is capable of and by no means do a full implementation. This is in order to gain a better understanding of VMs and the BEAM, so then I can move on to making more contributions in that area and moving a stepping stone for learning project #2. Implement my own erlang :)
[19:02:53] nickjj: josevalim, thanks. the schemas are mappers seems interesting but there's still a lot of unknowns, i'll see what i can do tho
[19:03:09] mahmudov: http://beam-wisdoms.clau.se/en/latest/ where can i find details of latest news?
[19:16:40] Gika: has joined #elixir-lang
[19:32:36] micmus: starbelly: I think this is a decent resource http://www.craftinginterpreters.com/ - it builds a stack-based VM instead of a register-based one, but the differences between them aren't that huge and stack-based VMs are simpler (you don't need the whole register allocator shebang), so it might be a better learning tool
[19:32:44] squall: has joined #elixir-lang
[19:33:07] blahdodo: has joined #elixir-lang
[19:36:52] lauromoura_: has joined #elixir-lang
[19:37:17] starbelly: micmus: Awesome.
[19:41:23] netrino_: has joined #elixir-lang
[19:51:35] squalloster: has joined #elixir-lang
[20:01:44] asabil: has joined #elixir-lang
[20:04:00] PragTob: has joined #elixir-lang
[20:08:49] mahtob: has joined #elixir-lang
[20:11:53] mahtox: has joined #elixir-lang
[20:20:50] lauromoura_: has joined #elixir-lang
[20:21:39] Gika: has joined #elixir-lang
[20:29:21] lauromoura_: has joined #elixir-lang
[20:36:16] Adkron: has joined #elixir-lang
[20:38:33] asabil: has joined #elixir-lang
[20:58:13] mahmudov: has joined #elixir-lang
[21:01:44] gvaughn: has joined #elixir-lang
[21:09:40] ur5us: has joined #elixir-lang
[21:22:17] Gika: has joined #elixir-lang
[21:23:40] lpil: TIL about beam-wisdoms. This is really neat!
[22:02:30] Soni: has joined #elixir-lang
[22:09:30] evax: has joined #elixir-lang
[22:19:18] __charly__: has joined #elixir-lang
[22:26:46] m1dnight_: has joined #elixir-lang
[22:43:18] ur5us_: has joined #elixir-lang
[22:45:05] Adkron: has joined #elixir-lang
[22:55:06] asabil: has joined #elixir-lang
[23:00:30] icecreamcohen: has joined #elixir-lang
[23:22:41] Guest42: has joined #elixir-lang
[23:25:19] jnoon2: has joined #elixir-lang
[23:26:04] Adkron: has joined #elixir-lang
[23:32:42] weird_error: has joined #elixir-lang
[23:36:29] blahdodo: has joined #elixir-lang
[23:42:15] Guest42: has joined #elixir-lang
[23:42:19] craigp: has joined #elixir-lang