#elixir-lang - 17 July 2019
« Back 1 day Forward 1 day »
[10:14:52] za1b1tsu: if anyone has any experience with yeex, can you help me with this: https://pastebin.com/raw/NmCwV40n ?
[11:47:51] absolutejam1: ugh, if I move my `FooWeb.Endpoint.subscribe(...)` call from `mount/2` (LiveView) to my GenServer, the GenServer then receives any `handle_info` calls...
[11:48:08] absolutejam1: or could it be because I'm not instantiating the GenServer in the `mount/2` call but in a supervisor...
[12:21:24] absolutejam1: I need to reason about it a bit more. Just kinda lopped and chopped some code from one location to another
[13:58:34] davic: the applications are loaded etc, but they arent started and no logging is returned as of why they arent starting
[14:56:07] dch: davic: try setting mmmm ERL_FLAGS="-init_debug" and re-starting the release, maybe you see some information.
[18:26:03] ankhers: I had this issue previously, but I do not remember the solution. When running mix hex.publish, I am getting an undefined function error for ExDoc.Config.default_formatter/0. I am currently using Elixir 1.8 and ex_doc version 0.18.1.
[19:44:48] serafeim: let's say i have a string in DDMMYY format (i.e 220682 = 22 may 1982). how can i check if this date is valid ?
[19:45:26] serafeim: i mean i want `is_date_valid("220484")` to return true and `is_date_valid("441231")` to return false
[19:51:46] serafeim: my problem is how to convert the "220482" string to a format compatible with this... i mean in an idiomatic way
[19:52:27] rawtaz: i dont know but i would presume thats pretty simple, just grab the pair of chars?
[19:54:08] rawtaz: im not sure if this is old, i recall that calendar and stuff was rewritten or added recently, so this might be outdated, but in case it helps: https://stackoverflow.com/questions/40962261/how-to-parse-datetime-in-elixir#40963922
[19:55:07] serafeim: rawtaz: i'd like it to be idiomatic. for example, I don't like this: https://dpaste.de/Bu1h
[20:00:53] serafeim: the string is in the form "DDMMYY". one solution would be to convert it to "YYMMDD" (how ?) then stick "19" in front like "19YYMMDD" then put two dashes in positions 4 and 6 like "19YY-MM-DD" and finally just pass this to `Date.from_iso8601`
[20:02:33] rawtaz: if you throw it through a regex that replaces to rearrange thats easy. something like dadate |> regex_replace('(\d\d)(\d\d)(\d\d)', '19\3-\2-\1') |> Date.from_iso..
[20:08:37] serafeim: rawtaz: this `Regex.replace(~r/(\d\d)(\d\d)(\d\d)/, "250611", "19\\3-\\2-\\1")` actually works, ie it returns `"1911-06-25"`
[20:09:02] rawtaz: doesnt elixir have something so you dont have to \\ , like single quotes or similar?
[20:09:22] rawtaz: why not? looks perfectly fine to me, you are sending the data through something that changes the format of it before you use it
[20:09:58] rawtaz: better would of course be if there was a parser function to Date or Calendar where you could provide the format it should read the data in. but i cant find one
[20:10:51] serafeim: rawtaz: i don't think so about the `\\` all examples here are with `\\`: https://hexdocs.pm/elixir/Regex.html#replace/4
[20:12:46] serafeim: a more idiomatic thing (for me) would be to group "DDMMMYY" in pairs, reverse that list, insert the dashes and re-join everything to a string
[20:14:10] serafeim: so "DDMMYY" -a> ["DD", "MM", "YY"] -b> ["YY", "MM", "DD"] -c> ["YY", "-", "MM", "-", "DD"] -d> "YY-MM-DD" -e> "19YY-MM-DD"
[20:24:04] serafeim: `"250615" |> String.graphemes |> Enum.chunk_every(2) |> Enum.reverse |> Enum.flat_map(& &1) |> Enum.join`
[20:24:22] ankhers: If you are okay with bringing in a library, timex accepts a parsing format. So you can parse any date format you want.
[20:26:58] serafeim: so here's the final solution: `"150615" |> String.graphemes |> Enum.chunk_every(2) |> Enum.reverse |> Enum.flat_map(& &1) |> List.insert_at(2,"-") |> List.insert_at(5,"-") |> List.insert_at(0, "19") |> Enum.join |> Date.from_iso8601`
[20:30:00] ankhers: <<day :: binary-size(2), month :: binary-size(2), year :: binary-size(4)>> = "DDMMYYYY"
[20:33:44] rawtaz: is there a bot in here that you can ask for function/x or Date.from_erl or whatever to get basic info and links to docs?
[20:38:16] rawtaz: one could make the bot just refer users to private messages with it, problem solved.
[20:38:46] ankhers: Then there would just be random people doing ,doc DateTime.to_erl/2 or something.
[20:38:57] rawtaz: i made one for yii 1.1 many years back, it has a pretty nice feature set in terms of how you can ask it for docs about classes and functions (including properties and parameters/arguments): https://www.yiiframework.com/wiki/369/the-mrfisk-irc-bot#the-doc-ltquerygt-and-api-ltquerygt-commands
[20:39:36] rawtaz: Ankhers: yeah but the bot would refer them (in a single line) to ask him/her in private, and do that only once per X minutes or so. so for every spammer there would at most be one message in the channel per X minutes
[20:40:59] rawtaz: josevalim: well you kinda got me :) i probably should, it's just that when youre in a channel on the irc chatting away and you want a quick reference to something, it's lovely to just be able to say func/2 and get a clickable link to the entire online docs for that function
[20:49:17] rawtaz: the multiple matches selection correctly addresses the targeted user as well, e.g. Gilette if there were to be multiple matches to my !doc to that user, the bot would ask Gilette to select.
[20:50:03] rawtaz: correction, that's wrong: it would first ask *me* to select, then once i do that give the selected option to Gilette.
[20:51:45] ankhers: josevalim: What was the solution to the undefined function ExDoc.Config.default_formatter/0 issue again? I can't seem to remember what I did to fix it.
[20:57:46] ankhers: rawtaz: I think if we just did the same thing as iex would be easiest. Simply `h Date.to_erl'
[20:59:15] rawtaz: yeah. thats a start. but there's way more to the bot that could be done. but it's a start, indeed!
[20:59:38] rawtaz: but youre right, one could just feed the entire query to iex, as long as it begins with h
[21:01:19] rawtaz: one could just fix an alias in the irc client that pulls up a window with the info from iex :)