ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
qard has joined #crystal-lang
qard has quit [Ping timeout: 256 seconds]
sz0 has joined #crystal-lang
<FromGitter> <faustinoaq> Groogy, your code is not that bad 😉 Just remove some indentation by using some extra def's
<FromGitter> <fgimian> Hey guys, I'm trying to define the following struct in Crystal atm
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a04b052e35117cde4718a]
<FromGitter> <fgimian> However, Crystal doesn't like the fact that the attributes begin with an uppercase character.
<FromGitter> <fgimian> I'm concerned that if I change these names to lowercase, the binding won't work.
<FromGitter> <fgimian> Am I missing something?
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a04fca7abc8692ee8aaad]
<FromGitter> <fgimian> this is where I'm at 😄
<FromGitter> <fgimian> answered here 😄
<FromGitter> <fgimian> ok I'll proceed
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<FromGitter> <faustinoaq> @fgimian Also check: https://github.com/crystal-lang/crystal/pull/4934
<FromGitter> <fgimian> thanks @faustinoaq 😄
<FromGitter> <faustinoaq> Oh, I just realize `--profile` is an available flag 😄 https://github.com/crystal-lang/crystal/issues/3186#issuecomment-392299206
<FromGitter> <evandrojr> Hi guys! I am getting this error while trying to build crystal from sources
<FromGitter> <evandrojr> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a0d0f4eaffb692d5b04dc]
<FromGitter> <evandrojr> I added llvm from here:
<FromGitter> <evandrojr> Xenial (16.04) - Last update : Wed, 23 May 2018 05:23:55 UTC / Revision: 333043 ⏎ ⏎ deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main ⏎ deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main [https://gitter.im/crystal-lang/crystal?at=5b0a0d36edd06f7d15e7c7bd]
<FromGitter> <evandrojr> But is seems to be using a old version of llvm
<FromGitter> <evandrojr> I am using Linux Mint 18 that is compatible with Ubuntu 16.04
<FromGitter> <evandrojr> I have seen this post: https://github.com/crystal-lang/crystal/issues/5739 but how do I tell the compiler to use the newest LLVM?
<FromGitter> <fgimian> One more tiny question from me too, what's the most equivalent and safe LibC type to use for `wchar_t`?
<FromGitter> <evandrojr> Managed to install llvm7 but the error continues
<FromGitter> <evandrojr> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a105752e35117cde4881b]
<FromGitter> <faustinoaq> https://speakerdeck.com/matz/ruby-everywhere ⏎ ⏎ Wow, I come from Python and I just realize Ruby is better than I though 😄
rohitpaulk has joined #crystal-lang
<FromGitter> <fgimian> @faustinoaq Same here, I don't miss much about Python having used Crystal for a few days. I've coded a bit in Ruby in the past too and always enjoyed it. I would honestly say that Ruby / Crystal are more "beautiful". The import system in Ruby/Crystal is more like C/C++ though, while Python has a very strict way to ensure no namespace collisions.
<FromGitter> <fgimian> Python is an awesome language though, and I havev been coding in it since 2011 and always enjoyed it too 😄
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <S-YOU> For wchat_t, I think you need to define it inside {% if flag?(x86_64) %} or even by OS flags
<FromGitter> <fgimian> @S-YOU thanks, I'll see if I can find an example of that in the Crystal source now 😄
<FromGitter> <S-YOU> @evandrojr, I am not sure you could use LLVM 7 to compile crystal, working LLVM is 5 as far as I noticed.
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <fgimian> @S-YOU Sorry, but just one more question if I may; any idea how I can do this in Crystal ⏎ ⏎ ```typedef int (CALLBACK *UNRARCALLBACK)(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2);`````` [https://gitter.im/crystal-lang/crystal?at=5b0a2025edd06f7d15e7ec1f]
<FromGitter> <fgimian> 😕
<FromGitter> <evandrojr> thank @S-YOU here @RX14 said to use the newest but I guess 7 is too new!
<FromGitter> <S-YOU> I think something like ⏎ `alias UNRARCALLBACK = (msg : UInt32, user_data : LPARAM, p1 : LPARAM, p2 : LPARAM) -> CALLBACK*`
<FromGitter> <bew> note: it doesn't return a `CALLBACK*`, but a `int`
<FromGitter> <S-YOU> Ah, then -> Int32, sorry I am not good at C/C++.
<FromGitter> <fgimian> thank you so much @S-YOU !!!!
<FromGitter> <fgimian> 🍻
<FromGitter> <S-YOU> 🍻
<FromGitter> <fgimian> hehehe 😄
<FromGitter> <fgimian> ok I'm super duper close now 😄 ... I have SOMETHING working
<FromGitter> <fgimian> this library uses lots of static strings
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a28f1a7abc8692ee8ee17]
<FromGitter> <fgimian> so the final thing I'm trying to figure out is how to convert a StaticArray of unsigned 8 bit ints to a string
<FromGitter> <bew> `String.new(the_array.to_slice)`
<FromGitter> <fgimian> thanks @bew testing now!
<FromGitter> <fgimian> 👯 💃 👯
<FromGitter> <bew> Note that you'll end up with a string of size 1024
<FromGitter> <bew> but the actual content is probably less than that
<FromGitter> <fgimian> I see, is that'll do for now, but is there any way to strip off the \0s?
<FromGitter> <fgimian> yeh it is
<FromGitter> <bew> you could send a pointer, like `String.new(the_array.to_unsafe)` and the String constructor will do a `LibC.strlen` to find out the size of the string (finding the first \0)
<FromGitter> <bew> or if you have another way to get the size, you can pass it as 2nd param
sz0 has joined #crystal-lang
<FromGitter> <fgimian> thanks so much @bew
<FromGitter> <fgimian> sorry for the late reply, was just grabbing lunch
<FromGitter> <michaelteter_twitter> Super-beginner question... I see how to init (create) an app, and I know how to run a single file.cr, but what is the standard way of running a project? In some other languages, the build tool will have a concept of "build and run the project from this top level project directory"
<FromGitter> <fgimian> @michaelteter_twitter are you perhaps just looking for the `crystal build` command that will build a binary for you?
<FromGitter> <fgimian> 😄
<FromGitter> <michaelteter_twitter> Yes, but without args I just get a usage output
<FromGitter> <michaelteter_twitter> for example, in Clojure with Leiningen, in the top level directory of my project i would just "lein run"
<FromGitter> <michaelteter_twitter> So if my project is dbtest, and I am in dbtest/, I need to type crystal ./src/program.cr
<FromGitter> <fgimian> that's my understanding thus far with Crystal, you must reference the top-level `*.cr` file as far as I know
<FromGitter> <fgimian> *Disclaimer*: I only started coding in Crystal on Friday
<FromGitter> <fgimian> 😆
<FromGitter> <michaelteter_twitter> ahh ok
<FromGitter> <fgimian> perhaps someone more experienced can confirm this 😄
<FromGitter> <michaelteter_twitter> well I guess crystal build src/prog.cr is fine. it generates an executable "prog" in the top directory
<FromGitter> <fgimian> yep
<FromGitter> <fgimian> 😄
<FromGitter> <michaelteter_twitter> Thanks
<FromGitter> <fgimian> np mate, glad I could help
<FromGitter> <michaelteter_twitter> I didn't get very far before I got stuck again! Trying to make a connection to postgres, but I can't figure out what name to require to use the crystal-pg shard
<FromGitter> <michaelteter_twitter> I've tried "pg", "crystal-pg", "postgres", etc. The Crystal docs show "mysql", which I'm sure works for mysql. But sadly the crystal-pg readme doesn't have an example.
<FromGitter> <bew> It should be pg
<FromGitter> <bew> Did you installed the shard?
<FromGitter> <michaelteter_twitter> Thanks. I guess it's late and I'm tired. I tried "PG" but not "pg". Now it builds.
dragonkh has quit [Ping timeout: 248 seconds]
<FromGitter> <michaelteter_twitter> now to find a connection string example that includes username and password...
<FromGitter> <michaelteter_twitter> (for pg)
<FromGitter> <bew> Probably the same as everything: `user:passwd@host:port` or sth like that
<FromGitter> <bew> Probably with `postgres://` in front of that
<FromGitter> <michaelteter_twitter> Perhaps
<FromGitter> <michaelteter_twitter> That was it, thank you
dragonkh has joined #crystal-lang
dragonkh has quit [Read error: Connection reset by peer]
<FromGitter> <hmans> @michaelteter_twitter - you would be looking for `shards run`, which sadly does not exist at this moment -- I remember seeing a discussion on GitHub where people weren't exactly agreeing on how much tooling shards should provide that you could otherwise get from established tools like `make`.
<FromGitter> <hmans> I did stumble over this too, when I was starting out. `shards` certainly set the expectation that it would also be able to run a project
<FromGitter> <michaelteter_twitter> I know this is a young language and tooling, so I can live with it :) I was just a bit lost... And from the examples I've seen, I haven't noticed a start to finish demonstration of some of these things.
rohitpaulk has joined #crystal-lang
<FromGitter> <fgimian> I've got another little / weird question. It seems that the RAR C library uses a widechar for its unicode strings. i.e. a static array of UInt32T. Now I "believe" this means that it's UTF-32 encoded. My archive name is `capsule_container.rar` and I can see the following being return from the library: ⏎ ⏎ ```arc_name_w: StaticArray[99_u32, 97_u32, 112_u32, 115_u32, 117_u32, 108_u32, 101_u32, 95_u32,
<FromGitter> ... 99_u32, 111_u32, 110_u32, 116_u32, 97_u32, 105_u32, 110_u32, 101_u32, 114_u32, 46_u32, 114_u32, 97_u32, 114_u32, 0_u32, 0_u32, 0_u32, 0_u32, ...```
<FromGitter> <fgimian> Can you suggest a way that I can convert this to and from a regular UTF-8 String as used by Crystal?
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <fgimian> i think that perhaps I'm misunderstanding, I'm certain they use a UInt32 for each character, but indeed that could be storing each character in UTF-8 encoding ... this stuff always confuses me 😆
<FromGitter> <fgimian> ok so yeah, unicode characters can be up to 4 bytes, and this is the length of a UInt32, so I guess it IS UTF-8
<FromGitter> <fgimian> but I'm just not sure how to "convert it" to a String 😄
<FromGitter> <fgimian> ```header_data.arc_name_w[0].chr``` gives me the character
<FromGitter> <hmans> https://play.crystal-lang.org/#/r/45hg - This still confuses me. Why would the compiler complain about `greet(name : Nil)` not being implemented, considering the path through the code is pretty static?
<FromGitter> <hmans> I would have expected the `if ` in line 23 to mark `user.name` as non-nil within this branch
<FromGitter> <hmans> Oh!
<FromGitter> <hmans> I remember that detail from the book about assigning something to a local variable first.
<FromGitter> <hmans> This works fine: https://play.crystal-lang.org/#/r/45hh
<FromGitter> <hmans> Thanks for being my rubberdruck, everyone \o/
<FromGitter> <bew> what if the second time `user.name` returns nil? the compiler can't assert that it won't change
<FromGitter> <hmans> @bew That makes complete sense. Thanks.
<FromGitter> <hmans> It'd be great to be able to write one-liners like `greet name if name = user.name`
<FromGitter> <hmans> Best alternative I can come up with for now: `(name = user.name) && greet name`
<FromGitter> <bew> great I don't know, I prefere the multi-line form, to better see the condition and the new variable
<FromGitter> <hmans> Yeah, I'm not being entirely serious about using the form I just posted, it does obfuscate intent more than I like.
<FromGitter> <hmans> (I'm building an ATOM feed builder, and I'm doing these sanity checks within its implementation to keep the usage as straight-forward as possible)
<FromGitter> <S-YOU> `greet name if name = user.name` works? https://play.crystal-lang.org/#/r/45i0
<FromGitter> <hmans> @S-YOU It does there because the code initialized `name` earlier
<FromGitter> <S-YOU> I see. assigning to nil changed behavior of variable. Didn't realize that.
<FromGitter> <S-YOU> I am not sure what is the correct way to convert UInt32 to string, but you can do like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a54b8352b9e1a4b370a49]
<FromGitter> <fgimian> thanks!
<FromGitter> <fgimian> yeah, the only thing I would like is to stop when I hit the null terminator, so I unded up with an uglier loop
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a57cab6eece791db7881c]
<FromGitter> <fgimian> This is the best I could come up with 😄
<FromGitter> <fgimian> I added a Chinese character in there to test unicode properly
<FromGitter> <S-YOU> Actually Decoder class(private) in IO (io/encoding.cr) should do that properly with Iconv, but I couldn't come up with working solution.
<FromGitter> <bararchy> Just figured out that ⏎ ⏎ ```crystal tool forma``` ⏎ ⏎ t excluded, will also run the `crystal tool format` command [https://gitter.im/crystal-lang/crystal?at=5b0a59af4eaffb692d5ba584]
<FromGitter> <bararchy> is this a bug? or a feature for typos :)
<FromGitter> <godmode97> so i am running crystal on my windows machine and it gave me an error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a5a3d4eaffb692d5ba638]
moei has quit [Quit: Leaving...]
<FromGitter> <bararchy> @godmode97 you are missing dev libs, if you're on Ubuntu please run `apt-get install libxml2-dev`
<FromGitter> <godmode97> im using ubuntu on windows, thank you @bararchy , kemal is running now :)
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> 👍
rohitpaulk has quit [Ping timeout: 260 seconds]
<FromGitter> <hmans> @godmode97 How is the Linux subsystem in Windows working out for you? After more than a decade of developing on a Mac, I'm tempted to give that a try...
Nik736 has joined #crystal-lang
<FromGitter> <S-YOU> Is this normal? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a708a54ce2313615a6cd0]
<FromGitter> <S-YOU> Same for this too. ⏎ ⏎ ```lib LibA ⏎ $b : UInt8[12] ⏎ end ⏎ ⏎ x = LibA.b``` [https://gitter.im/crystal-lang/crystal?at=5b0a71e1016ae21a4ce96bff]
<FromGitter> <hmans> Is it possible to programmatically add another path to the list of paths searched by `require`?
<FromGitter> <S-YOU> CRYSTAL_PATH=your_path crystal build your_program.cr?
<FromGitter> <hmans> Programmatically as in: from within my code. Sorry, I should have been clearer about that.
<FromGitter> <S-YOU> After compile?
<FromGitter> <hmans> During
<FromGitter> <hmans> I'm not counting on it, it was just something I was wondering.
<FromGitter> <S-YOU> Interesting
<FromGitter> <S-YOU> How about modifying ENV['CRYSTAL_PATH']?
<FromGitter> <hmans> I'm 100% positive that will not work
<FromGitter> <S-YOU> really
<FromGitter> <S-YOU> Looks like it is baked into compiler, I see.
<FromGitter> <hmans> Explicitly setting CRYSTAL_PATH in my build pipeline will be fine
Raimondii has joined #crystal-lang
<FromGitter> <S-YOU> Right
Raimondi has quit [Ping timeout: 252 seconds]
Raimondii is now known as Raimondi
moei has joined #crystal-lang
<Groogy> faustinoaq: I'm probably going to move the whole "find widgets to paint and call graphics to paint them" to it's own callss
<Groogy> class*
<Groogy> going to make it look prettier and split up responsibilities a bit better
<FromGitter> <evandrojr> Hi guys! Do you have any clue of what is going on here: https://github.com/crystal-lang/crystal/issues/6134 it is happening with LLVM 3.8 and 7
<Groogy> does crystal still support llvm version 3.8? 🤔
<Groogy> wow
<FromGitter> <evandrojr> It says in the docs
<FromGitter> <evandrojr> The official crystal docker image uses LLVM 3.5
<Groogy> yeah no just suprised
<FromGitter> <fgimian> Folks, is there any way to access `!functions` in YAML: ⏎ ⏎ e.g. ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5b0a80d7352b9e1a4b377078]
<FromGitter> <fgimian> I'd like to access `!join`
That_Guy_Anon has joined #crystal-lang
<FromGitter> <fgimian> or to setup a function that runs against it
<FromGitter> <fgimian> In Python this is done with the function `yaml.add_constructor`
<FromGitter> <fgimian> I believe these are technically called *tags* 😄 (just double checked, hehe)
<Groogy> hmm been looking through and haven't seen any obvious way in the documentation
<FromGitter> <evandrojr> thanks groogy
<FromGitter> <evandrojr> what distribution id
<FromGitter> <evandrojr> what is the easiest linux dist to build crystal?
<FromGitter> <evandrojr> the docker official image does not work
rohitpaulk has joined #crystal-lang
<Groogy> I built it on Arch
<Groogy> the repo maintainer fucked up so had to build it manually
<FromGitter> <evandrojr> here is does not tell the arch deps https://github.com/crystal-lang/crystal/wiki/All-required-libraries
<FromGitter> <evandrojr> do you have it?
<FromGitter> <evandrojr> I am tryng the arc official docker but it seems to be missing parts
<FromGitter> <evandrojr> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0a8cf454ce2313615ab074]
<Groogy> eh that looks like arch is missing the actual repositories?
<Groogy> docker is Mac's like virtual linux thingy or?
<FromGitter> <bararchy> Hi Groogy :) long time
rohitpaulk has quit [Ping timeout: 245 seconds]
<Groogy> Yo! Yeah Pdxcon over and I've finally had time to restafter that :D
<Groogy> rest after*
<FromGitter> <bararchy> how's your mega game engine going?
rohitpaulk has joined #crystal-lang
<Groogy> forward I guess, mostly focusing on the game ^^
<FromGitter> <evandrojr> this commnad pacman -Syy fixed the repos
<FromGitter> <bararchy> Groogy you mean `ego` ?
<Groogy> yeh
sz0 has quit [Quit: Connection closed for inactivity]
That_Guy_Anon has quit [Remote host closed the connection]
<Groogy> ugh I want to implement noise based random and all I get is hardware based random generators D:
<FromGitter> <evandrojr> hi gyd
<FromGitter> <evandrojr> hi guys, the official docker image is not building crystal: https://github.com/crystal-lang/crystal/issues/6136
<FromGitter> <evandrojr> where is crystal source code meant to be?
p0p0pr37_ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37_ is now known as p0p0pr37
<Groogy> Aaaah found the lecture, knew I had seen it somewhere ages ago
<Groogy> really interesting if you find random interesting
rohitpaulk has joined #crystal-lang
Nathanaelle has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
<Groogy> hmmm trying to debug using lldb but it keeps saying I am not in a thread, thought lldb worked with crystal?
<Groogy> an exception is thrown and I want to step through how it gets to that point :/
<FromGitter> <bararchy> does GDB work for you?
<Groogy> hmm doesn't for me... hmm
<Groogy> I tried manually in the terminal though
<Groogy> and when exception was thrown GDB said "no stack" and LLDB said "no thread"
<FromGitter> <fgimian> Hey guys, can you confirm this bug? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0aa756a7abc8692eea1d2f]
<FromGitter> <fgimian> In Crystal 0.23.x it works correctly and outputs ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0aa76dba1a351a68c9d412]
<FromGitter> <fgimian> however, in the latest version 0.24.1 and 0.24.2, it doesn't output the `null`
<FromGitter> <fgimian> Also tested on the web compiler, and that's how I noticed which version broke it
dreamer_ has joined #crystal-lang
<dreamer_> crsfml works fine with xming and WSL
Nathanaelle has quit [Read error: Connection reset by peer]
<Groogy> that does sound like an issue if you ask me @fgimian
<Groogy> brb
Groogy has quit [Quit: WeeChat 2.1]
Nathanaelle has joined #crystal-lang
<FromGitter> <fgimian> thanks, is there an easy way to grab a build of the master branch so I can verify it before submitting an issue?
<FromGitter> <fgimian> I'm just installing `llvm` and hoping that will let me build the latest master branch on my Mac 😄
<FromGitter> <evandrojr> I guys! I managed to build crystal! there is a dep missing for ubuntu llvm-dev it is likely to be missing for other distros
<FromGitter> <fgimian> Sweet @evandrojr, you're one step ahead of me hehehe 😄
Groogy has joined #crystal-lang
<FromGitter> <evandrojr> I just fixed that dep for ubuntu. I didn't know I had that permission. Cool! https://github.com/crystal-lang/crystal/wiki/All-required-libraries
<FromGitter> <evandrojr> Is it public to edit?
<FromGitter> <fgimian> 😟
Nathanaelle has quit [Ping timeout: 252 seconds]
* FromGitter * fgimian didn't know that page existed, thanks!
Nathanaelle has joined #crystal-lang
That_Guy_Anon has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 264 seconds]
p0p0pr37_ is now known as p0p0pr37
dreamer_ has quit [Quit: Leaving]
<FromGitter> <fgimian> Have a great week everyone, I'm off for the night 😄
<FromGitter> <evandrojr> Hi guys, do you think it is feasible to have a pc command that would be PrettyPrint p with colored output?
<FromGitter> <evandrojr> It would suppose that the terminal background color is back
<FromGitter> <evandrojr> But that could be set up
<Groogy> You mean using the escape sequences in bash or?
<FromGitter> <evandrojr> Using same way that colorize currently uses
<FromGitter> <evandrojr> to get something like that: https://github.com/evandrojr/awesome_print.cr but with PrettyPrint power of identation of nested data structures
<FromGitter> <drum445> why do I get this: ⏎ ```time_left = finish_time.total_seconds``` ⏎ ```protected method 'total_seconds' called for Time```
<FromGitter> <evandrojr> @ed did you try the second method?
rohitpaulk has joined #crystal-lang
<oprypin> drum445, https://crystal-lang.org/api/0.24.2/Time.html no such thing total_seconds here, so don't try to call it
That_Guy_Anon has quit [Quit: Leaving]
<oprypin> wait a minute
<FromGitter> <drum445> Nah it does work, my code was just wrong lol ;)
<FromGitter> <drum445> fixed now, cheers
<FromGitter> <drum445> Do you know the JSON.mapping. Is there a way to have the object param be "time_left" but the json name be "timeLeft" ⏎ I don't like having to use camel case param names in ruby
<oprypin> yes there is, see docs https://crystal-lang.org/api/0.24.2/JSON.html#mapping%28_properties_%2Cstrict%3Dfalse%29-macro
<oprypin> > ruby
<FromGitter> <drum445> oh they key is perfect, thanks
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <drum445> What is the standard: ⏎ ⏎ ```class X ⏎ property id, name, age``` [https://gitter.im/crystal-lang/crystal?at=5b0ac07e160c567d16dfbe4f]
<oprypin> drum445, not comma. also specify types.
<FromGitter> <drum445> cool, so one line per param ⏎ ⏎ ```class X ⏎ property id : Int32 ⏎ property name : String ⏎ property age : Int32``` [https://gitter.im/crystal-lang/crystal?at=5b0ac4f993dc78791c8c8084]
<FromGitter> <drum445> ?
<oprypin> seems good
jokke has quit [Quit: WeeChat 2.1]
jokke has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 256 seconds]
p0p0pr37_ is now known as p0p0pr37
Nik736 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
alex`` has quit [Ping timeout: 260 seconds]
return0e has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
<FromGitter> <michaelteter_twitter> Has anyone used stumpy_core shard? I tried to add it to my shards file, but I get `Error resolving stumpy_core (*, ~> 1.8, ~> 1.7.0)`
<FromGitter> <michaelteter_twitter> unfortunately the github readme for the stumpy projects don't show examples of how it should be stated in the shards.yml file, so maybe I've described things wrong...
<FromGitter> <michaelteter_twitter> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0ae07fa45f930a65dc024a]
<RX14> stumpy_core's latest release is 1.8.2
<RX14> wait a sec
<FromGitter> <michaelteter_twitter> I didn't specify a version, so shouldn't it just grab the most current?
<RX14> yes it should
<RX14> stumpy_png depends on stumpy_core
<FromGitter> <michaelteter_twitter> I removed the version from png as well. same problem
<FromGitter> <michaelteter_twitter> are the dependencies not fetched in order?
<RX14> nope
<RX14> i see the problem
<RX14> the latest tagged version of stumpy_core specifies ~> 1.8
<RX14> oops
<RX14> the latest tagged version of stumpy_png specifies ~> 1.8
<RX14> the latest tagged version of stumpy_utils specifies ~> 1.7
<RX14> and those are incompatible
<RX14> stumpy_utils is the one specifying ~> 1.7.0
<FromGitter> <michaelteter_twitter> hmm
<RX14> so it needs to be forced `branch: master`
Nathanaelle has quit [Ping timeout: 260 seconds]
<FromGitter> <michaelteter_twitter> Is stumpy the only (or best) library for drawing? I just need some primative drawing tools and the ability to generate svg or png
<RX14> i think it's really the only one
<FromGitter> <michaelteter_twitter> Sorry, which needs to be branch: master? This is my 3rd hour of exposure to Crystal, so I'm not clear on much of this initial stuff
<RX14> the problem is that stumpy_png depends on stumpy_core 1.8.x and stumpy_utils depends on stumpy_core 1.7.x
<RX14> stumpy_utils has a commit in master to fix this
<RX14> but it's not in a release yet
<RX14> so you should force branch: master on stumpy_utils
<FromGitter> <michaelteter_twitter> Understood. So I put "branch: master" under the stumpy_utils dep
<RX14> yes
<FromGitter> <michaelteter_twitter> thanks
<RX14> and you can remove the stumpy_core one :)
<RX14> if you want
Nathanaelle has joined #crystal-lang
<FromGitter> <michaelteter_twitter> excellent, thank you very much!
<RX14> no problem
<RX14> the error message should be improved tbh
<RX14> say which dependencies have which version specifiers
<RX14> then you'd know that stumpy_png depends on stumpy_core 1.8.x and stumpy_utils depends on stumpy_core 1.7.x
<RX14> and that's a pretty good place to start debugging
<RX14> i hate that gitter appends _twitter to some people's usernames
return0e has joined #crystal-lang
<FromGitter> <michaelteter_twitter> yup, sorry. I didn't even want to use twitter, but I didn't like the other two oauth login options
<Vexatos> I mean you could change the bot to remove any _twitter
<RX14> thats not a bijective mapping Vexatos
<Vexatos> The chance of that actually being part of a username is rather low I feel
<Vexatos> well true I guess
<RX14> and the chances of it being abused are high?
<Vexatos> RX14, I mean I could change the hexchat script to not show it, but autocomplete to still use it
<Vexatos> The version you have is specific to you anyway soo
<oprypin> Vexatos, problem is to ping that person you need the suffix
<Vexatos> yea which is why I suggested the latter to RX14
<RX14> yes but what if you have both
<Vexatos> Hm
<Vexatos> well they would show up as the same person
<RX14> what if someone signs up to gitter with asterite_twitter
<oprypin> there is, like, one user of the hexchat script, so whatever
<Vexatos> tab complete would obviously still distinguish them
<RX14> and then I dont notice
Nathanaelle has quit [Ping timeout: 260 seconds]
<RX14> it's added complexity for a really tiny bother
<Vexatos> does the gitter twitter login use the twitter account name?
<oprypin> yes
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
<Vexatos> then it's not an issue
<oprypin> (then there's _gitlab btw)
<Vexatos> good to know.
<Vexatos> I mean if it doesn't bother you that much I don't need to bother either
<Vexatos> Was just a suggestion :P
Nathanaelle has joined #crystal-lang
<oprypin> the hope is that it bothers the actual person enough to give up the twitter login :|
p0p0pr37 has quit [Ping timeout: 248 seconds]
p0p0pr37_ is now known as p0p0pr37
Nathanaelle has quit [Ping timeout: 252 seconds]
Nathanaelle has joined #crystal-lang
<FromGitter> <drum445> General question, if I have a method that carries out a process and will return the issue (if there is one) but this issue can vary, how would I best go about doing this ⏎ something like: https://play.crystal-lang.org/#/r/45n6
<FromGitter> <drum445> It's a JSON api so if the db call can't find x I want to say that, same as if it can't find y
<FromGitter> <drum445> I've started doing ⏎ ⏎ ```# if criteria ⏎ return 400, {"message": "custom error"}``` [https://gitter.im/crystal-lang/crystal?at=5b0aeb534eaffb692d5d1c6b]
<FromGitter> <drum445> then the controller just checks if it's != 200 and returns the message
<FromGitter> <drum445> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0aeb76ba1a351a68ca8864]
<oprypin> drum445, this is exceptions territory
<oprypin> or enum
<FromGitter> <drum445> so I'd raise custom exceptions from my method?
<oprypin> possiblt
<FromGitter> <drum445> hmm, atm ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b0aec3093dc78791c8ce670]
rohitpaulk has quit [Remote host closed the connection]
Nathanaelle has quit [Ping timeout: 260 seconds]
Nathanaelle has joined #crystal-lang
Nik736 has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
<FromGitter> <godmode97> @hmans windows has its own subsystem of ubuntu, it's also the same as running it with the usual ubuntu. though the files are stored inside the `APPDATA` which makes it quite difficult for me to locate.
Nathanaelle has joined #crystal-lang
Nathanaelle has quit [Read error: Connection reset by peer]
Nathanaelle has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 245 seconds]
p0p0pr37_ is now known as p0p0pr37
Jenz has joined #crystal-lang
<FromGitter> <godmode97> any idea of this error? ⏎ ⏎ ```usr/bin/x86_64-linux-gnu-ld: cannot find -lyaml``` [https://gitter.im/crystal-lang/crystal?at=5b0b07e4352b9e1a4b38d738]
<FromGitter> <fridgerator> which includes libyaml-dev, it looks like it cannot find the libyaml library
<FromGitter> <godmode97> @fridgerator thanks! it's now working!
<FromGitter> <fridgerator> 👍
Jenz has quit [Quit: leaving]
Nik736 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Read error: No route to host]
p0p0pr37_ is now known as p0p0pr37
Nathanaelle has quit [Ping timeout: 256 seconds]
<FromGitter> <vladfaust> I got 1ms response on a real-world application with JWT authentication, PostgreSQL querying and JSON response building; only 135μs goes to Crystal itself, other to Postgres. Is that a break-through?
sherjilozair has joined #crystal-lang
<FromGitter> <drum445> I have similar results, but using Maria and cookie based sessions
<FromGitter> <drum445> although I imagine that must be running locally and not on https
<FromGitter> <vladfaust> I measure it by handlers, not from outer tools, therefore "locally" and "https" do not make sense, I suppose
<FromGitter> <drum445> ah makes more sense, still super nice
<FromGitter> <drum445> Crystal and Go are just the kings of performance
<FromGitter> <drum445> Especially with how cheap fibers are to create
<FromGitter> <vladfaust> So, this performance is comparable with Go?
<FromGitter> <vladfaust> I got 100k on 4 cpus with empty server
<FromGitter> <drum445> There is a lot of variables, such as frameworks to consider
<FromGitter> <drum445> but Go and Crystal seem to be on the upper end of performance
<FromGitter> <Blacksmoke16> is there reasoning behind why you can type restrict params on macros?
<FromGitter> <bew> you can't
<FromGitter> <bew> as to why, I don't know, I'd like to too sometimes
<FromGitter> <vladfaust> +1 to typed arguments in macros, here's the usecase: https://github.com/vladfaust/core.cr/blob/b8a0603cebd3c93b2c83e55a9f9fcd04dfc38b5d/src/core/params.cr#L46
<FromGitter> <vladfaust> I'm benching with wrk and get 400ms responses from PostgreSQL when using multiple wrk threads
<FromGitter> <Blacksmoke16> oh well
<FromGitter> <drum445> more general question, but why do you choose Postgres over Maria/MySQL ?
<FromGitter> <vladfaust> I got used to it. Doing PostgreSQL for like 4 years
sherjilozair has quit [Quit: Leaving...]
<FromGitter> <drum445> Fair enough, I've been interested in using it but don't see any reason to use it over the others tbh
<FromGitter> <drum445> I guess it's just stick to what you know
<FromGitter> <bew> (note @vladfaust : you can do `Core.prepare_params {{ *params }}` too ;)
<FromGitter> <vladfaust> @bew noted, would experiment with
<FromGitter> <vladfaust> Despite of a single response being stretched to 250-400ms, wrk gives 1800 rps, which results in 0.55ms (!) response time
<FromGitter> <vladfaust> BTW, scaling from 1 to 4 cores gives 2100 RPS, I think it's the DB's issue - it's running in a single Docker container on my local machine as well
<FromGitter> <vladfaust> I wish tarantool 2.0 released, I've already written driver for it: https://github.com/vladfaust/tarantool-crystal. It gives 40k rps at dozen of simul connections; 25 microseconds vs PostgreSQL's milliseconds
<FromGitter> <vladfaust> Anyone knows a cloud provider for PostgreSQL suitable for tons of simultaneous connections and maybe give me free credits for benchmarking realworld.io back-ends?
<FromGitter> <vladfaust> BTW, I don't think I'm capable of benching all the back-ends by my own 😕
<FromGitter> <j8r> You can try Amazon RDS in the free tier https://aws.amazon.com/free/
<FromGitter> <vladfaust> Thx
<FromGitter> <girng> Then after it's free,RIP your wallet
<FromGitter> <j8r> yes :-| and also this is a micro instance
<FromGitter> <vladfaust> Of course I know about Amazon's greed
<FromGitter> <vladfaust> Everyone knows
<FromGitter> <vladfaust> I think single Crystal bench with 0.4ms per request would be enough to shock the IT world
<crystal-gh> [crystal] Sija opened pull request #6138: Use ~ character for Nil#to_yaml (master...nil-to-yaml-with-tilde) https://git.io/vhm49
<FromGitter> <vladfaust> Am I right?
<FromGitter> <vladfaust> Like, the only competitor is Go but it literally has unhuman syntax
<FromGitter> <vladfaust> Line-by-line 😆
<FromGitter> <vladfaust> Night, everyone!
<FromGitter> <girng> "inhuman syntax" Haha agreeed
<FromGitter> <girng> You could even say "inhumane syntax" since it's basically torture 😆
<FromGitter> <faustinoaq> "inhuman syntax" XD
<FromGitter> <faustinoaq> What about Rust? :;)
bmcginty has quit [Ping timeout: 256 seconds]
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Read error: Connection reset by peer]
p0p0pr37_ is now known as p0p0pr37
<FromGitter> <j8r> the worst are the Windows `bat` files - when I first see the syntax, I wanted to flew away back to `sh` 💀
<FromGitter> <fridgerator> batch files are the worst
<FromGitter> <fridgerator> I have to write them sometimes for jenkins builds
<FromGitter> <fridgerator> I hate it
<FromGitter> <galvertez> is there a better way to turn `Hash(K,V)` into `JSON::Any` than doing `JSON.parse(object.to_json)`? i can't figure out how to cast anything as `JSON::Any` and i'm completely out of ideas
<FromGitter> <galvertez> JSON::Type wasn't much help either because as soon as i return anything more specific than JSON::Type it barks at me just the same
<FromGitter> <fridgerator> are the keys known at compile time or not?
<FromGitter> <girng> S T A T I C A L L Y - T Y P E D
<FromGitter> <girng> @faustinoaq 😆
<FromGitter> <j8r> @galvertez what do you want to do?
<FromGitter> <galvertez> they're not known
<FromGitter> <j8r> has you JSON a mapping?
<FromGitter> <galvertez> i'm trying to build jsonrpc because the only jsonrpc shard i found... i wasn't crazy about the way it worked and the last commit is over a year old.
<FromGitter> <galvertez> so when a request comes into the server it will be known what the parameters and return types are, but that is only when writing the methods. they're not knowable before the methods are known. i am trying to store the methods as `Proc(JSON::Any, JSON::Any)` so that based on the request's `method` key, it will know which block to use
<FromGitter> <galvertez> however, the `parameters` key is not knowable at the time i create a storage for the blocks
<FromGitter> <galvertez> rather, the value of that key is not knowable
<FromGitter> <galvertez> and might not even exist for some requests
<FromGitter> <j8r> I'm reading the specs
<FromGitter> <j8r> I think you can use a mapping
<FromGitter> <galvertez> so what i want is for the handler to parse the request, select the correct block based on `request.method` and then pass that block `request.params`. that part hasn't been difficult; since `JSON.mapping` can't decide what type the `params` key should hold, it will always be `JSON::Any`. no problem there. but during processing, (what the methods will return can't be known until after the handler is already
<FromGitter> ... instantiated)
<FromGitter> <j8r> I agree for params yes, it can be Array or Hash or nil
<FromGitter> <galvertez> right, params isn't the hard part
<FromGitter> <galvertez> `result` from the response object is the hard part
<FromGitter> <girng> imo, you should just do json.parse it makes your life 10x easier and unless you run into perf issues (which 90% won't happen) you should be fine
<FromGitter> <j8r> why result is the hard part?
<FromGitter> <galvertez> because i, while writing this shard
<FromGitter> <galvertez> can't know what a user of the shard's return type will be when they write an rpc method
<FromGitter> <j8r> Note that you may want to avoid using JSON.parse, because vs a mapping the performances are considerably worse
<FromGitter> <galvertez> yeah, i'm using mapping right now for capturing requests and responses
<FromGitter> <j8r> so the result can be either a string or an int?
<FromGitter> <galvertez> but getting them packaged after processing is really confusing for me
<FromGitter> <galvertez> the result can be any type
<FromGitter> <galvertez> any valid json type
<FromGitter> <galvertez> i can't know what the result will be ahead of time; that is up to the developer using the shard
<FromGitter> <j8r> Crystal is statically typed, so at the end either you enforce a type for result, or do a tricky hack and have a hard-to-handle union type like `String | Int32 | Nil`
<FromGitter> <galvertez> the type will be enforced
<FromGitter> <galvertez> it will be knowable when the rpc is defined
<FromGitter> <j8r> so... no problem?
<FromGitter> <galvertez> the problem is that i can't write the shard to be used
<FromGitter> <galvertez> without already knowing the type that the users will return
<FromGitter> <j8r> What do you mean?
<FromGitter> <j8r> I think I understand you
<FromGitter> <j8r> You can use a macro
<FromGitter> <galvertez> i can't store the `Proc(A,R)` without knowing what `R` is going to be. i want to use `JSON::Any` or `JSON::Type` but i can't cast the results as those
<FromGitter> <faustinoaq> Wow, nice! 😄 👍 https://jwt.io/
<FromGitter> <j8r> But you tell that the user will know?
<FromGitter> <j8r> The user can use your shard, and the type on your method will be completed a compile time
<FromGitter> <galvertez> i tried a macro. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ this it told me i can't do that. i also tried it with `.as(JSON::Type)` and it didn't like that either [https://gitter.im/crystal-lang/crystal?at=5b0b3e50361a950a661da8db]
<FromGitter> <galvertez> oh that's not the right snippet
<FromGitter> <galvertez> hang on
<FromGitter> <j8r> carc.in me a sample to fix ;-)
<FromGitter> <bew> you could store a proc that returns a json, or that write the final result json to an io
<FromGitter> <galvertez> yeah @bew that's exactly what i'm trying to do. but as soon as a proc returns anything other than JSON::Any or JSON::Type, i have problems. i tried writing a macro that would wrap the user's proc and cast the result as one of those but it said i can't
<FromGitter> <bew> what do you want to return a JSON::Any ?
<FromGitter> <bew> or JSON::Type
<FromGitter> <bew> what will you do with it?
<FromGitter> <bew> (first question was 'why' not 'what')
<FromGitter> <j8r> furthermore the user expect a type, thus `Any` can be avoided
<FromGitter> <j8r> @galvertez can you paste some code in https://carc.in/ ?
<FromGitter> <galvertez> i'll have to re-type it
<FromGitter> <galvertez> i have basically torn my program apart trying to get *anything* resembling my intent to work lol
<FromGitter> <galvertez> @bew i don't care which it is. as long as it can turn into a JSON string and the client can parse it :)
<FromGitter> <galvertez> the result object will only exist long enough to be serialized and shipped off to the client; no further processing will occur ever
bmcginty has joined #crystal-lang
<FromGitter> <galvertez> @j8r https://play.crystal-lang.org/#/r/45oz that's more or less what i'm trying to do
<FromGitter> <bew> and what do you plan to do with the result? why not serialize the result in the proc?
<FromGitter> <galvertez> because it then gets set as an instance variable of the `Response(T)` and would get serialized twice
<FromGitter> <galvertez> so i guess it wasn't totally true that no further processing occurs
<FromGitter> <bew> not necessarily, can you post a full example with request & response, until the data is sent back to the client
<FromGitter> <bew> ?
<FromGitter> <bew> as you see it
<FromGitter> <galvertez> an example of jsonrpc in the abstract or an example of my implementation?
<FromGitter> <galvertez> ```code paste, see link``` ⏎ ⏎ this is basically what i want to happen [https://gitter.im/crystal-lang/crystal?at=5b0b461cba1a351a68cb7561]
<FromGitter> <galvertez> ! gitter should support ```crystal