« Back to channel list

#elixir-lang - 09 April 2019

« Back 1 day Forward 1 day »
[00:23:09] k1nd0f: has joined #elixir-lang
[00:39:40] duane: has joined #elixir-lang
[00:42:45] ariedler: has joined #elixir-lang
[00:54:33] __charly__: has joined #elixir-lang
[01:02:40] mdbm: has joined #elixir-lang
[01:06:54] carldd: has joined #elixir-lang
[01:15:31] shritesh: has joined #elixir-lang
[01:19:58] sevenseacat: has joined #elixir-lang
[01:23:05] mozzarella: has joined #elixir-lang
[01:45:21] Saukk: has joined #elixir-lang
[02:06:28] tomterl: has joined #elixir-lang
[02:20:02] lauromoura_: has joined #elixir-lang
[02:37:17] lauromoura_: has joined #elixir-lang
[03:20:10] duane: has joined #elixir-lang
[03:22:19] carldd: has joined #elixir-lang
[03:56:41] siwatpru: has joined #elixir-lang
[04:01:21] kapil____: has joined #elixir-lang
[04:05:42] mbuf: has joined #elixir-lang
[04:07:23] gvaughn: has joined #elixir-lang
[04:23:16] Moondhum: has joined #elixir-lang
[05:27:02] voltone: has joined #elixir-lang
[05:27:13] gvaughn: has joined #elixir-lang
[05:53:36] k1nd0f: has joined #elixir-lang
[06:05:15] Beam`: has joined #elixir-lang
[06:10:50] proteusguy: has joined #elixir-lang
[06:11:53] ur5us: has joined #elixir-lang
[06:16:41] salasrod: has joined #elixir-lang
[06:19:06] ariedler: has joined #elixir-lang
[06:19:47] Beam`: has joined #elixir-lang
[06:23:34] cschneid: has joined #elixir-lang
[06:24:33] voltone: has joined #elixir-lang
[06:37:25] voltone: has joined #elixir-lang
[06:46:37] voltone: has joined #elixir-lang
[06:55:56] cschneid: has joined #elixir-lang
[07:00:56] DTZUZO: has joined #elixir-lang
[07:11:05] proteusguy: has joined #elixir-lang
[07:11:58] cschneid: has joined #elixir-lang
[07:13:22] helpa: has joined #elixir-lang
[07:14:27] Ninja3047_: has joined #elixir-lang
[07:14:57] fmccann_: has joined #elixir-lang
[07:15:29] lpil: has joined #elixir-lang
[07:18:01] tgrk: has joined #elixir-lang
[07:18:04] bind: has joined #elixir-lang
[07:19:07] PragTob: has joined #elixir-lang
[07:21:36] gvaughn: has joined #elixir-lang
[07:27:28] za1b1tsu: has joined #elixir-lang
[07:31:12] za1b1tsu_: has joined #elixir-lang
[07:32:51] cschneid: has joined #elixir-lang
[07:35:29] tgrk: has joined #elixir-lang
[07:39:05] shritesh: has joined #elixir-lang
[07:39:14] lpil: has joined #elixir-lang
[07:40:19] Jetimon: has joined #elixir-lang
[07:44:04] cschneid: has joined #elixir-lang
[07:46:33] proteusguy: has joined #elixir-lang
[07:52:02] cschneid: has joined #elixir-lang
[07:58:32] lpil: has joined #elixir-lang
[07:59:12] kapil____: has joined #elixir-lang
[08:03:30] cschneid: has joined #elixir-lang
[08:03:55] ur5us: has joined #elixir-lang
[08:09:54] lpil: has joined #elixir-lang
[08:13:22] DarkSeid: has joined #elixir-lang
[08:15:22] cschneid: has joined #elixir-lang
[08:16:55] mdbm: has joined #elixir-lang
[08:24:08] mdbm: when I enter in IEx: str = "Français"
[08:24:13] mdbm: I have the following result: <<70, 114, 97, 110, 0, 97, 105, 115>>
[08:24:15] mdbm: The ç character is converted into byte 0
[08:24:23] mdbm: I have ConEmu and enabled UTF-8
[08:24:48] mdbm: command chcp prints "Active code page: 65001) (which is UTF-8)
[08:26:10] kyrylo: has joined #elixir-lang
[08:29:06] wonko7: has joined #elixir-lang
[08:33:25] mrus: it seems pretty much impossible to find Elixir "Hello World" examples where there's no pre-built long-running module (e.g. Cowboy/Plug) involved. Nobody seems to care to build a bare "Print Hello World 10 times on the screen" example that follows the Application/GenServer design principles.
[08:39:38] gvaughn: has joined #elixir-lang
[08:40:59] DarkSeid: has joined #elixir-lang
[08:42:17] nicholasruunu: mrus https://github.com/kerryb/genserver-hello-world
[08:43:15] DarkSeid: has joined #elixir-lang
[08:45:34] lpil: mrus: That's pretty much `mix new app_name --sup`
[08:46:30] lpil: Beyond that it depends what you're trying to do
[08:46:38] mrus: nicholasruunu: thanks, unfortunately that example doesn't implement init.
[08:46:54] lpil: init is optional :)
[08:47:07] lpil: What do you with it depends on what you are trying to achieve
[08:47:09] mrus: lpil: unfortunately the mix new command doesn't create an example GenServer
[08:47:37] lpil: There's no need for one unless you have a task in mind. Could you give more of an example of what you want to do?
[08:48:12] lpil: nicholasruunu: It's best not to make a GenServer sleep with Process.sleep/1 as it stops the GenServer responding to messages (including system ones). Instead use Process.send_after
[08:49:07] nicholasruunu: Yeah, didn't make that one. :P
[08:49:23] lpil: Oh cool! Probably best not to share it as an example then.
[08:49:52] nicholasruunu: Looked ok for a hello world example to me.
[08:49:58] mrus: lpil: well, no specific task in mind, I just noticed that all example really just rely on some other module to do all the ground work, but there don't seem to be a lot of examples describing how the heavy lifting can be done manually in case one would want to implement something totally different than yet another Phoenix site or some API project.
[08:50:50] lpil: The problem is largely that the way these tools are used will be very different depending on what you want to achieve, and generally it's best to avoid them and write synchronous code until you have a good reason to do otherwise.
[08:51:11] lpil: If you want to learn about them in the abstract I would recommend the book Learn You Some Erlang https://learnyousomeerlang.com
[08:51:28] lpil: It has plenty of toy projects to learn from
[08:51:49] lpil: It's in Erlang, but it all applies to Elixir
[08:53:59] mrus: lpil: so, let me put it different. Let's assume you're new to Elixir and you ran `mix new myapp --sup` and now you'd like the app to print Hello World on the screen.
[08:55:11] lpil: I would put `IO.puts "Hello, world!"` in Thing.Application.start/2
[08:56:44] mrus: heh :) sure, that's one way
[08:56:55] lpil: I would argue that's the correct way :)
[08:57:06] sevenseacat: without any other requirements, that seems the most appropriate way
[08:57:54] mdbm: how can I display the bytes of a string?
[08:58:06] mrus: well, alright, then I guess my expectations are misaligned here. I would have expected "myapp.ex" to contain an example GenServer that's already connected to application.ex.
[08:58:12] mdbm: (decimal codepoints actually)
[08:58:34] lpil: mdbm String.codepoints/1
[08:58:38] sevenseacat: why do you need a genserver to print hello world
[08:58:47] mrus: well you don't
[08:58:56] mdbm: lpil, this will just print the string on my screen
[08:59:17] lpil: That would almost always be deleted as most applications don't need a top level genserver
[09:00:28] lpil: mdbm: Huh, it should return a list of strings where each is a codepoint. There's some detail for getting them as ints here -> https://hexdocs.pm/elixir/String.html#module-integer-codepoints
[09:08:20] cschneid: has joined #elixir-lang
[09:16:39] mdbm: lpil, I would like to know what are the bytes of this: "ç" and I just can't. In IEx even if I have utf8 configured in ConEmu, it shows byte 0
[09:17:11] mdbm: lpil, I get the decimal codepoint 231 thanks to your doc, but I think it's two bytes then
[09:17:53] lpil: If you want to see the bytes try appending a null byte to make it invalid, then the repl will print it in bitstring format
[09:17:59] lpil: "ç" <> <<0>>
[09:18:47] mdbm: lpil, IO.puts "ç" <> <<0>> just shows ç
[09:19:35] lpil: That's odd. It should print <<195, 167, 0>>
[09:20:10] Nikkel: has left #elixir-lang: ("WeeChat 1.9.1")
[09:20:31] mdbm: yeah not for me
[09:20:45] mdbm: lpil, well you gave me the bytes so I'm ok now haha
[09:21:23] lpil: Might be something up with your Elixir installation, though I couldn't say what...
[09:21:25] mdbm: lpil, but I'm confused now, the decimal codepoint for "ç" is 231, which is less than 255, so why are there two bytes 195 and 167?
[09:21:34] lpil: ACTION shrugs
[09:21:42] lpil: I don't understand utf8
[09:24:08] mdbm: lpil, ok code points higher than 128 take two bytes
[09:25:13] mdbm: lpil, I guess it's because UTF-8 reserves the first bit of each byte to know the number of bytes a character occupies
[09:25:32] mdbm: so 7 bits available, go up to 128
[09:26:03] lpil: Oh cool :)
[09:27:02] mdbm: lpil, in iso-8859-1 or windows-1252 ç takes then only one byte
[09:27:29] mdbm: because they use all 8 bits of the byte
[09:30:20] lpil: Encodings make my head hurt
[09:34:15] voltone: has joined #elixir-lang
[09:40:54] mdbm: lpil, it's easy. You got ASCII encoding which is a 7 bit encoding. Doesn't include characters such as à, é, è, ç, ö and so on. So people invented 8-bit encodings to use that wasted bit, most famous: iso-8859-1 and windows-1252. But not enough for other languages such as Chinese. So then Unicode was invented which defines the codepoint for each character, then you have UTF-8, UTF-16, etc. which are multi-byte encodings
[09:40:55] mdbm: that translates those codepoints into bytes.
[09:41:12] ur5us: has joined #elixir-lang
[09:41:41] rawtaz: lovely explanation mdbm!
[09:43:19] mdbm: thank you, I meant variable length encoding* (e.g. minimum 1 or more bytes for UTF-8, minimum 2 or more bytes for UTF-16)
[09:44:38] dimitarvp: has joined #elixir-lang
[09:45:41] mdbm: note that Unicode is not an encoding, it is the table that maps a character with a codepoint. Then you have UTF-8, UTF-16, etc. which are the encodings using Unicode codepoints to translate those codepoints into bytes.
[09:49:23] blahdodo: has joined #elixir-lang
[09:50:16] gvaughn: has joined #elixir-lang
[09:50:25] rawtaz: lpil: i agree with mdbm - it's easy. and especially if you just go the simple route - make sure everything is utf8, then it will all Just Work[tm]
[09:50:55] rawtaz: every single time ive worked out problems with encoding in systems it's come down to some piece not using utf8. when everything uses utf8, it just works
[09:50:56] lpil: That's my usual approach
[09:51:07] rawtaz: at least for my use cases, i guess some exotic languages could see other types of issues
[09:51:22] lpil: I think using English is easy mode
[09:51:26] rawtaz: btw, Joel Spolsky made a nice article about Unicode many years ago, if you want to read up on it
[09:58:01] DarkSeid: has joined #elixir-lang
[10:08:46] dimitarvp: has joined #elixir-lang
[10:10:27] netrino: has joined #elixir-lang
[10:20:27] ariedler: has joined #elixir-lang
[10:23:33] KeyJoo: has joined #elixir-lang
[10:26:16] DarkSeid: has joined #elixir-lang
[10:31:12] griffinbyatt: has joined #elixir-lang
[10:31:14] craigp_: has joined #elixir-lang
[10:47:43] HendrikPeter: has joined #elixir-lang
[10:49:29] Nicd-: hello HendrikPeter
[10:55:08] ariedler: has joined #elixir-lang
[10:56:03] cschneid: has joined #elixir-lang
[11:01:41] CapNemo: has joined #elixir-lang
[11:06:01] gvaughn: has joined #elixir-lang
[11:06:37] DarkSeid: has joined #elixir-lang
[11:25:42] nox: https://unicode.fyi
[11:37:00] voltone: has joined #elixir-lang
[11:43:06] __charly__: has joined #elixir-lang
[11:49:52] serafeim: has joined #elixir-lang
[11:52:27] shmink: has joined #elixir-lang
[12:05:52] serafeim_: has joined #elixir-lang
[12:21:35] k1nd0f: has joined #elixir-lang
[12:25:05] serafeim_: has joined #elixir-lang
[12:31:42] cschneid: has joined #elixir-lang
[12:32:25] voltone: has joined #elixir-lang
[12:32:55] either|or: has joined #elixir-lang
[12:34:53] inoas: has joined #elixir-lang
[12:35:53] serafeim__: has joined #elixir-lang
[12:58:17] gvaughn: has joined #elixir-lang
[13:02:22] proteusguy: has joined #elixir-lang
[13:09:16] drincruz: has joined #elixir-lang
[13:12:35] tnez: has joined #elixir-lang
[13:12:40] duane: has joined #elixir-lang
[13:18:49] serafeim_: has joined #elixir-lang
[13:27:02] DarkSeid: has joined #elixir-lang
[13:33:59] wsieroci: has joined #elixir-lang
[13:40:56] ariedler: has joined #elixir-lang
[13:43:44] cmk_zzz: has joined #elixir-lang
[13:47:33] duane: has joined #elixir-lang
[13:49:12] mdbm: has joined #elixir-lang
[13:56:30] PragTob: has joined #elixir-lang
[13:57:41] shritesh: has joined #elixir-lang
[14:09:15] gvaughn: has joined #elixir-lang
[14:10:02] lizzin: has joined #elixir-lang
[14:11:26] cschneid: has joined #elixir-lang
[14:19:09] gvaughn: has joined #elixir-lang
[14:21:57] lizzin: has joined #elixir-lang
[14:25:00] za1b1tsu: has joined #elixir-lang
[14:29:15] cschneid: has joined #elixir-lang
[14:35:07] duane: has joined #elixir-lang
[14:36:48] warmwaffles: has joined #elixir-lang
[14:44:59] jeffro: has joined #elixir-lang
[14:47:01] voltone: has joined #elixir-lang
[14:53:07] 7JTABIYQC: has joined #elixir-lang
[14:58:16] jeffro_: has joined #elixir-lang
[14:58:39] snapet: has joined #elixir-lang
[15:01:24] 7ITAADJK7: has joined #elixir-lang
[15:02:10] 7ITAADJLB: has joined #elixir-lang
[15:02:31] ios: has joined #elixir-lang
[15:08:07] 18WAAITP7: has joined #elixir-lang
[15:09:33] jmiven: has joined #elixir-lang
[15:13:49] aalmazan: has joined #elixir-lang
[15:19:44] duane: has joined #elixir-lang
[15:20:55] wonko7: has joined #elixir-lang
[15:22:48] maxbeizer: has joined #elixir-lang
[15:26:58] davidw: has joined #elixir-lang
[15:40:55] voltone: has joined #elixir-lang
[15:48:32] Saukk: has joined #elixir-lang
[16:14:03] torwegia: has joined #elixir-lang
[16:18:04] laut: has joined #elixir-lang
[16:20:09] shmink: Is there a way when in iex and you do an ecto query you don't see the debug information outputed?
[16:20:23] shmink: I'm guessing there is some kind of flag I could pass?
[16:22:15] dysfun: you can either set the minimum logging level for the application or ecto's log level
[16:22:33] shmink: how would one go about that? :)
[16:23:03] dysfun: the former, `config :logger, level: :error` in your relevant config
[16:23:57] shmink: Champion :)
[16:27:32] umamaistempo: has joined #elixir-lang
[16:27:36] umamaistempo: Good mowning o/
[16:34:29] orbyt_: has joined #elixir-lang
[16:37:12] greengriminal: has joined #elixir-lang
[16:41:32] orbyt_: has joined #elixir-lang
[16:48:02] orbyt_: has joined #elixir-lang
[16:56:39] mrus: What's the proper way to implement a GenServer that is able to retrieve messages (`receive do ..`) and process them?
[16:57:00] dysfun: handle_info
[16:57:53] duane: has joined #elixir-lang
[16:58:47] mrus: dysfun: so, simply return the desired state from init() and then have handle_info retrieve it as soon as some other process posts something to the GenServer's inbox?
[17:01:11] dysfun: handle_info is a callback, you don't retrieve it, you handle it
[17:01:34] mrus: yup, sorry, that's what I meant.
[17:02:47] hypercore: has joined #elixir-lang
[17:03:23] felipevolpone: has joined #elixir-lang
[17:06:18] duane: has joined #elixir-lang
[17:08:12] dysfun: genserver handles the message loop. handle_info is called for messages that weren't sent through genserver
[17:08:26] dysfun: (i.e. isn't a call, isn't a cast)
[17:09:40] pera: has joined #elixir-lang
[17:09:48] mrus: cool, just tested it, works. Thank you! I'm just wondering... I see the init() output a couple of times now. And every time init starts with an empty state.
[17:10:08] dysfun: init starts with whatever you tell it to start with
[17:10:19] mrus: yeah I know.. I just thought it would run once.
[17:10:30] mrus: but it looks like it's being run 3 or 4 times
[17:10:43] dysfun: then you should find out what's wrong :)
[17:12:06] mrus: When I remove handle_info it only show the init output once.
[17:12:28] dysfun: very weird
[17:13:26] mrus: Could it be that the code inside handle_info is silently crashing what would lead to the GenServer being restarted a couple of times?
[17:14:11] dysfun: have you turned the log level right down?
[17:15:03] mrus: haven't adjusted it and running MIX_ENV=dev, so.. hm.
[17:15:14] dysfun: i mean ordinarily i'd expect to see a process crash quite loudly on my terminal
[17:15:35] dysfun: pastebin the module code?
[17:16:48] mrus: dysfun: https://pastebin.com/R6jhCMAe
[17:18:54] dysfun: my gut feeling is your `with` block in init has something not returning what you think
[17:20:07] dysfun: wait why are all those = not <- ? what's the point in the with block?
[17:20:19] mrus: it returns an array of References (`[#Reference<0.951360907.333053985.34902>, ...]`) which is fine for me.
[17:20:51] mrus: you're right with the <-
[17:20:54] dysfun: handle_info should return {:noreply, state}
[17:21:22] dysfun: and turn up your logging level :)
[17:21:46] mrus: ah! That did it, nice.. thank you!
[17:36:14] DarkSeid: has joined #elixir-lang
[17:58:15] shmink: I would like to set up a docker container where it has my elixir project loaded in and ready to go. You would then go interactivley into it at command line where you would be able to run `mix test` for example.
[17:58:27] serafeim: has joined #elixir-lang
[18:01:42] dysfun: docker run ; docker ssh
[18:02:14] dysfun: or docker exec
[18:02:34] Phylock: has joined #elixir-lang
[18:03:28] orbyt_: has joined #elixir-lang
[18:03:49] shritesh: has joined #elixir-lang
[18:06:01] umamaistempo: has joined #elixir-lang
[18:08:33] blahdodo: has joined #elixir-lang
[18:09:05] mrus: or distillery
[18:09:19] dysfun: distillery for dev?
[18:09:49] mrus: it would run mix test on build
[18:15:00] lizzin: has joined #elixir-lang
[18:15:40] HendrikPeter: has joined #elixir-lang
[18:18:12] squall: has joined #elixir-lang
[18:30:54] k1nd0f: has joined #elixir-lang
[18:36:51] shmink: dysfun: what would my dockerfile look like? I mean I have the following so far but not sure how to wrap it up https://hastebin.com/ekoliqevar.css
[18:38:19] dysfun: you'll want to mount the directory into it
[18:38:25] dysfun: rather than copy
[18:38:36] dysfun: for development, i mean
[18:42:02] mahmudov: has joined #elixir-lang
[18:43:18] shmink: I'll explain my situation. I'm completing a technical exercise for a potential job oppurtunity. They let me choose to do it in any language. I done it in elixir but I don't want the possibility of them not being able to install elixir correctly or whatever so I was thinking having a container removed that potential risk. So they could just run the image and then going interactivley into it they could then just go ahead
[18:43:18] shmink: and run tests or go into iex or whatever else. So I don't think a volume would be the best for this perhaps?
[18:55:43] orbyt_: has joined #elixir-lang
[19:21:26] shritesh: has joined #elixir-lang
[19:44:31] DarkSeid: has joined #elixir-lang
[19:44:36] toure: has joined #elixir-lang
[19:51:48] lizzin: has joined #elixir-lang
[20:00:08] kyrylo: has joined #elixir-lang
[20:09:18] HendrikPeter: has joined #elixir-lang
[20:19:36] work_: has joined #elixir-lang
[20:31:03] HendrikPeter: has joined #elixir-lang
[20:35:27] wsieroci: has joined #elixir-lang
[20:47:16] HendrikPeter: has joined #elixir-lang
[20:47:29] orbyt_: has joined #elixir-lang
[20:58:53] inoas: has joined #elixir-lang
[21:02:50] hypercore: has joined #elixir-lang
[21:16:09] ur5us: has joined #elixir-lang
[21:27:17] inoas: is ecto conventioned around plural or singular only btw? as for table names, foreign keys etc?
[21:27:26] inoas: pain again with matrix/matrices
[21:45:43] whatyouhide: inoas: i *think* singular except for table names
[21:46:07] inoas: urgh... so again peoples => person_id?
[21:46:11] inoas: matrices => matrix_id
[21:46:24] inoas: Can I switch that to be either singular or plural only?
[21:47:01] josevalim: inoas: ecto doesn’t care about your table names
[21:47:05] josevalim: So whatever you want
[21:47:14] josevalim: Everything else is singular
[21:47:15] inoas: ah it uses the fks of the database right?
[21:47:20] inoas: josevalim: good pick.
[21:47:32] inoas: the inflector stuff in rails/cakephp3 annoys me to death :(
[21:55:37] lizzin: has joined #elixir-lang
[22:05:21] pera: has joined #elixir-lang
[22:05:43] __charly__: has joined #elixir-lang
[22:11:08] lao-tzu: has joined #elixir-lang
[22:24:12] Vircung: has joined #elixir-lang
[22:37:06] orbyt_: has joined #elixir-lang
[22:54:46] toure: has joined #elixir-lang
[23:00:33] lauromoura_: has joined #elixir-lang
[23:03:30] starbelly: josevalim: You should give a talk on when it's a good thing to side step ecto and just go for SQL :)
[23:09:26] toure: has joined #elixir-lang
[23:22:57] starbelly: Feel free to ask me about it... it really has to do with extremes... i.e., using your tool vs fighting it... it's no fault of ecto, but a human problem really. But I think until devs in general hear from the mouth of an "authority", then they will try to do everything possible to use that tool, even when it's folly.
[23:24:51] starbelly: there's a lot of examples where it's just simpler and more time efficient to use some raw sql and query/4 vs spending a LOT of time trying to conform to a pattern or perceived prescribed way of doing things. This applies to phoenix too I think... and I mean, every other tool right... but when it comes to web dev etc. this is especially true.
[23:25:52] starbelly: As stated, regretfully, until they you, or Chris Mccord, or whomever say it, and point it out... the anti-pattern of conforming to patterns etc. results in time lost and more problems created vs solved.
[23:34:41] pera: has joined #elixir-lang
[23:43:15] lizzin: has joined #elixir-lang
[23:53:47] lizzin_: has joined #elixir-lang