<     May 2017     >
Su Mo Tu We Th Fr Sa  
    1  2  3  4  5  6  
 7  8  9 10 11 12 13  
14 15 16 17 18 19 20  
21 22 23 24 25 26 27  
28 29 30 31
00:02 justinmcp joined
00:05 isubasti joined
00:12 Vooch joined
00:13 jleon joined
00:15 northfurr joined
00:15 Vooch joined
00:19 mika__ joined
00:23 northfurr joined
00:28 sevenseacat joined
00:32 rozap joined
00:38 northfurr joined
00:42 arquebus joined
00:42 __charly__ joined
00:44 cschneid_ joined
00:45 cschnei__ joined
00:45 refriedchicken joined
00:57 cschneid_ joined
01:03 ur5us joined
01:04 markw_ joined
01:06 justelex_ joined
01:06 srxa joined
01:08 jleon joined
01:11 nighty-- joined
01:14 pbj joined
01:15 jhack joined
01:18 sfbw joined
01:20 refriedchicken66 joined
01:25 <cmk_zzz> are there any built-in way to transform data from a phoenix form? Things like trimming incoming string values, or format specific fields in a certain way?
01:26 <cmk_zzz> I'm imagining something like changeset |> transform([:name], fn x -> String.trim x
01:31 northfurr joined
01:34 pufuddled1 joined
01:34 <pufuddled1> Hello.
01:35 <pufuddled1> I have a running phoenix application. What is the best way to broadcast to a channel from the command line?
01:37 tomterl_ joined
01:38 <pufuddled1> If I start the server with `iex -S mix phoenix.server`, I can use MyApp.Endpoint.broadcast from REPL. Clearly, executing `mix run broadcast_something.exs` from the command line is not working.
01:47 jschneck joined
01:54 ur5us joined
01:54 jschneck joined
01:54 lehoff joined
01:55 mspo joined
01:55 <jschneck> is there any way to access information about a caller other than __CALLER__. I am trying to figure out how to get at the module or otp_app that a pid was spawned from
01:56 <jschneck> but I don't want to "macro"-tize my API just so I can get __CALLER__
01:56 Tallys__ joined
01:57 mika__ joined
01:58 refriedchicken66 joined
02:02 jleon joined
02:03 definiv joined
02:06 mika__ joined
02:07 kronicdeth joined
02:07 <kronicdeth> Is there an example of how to setup the `foreign_key_constraint` for the schema that has the has_many, so that `delete` foreign key constraint key is properly transformed?
02:10 <kronicdeth> found no_assoc_constraint. It's what I wanted
02:13 myronmarston joined
02:18 <pufuddled1> The following is working to broadcast from the command line, but it leaves the REPL open after running the script. Is there are better way of doing this? `iex --sname "${BROADCAST_NODE}" --remsh "${PHOENIX_NODE}" -S mix run broadcast_something.exs`
02:39 sfbw_ joined
02:42 myronmarston joined
02:42 <pufuddled1> Where do I put code to run when the phoenix server is terminated?
02:45 northfurr joined
02:53 fmccann joined
02:58 ssswitch joined
02:58 nhooyr joined
03:01 myronmarston joined
03:03 hq1 joined
03:03 hq1 joined
03:08 <asonge> pufuddled1: that's not really a good thing to try to do.
03:08 <asonge> pufuddled1: you can wire stuff up to do stuff when a node is being shut down, but there's only a few seconds before timeouts start firing and things get brought down more...hard.
03:08 mika__ joined
03:08 <asonge> (and there's always the possibility of hard crashes you have to code for anyway)
03:09 <asonge> and iex leaves it open because it's a remote shell into the system
03:09 <asonge> you're just running a startup command
03:11 nighty-- joined
03:12 WhiskyRyan joined
03:14 hakunin joined
03:19 griffinbyatt joined
03:36 myronmarston joined
03:40 northfurr joined
03:41 rozap joined
03:45 __charly__ joined
04:01 justelex_ joined
04:09 bike-rider joined
04:09 __charly__ joined
04:10 bike-rider left
04:18 myronmarston joined
04:33 m00dy joined
04:35 refriedchicken66 joined
04:40 kansi joined
04:42 elixir-lang518 joined
04:42 samof76 joined
04:45 jleon joined
04:47 <kansi> hi, am trying to understand elixir flow, but I can't seem to figure out how to create a custom enumerable for my implementation ?
04:48 <kansi> for eg. this article http://teamon.eu/2016/tuning-elixir-genstage-flow-pipeline-processing/ start its flow with a `select` but no detail on how to implement the select has been discussed
04:49 jhack_ joined
04:50 <kansi> can anyone suggest how to go about this ?
04:51 jhack__ joined
04:55 jmcintosh joined
04:58 jeffweiss joined
04:59 treaki joined
05:05 OtherAllan joined
05:06 Vooch joined
05:06 <pufuddled1> I want to broadcast a shutdown message to connected clients right before phoenix terminates.
05:07 <pufuddled1> Is this an incredibly bad idea?
05:07 cemilowski joined
05:11 elgenie joined
05:13 craigp joined
05:15 notdaniel joined
05:18 dec0n joined
05:21 griffinbyatt joined
05:22 manukall joined
05:32 hakunin joined
05:32 imack joined
05:34 <Ioyrie> pufuddled1: if you mean, a message saying "this message is now shutting down" string message, it's definitely fine. Otherwise, you'd have to assume you can confidently shutdown remote clients with an actual shutdown command payload.
05:35 <Ioyrie> which I think is fine too.. but this is phoenix, right? so err, I don't think that would be okay at all.
05:35 <OliverMT> cmk_zzz: only default thing in phoenix is the null scrubber, plug scrub
05:35 <pufuddled1> The goal is not to shut down remote clients, just to give them a heads up. I figure that maybe letting them know that the sever is going down is better than not. My question is, where should this logic live?
05:35 gvaughn joined
05:35 <OliverMT> pufuddled1: I suggest setting up a release, thehn you can use rpc command to send to the running instance
05:36 <OliverMT> thats how I run migrations
05:36 <OliverMT> simply make a service with the event hardcoded
05:37 <OliverMT> then simply bin/yourapp rpc MyService.send_warning
05:37 <OliverMT> as asonge says, you have terminate/1 in genservers etc that :init.stop will notify when you shut down the otp tree, but its not somewhere you can do long-running work
05:37 <OliverMT> like sending out a lot of broadcasts
05:38 <OliverMT> so notifying from bash BEFORE you shutdown node is probably better
05:38 <pufuddled1> Sending a notification before shutting down is definitely cleaner.
05:38 <cmk_zzz> OliverMT: thanks. It is easy to implement anyway so I'll just do that
05:39 <pufuddled1> It sounds like I should broadcast and then run `:init.stop()`.
05:40 <OliverMT> it sounds like you should have a release and handle this in bash
05:40 <OliverMT> :D
05:40 <OliverMT> bin/yourapp rpc MyService.send_warning && bin/yourapp stop
05:40 <OliverMT> :p
05:41 <OliverMT> there are very few reasons to not use a proper release in prod
05:41 <OliverMT> its a 1 hour effort to learn distillery
05:41 <OliverMT> 5min to set up something you copy paste from stackoverflow
05:41 <pufuddled1> Right, but the release RPC logic should be broadcast, :init.stop(), right?
05:41 <OliverMT> no, init.stop is what the stop script doeds
05:42 <OliverMT> I think thats what is sent out if you ctrl c out of an iex session
05:42 <OliverMT> but I am not sure
05:42 <OliverMT> I have no idea what happens when you ctrl c just plain mix phoenix.server
05:46 <OliverMT> also, make a module RpcService or something and stick to sending simple commands that you predefine
05:46 rkazak joined
05:46 <OliverMT> sorta like prod scripts
05:46 <OliverMT> thats my reccomendation
05:46 <OliverMT> asonge: all your facebook spam about handmaids tale made me and wifey start it yesterday, its pretty good dystopian stuff I'll say
05:46 <pufuddled1> Is there any reason why I should create MyService.graceful_shutdown that bundles the warning and stop call?
05:46 myronmarston joined
05:47 <OliverMT> it's bad form to stop the server in your own service imo
05:47 ZippoWeb2 joined
05:47 <OliverMT> when there is a stop script provided by distillery
05:47 <OliverMT> but sure, you *can* do that if you want to :)
05:47 <pufuddled1> Does distillery provide a callback for pre shutdown logic?
05:48 <OliverMT> I am still on exrm (sorta distillery 0.1)
05:48 <pufuddled1> In that case I can drop the callback there and the problem is solved.
05:48 <OliverMT> I dont think so, but just check the docs
05:48 <OliverMT> spinning up server and down server etc is a host system concern imo
05:48 <OliverMT> which is why I think just calling rpc from bash in the scripts is cleaner
05:48 <OliverMT> and more well defined
05:49 <OliverMT> hence my && example above :)
05:49 <pufuddled1> Sure, but the goal is literally to broadcast on server shutdown. The question is, what is the cleanest way to do this?
05:49 <pufuddled1> "I am shutting down now."
05:50 <OliverMT> what I just said
05:50 <OliverMT> make a rpcservice with a function that does all that
05:50 <OliverMT> call it from rpc from bash
05:50 <OliverMT> then run bin/yourapp stop
05:52 <pufuddled1> OK, so just broadcast and shutdown sequentially as separate tasks.
05:55 cemilowski joined
05:57 <OliverMT> correct :)
05:58 <Nicd-> good morning everyone!
05:59 cschneid_ joined
06:03 dec0n joined
06:04 definiv joined
06:05 sunaku joined
06:10 sfbw joined
06:17 <pufuddled1> Is RPC documented? I am having trouble finding the documentation although I may have missed something basic.
06:22 griffinbyatt joined
06:24 elgenie joined
06:27 <OliverMT> I actually dont see it in the docs
06:30 tuacker joined
06:30 gvaughn joined
06:38 synProgrammer joined
06:40 proteus-guy joined
06:43 guardianJ joined
06:43 cemilowski joined
06:48 jkreeftmeijer joined
06:50 tomaz_b joined
06:52 josevalim joined
06:54 samof76 joined
06:54 guardianJ joined
07:00 guardianJ joined
07:01 iamvery joined
07:03 <justinmcp> hey, using phoenix, cannot seem to have put_status affect the status code (it's always 200)
07:04 <justinmcp> any obvious things to check here, I am elixir + phoenix noob
07:04 <Nicd-> justinmcp: show how you are using it
07:04 <Nicd-> most likely you are ignoring the return value of it
07:04 <manukall> justinmcp: are you assigning the conn after that?
07:05 guardianJ joined
07:05 <Nicd-> manukall: I was first!
07:05 <Nicd-> :D
07:05 <manukall> damn :-)
07:05 <manukall> well, second winner is still not too bad ;-)
07:08 <justinmcp> thanks guys, plenty of noob to go around :)
07:08 <justinmcp> here is an example https://github.com/justinmcp/blake_test/blob/master/web/controllers/progress_controller.ex#L50
07:08 <Nicd-> you need to do conn = put_status(conn, 400)
07:09 <Nicd-> values in Elixir are immutable so you cannot implicitly change the conn
07:09 <Nicd-> so put_status returns a changed conn
07:09 <justinmcp> thanks, then the threading through case uses the rv in the next thread?
07:10 <justinmcp> each |>
07:10 <Nicd-> what do you mean by threading?
07:11 <justinmcp> sorry, nothing to do with "tasks", making use of the |> operator
07:11 sfbw joined
07:11 <Nicd-> oh, that's a pipe
07:11 <Nicd-> pipe takes the first value, sets it as the first argument of the next call, takes the result of that and sets it as the first argument of the next call and so on
07:12 <Nicd-> so lines 66-68 are how you'd typically write many subsequent calls to change conn
07:12 guardianJ joined
07:15 <justinmcp> Nicd-: thanks very for your help, I can fix this up now
07:16 <Nicd-> justinmcp: if you have any more issues, just ask here and we'll help :)
07:16 <Nicd-> welcome to the Elixir community
07:18 jschneck joined
07:19 gmcabrita joined
07:19 <justinmcp> thanks, I hope in turn I can be of help to others
07:23 mattyw joined
07:24 <Nicd-> good attitude!
07:25 <Nicd-> I'm sure you will :) for other community places, there's chat channels in Matrix and Discord and a forum at https://elixirforum.com/
07:26 vmoravec joined
07:26 griffinbyatt joined
07:28 ZippoWeb2 joined
07:29 m00dy joined
07:30 mark_66 joined
07:31 marr joined
07:34 asabil joined
07:35 PaReeOhNos joined
07:36 peterpp joined
07:39 jkreeftmeijer joined
07:41 <manukall> the slack community is pretty big and active, too
07:41 xdcfvgbh joined
07:43 <jschneck> Does anyone know how I can get the OTP app name from a pid or or module?
07:44 <jschneck> process_info seemed to lead to a dead end and the Macro env gets me at the module of the caller
07:45 <jschneck> My use case is that I have a GenServer that wants to segment work based off which otp app is requesting it
07:46 m00dy joined
07:49 InternetFriend joined
07:50 m00dy joined
07:50 <gazler> jschneck: :application.get_application(pid_or_module)
07:51 <jschneck> haha yeah I just saw this in a slack channel too
07:51 <gazler> Or Application.get_application(pid_or_module)
07:51 <jschneck> I like to cover all the mind meld
07:51 <jschneck> looks like I need to fire it up in a real tree instead of just on iex or in a test because I get :undefined
07:52 <gazler> Application.get_application(IEx.Config) works in iex
07:53 <jschneck> yeah so maybe having access to the module name is safer then the pid
07:53 <jschneck> I am trying to use the senders pid to id in a test
07:53 <jschneck> which I would assume should come from ExUnit or my own app
07:54 <jschneck> I wanted to use the pure pid instead of the module
07:54 <gazler> jschneck: Actually, looks like :application.get_application works with a pid, but Application.get_application only works on a module.
07:54 <gazler> So you can try this in iex: pid(0, 27, 0) |> :application.get_application()
07:55 <jschneck> in iex if you call just :application.get_application() it defaults to self()
07:55 <jschneck> which pulls back :undefined
07:55 <jschneck> same for tests
07:56 <micmus> Application.get_application won't be the fastest solution, though - it loops through all loaded applications to find where the module is coming from
07:57 <nyaray> justinmcp: "plenty of noob to go around" hahah :D
07:57 <micmus> jschneck: I think a process is considered to "belong" to an application only if it is part of it's supervision tree
07:58 ZippoWeb2 joined
07:59 PaReeOhNos joined
08:00 <jschneck> so expanding it all at compile time and using modules is probably fastest / safest
08:01 akeating joined
08:01 akeating joined
08:04 jkreeftmeijer joined
08:05 vigo joined
08:08 jkreeftmeijer joined
08:14 Guest67 joined
08:15 PaReeOhNos joined
08:16 asabil joined
08:17 tomfbiz joined
08:17 flaviodesousa joined
08:17 ZippoWeb2 joined
08:17 jkreeftmeijer joined
08:18 <tomfbiz> hello, I am having a syntax problem, trying to add a key to the params passed into my controller.
08:18 ur5us joined
08:19 <Nicd-> please gist your code :)
08:19 <tomfbiz> I tried "Map.put(map_params, :xx, 1)" but that gave a syntax error.
08:19 <tomfbiz> "EnhancedMap.Map.put/3 is undefined or private"
08:20 <tomfbiz> I'm stuck, thanks for any hints.
08:20 <cmk_zzz> tomfbiz: Is your module named Map? If so try Elixir.Map.put
08:21 <Nicd-> tomfbiz: gist the code where you are doing that
08:21 <Nicd-> the controller
08:22 <tomfbiz> I may see the error -- I tried Exilir.Map and I get this error -- "** (UndefinedFunctionError) function Exilir.Map.put/3 is undefined (module Exilir.Map is not available)"
08:23 jkreeftmeijer joined
08:23 <Nicd-> Elixir, not Exilir :)
08:23 permalac joined
08:23 <tomfbiz> Doh! thx
08:24 <jschneck> gazler sadness, since the application the macro is being expanded into is compiling that module, Application.get_application doesn't work at compile time
08:24 <Nicd-> it seems you have aliased or imported an EnhancedMap module?
08:24 <gazler> jschneck: Worst day ever.
08:24 <jschneck> worst
08:24 <Nicd-> it probably conflicts with Elixir's Map
08:24 pufuddled joined
08:24 <jschneck> sigh, I woke up at 3am to do this?
08:25 <jschneck> its too bad the compile time env doesn't give access to current app
08:28 samof76 joined
08:28 eddd joined
08:37 Ilyes512 joined
08:39 <Ilyes512> hey guys... is it possible to call multiple "Record.defrecord ..." based on a list? So I want to loop over it and create a Record.defrecord for every value
08:39 <nyaray> jschneck: so, are you going to turn it into a system test? I'm assuming you were trying to do it in a unit test
08:40 <jschneck> I was trying to do it in a unit test, but, I am finding it incredibly difficult to access otp_app name at compile time
08:41 asabil_ joined
08:41 m00dy joined
08:43 ariejan joined
08:45 pufuddled joined
08:48 meandi joined
08:48 gvaughn joined
08:49 inoas joined
08:51 m00dy joined
08:54 <nyaray> if it's a library you can't really know until runtime
08:57 <nyaray> noo, he left :(
08:59 lexmag joined
09:04 definiv joined
09:06 pufuddled joined
09:10 asabil joined
09:13 sfbw joined
09:16 colrack joined
09:28 griffinbyatt joined
09:28 pufuddled joined
09:35 Havvy joined
09:36 nd___ joined
09:48 akeating joined
09:49 pufuddled joined
09:50 InternetFriend joined
09:51 m00dy joined
09:51 m00dy joined
10:02 nickjj joined
10:06 Vooch joined
10:06 m00dy joined
10:06 cemilowski joined
10:11 pufuddled joined
10:14 m00dy joined
10:14 sfbw joined
10:14 ZippoWeb2 joined
10:18 mika__ joined
10:21 Ilyes512 joined
10:21 ur5us joined
10:27 inoas joined
10:29 griffinbyatt joined
10:32 pufuddled joined
10:32 samof76 joined
10:39 jhack joined
10:39 jhack joined
10:40 akeating joined
10:53 pufuddled joined
10:53 nhooyr joined
10:53 tuacker joined
10:58 m00dy joined
10:58 cevado joined
11:00 cschneid_ joined
11:02 jkreeftmeijer joined
11:02 Vooch joined
11:04 nighty-- joined
11:06 Ilyes512 joined
11:06 gvaughn joined
11:10 griffinbyatt joined
11:13 papachan joined
11:14 pufuddled joined
11:15 sfbw joined
11:26 srxa_ joined
11:28 mika__ joined
11:30 dimitarvp joined
11:31 pufuddled joined
11:42 samof76 joined
11:45 <m1dnight1> where does one typically store sensitive config information in elixir?
11:45 <m1dnight1> in the config/*.exs files, or in a seperate file excluded from vcs?
11:46 <m1dnight1> Im pondering where to put stuff like slack token, and slack bot owner nickname in my slackbot project
11:46 <Nicd-> m1dnight1: maybe config/prod.secret.exs for example
11:46 <Nicd-> then include that from prod.exs
11:46 <Nicd-> and gitignore
11:46 <m1dnight1> ah
11:46 <m1dnight1> that makes sense
11:46 <m1dnight1> thanks
11:46 <Nicd-> that's how the phoenix template does it at least
11:52 pufuddled joined
11:59 markw_ joined
12:01 m00dy joined
12:02 jerel joined
12:02 m00dy joined
12:03 m00dy joined
12:04 ZippoWeb2 joined
12:06 kronicdeth joined
12:06 fmcgeough joined
12:09 <Ilyes512> Any got experience working with (erlang) Records in elixir? https://elixirforum.com/t/cant-use-erlang-records-that-start-with-an-uppercased-letter/5020
12:11 akeating joined
12:13 pufuddled joined
12:16 sfbw joined
12:16 jadlr joined
12:21 elgenie joined
12:22 jkreeftmeijer joined
12:31 gvaughn joined
12:33 vmoravec joined
12:34 pufuddled joined
12:37 aeliton joined
12:37 akeating joined
12:42 sfbw joined
12:42 Vooch joined
12:44 kiltzman joined
12:47 dj_goku joined
12:47 dj_goku joined
12:52 akeating joined
12:52 m00dy joined
12:54 northfurr joined
12:55 pufuddled joined
12:58 m00dy joined
12:58 isubasti_ joined
12:59 s_kilk joined
12:59 mika__ joined
12:59 tomaz_b joined
13:01 griffinbyatt joined
13:04 ramortegui joined
13:05 m00dy joined
13:05 stephen_m joined
13:07 <benwilson512> alisdair: do you use ECS at all?
13:07 <* jer> does
13:07 <benwilson512> jer: sweet! do you cluster your elixir nodes?
13:08 <jer> some of the services do yes
13:08 <benwilson512> I'm a bit unclear on how to do the networking part of that, ECS doesn't have container level IPs like kubernetes pods do
13:08 <alisdair> no. tried but the ecs scheduler has issues in production
13:09 <benwilson512> you could bind elixir to the actual instance ports but that seems less than ideal
13:13 Ioyrie joined
13:13 <jer> benwilson512, we use a zookeeper to track what nodes are where, and to register new nodes. connect them up that way. also for the services i build, the deployment strategy is single elixir node per machine, so i've not had to worry about that
13:14 ssswitch joined
13:15 <benwilson512> yeah, I'm not planning on doing more than one elixir node per instance, so that should be fine. how do you name your nodes?
13:15 samof76 joined
13:16 acetoxy joined
13:17 pufuddled joined
13:18 definiv joined
13:19 isubasti_ joined
13:22 elgenie joined
13:22 srxa joined
13:23 cschneid_ joined
13:24 duane joined
13:25 dikaio joined
13:26 ZippoWeb2 joined
13:26 gvaughn joined
13:28 <junsuijin> Is it common practice to keep an accumulator at the end of your argument list?
13:29 al-maisan joined
13:29 <junsuijin> Parameter list
13:34 northfurr joined
13:35 akeating joined
13:38 pufuddled joined
13:39 <junsuijin> I ask because I just did some tail recursion practice from "Elixir in Action" and I put my accumulators as first parameter. As such I could use the pipeline operator. But it looks like the author always has them last, and moving onto higher-order functions in the book, it looks like Enum functions have the accumulator as the last parameter too.
13:40 isubasti_ joined
13:41 <benwilson512> junsuijin: yes, that's the convention
13:41 <junsuijin> benwilson512: Thanks!
13:41 ramortegui joined
13:46 Ilyes512 joined
13:47 maxbeizer joined
13:49 gvaughn joined
13:51 InternetFriend joined
13:51 r00tl3ss joined
13:52 r00tl3ss_ joined
13:55 akeating joined
13:56 PaReeOhNos joined
13:59 pufuddled joined
14:00 m00dy joined
14:00 isubasti_ joined
14:01 griffinbyatt joined
14:03 Ilyes512 joined
14:04 samof76 joined
14:05 akeating joined
14:06 gmcabrita joined
14:09 Gringill joined
14:09 InternetFriend joined
14:09 meh` joined
14:11 jschneck joined
14:12 m00dy joined
14:12 <Gringill> With respect to umbrella projects: if I have 2 apps that wanna use dogma is it ok to specify that dep in the top level mix.exs once? Or is it more correct to specify that dep in both apps.
14:14 jschneck joined
14:14 __charly__ joined
14:15 PaReeOhNos joined
14:16 jerel joined
14:16 kronicdeth joined
14:17 <jschneck> nyaray I saw your message from earlier, I think I am going to just require that the module is passed in as part of the call for now
14:17 northfurr joined
14:17 tuacker joined
14:18 <nyaray> jschneck: seems legit
14:18 <jschneck> it might make the api really noisy, but, its a start
14:19 <nyaray> unless you need to be able to vary it, you could make it a module attribute that gets its value by reading a config value
14:19 Vooch joined
14:20 pufuddled joined
14:21 fernandomm joined
14:21 isubasti_ joined
14:21 m00dy joined
14:23 papachan joined
14:26 <nyaray> that way you could have it be one thing when building for tests and another for other envs
14:28 <nyaray> s/other/actual
14:31 ZippoWeb2 joined
14:32 cemilowski joined
14:34 d10n-work joined
14:41 rkazak joined
14:41 elgenie joined
14:41 northfurr joined
14:42 isubasti_ joined
14:42 pufuddled joined
14:42 r00tl3ss joined
14:51 <fishcakez> jschneck: :application.get_application uses group_leaders, so you could segment by group_leader?
14:54 <fishcakez> the lookup for the group leader is by ets key so should be plenty fast enough
14:54 <fishcakez> (key lookup on set with read concurrency, true is fast)
14:55 m00dy joined
14:55 <fishcakez> or not https://github.com/erlang/otp/blob/maint/lib/kernel/src/application_controller.erl#L326 boo
14:56 <fishcakez> but likely group_leader would be sufficient, unless you need special handling per app
14:57 m00dy joined
14:58 akeating joined
14:58 m00dy joined
14:58 m00dy joined
14:59 m00dy joined
15:00 <fishcakez> jschneck: you could use Application.get_env(:logger, :compile_time_application) ^^
15:00 <fishcakez> at compile time...
15:02 kronicdeth joined
15:02 isubasti_ joined
15:02 griffinbyatt joined
15:03 pufuddled joined
15:03 drincruz joined
15:04 hakunin joined
15:04 cschneid_ joined
15:10 <mhutter> Hey, I need some tips about code formatting.... how would I format a function definition with large pattern matches? eg. like this: https://gist.github.com/mhutter/f265280b27385d9ba2831aa377f06cf6
15:10 myronmarston joined
15:10 JEG2 joined
15:11 <mhutter> or even better, is there a way of getting rid of such ugly def's?
15:11 <micmus> mhutter: I would probably grab the whole attributes map and pass down to another function that would unpack this. But yeah, complex matches are quite verbose :(
15:12 <mhutter> All examples I find on Goolge only match one or two values :D
15:12 cdg joined
15:13 <gazler> I too would grab the whole match and pass it on. I'd probably do something like Accounts.register_user(Map.take(params, ["email", "password", "password_confirmation"]))
15:14 <gazler> Or just Accounts.register_user(params) and handle it there.
15:14 <nyaray> TIL: Map.take/2 exists
15:14 <nyaray> that's really neat! :)
15:15 <gazler> Your current example will blow up (500) if the params don't match. Normally in this sort of situation you want a validation error on the empty fields.
15:15 <mhutter> mhm I see
15:15 <gazler> nyaray: Map.split is useful too.
15:15 <gazler> mhutter: That may be desirable in your application though. I don't know. :)
15:16 <nyaray> gazler: I can see how :)
15:16 <mhutter> gazler: No I actually do check the fields later on :D
15:17 <mhutter> Cool, thanks for the inputs!
15:18 <nyaray> mhutter: why not check at the edge, when the data enters the system?
15:19 <gazler> nyaray: That's what they were doing in their pattern matching example.
15:20 <mhutter> Yeah, this is about as early as it gets
15:20 <gazler> That said, if the input is coming from a page with a form, the fields should be present anyway.
15:21 <gazler> If it is coming from somewhere else (curl or whatever) then it is possible for the field to be absent.
15:23 <nyaray> gazler: hm, yeah.. But like you said it comes down to what the defined behaviour is
15:23 isubasti_ joined
15:23 icecreamcohen joined
15:24 <nyaray> Still, I'd rather have a 400 than a 500
15:24 icecreamcohen joined
15:24 pufuddled joined
15:24 <mhutter> a 422 Unprocessable Entity in this case :)
15:25 <gazler> The map is also nested. So if there is no data, or data.attributes key then you'll get a 500 anyway
15:25 <nyaray> Not sure... I mean, you didn't even get to processing it
15:25 Vooch joined
15:26 <gazler> I'd return a 422.
15:26 <mhutter> hmm... imho invalid data is something that has to be handled in an application and should not end in a 500
15:27 <mhutter> I usually only want 500s for stuff that really IS broken
15:27 <mhutter> As the saying goes: 400? You fucked up. 500? We fucked up.
15:28 <nyaray> mhutter: now that's some t-shirt shit right there
15:28 <mhutter> :D full disclaimer: I stole that from a talk I saw few weeks ago :P
15:29 <nyaray> Still good though :D
15:30 cevado joined
15:30 <mhutter> related: https://twitter.com/stevelosh/status/372740571749572610
15:31 bitmod joined
15:37 <nyaray> gazler: I realised that I completely derped up on the 422, btw.
15:37 <gazler> I wouldn't worry too much. You'e not taking a test or anything.
15:39 hakunin joined
15:40 hakunin joined
15:40 jschneck joined
15:44 squallstter joined
15:45 MotherFlojo joined
15:46 Grych joined
15:48 Grych2 joined
15:48 Ioyrie joined
15:50 wsieroci joined
15:53 kiltzman joined
15:55 <nox> gazler: He is though.
15:55 <nox> Though it's just a mock exam... For now.
15:57 amclain joined
15:58 <Guest67> Hello
15:58 <Guest67> Is there any way in phoenix to have websockets with this pattern
15:58 <Guest67> http://localhost:3000/api/[uuid]
15:58 <Guest67> Something like that
15:58 <Guest67> http://localhost:3000/api/368c1ce7-5b89-4beb-8e3f-1fcc6eec6506
15:58 <Guest67> Im using a JS api to upload files and it uses web sockets for realtime feed to the client while upload is going on
15:58 <Guest67> but JS client doesn’t match with Phoenix web sockets.
15:58 <Guest67> Any idea
15:58 <nyaray> nox: bah-dum-tshhhh
15:58 jschneck joined
15:59 <nox> nyaray: Keep your drums to your music exam next week pls.
15:59 <nyaray> yes, sir o>
15:59 myronmarston joined
16:02 lexmag_ joined
16:03 griffinbyatt joined
16:03 samof76 joined
16:05 kiltzman joined
16:05 ZippoWeb2 joined
16:05 kiltzman joined
16:06 aeliton joined
16:07 kiltzman joined
16:08 kiltzman joined
16:11 __charly__ joined
16:11 refriedchicken joined
16:11 jkreeftmeijer joined
16:12 bitmod joined
16:13 meandi_2 joined
16:13 Vooch joined
16:15 notdaniel joined
16:16 ikcerog joined
16:17 cevado joined
16:17 PaReeOhNos joined
16:17 kiltzman joined
16:19 elgenie joined
16:19 hbraun joined
16:20 akeating joined
16:21 elgenie_ joined
16:21 Vooch joined
16:22 mika__ joined
16:23 elgenie__ joined
16:26 rozap joined
16:27 elgenie joined
16:29 elgenie_ joined
16:31 PaReeOhNos joined
16:37 myronmarston joined
16:41 wsieroci joined
16:44 PaReeOhNos joined
16:46 josevalim_ joined
16:48 fmccann joined
16:48 imack joined
16:52 northfurr joined
16:59 nd___ joined
17:01 sunaku joined
17:02 bitmod joined
17:03 PaReeOhNos joined
17:03 Vooch_ joined
17:04 griffinbyatt joined
17:09 imack joined
17:11 jeffweiss joined
17:14 PaReeOhNos joined
17:15 msantos joined
17:17 Ilyes512 joined
17:17 rozap joined
17:18 DeadTrickster joined
17:19 kronicdeth joined
17:20 jkreeftmeijer joined
17:24 wsieroci_ joined
17:25 isorehalav joined
17:26 aeliton joined
17:27 definiv joined
17:28 sunaku joined
17:29 nahtnam joined
17:29 sfbw joined
17:33 justelex_ joined
17:33 kiltzman joined
17:36 kronicdeth joined
17:36 elgenie joined
17:37 akeating joined
17:38 elgenie_ joined
17:38 isubasti_ joined
17:38 strykerkkd joined
17:41 myronmarston joined
17:42 mika__ joined
17:42 wsieroci joined
17:44 gem joined
17:45 PaReeOhNos joined
17:45 kronicdeth joined
17:47 wsieroci_ joined
17:49 lexmag joined
17:51 jkreeftmeijer joined
17:57 cemilowski joined
17:57 akeating joined
18:03 PaReeOhNos joined
18:05 JuanMiguel joined
18:05 griffinbyatt joined
18:06 jkreeftmeijer joined
18:07 cemilowski joined
18:11 cemilowski joined
18:16 dimitarvp` joined
18:16 <dimitarvp`> arvp
18:24 ur5us joined
18:27 OtherAllan joined
18:27 mika__ joined
18:44 icanhazbroccoli joined
18:45 pratch joined
18:46 icanhazbroccoli joined
18:49 kronicdeth joined
18:57 myronmarston joined
18:58 sp4rrow joined
19:01 MotherFlojo joined
19:04 PaReeOhNos joined
19:06 griffinbyatt joined
19:07 rozap joined
19:17 jkreeftmeijer joined
19:18 girish joined
19:19 wsieroci joined
19:20 girish left
19:20 girish joined
19:21 the_voice- joined
19:21 tomaz_b joined
19:23 fernandomm joined
19:23 girishramnani joined
19:25 rozap joined
19:28 cemilowski1 joined
19:30 girishramnani joined
19:33 MotherFlojo joined
19:34 cemilowski joined
19:37 cemilowski joined
19:39 papachan joined
19:39 elgenie joined
19:43 cemilowski joined
19:43 Tallys__ joined
19:45 cevado joined
19:46 cemilowski joined
19:51 marr joined
19:51 fernandomm joined
19:54 isubasti_ joined
20:05 MononcQc joined
20:05 Ven joined
20:06 griffinbyatt joined
20:09 elgenie joined
20:10 myronmarston joined
20:10 cdg joined
20:15 dimitarvp` joined
20:20 sp4rrow joined
20:22 dimitarvp joined
20:28 hahuang65 joined
20:33 dimitarvp joined
20:38 srxa_ joined
20:43 dimitarvp joined
20:50 nipicasa joined
20:51 dimitarvp joined
20:57 dimitarvp` joined
21:00 dimitarvp_ joined
21:00 Ven joined
21:04 hakunin joined
21:05 MotherFlojo joined
21:07 griffinbyatt joined
21:11 rozap joined
21:14 PaReeOhNos joined
21:15 PaReeOhNos joined
21:16 PaReeOhNos joined
21:17 PaReeOhNos joined
21:19 jkreeftmeijer joined
21:20 ur5us joined
21:29 srxa joined
21:32 MotherFlojo joined
21:34 Ven_ joined
21:46 rozap joined
21:47 cevado joined
21:57 Ilyes512 joined
22:01 sp4rrow joined
22:02 rozap joined
22:08 griffinbyatt joined
22:10 isubasti_ joined
22:12 jerel joined
22:12 cemilowski joined
22:14 refriedchicken joined
22:16 Guest67 joined
22:18 __charly__ joined
22:24 sfbw joined
22:41 Vooch joined
22:50 myronmarston joined
22:53 MotherFlojo joined
22:56 zealsham_ joined
22:56 <zealsham_> elixir is such a weird language
22:58 mika__ joined
22:58 inoas joined
22:58 <icecreamcohen> weird good or weird bad?
22:59 jhack_ joined
23:01 myronmarston joined
23:05 junsuijin joined
23:08 griffinbyatt joined
23:09 junsuijin joined
23:10 isubasti_ joined
23:12 <zealsham_> icecreamcohen: weird goood
23:12 <icecreamcohen> that’s what I like to hear
23:14 <zealsham_> is jose vaslim here sometimes?
23:15 <icecreamcohen> zealsham_: yes, hes’s here a lot of the time.
23:15 MotherFlojo joined
23:17 <zealsham_> ohh thats great
23:18 meandi joined
23:20 <icecreamcohen> zealsham_: do you have any questions?
23:20 jkreeftmeijer joined
23:22 <zealsham_> icecreamcohen: yeah, being a beginner in the language i have so many questions, like where does elixir shines , why do we need it when we have OOP MODEL. why is it a good thing that data is immutable
23:22 <zealsham_> how does that benefit and make things easy
23:22 <icecreamcohen> those are good questions
23:22 duane joined
23:23 <benwilson512> and very broad questions ;)
23:23 <icecreamcohen> elixir doesn’t do well when you have a lot of CPU bound tasks. Video encoding, data munging, etc.
23:23 <icecreamcohen> it does very, very well when you’re waiting on I/O
23:23 <icecreamcohen> like most webapps.
23:23 <benwilson512> the functional paradigm limits the amount of stuff that you have to worry about at any given time
23:23 <asonge> zealsham_: those are really good questions. oop has a lot of tradeoffs, and its near monopoly is seemingly coming to an end. as far as immutability goes, it's got tons of advantages...so many, lots of things use it under the hood and you don't notice.
23:23 <icecreamcohen> here we go
23:23 <benwilson512> hehe
23:23 <asonge> :D
23:24 <icecreamcohen> immutability also enables the erlang VM to do things like stop code from running, run other code and come back and pick up where it left off.
23:24 sfbw joined
23:24 <asonge> zealsham_: here's a non-elixir justification for making most things immutable: http://queue.acm.org/detail.cfm?id=2884038
23:24 <icecreamcohen> as far as I know, no mutable language can do that.
23:24 <zealsham_> that means elixir has asynchronous abilities like say nodejs
23:24 <cmk_zzz> icecreamcohen: well, to be fair, golang which is not immutable in any way manage to do that just fine
23:25 <icecreamcohen> yeah, but golang doesn’t do that.
23:25 <icecreamcohen> I assume you’re talking about inside goroutines.
23:25 <cmk_zzz> icecreamcohen: it yields on function calls just like erlang
23:25 <asonge> zealsham_: kinda? but it's async doesn't come from needing async io. the vm can actually do async io even if the OS doesn't provide an async mechanism.
23:26 <icecreamcohen> cmk_zzz: but a busy loop in a goroutine can hog, correct?
23:26 <asonge> icecreamcohen: not anymore, iirc
23:26 <cmk_zzz> icecreamcohen: yes
23:26 <icecreamcohen> lol
23:26 <icecreamcohen> go figure it out!
23:26 <asonge> i thought they "fixed" that?
23:26 <icecreamcohen> How can they?
23:26 <asonge> with compiler trickery
23:26 <cmk_zzz> I haven't kept up to date
23:26 <cmk_zzz> so it is possible
23:26 <icecreamcohen> asonge: isn’t that the halting problem though?
23:26 <asonge> icecreamcohen: what do you mean?
23:27 <zealsham_> ohh, now i see the benefits of the language
23:27 <icecreamcohen> how do you know that you can stop something from executing?
23:27 <icecreamcohen> and how do you know it won’t produce side effects?
23:27 <icecreamcohen> Maybe you don’t care?
23:27 <asonge> icecreamcohen: you have the compiler add instructions to the loop, so that it maintains a counter in a loop to yield?
23:27 <icecreamcohen> (you == go devs)
23:28 <icecreamcohen> asonge: but how can you guarantee that something else won’t modify data when you yield?
23:28 <asonge> oh wait, you still have to yield yourself
23:28 <benwilson512> zealsham_: setting aside performance stuff for a second
23:29 <benwilson512> in an OO or other paradigm with a lot of mutable data
23:29 <icecreamcohen> asonge: you now owe me boudin
23:29 <benwilson512> when looking at a piece of code you not only need to keep in mind that parts in front of you, but all the other state all over the program
23:29 <asonge> just had some yesterday :P
23:29 <benwilson512> that those pieces could modify
23:29 <* icecreamcohen> is jealous.
23:29 <benwilson512> so in a class if you're looking at a method
23:29 <benwilson512> and that method modifies other state in the object, you need to think about every other method that uses that state
23:30 <benwilson512> functional programming simplifies this significantly, because all you can do is map inputs of a function to outputs
23:30 <benwilson512> it narrows the scope of things you need to think about
23:30 <asonge> ^^^
23:30 <benwilson512> and with that narrow scope comes fewer opportunities for bugs, and easier reasoning
23:30 MotherFlojo joined
23:30 <zealsham_> benwilson512: that was really helpful
23:31 <icecreamcohen> and better / easier testing too
23:31 <benwilson512> aye
23:31 <asonge> zealsham_: OOP and FP and other stuff have a full set of tradeoffs, not just this stuff, and they are also different "mental models" of what kinds of things exist.
23:32 <asonge> (there's also logical programming, and also i think that there aren't enough turing-incomplete languages in the world)
23:32 <icecreamcohen> zealsham_: there are also runtime benefits too. You have fairly unprecedented access to your running system. You can investigate it as it runs in production, for instance.
23:32 stepitime joined
23:33 elgenie joined
23:35 <zealsham_> i like the language, although someone told me i might say otherwise when i get to otp
23:35 <asonge> otp abstracts things you're totally not used to abstracting
23:35 <asonge> so it's hard to just...get it
23:36 <asonge> it's not actually all that complicated
23:36 <icecreamcohen> I think the worst thing about the larger ecosystem is that it can be very inconsistent.
23:37 <icecreamcohen> but OTP is very nice.
23:37 <cmk_zzz> OTP and the virtual machine is what makes it worthwhile. The actual language (erlang/elixir/lfe) is just a way to get to it
23:38 <zealsham_> this eased my fears towards otp
23:38 <asonge> also, it's so much easier to write elixir/erlang than javascript. lie, imagine if you could write C by writing a bunch of really really tiny 100 line programs, and just run a bunch of them.
23:38 <asonge> *like
23:38 <icecreamcohen> yeah, there’s no question that elixir / erlang is easier on you than JS / Node.
23:39 <icecreamcohen> the model is more sane.
23:39 <asonge> i think the hardest thing to really get a handle on, for me when i learned erlang anyway, was that processes functionally do what objects do in OO (in that they hold on to state), but you don't use them for everything like you use objects for everything.
23:40 <icecreamcohen> +1 to that
23:40 <icecreamcohen> that’s a very simple and useful mapping from OO -> actor system
23:40 <benwilson512> yeah sasa juric had a nice blog post recently on when to use processes for stuff
23:40 <benwilson512> it basically boiled down to "use them to get particular execution behaviour"
23:41 <benwilson512> vs "use them as the data model"
23:41 <icecreamcohen> me = self() ; spawn(fn -> send(me, 1 + 1) end) receive, do: answer -> answer end
23:41 <icecreamcohen> wait, benwilson512, not like ^^
23:42 <cmk_zzz> when to use processes is the hard part. They classic answer is: one for every concerrency *activity* but it is not always clear what *activity* means. It is quite easy to fall into the trap to have one process per unique thing.
23:42 sp4rrow joined
23:42 notdaniel joined
23:42 <icecreamcohen> zealsham_: don’t worry, Elixir is very tolerant of abuse.
23:43 <icecreamcohen> my first app was, in retrospect, a mess and it was fine.
23:43 <icecreamcohen> and you can go back and fix it.
23:43 sp4rrow joined
23:43 <zealsham_> ohhh
23:43 <zealsham_> i would love to do that
23:43 <cmk_zzz> zealsham_: I'm sure icecreamcohen would love if you went back and fixed his app too
23:43 <icecreamcohen> go back and fix your mistakes? That’s what most of us are paid to do.
23:43 sp4rrow joined
23:43 <zealsham_> icecreamcohen: you wrote it in pure elixir or you used phoenix?
23:43 <icecreamcohen> it’s fixed already!
23:44 <icecreamcohen> pure elixir.
23:44 <icecreamcohen> everything I’ve written so far has just been a server
23:44 <zealsham_> icecreamcohen: is it open source
23:44 <icecreamcohen> zealsham_: no
23:44 <icecreamcohen> but damn, I’d like it to be
23:45 <zealsham_> i think i will look around for some elixir projects on github
23:45 <icecreamcohen> zealsham_: have you done the walkthrough on elixir-lang.org ?
23:45 <benwilson512> icecreamcohen: yeah my first project was a pubsub / webhook server that was basically just "spawn a process for each subscriber"
23:46 <benwilson512> icecreamcohen: it scaled ENTIRELY too well for how bad the architecture was
23:46 sunaku joined
23:46 <icecreamcohen> I know.
23:46 <icecreamcohen> mine was a rate limiter. Each key had its own process.
23:46 <benwilson512> heh
23:46 <icecreamcohen> worked well.
23:47 <icecreamcohen> (works, it’s still in prod)
23:47 <benwilson512> very nice
23:48 <icecreamcohen> well, as far as I know.
23:48 <icecreamcohen> I don’t know if I told you, but I left.
23:48 <benwilson512> yup yeah
23:48 <benwilson512> discord right?
23:48 <icecreamcohen> yesp
23:49 <benwilson512> definitely seems like a cool place to be for elixir
23:49 <icecreamcohen> for sure
23:49 <icecreamcohen> they’re using it as a core service.
23:49 <zealsham_> i think my learning process is gonna be like this. finish the tutoriapoint tutorial--->finish elixir school tutorial--->read programming elixir--->read elixir in action-->read the otp book--->programming phoenix
23:50 <zealsham_> all this why building a couple of stuff along
23:50 <benwilson512> that's a good progression, although personally I'd just dive into programming elixir
23:50 <benwilson512> depending on how well you learn from books
23:50 <icecreamcohen> yeah, build a bunch of stuff.
23:53 mika__ joined
23:53 <zealsham_> can i ask why elixir chose to store lists as linked list, i know insertion and deletion are faster on linked list
23:53 <benwilson512> zealsham_: it's common in functional languages
23:53 <benwilson512> because it is an easy structure to build recursively
23:54 <benwilson512> and walk recursively
23:54 <benwilson512> and since you don't modify indexes in functional languages (immutability and all of that)
23:54 <benwilson512> recursion is the way to go
23:55 <zealsham_> benwilson512: thanks again
23:56 fowlduck joined
23:57 duane joined