nickjj

Activity Graph

Page 1 of 15 | Next »

2019-08-17

[13:48:11] nickjj: keden, "the switch" is a pretty popular way to get work
[13:48:53] nickjj: not so much convincing people to rewrite everything in elixir, but in my case i was able to start new projects in elixir (with good reason)
[13:49:48] nickjj: for example, maybe you've done some ruby or python work a client for years but now they want you to make a new service and you found elixir is a good fit -- suddenly you're getting paid to write elixir if they let you use it

2019-08-15

[01:47:01] nickjj: Read error: Connection reset by peer
[10:42:10] nickjj: has joined #elixir-lang

2019-08-05

[08:19:55] nickjj: Ping timeout: 268 seconds

2019-08-04

[20:51:35] nickjj: Read error: Connection reset by peer
[20:53:04] nickjj: has joined #elixir-lang

2019-07-29

[12:49:14] nickjj: does live reload hang for a few seconds before reloading for anyone else? it gets triggered, then there's a busy mouse cursor and 3-4 seconds later the page reloads
[12:51:12] nickjj: i wonder if it's something specific to docker, using docker for windows and experimenting with vscode's remote containers live reload works but it hangs for a really long time
[12:51:43] nickjj: but if i use the same docker set up with other frameworks, the hanging isn't there (it's immediate)

2019-07-27

[18:24:04] nickjj: rawtaz, try putting in /users/abc and then looking up a user by id with abc -- then check the status code of the response
[18:24:23] nickjj: i don't know offhand but i am pretty sure it will be a 400
[18:30:25] nickjj: if you only care about the user_id you could also choose to deconstruct it from the params and then put a guard clause on the route and now it won't even run the function unless it's an integer
[18:32:55] nickjj: def my_route(conn, "user_id" => user_id) when is_integer(user_id), do: IO.puts("doing stuff!")
[18:34:00] nickjj: or maybe just user_id would work in this case , it depends on what's going on
[18:42:49] nickjj: it would go in your controller for whatever action is expecting a user_id
[18:43:05] nickjj: probably your new/create/edit/update/delete actions

2019-07-25

[11:41:38] nickjj: Ping timeout: 272 seconds

2019-07-23

[15:36:45] nickjj: mdbm, it's one way to avoid having to put secrets into version control
[15:39:59] nickjj: if it's not sensitive info i'd probably put that into your prod config, and then use a different value in the dev config if it's different
[15:41:54] nickjj: you asked about putting production settings in environment variables
[15:42:31] nickjj: personally i wouldn't commit uploaded files to version control
[15:46:18] nickjj: up to you, i put mine in /priv/uploads to keep it separate from static
[18:48:26] nickjj: Zarathu, i use /priv/uploads in development
[20:05:17] nickjj: digitalocean's block storage is also nice if you're dealing with 1 server but still want to keep your instance dumbed down
[20:08:04] nickjj: yeah, it basically works as an external drive that you can plug in to an instance
[20:12:05] nickjj: yep, but if you're backing up a DB or dealing with user uploaded files , $10 for 100GB seems reasonable , i've never approached that size
[20:14:35] nickjj: there's spaces too, which acts more like s3 , i think that's about $5/month for 200gb+ with generous data transfers
[20:15:17] nickjj: yeah $5 for 250gb, and you get a CDN built in
[20:17:47] nickjj: i'm not sure offhand but it would be a lot more if you factor in the CDN, using close to 250gb of space and ~1TB of transfer
[20:22:49] nickjj: cloudfront says 0.085 per gig to the US so even if you transferred 500gb (half of what DO offers) you'd be paying $42.50 a month
[20:23:16] nickjj: and that's just network transfer costs

2019-07-12

[17:39:21] nickjj: serafeim, thx for linking that vscode plugin, i've been using vim for a few months and use ctrl+o/i a decent amount but didn't know about ctrl+^ (seems handy when you jump a lot in 1 file but want to immediately goto the prev buffer regardless of current file jumps)
[17:40:36] nickjj: yeah i've been using ctrl+o for that, but it also accounts for any jumps you've made in file A
[17:41:23] nickjj: but in general yes, that's a killer feature that's hard to give up if you don't have that option in your editor
[17:43:49] nickjj: my workflow usually involves having 4x buffers vertically next to each other but i still find myself jumping between files in 1 of the buffers
[17:44:08] nickjj: sometimes tabs too, to group things up, depends on what i'm working on
[17:45:08] nickjj: did vscode any anything like vim tabs in recent updates? i find them to be wildly useful when you want the behavior of having an isolated group of buffers
[17:45:18] nickjj: *add anything
[17:46:22] nickjj: i run a 2560x1440 monitor at native res, 4x side by side ends up showing 85ish chars per buffer (i tried to stick to 80 per line)
[22:28:47] nickjj: when it comes to style preference for ecto custom validators, is it best to use validate_change(:foo, &myfunc/1) in a changeset and in the error case return [foo: "..."] and [] in the ok case , or do something like validate_myfunc() in the changeset and then use add_error in the error case and return the changeset in the ok case?

2019-07-11

[03:51:02] nickjj: Read error: Connection reset by peer
[09:26:46] nickjj: has joined #elixir-lang
[13:51:57] nickjj: i just discovered Module.concat, but is there a way to convert something like :accounts into Accounts? concat converts :accounts to accounts and then the module isn't available
[13:52:24] nickjj: also, is this overall strategy the best way to deal with wanting to call a specific module based on an atom's value?
[13:54:22] nickjj: i'm just finding myself having to repeat the same case statement 5 or 6 times where i'm casing on an atom and executing specific functions in specific modules based on what the atom's value is
[13:54:50] nickjj: if it's :foo then call Hello.Foo.yay , if it's :bar then call Hello.Bar.yay -- that type of thing
[13:56:44] nickjj: would something like this work? mod = %{foo: Hello.Foo, bar: Hello.bar} ; mod[some_atom].yay()
[13:57:01] nickjj: it's important that the function name isn't stored in the map because there are going to be 5 or 6 different functions
[13:57:39] nickjj: the actual use case is having 3 payment gateways , each with 5 or 6 functions , each in their own behavior driven module , and now based on an atom (an enum) i want to call a specific gateway's function to do the work
[13:58:14] nickjj: so i rigged it with a case on the enum in every function but this is starting to feel like maybe there's a better way
[14:01:52] nickjj: thanks i'll try using that for now
[14:05:47] nickjj: wow it actually worked (haha, always surprised), hopefully this isn't too inefficient tho, but i doubt it'll be anything to worry about in the grand scheme of things
[14:05:58] nickjj: only real concern is now i need to remember to keep this map up to date
[14:08:28] nickjj: i did drop it into a @payment_gateways module attribute, i think manually will be ok. this is something that might change literally 2 or 3 times in the entire life time of the project
[14:10:39] nickjj: benwilson512, should i even bother looking into that?

2019-07-10

[22:06:10] nickjj: if you were going to implement a way to make purchases using 1 or more payment gateways (and this is picked at runtime), would using a macro make sense to set up a bunch of expected functions that you would implement and then override each function in a gateway specific module?
[22:17:40] nickjj: the macro idea came from https://github.com/aviabird/gringotts/blob/dev/lib/gringotts/gateways/base.ex
[22:17:54] nickjj: seems to be one of the few open source tools for dealing with payments (which i don't plan on using tho)
[22:18:51] nickjj: my thought process was to have something like an Ordering.authorize(Gateways.Stripe, ...) type of function , since the gateway being used will depend on a form field value
[22:22:05] nickjj: josevalim, so basically do something like what hexpm is doing? https://github.com/hexpm/hexpm/blob/master/lib/hexpm/billing/billing.ex -- and in this case, if i had shared functionality in the common module, instead of calling impl().foo(...) , i would just do the common work there?
[22:23:00] nickjj: although hex's payment system is much different, you pick it once at config time and it can only be 1 potential thing at a time
[22:23:29] nickjj: sort of like how some email libs work where at config file you pick what adapter to use
[22:23:35] nickjj: *config time
[22:27:03] nickjj: thanks a lot
[22:27:35] nickjj: i'll research behaviors/callbacks/protocols because it sounds like it'll be one of those things in the end and from my super basic knowledge i think i read behaviors are pretty similar to protocols

2019-07-09

[13:22:42] nickjj: how do you guys use pattern matching when you have multiple optional arguments? i'm having difficulty figuring out how i should refactor this function to be less riddled with conditions while still having 2 optional args https://gist.github.com/nickjj/5933336ac9975f18d81fc4827a70f065
[13:25:00] nickjj: gamache, thanks, guess i'll run with it, it's funny how out of place multiple conditions look when you're not used to seeing them
[13:48:46] nickjj: hmm, that's potentially an improvement, at least it names what the enums are doing
[13:52:34] nickjj: putting :hello on its own line is cool too, i didn't think about that
[13:55:58] nickjj: i think i'll roll with your approach, it is a few more lines of code but it's also more readable and maybe if i ever use a DB backed value, your solution is slightly more adaptable to change
[13:56:34] nickjj: suddenly those maybe_* functions just become composed queries
[13:57:44] nickjj: serafeim, i'll have to keep that in mind for future queries
[15:01:29] nickjj: i couldn't find a discussion of this online, but why isn't `pattern: "**/*"` the default for hello_web.ex when you use Phoenix.View? are nesting partials inside of sub-folders considered a bad idea?
[15:03:06] nickjj: do you have any examples of when it would become problematic? just so i have a better idea of what to watch out for
[15:04:59] nickjj: in that example User.ProfileView is optional right?
[15:05:42] nickjj: oh, in my case i was just looking to clean up having a bunch of partial sitting in a templates/ directory
[15:06:17] nickjj: _payment_gateway_stripe.html , _payment_gateway_paypal.html vs payments_gateways/_stripe.html , stuff like that

2019-07-08

[12:34:11] nickjj: is it possible to have a generic config item supplied in config.exs but then in let's say another config (prod.exs), read in that config file and modify a component of that value without having to redefine it?
[12:34:44] nickjj: like if the config value were a map, i want to remove 1 key of the map -- without having to manually define the map again without that 1 key
[13:07:33] nickjj: Ankhers, that is what i tried originally, then i did a string replace on the result of get_env but the end game config value was the result of get_env without the string replace's effect
[13:11:03] nickjj: i had this in my prod.exs , config :hello, :someopt, fruit: String.replace(Application.get_env(:hello, :someopt), "apple", "orange")
[13:11:20] nickjj: and in config.exs i had the fruit set to "apple" -- but in prod.exs the value of :someopt was still apple
[13:12:22] nickjj: i was working with strings for now just to see if it would work, before i went ahead and used my real data structure
[13:13:12] nickjj: it's not the end of the world if i have to copy / paste things around but it would have been nice if i could modify it with code
[13:32:22] nickjj: Ankhers, thanks. i think you're right in that it's probably doing things i shouldn't be doing
[16:28:09] nickjj: is it common practice / idiomatic to do: use HelloWeb, :view , in your view helper files?
[16:34:52] nickjj: Ankhers, a foo_helpers.ex file that lives in views/ , this is the spot to put functions that help you display things right?
[16:36:00] nickjj: for example a def full_name(first, last) function that would return "#{first} #{last}"
[16:36:50] nickjj: in this case i'm using things like img_tag, routes helpers and rendering partials
[16:37:12] nickjj: so i'm finding myself maybe wanting to use it (since all of that stuff is set up by the view macro in hello_web.ex
[16:37:23] nickjj: but at the same time it seems maybe wrong since it's not technically a view module?
[16:40:33] nickjj: yeah, initially i put them in foo_view.ex but then i read that the view file should only be used for handling rendering actual templates
[16:40:49] nickjj: like if you wanted to render a json response or something, you'd put it there
[18:36:18] nickjj: does anyone else find it more difficult to read forum posts after the updates? the white on white makes it much more difficult to glance replies
[19:20:20] nickjj: i hope you get an an answer serafeim, that seems like a really useful thing to have
[23:50:08] nickjj: Exuma, i ran into a chicken / egg problem recently where i ended up doing the insert + update and it worked really nicely
[23:50:37] nickjj: basically i inserted a record with a status of active = false and then after i got a confirmation from something, i updated it to true
[23:50:50] nickjj: and the app itself only deals with active thing
[23:53:14] nickjj: it's strange because that pattern isn't obvious at all, i actually think OvermindDL1 may have recommended it haha, i honestly forgot

2019-07-07

[09:42:37] nickjj: cmk_zzz, i just use bamboo -- sending email isn't easy and bamboo really only involves pulling in 1 or 2 libs (most of its deps are related to its test and dev environments)
[10:40:24] nickjj: cmk_zzz, it handles local with its own local adapter, basically an in memory mail queue that can be accessed with a web front end, so you don't need to set up sendmail unless you really wanted it
[10:41:38] nickjj: there's also a general purpose smtp extension too
[10:43:29] nickjj: i think it is too, i had the same dilemma when i set up email too, i ended up choosing bamboo because i saw a lot more projects using it
[10:44:59] nickjj: i think what sold me on bamboo too was how it handled sending emails in the background
[10:45:13] nickjj: it had more options implemented for you
[11:52:30] nickjj: is it possible to change L3 in this gist to use the [x | y] syntax instead of ++? i tried a bunch of things and can't get the syntax right https://gist.github.com/nickjj/474440751c1ddcd980c424cadab526fe
[11:53:02] nickjj: also as a side question -- if that is defined in a module , this is happening at compile time right? ie. after compile that enum will be only 1 thing without running the condition
[11:58:03] nickjj: oh cool, that worked -- what style would you prefer in that case?
[11:58:42] nickjj: i've been trying to use the [x | y] style whenever possible if i'm prepending to a list
[11:59:28] nickjj: i forgot why tho, i think i read somewhere if you prepend to a list like that, it's really efficient and doesn't have to read the whole list
[11:59:39] nickjj: but maybe ++ is smart enough to do that too?
[12:00:44] nickjj: right, thanks -- in this case it's hilariously small (2 items) but i may use the tuple version just for style consistency
[12:04:23] nickjj: as for the 2nd question, that condition is compile time right?
[12:17:21] nickjj: yikes, it seems like ecto enum doesn't like defining it how i did in the end -- it says the enum isn't defined when i try to access the page that references that module
[12:22:13] nickjj: mdbm, you can use validate_format and pass in a regex if you wanted to
[12:22:55] nickjj: but i would be careful with how far you take that validation, valid emails can look very different
[12:24:05] nickjj: validate_format(:email, ~r/\A\S+@\S+\.\S+\z/)
[12:24:37] nickjj: it really just checks for something then an @ then something and a . and then something
[16:33:53] nickjj: that would be a fun regex to debug if it were a 1 liner "missing ) on line 1"
[16:41:28] nickjj: that includes errors too, because it's nice being able to see "can't be blank" as a form error for an email field that was left empty
[16:47:24] nickjj: if the form didn't know about your changeset then you wouldn't be able to do things like <%= label f, :email %>
[16:49:37] nickjj: there's no way for the label to know what :email is without it knowing about your changeset
[16:51:30] nickjj: serafeim, i only picked label because it's a short tag, it could be an text_input or anything else
[16:53:51] nickjj: how far did you read in the book? because it covers things like error_tag
[16:54:07] nickjj: if you had <%= error_tag f, :email %> and the form didn't know what your changeset, how would it know to show an email validation error there?
[16:54:44] nickjj: since it knows about your changeset, it can look through all of the errors and then display the validation error if there happens to be one -- but if there is no error, then that tag doesn't output anything
[16:56:03] nickjj: mdbm, correct, you would need to apply those attributes as arguments to the form helpers you're using
[16:56:55] nickjj: so for an email field on a sign up page, you might decide to do something like: <%= email_input f, :email, maxlength: 254, class: "form-control #{error_class(f, :email)}", placeholder: "Email", autofocus: true, required: true %>
[16:57:37] nickjj: and now your field is totally tricked out with maxlengths, required and auto-focused and if there's errors it'll even color it red
[16:58:46] nickjj: but that error_class depends on what css framework you're using -- it's also a custom function, but it's a 1 liner
[16:59:12] nickjj: yeah it adds an error class if there's an error (not a default phoenix behavior but useful in a real app)
[16:59:23] nickjj: if form.errors[field], do: "is-invalid", else: ""
[16:59:23] nickjj: def error_class(form, field) do
[16:59:37] nickjj: if you wanted that, drop the above in your lib/hello_web/views/error_helpers.ex file
[16:59:45] nickjj: and change is-invalid to whatever you want the error class to be
[17:00:40] nickjj: and if you look in that file, you'll find error_tag too which phoenix does generate for you, which lets you customize what error messages look like, such as "can't be blank" or whatever
[17:00:51] nickjj: and that's a tag you can put into your form under your input field or whatever you're displaying
[21:26:09] nickjj: mspo, with remote container support yes

2019-07-06

[19:20:50] nickjj: Ankhers, they responded with:
[19:21:04] nickjj: <OvermindDL1> It's pretty simple, just sets fields
[19:21:04] nickjj: <OvermindDL1> Should be able to just alter table and use the timestamp macro?
[23:36:21] nickjj: is it better to pretty much always use hd/1 instead of List.first/1 to get the first item in a list?

2019-07-05

[14:09:08] nickjj: are there any patterns i can take advantage of to make my tests more concise? for example, i will want to do about 6 or 8 slight variations of this test where i change 1 or 2 attributes of a specific resource but each test is ~20 lines of code https://gist.github.com/nickjj/6759ce55ed572ad0a1bf5c4455fcc34c
[14:10:37] nickjj: i know i can use setup but i'm not sure if it really helps here since i would want to modify some of the attribs of the thing being created
[14:13:00] nickjj: overall i'm finding almost an 8:1 ratio of code written vs test code written so i feel like maybe i'm doing something wrong, i have this one 800 line test file to test about 100 lines of code
[14:50:34] nickjj: gazler, in my case, what would that buy me in the end to reduce boilerplate?
[14:55:39] nickjj: gazler, oh yeah -- updated the gist with a few tests (which i wrote in between posting my question and now)
[14:56:37] nickjj: it just feels like by the time i'm done testing all of the combinations i'm going to end up with easily 1k lines to test another ~60 lines of code
[15:07:39] nickjj: hmm, but what happens when those tests want to twiddle with the attrs of a package?
[15:09:45] nickjj: so make a new function like create_course_with_packages_that_have_no_discounted_price?
[15:10:42] nickjj: it's a course that has many packages being created btw
[15:10:50] nickjj: where many could be 1 or more
[15:12:16] nickjj: here's another case too, i have literally 650 lines of tests like this https://gist.github.com/nickjj/e69fb9ffb273f1ccfd474861f0715c23 --- is that pretty much expected? in this case it's more of a unit test than controller test
[15:15:41] nickjj: my thought process was it protects me from being stupid and accidentally removing a validation rule
[15:15:54] nickjj: or forgetting to put a uniqueness check on something
[15:17:08] nickjj: the funny thing is i don't like TDD and all of these tests were written after i wrote the code
[15:18:35] nickjj: there's also certain things that make me feel a little uneasy if they are not tested, like this https://gist.github.com/nickjj/e69fb9ffb273f1ccfd474861f0715c23#file-3-ex -- but at the same time it's a lot of code for a small test
[15:18:47] nickjj: basically making sure my constraints are set up correctly
[15:21:49] nickjj: for the most part tho, it sounds like maybe using setup and a couple of varied functions could help shave a couple of lines off but ultimately doesn't save too much?
[15:26:09] nickjj: not writing tests can be dangerous because then it makes it really hard to change things later
[15:26:25] nickjj: because you wonder if changing 1 line of code broke 17 things
[15:27:14] nickjj: accidentally deleting is probably close to impossible
[15:27:34] nickjj: unless i'm using vim with a blind fold on, in which case, anything could happen
[15:29:04] nickjj: thanks gazler, that looks like it has potential to clean things up
[15:30:00] nickjj: maybe even go it from a different approach of looping over validation types , like "reject empty #{field}" and then loop over that while passing in field names?
[15:31:24] nickjj: because another issue too is, if you decide to change your validation rule to be 20 chars instead of 19 -- if you hard code the exact changeset error message now you need to update that too
[15:33:29] nickjj: yeah i've seen that one, i also read the programming phoenix book which i based most of my tests on
[15:34:27] nickjj: that's where i picked up patterns like `assert [%Discount{id: ^id}] = Promotions.list_discounts()`
[16:42:20] nickjj: Zarathu, yeah in this case i'm testing a checkout controller and i really want to make sure the html response has specific things in or not in it based on what the user enters into the form
[16:42:47] nickjj: usually i would have a unit test to test a bunch of combos and then a single happy / unhappy test for a controller
[16:43:12] nickjj: well, for each controller action
[16:44:10] nickjj: those tests are all wrapped into a "apply discount form" describe already
[16:44:28] nickjj: since that controller has 3 actions (apply_discount, rendering the checkout form and the POST for the checkout form)
[16:45:18] nickjj: yep, i also have a :as_user and :as_inserted_user setup tags in my conn_case to deal with signed in users
[16:46:38] nickjj: this controller is a bit more involved since technically the email address can originate from a signed in user's email address, or a signed out user's email address
[16:47:21] nickjj: the other tests in this controller? they still have yet to be written , my strategy so far has been to have a describe block for each controller action
[16:48:29] nickjj: other controllers are less complicated, such as https://gist.github.com/nickjj/cc77a98fe54644082ac344d1f088fa80
[16:49:03] nickjj: which is a test to make sure if you goto /home , you get redirected to /home/account
[16:49:08] nickjj: (as a signed in user)
[16:49:32] nickjj: and that @tag :as_user injects a factory built user as current_user to make it available in assigns current_user
[16:50:32] nickjj: it's very similar to https://github.com/thechangelog/changelog.com/blob/master/test/support/conn_case.ex#L50
[17:18:51] nickjj: serafeim, google says <- is ∈ which is supposed to mean "element of"
[17:19:37] nickjj: but that's when used with comprehensions i'm guessing
[17:20:28] nickjj: come to think of it, why exactly did they go with <- for "with" instead of "="? isn't = what's really happening there?
[17:21:35] nickjj: oh, do you mean if they used = then it would throw an error instead of being able to handle it in an "else"?
[17:22:26] nickjj: when i see <- in "with" i just think "shoveling the output of the thing on the right into the thing on the left"
[17:23:04] nickjj: but with a for x <- [...] comprehension i do not think the same thing about <-
[18:25:06] nickjj: is it considered a bug if mix format does not pull excess lines up to fit a certain length? i have a repeatable case here
[23:14:36] nickjj: can someone explain how you can test for a specific redirect message in exunit after you've already redirected?
[23:15:30] nickjj: *flash message -- here's what i have based on what chris once wrote on the elixir forums https://gist.github.com/nickjj/c403cd7b5a73193eec3a1a3da5b1f67c -- but when i do this, the last assert fails saying `<html><body>You are being <a href=\"/signin\">redirected</a>.</body></html>`
[23:16:16] nickjj: i have a feeling the recycled connection doesn't have the original connection's assigned current_user but i'm not sure how to solve that

2019-07-04

[09:52:39] nickjj: cmk_zzz, in theory you should be able to replace that Timex.now() call with DateTime.utc_now()
[09:55:04] nickjj: yeah i mean in that helper function , Timex.now() was being used in to_local_time/1 , i think you can drop in replace that with DateTime.utc.now() and potentially avoid the Timex dependency if that's all you want
[10:02:15] nickjj: i use timex too, it's very welcome for formatting dates or timestamps
[10:03:23] nickjj: although if i can, i try to do all date formatting on the client side , this way i can keep things rendered server side in UTC and not worry about it
[10:03:54] nickjj: also helps with caching if you can render a utc timestamp and then use javascript to convert that to things like "5 minutes ago"
[10:05:52] nickjj: serafeim, just for the formatting of the server provided utc time
[10:06:41] nickjj: i usually just drop times into a <time> tag with a specific class and then JS takes over and formats the time how i want it based on the class i used
[10:07:28] nickjj: relative time, 2019-07-04, Jul 4th 2019, etc.
[10:10:00] nickjj: and with data attributes you can still store things like the user's local time in your database in the cases where you don't want to use whatever value the browser provides
[10:10:18] nickjj: *local timezone
[10:20:40] nickjj: serafeim, yeah, although on this new project i'm working on, i'm going to check around and see if there's something more light weight but still compatible with most browsers since moment.js is kind of heavy and i use such a tiny fraction of what it offers
[10:22:53] nickjj: yep you really can't go too wrong with it
[10:23:28] nickjj: although a quick googling seems promising https://github.com/iamkun/dayjs
[10:24:12] nickjj: i haven't gotten around to researching that yet since i'm so focused on the server side , but i'd probably start with at least evaluating that
[10:25:56] nickjj: seems to have good browser compatibility too and it's ~50kb less than momentjs
[10:26:52] nickjj: i have to say, the used by state on github is really useful for this too
[10:27:10] nickjj: you can really see how crazy popular momentjs is , it's used by almost a million projects vs 16k for dayjs
[10:29:02] nickjj: you mean you don't want to click next through hundreds of repos? haha
[10:30:29] nickjj: i try to keep js to the minimum too btw
[13:26:38] nickjj: josevalim, just wanted to say thanks for our discussion the other week, it really helped me think about things and overcome organizational problems
[13:27:42] nickjj: sure no problem, a billion blog posts will be the next step

2019-07-03

[00:00:44] nickjj: it still surprises me (in a good way) that you can run code directly in a module like that
[00:03:08] nickjj: so for 100% clarity, if i dropped that if statement at the top of the module, it'll only be evaluated once at compile time and @fields will be set to a "static" value for the lifetime of the app?
[09:24:10] nickjj: Zarathu, yeah after sleeping on it, i don't think i'll end up needing that, what i really want is just 2 separate changesets (one that allows editing X and one that does not), and this would apply the same to all envs
[13:30:52] nickjj: can someone lend a hand and explain why this assertion is failing? i've done pretty similar things in the past and it worked https://gist.github.com/nickjj/344ca52e4839074f691fc97c4bf25c2f
[13:32:05] nickjj: the end goal is i want to assert that only 1 discountpackage is returned, and it's the one with a nil package_id (the 2nd one has a package_id that doesn't match package.id)
[13:41:22] nickjj: oh, i guess repo.all isn't returning {:ok, results} , instead it's just results
[15:12:48] nickjj: Zarathu, yep, it ended up being really nice to implement too, the 2nd changeset accepts a changeset as input and calls |> delete_change(:foo) on the field i wanted to disallow editing
[15:33:50] nickjj: Zarathu, how would you use those 2 changesets together in a way where the original changeset doesn't overwrite the special one?
[15:34:31] nickjj: for example , let's say you have 1 main changeset that's used for both inserting and updating , and you want to allow "name" for inserts but not allow "name" to be changed for updating
[15:35:48] nickjj: with your example, you'd run the special changset before the original changeset right? but then the original changeset would cast(attrs, @allowed_fields) and now its cast would overwrite that extra item from the special one?
[15:44:51] nickjj: thanks, that makes sense -- the third changeset was the missing link
[15:45:51] nickjj: btw, is it considered a best practice to inline variables like that next to where you use them vs the top of the file?
[15:46:03] nickjj: in this case the @allowed_fields declaration
[15:47:42] nickjj: good to know thanks
[15:47:58] nickjj: so wherever you use it first is where you place it basically? as a general rule?
[15:56:16] nickjj: Zarathu, just to come full circle you mentioned deleting it after can be error prone, what would the error case be by doing it the old way?
[15:56:23] nickjj: because it wasn't immediately obvious
[16:14:24] nickjj: your pattern is also really nice because it works exactly the same for when i want to do this same thing to a cast_assoc'd changeset too
[16:14:43] nickjj: where as my original plan would have kind of fell apart
[18:51:07] nickjj: has anyone else ever hit an error of `(DBConnection.OwnershipError) cannot find ownership process for` when running tests? i tried turning off async for the entire module and it happens with or without async
[18:51:50] nickjj: the test code is just making a db entry, querying the db and then asserting the result i expect (it's pretty much an exact copy / paste of a test that did not throw this error)
[18:57:22] nickjj: wow crazy lol, so i had a typo in my test case , it was defined as `with "my test" do` instead of `test "my test" do` -- other than not being an idiot, is there a better way to track down errors like that?

2019-07-02

[15:43:10] nickjj: with ecto, if you wanted a read-only attribute in a changeset that's only changeable for tests, what's the best way of going about that?
[15:43:25] nickjj: would you code a MIX_ENV check in your changeset to only cast that attrib for tests?
[16:10:54] nickjj: yeah non-castable, but the thing that's read-only is very important so i'd like to test it when it's either X or Y -- but it needs to be castable in order to modify it for a test
[16:11:20] nickjj: it feels really dirty to modify the main code execution for tests tho
[23:59:59] nickjj: Zarathu, thanks, i didn't think checking the mix env would be common practice

2019-07-01

[11:45:26] nickjj: so if you wanted a generic solution that you can pop into your apps, look at ex_admin or torch maybe
[20:47:12] nickjj: for an update ecto schema function, if you wanted to disallow editing a field based on the value of another field would you typically write 2 changeset functions , one with the field you want to allow/disallow cast and the other without?
[20:49:41] nickjj: the overall thing i'm trying to do is not allow someone to edit abc if xyz > 0 , and both fields belong to the same schema -- perhaps this should be a custom validation instead?