ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | 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
lunarkitty has quit [Ping timeout: 272 seconds]
lunarkitty has joined #crystal-lang
ur5us has quit [Ping timeout: 265 seconds]
ur5us has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#5b4df7f (master - Log: add trace and notice, drop verbose (#9107)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/677520100
<DeBot> https://github.com/crystal-lang/crystal/pull/9107 (Move verbose to a lower level than debug)
alexherbo2 has joined #crystal-lang
ur5us has quit [Ping timeout: 265 seconds]
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> hello
<FromGitter> <grkek> Hi there
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
<FromGitter> <kingsleyh> morning
<FromGitter> <grkek> What's up
<FromGitter> <kingsleyh> does anyone know what this should look like in Crystal? https://github.com/openssl/openssl/blob/4350a6bd427f52d38f32b19f1c4b38a3afe62941/crypto/evp/pmeth_lib.c#L771
<FromGitter> <kingsleyh> currently I have: ` fun EVP_PKEY_CTX_set_signature_md(ctx : EVP_PKEY_CTX, ???) `
<FromGitter> <grkek> that is a setter
<FromGitter> <grkek> so probably something like `signature_md=` ?
<FromGitter> <kingsleyh> The example looks like this: `VP_PKEY_CTX_set_signature_md(ctx, EVP_sha256())`
<FromGitter> <kingsleyh> but how do I make that `EVP_sha256()` ?
<FromGitter> <kingsleyh> in my binding
<FromGitter> <grkek> Hm, I am not really good with the bindings
<FromGitter> <grkek> wait a bit someone will respond
<FromGitter> <kingsleyh> ok thanks - I'll check back shortly after a shower - hmm maybe too much information lol
<FromGitter> <grkek> Lol
<FromGitter> <grkek> it's allright
DTZUZU has quit [Ping timeout: 240 seconds]
<raz> oprypin: that golang base62 looks interesting (so this is what quantum computing is all about :D)
<FromGitter> <grkek> :D
<raz> but overall i've come to think that b62 is just stupid. so much effort just to avoid _ and -
<raz> and it totally screws up the 'easy to implement' claim, as no language has it in the stdlib
DTZUZU has joined #crystal-lang
zorp_ has joined #crystal-lang
zorp_ has quit [Ping timeout: 265 seconds]
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 264 seconds]
alexherbo21 is now known as alexherbo2
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo20 is now known as alexherbo2
<FromGitter> <naqvis> ```type EVP_MD = Void*``` ⏎ ⏎ `EVP_sha256()` is function invocation which is returning `EVP_MD` [https://gitter.im/crystal-lang/crystal?at=5e9ec492c38aa05a1a8f3a71]
<FromGitter> <naqvis> @kingsleyh ☝️
<FromGitter> <naqvis> Crystal already have bindings for `openssl`, so believe you needn't to re-implement them
<FromGitter> <naqvis> but only in case, when crystal openssl bindings aren't sufficient enough for your use-case
<FromGitter> <kingsleyh> Ali - how do indicate that I want to use the evp_sha256 ?
<FromGitter> <kingsleyh> I will need to pass it to EVP_PKEY_CTX_set_signature_md as the second argument
<FromGitter> <kingsleyh> So I can’t put it as Void*
<FromGitter> <naqvis> in the example above you shared, you are passing the return value of function
<FromGitter> <naqvis> you are not passing function pointer
<FromGitter> <naqvis> `int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md)` 2nd param is expecting the EVP_MD pointer, not the function reference
<FromGitter> <lodenos> I have a problem not really understand I have declare`objSource = Hash(String, Array.class | String).new` and after I doing that `objSource["searchEngine"] = Array(Hash.class).new` but I have an error of compiling `Error: no overload matches 'Hash(String, Array(T).class | String)#[]=' with types String, Array(Hash(K, V).class)` But I would like creat an Array with any Type not typeded before
<FromGitter> <naqvis> you would have to use generics here
<jhass> also not sure why you're doing Array.class
<jhass> or Hash.class
<jhass> "container for any type" is not really possible in Crystal right now, not directly like that
<FromGitter> <lodenos> I see
<FromGitter> <lodenos> But in the future be possible Container fo any Type ? or it's not in the roadmap, I from of C++ world ^^
<FromGitter> <kingsleyh> Ali - thanks - I still don't quite understand - how will the EVP_PKEY_CTX_set_signature_md function know which value to use? I specifically want to use sha256 and not some other thing
<FromGitter> <kingsleyh> also even with your suggestion it's not finding that function: Undefined symbols for architecture x86_64: "_EVP_PKEY_CTX_set_signature_md"
<FromGitter> <kingsleyh> when it says Undefined symbols does that mean it can't find the function in the header file?
<FromGitter> <kingsleyh> or that the compiled library does not have that function?
deavmi has quit [Quit: Eish! Load shedding.]
<FromGitter> <naqvis> yeah, but could be multiple reasons, have you compiled the lib for 32bit? as error you shared above is trying to find that under 64bit
<FromGitter> <naqvis> another option would be use either `nm` or 'objdump` like utility to see if compiled library does contain the exported function you are calling externally
<FromGitter> <kingsleyh> in the evp.h file it's like this:
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9ededc85b01628f069c4db]
<FromGitter> <kingsleyh> does the define mean that the function may not be compiled for my arch?
<FromGitter> <kingsleyh> and is only avail on 32bit for example?
<FromGitter> <naqvis> hmmmm, EVP_PKEY_CTX_set_signature_md is a macro
<FromGitter> <naqvis> this is not function and for sure you wont' be able to find it compiled library
<FromGitter> <kingsleyh> can I make a macro work in my binding?
<FromGitter> <naqvis> nope, you can define method in crystal, that does the same work as this macro is doing
<FromGitter> <naqvis> its just calling the `EVP_PKEY_CTX_ctrl` function
<FromGitter> <naqvis> with those fixed params
<FromGitter> <kingsleyh> that is avail: int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, ⏎ ⏎ ``` int cmd, int p1, void *p2);``` [https://gitter.im/crystal-lang/crystal?at=5e9edf7ed240da24338eb959]
<FromGitter> <kingsleyh> ok I will try that
<FromGitter> <naqvis> then write a method in crystal, that calls this `EVP_PKEY_CTX_ctrl` with those options
<FromGitter> <kingsleyh> ok thanks
<FromGitter> <naqvis> np
<FromGitter> <kingsleyh> I'm sorry but I'm probably going to ask another few questions in the next few hours :)
<FromGitter> <naqvis> no worries and always welcome to post your questions here
<FromGitter> <naqvis> community is great and people will jump in
<jhass> @lodenos: It's not ruled out, just quite hard, especially for value types. And to be honest most designs get better if you avoid doing this :P
zorp_ has joined #crystal-lang
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#eda7dd6 (ci/fix-nightly - Add spec for blocks): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/677671633
yxhuvud has quit [Remote host closed the connection]
yxhuvud has joined #crystal-lang
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
deavmi has joined #crystal-lang
<FromGitter> <kingsleyh> ali or jhass - so this is what I have now: `LibECCrypto.EVP_PKEY_CTX_ctrl(ctx, -1, LibECCrypto::EVP_PKEY_OP_TYPE_SIG, LibECCrypto::EVP_PKEY_CTRL_MD, 0, ???)`
<FromGitter> <kingsleyh> I'm still unsure about how to populate the ??? at the end
<FromGitter> <kingsleyh> this is C: `int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, int cmd, int p1, void *p2);`
<FromGitter> <kingsleyh> I think I need pass: EVP_sha256() where the ??? are - but not sure how to make it
raz has quit [Ping timeout: 260 seconds]
raz has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> long time no see, @kingsleyh
<FromGitter> <kingsleyh> yeah I only come when I'm stuck lol!!!
<FromGitter> <kingsleyh> hey @ImAHopelessDev_gitlab how are you?
<FromGitter> <ImAHopelessDev_gitlab> @kingsleyh good! are you linking a c library?
<FromGitter> <kingsleyh> yeah openssl
<FromGitter> <kingsleyh> wow github and gitter are on a go slow for me today
<FromGitter> <kingsleyh> anyone know how I can bind this ?
<FromGitter> <kingsleyh> ```const EVP_MD *EVP_sha256(void) ⏎ { ⏎ return &sha256_md; ⏎ }``` [https://gitter.im/crystal-lang/crystal?at=5e9f1a58b4c9207c21ca0267]
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f1a7ee432161f2825fe0f]
<FromGitter> <kingsleyh> oh I think crystal libcrypto might have it already
<FromGitter> <ImAHopelessDev_gitlab> damn, no idea. but lol at METH TABLE
<FromGitter> <naqvis> @kingsleyh you want to pass `EVP_sha256` to func?
<FromGitter> <kingsleyh> This is what I have so far
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f1beda36122108392e283]
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f1bfd285b886ab8891e72]
<FromGitter> <kingsleyh> but it returns 0 which means it's not working
<FromGitter> <naqvis> and how this function is being invoked in C?
<FromGitter> <naqvis> and how this function is being invoked in C?
<FromGitter> <naqvis> `pointerof(algo)` is passing the function pointer, which shouldn't be the case
<FromGitter> <watzon> Shouldn't 0 mean it is working?
<FromGitter> <kingsleyh> like in the example on this page: https://www.openssl.org/docs/man1.1.1/man3/EVP_PKEY_verify.html
<FromGitter> <kingsleyh> here: EVP_PKEY_CTX_set_signature_md
<FromGitter> <watzon> Lol look at OpenSSL doing things the wrong way
<FromGitter> <watzon> I mean unless it's returning a boolean
<FromGitter> <kingsleyh> EVP_PKEY_CTX_set_signature_md is a macro that calls down to EVP_PKEY_CTX_ctrl
<FromGitter> <watzon> 0 should mean it is working, should it not?
<FromGitter> <kingsleyh> so I had to bind EVP_PKEY_CTX_ctrl intead
<FromGitter> <kingsleyh> the docs say a positive number is good
<FromGitter> <watzon> Isn't `algo` an enum value?
<FromGitter> <naqvis> ```if (EVP_PKEY_CTX_set_signature_md(ctx, EVP_sha256()) <= 0)```
<FromGitter> <naqvis> notice `()` after the func call
<FromGitter> <naqvis> so its not function pointer, but the returned value of `EVP_sha256` func
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f1d4335a35031bf77a2d9]
<FromGitter> <kingsleyh> still not working
<FromGitter> <naqvis> ```code paste, see link```
<FromGitter> <kingsleyh> not working :(
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f1d89989acc6ab7a372ac]
<FromGitter> <kingsleyh> return 0 still
<FromGitter> <kingsleyh> maybe I got the wrong type on the binding
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f1e29989acc6ab7a374d9]
<FromGitter> <kingsleyh> what does the void* mean on the end?
<FromGitter> <naqvis> turn that to void pointer
<FromGitter> <naqvis> kind of Any lol
<FromGitter> <naqvis> algo is already a pointer
<FromGitter> <naqvis> so remove that `pointerof`
<FromGitter> <naqvis> also call to `algo()` shouldn't be working
<FromGitter> <naqvis> just pass `algo` as the last param
<FromGitter> <kingsleyh> but the C looks like this: `int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, ⏎ ⏎ ``` int cmd, int p1, void *p2);```` [https://gitter.im/crystal-lang/crystal?at=5e9f1e882fbcdb22ace08a36]
<FromGitter> <kingsleyh> why does it have void *p2 at the end
<FromGitter> <kingsleyh> and the define one has something different with (void *_(md)
<FromGitter> <naqvis> its same as `void* p2`
<FromGitter> <naqvis> p2 is just param name
<FromGitter> <kingsleyh> what does this mean? (void *)(md))
<FromGitter> <kingsleyh> is that the last parameter?
<FromGitter> <kingsleyh> or 2 parameters?
<FromGitter> <naqvis> (XXXX) is type conversion
<FromGitter> <naqvis> though crystal doesn't support type conversion, but think of it `as(XXX)` in crystal
<FromGitter> <kingsleyh> converting EVP_MD to void*
<FromGitter> <naqvis> yeah
<FromGitter> <kingsleyh> so I should pass in the EVP_MD type or the Void* type?
<FromGitter> <kingsleyh> pointerof(EVP_MD) or pointerof(Void)
<FromGitter> <naqvis> EVP_MD is already defined as `Void*` in crystal
<FromGitter> <naqvis> so just return that
<FromGitter> <kingsleyh> hmm
<FromGitter> <kingsleyh> I need to call this tho: LibCrypto.evp_sha256()
<FromGitter> <kingsleyh> which is EVP_MD
<FromGitter> <kingsleyh> and pointerof( LibCrypto.evp_sha256()) also doesn't work
<FromGitter> <kingsleyh> here is the full thing
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f1fa271a34b0149fd4916]
<FromGitter> <kingsleyh> yay
<FromGitter> <kingsleyh> ok thanks very much - got it working!!
<FromGitter> <kingsleyh> the thing you were saying all along - which I was clearly failing to understand - does work lol
<FromGitter> <kingsleyh> to return EVP_MD as the last Type on the binding
<FromGitter> <kingsleyh> ```code paste, see link```
<FromGitter> <naqvis> 👍
<FromGitter> <kingsleyh> ok 1 down - 10 more to go !!!
<FromGitter> <kingsleyh> going to be a long night!
<FromGitter> <naqvis> good luck lol
<FromGitter> <naqvis> i'm sure remaining ones will be easier to get done, as you already have the required interfaces and types defined
<FromGitter> <naqvis> so that's just a call to them
<FromGitter> <kingsleyh> sounds so easy when you say it like that haaha
<FromGitter> <naqvis> hahahaha
jetpack_joe has quit [Ping timeout: 272 seconds]
OvermindDL1 has quit [Ping timeout: 272 seconds]
Liothen has quit [Ping timeout: 272 seconds]
OvermindDL1 has joined #crystal-lang
jetpack_joe has joined #crystal-lang
jetpack_joe has quit [Max SendQ exceeded]
hsh has quit [Ping timeout: 272 seconds]
Liothen has joined #crystal-lang
jetpack_joe has joined #crystal-lang
hsh has joined #crystal-lang
melthelesbian has quit [Ping timeout: 246 seconds]
jetpack_joe has quit [Max SendQ exceeded]
jetpack_joe has joined #crystal-lang
melthelesbian has joined #crystal-lang
jetpack_joe has quit [Max SendQ exceeded]
jetpack_joe has joined #crystal-lang
<FromGitter> <kingsleyh> hmm ok - I have another issue
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f2607989acc6ab7a399c2]
<FromGitter> <kingsleyh> does this look correct:
<FromGitter> <kingsleyh> ```code paste, see link```
<FromGitter> <kingsleyh> const unsigned char *sig becomes UInt8* ?
<FromGitter> <grkek> UInt8 is equivalent of unsigned char yes
<FromGitter> <grkek> Char range is from 0 to 255
<FromGitter> <grkek> so is UInt8's
<FromGitter> <drum445> Can Crystal's MySQL shard call stored procs?
<FromGitter> <naqvis> yes, it should be, as long as you are using sql `CALL PROC_NAME`
<FromGitter> <naqvis> are you encountering any issues?
<FromGitter> <drum445> `Unhandled exception: PROCEDURE test.get can't return a result set in the given context (Exception)`
<FromGitter> <drum445> db.query "CALL test.get" do |rs|...
<FromGitter> <drum445> `db.exec "call test.create()"` works fine, just the reads fail
<FromGitter> <naqvis> don't you need to provide the parens `()` in your call to query?
<FromGitter> <naqvis> exception above seems to be from the mysql
<FromGitter> <naqvis> that doesn't look like shard exception
<FromGitter> <naqvis> make sure you can run `CALL test.get` in mysql cli
teardown has quit [Read error: Connection reset by peer]
teardown has joined #crystal-lang
<FromGitter> <watzon> Ever find yourself wishing that Crystal had algebraic data types like Rust?
<FromGitter> <watzon> I mean built in, I know that it's possible to create something like Rust's enum with macros
<FromGitter> <naqvis> with you
<FromGitter> <naqvis> what particular ADT you wish most?
<FromGitter> <watzon> I would just love to be able to handle enums in the same way that rust can, where values are basically containers that can contain other things. Obviously better pattern matching to go along with that would be nice.
<oprypin> watzon, u can just start using a hierarchy of abstract structs
<FromGitter> <watzon> There's a shard that replicates this functionality, but I'm hesitant to do that kind of thing with public APIs
<FromGitter> <grkek> ez win
<FromGitter> <watzon> @oprypin yeah I know, it's just not as nice
<oprypin> i definitely wish abstract structs and enums were unified
<FromGitter> <sam0x17> is there any way I can build up a collection of values over a number of macro calls and then emit those values all at once in a later macro?
<oprypin> sam0x17, ye use a constant
<oprypin> A=[5]; {% A << 6 %}
<FromGitter> <sam0x17> omg so I can just append to constants in macro mode?
<oprypin> ye
<FromGitter> <sam0x17> noiiice
<FromGitter> <sam0x17> ty
<FromGitter> <watzon> @oprypin has anyone ever brought that up as an issue?
<oprypin> or at least i hope i remember correctly 😂
<oprypin> watzon, i dont know
<FromGitter> <watzon> Hmm, might be worth exploring
<FromGitter> <watzon> Definitely would be a post v1.0 thing
<FromGitter> <watzon> Lmao I love that you called it "super fancy"
<FromGitter> <naqvis> +1 :plus1:
<FromGitter> <grkek> Mmmh that source code instantly turned me on vro
<FromGitter> <grkek> i am gay for the kode
<FromGitter> <watzon> 😂
<FromGitter> <watzon> Aren't we all
<oprypin> 😩😩😩
<FromGitter> <grkek> Oprypin please push my buttons and execute the init binary :)))))
<FromGitter> <sam0x17> fun fact -- apparently `macro finished` at the top level executes at exit
<oprypin> surely not at exit of the program, maybe of the compiler
<FromGitter> <sam0x17> well oddly, I threw a top level `macro finished` block into an amber app in an initializer and it didn't execute until I killed the program
<FromGitter> <sam0x17> as in: ⏎ ⏎ ```macro finished ⏎ puts "hey" ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e9f394c7e8b826dab2c2d96]
<FromGitter> <ImAHopelessDev_gitlab> yikes, open source can be rough
<oprypin> sam0x17, ha ok, yea i suppose that's right, it's like appending the code to the very bottom of the final program
<FromGitter> <grkek> @ImAHopelessDev_gitlab the dude had his own thing going and everyone just bullied him to death because of his choices
<FromGitter> <sam0x17> yes that was my thought @oprypin
<FromGitter> <ImAHopelessDev_gitlab> i'm reading more into it now. have pizza in the oven for all of this. ⏎ @grkek that sounds awful :/
<FromGitter> <drum445> @naqvis I can, it's an issue on the shard side
<FromGitter> <naqvis> then plz. raise an issue on shard repo with sample code
<FromGitter> <watzon> Unfortunately the creator of actix was very opinionated and not at all communicative, but he shouldn't have been treated the way he was
<FromGitter> <watzon> Not a good look for open source
<FromGitter> <ImAHopelessDev_gitlab> open source can be a hit or miss. entirely depends on the lead developers and their beliefs. when finding an open source project to use, i'd argue reading comments and posts by the lead devs on various message boards is just as important as the code itself
<FromGitter> <grkek> No one should be forced to maintain a project which they don't want to maintain
<FromGitter> <grkek> the idea of open source is contribution and sharing
<FromGitter> <grkek> if you don't like the way one does things fork the project and do your own thing
<FromGitter> <grkek> no need to cause huge drama over unsafe keywords
<FromGitter> <kinxer> I agree with @watzon's take, generally. While nobody should have to maintain anything they don't want to, it also sucks for the main dev of a project to refuse to take criticism. I've really appreciated seeing the Crystal core team work stuff out, 'cause everyone seems to have strong opinions about things but be able to work out the best way to proceed without holding on too hard to their own ideas. Also,
<FromGitter> ... especially for a widely-used web framework, the response to "hey, your framework has this potential security vulnerability" probably shouldn't be "I'm tired of hearing about how you don't like my way of doing things; just deal with it".
<FromGitter> <ImAHopelessDev_gitlab> in my honest opinion, i'd say a LARGE amount of github issues are not even needed. for example, godot had to create a separate repo just to weed out suggestions. i believe github issues should be used for PRs and crashing issues *only*. Anything else that causes ambiguity should be discussed on community channels. that's what i truly believe after almost a decade of contributing to open
<FromGitter> ... source projects. ⏎ ⏎ This will increase development speed tenfold. Not only that, but allow maintainers the freedom they deserve. I believe one reason it doesn't happen is because most lead devs are compassionate and don't want to be rude to contributors.
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#625884b (master - Win CI: Bootstrap Crystal, build things *on* Windows, publish the binary (#9123)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/677817099
<DeBot> https://github.com/crystal-lang/crystal/pull/9123 (Win CI: Bootstrap Crystal, build things *on* Windows, publish the binary)
<FromGitter> <grkek> Niceeeee
<FromGitter> <robacarp> Man, my hats off to @bcardiff for the new Log module. I think this is a great place for Crystal to innovate against the norm of a Logger class, and I think it's been done well.
<FromGitter> <bcardiff> <3
<raz> i still haven't found time to look into it
<raz> just keep filing tickets against other crystal projects that spit logger deprecation warnings on 0.34 :p
<FromGitter> <ImAHopelessDev_gitlab> ROFL https://github.com/uNetworking/uWebSockets/issues/792
<FromGitter> <ImAHopelessDev_gitlab> Imagine if all repos were like this :O
<FromGitter> <Blacksmoke16> thats already a thing https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md
<FromGitter> <Blacksmoke16> most of the time you put that stuff into a `CONTRIBUTING` FILE
<FromGitter> <Blacksmoke16> and/or using issue templates
<FromGitter> <ImAHopelessDev_gitlab> i mean the directiveness and tone of the post. it's wild
hightower2 has joined #crystal-lang
<FromGitter> <grkek> The developer is very polarizing
<raz> bcardiff: log context should be per instance not per fiber. but otherwise this looks like a better logger than any other languages have (from what i know)
<FromGitter> <Blacksmoke16> you can make it per entry
<FromGitter> <Blacksmoke16> having both is best
<raz> per entry?
* raz scratches head
<FromGitter> <Blacksmoke16> per logged instance
<FromGitter> <Blacksmoke16> i.e. `Log.info { "foo" }` would be an entry
<FromGitter> <Blacksmoke16> `Log.info { "bar" }` would be another
<FromGitter> <ImAHopelessDev_gitlab> @grkek i've been following that dev since my nodejs days. he got in a fight/argumentive with ryan dahl and ryan gave him the banhammer ;D
<raz> hmm ok, i have to try it out, i prob don't understand it yet
<FromGitter> <Blacksmoke16> benefit of having it be per fib is its possible, and super easy, to add context to all logged messages, while still being able to have context specific to one logged message
<FromGitter> <grkek> For that reason he was removed from The Benchmarker list
<raz> that's not the droi^Wcontext i'm looking for. with context i mean `Log.set_context(foo: bar)` and then foo is included with all future `Log.info` from that same instance
<FromGitter> <Blacksmoke16> right
<FromGitter> <Blacksmoke16> thats already how it works no?
<FromGitter> <Blacksmoke16> er i suppose you mean stuff logged in a spawned fiber wouldnt include context added outside of that spawn?
<FromGitter> <ImAHopelessDev_gitlab> @kinxer that's true
<raz> yep. or rather, if two instances (even of the same class) call Log.* in the same fiber, then each should include *their* context
<FromGitter> <Blacksmoke16> mm not sure i follow
<raz> well, i'm opininated, that's why i keep ending up writing my own logger ;)
<raz> i want context about the object that's logging, not about the fiber (that's easy enough to get in other ways anyway)
<raz> e.g. when there are two User objects at play, both log stuff, then each should include their user_id
<FromGitter> <Blacksmoke16> like in a web framework?
<raz> no like in a log framework!
<raz> could also be anything other than a User. for any type of Connection i want the remote-addr, status etc. included
<raz> there's always some, well, context that should be in all messages :)
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Log.html#with_context(&)-class-method
<FromGitter> <Blacksmoke16> also are some PRs to make that easier
<raz> yep but is that per object? or will *all* Log calls also from other objects then include it?
<FromGitter> <Blacksmoke16> including context within the block, or using named args like `Log.info(user_id: user.id) { "message" }`
<FromGitter> <Blacksmoke16> thats per that logged entry
<FromGitter> <Blacksmoke16> i.e. the thing that contains the message/context etc
<raz> well, i don't want to repeat it for every logged entry, that's the point ;)
<raz> because in a team of 2 devs you end up with it being forgotten 50% of the time
<raz> and then the bug hits in production and everyone is like 'meh, why didn't we log the user id there'
* raz sobs
<FromGitter> <Blacksmoke16> fiber can help with that as at the beginning once you resolve your user object you can do `Log.context.set user_id: user.id` then all other logs after that would have it
<FromGitter> <Blacksmoke16> but yea i see your point where if you have two users doing something within the same fiber it wouldnt work
<raz> well, *all* other logs, or only the ones issues from the object that set the context? :)
<FromGitter> <Blacksmoke16> option there would be to define a log method on the user class itself
<FromGitter> <Blacksmoke16> afaik its all, dont think it depends on source
<raz> well, i'll just try it out but prob stick with my logger for the time being. but i'm glad crystal is moving closer to proper logging. most languages still only have the ancient syslog-inspired glorified 'puts'
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8xhk yea its not depended on source
<raz> yup, thought so. that makes it less useful to me, but the rest is still cool (esp. that bind/filter stuff)
<FromGitter> <Blacksmoke16> makes things quite helpful in a web framework context
<FromGitter> <Blacksmoke16> since each request has its own fiber, it just works
<FromGitter> <Blacksmoke16> in auth handler `Log.context.set user_id: user.id` and done
<raz> well yea, but not when you're dealing with multiple objects ;)
<raz> then you're back to including the id with every log call
<FromGitter> <Blacksmoke16> nothing preventing you from having log methods on the objects
<FromGitter> <Blacksmoke16> feels kinda meh but it would solve that problem
<FromGitter> <Blacksmoke16> or even log helper methods using overloads
<FromGitter> <Blacksmoke16> `log user, "something"` :shrug:
<raz> well, my logger does it like this; https://github.com/busyloop/clog
<raz> it has to be in the log framework itself to be useful. otherwise everyone invents their own way (or, more likely, just ignores the admittedly minor problem and carries on w/ repeating everything)
<raz> that's why the log improvement (despite that pet peeve) makes me very happy. the stdlib logger is what every shard ends up using, there's no way to escape it. so all improvements to it make everyone's logging life better :)
<FromGitter> <Blacksmoke16> i deff see the usecase
<FromGitter> <Blacksmoke16> however im sure how to best handle it
<FromGitter> <kingsleyh> hello - I'm trying to find out what errors my binding is throwing - and this looks interesting: `void ERR_print_errors(BIO *bp);`
<FromGitter> <kingsleyh> Should I be able to pass some Crystal IO instance to it?
<FromGitter> <Blacksmoke16> i think what you have is deff able to be written using new module
<FromGitter> <Blacksmoke16> maybe just not as clean/same syntax as you have
<raz> probably, i may give it a shot
<FromGitter> <grkek> BIO as in the STDERR ?
<FromGitter> <kingsleyh> not quite sure how to use it though
<FromGitter> <kingsleyh> maybe pass in an IO::Memory
<raz> somehow everyone seems to be hacking on openssl today
<raz> oh wait n/m, same thread as earlier :D
<FromGitter> <kingsleyh> yeah sorry - I have been on and off
<raz> no all good! i was just confused ;)
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/8xhv
<FromGitter> <Blacksmoke16> prob could add some overloads like `.info` etc to make it cleaner
<FromGitter> <Blacksmoke16> or i could see including a module that defiles the stuff and you just have to implement a like `protected def default_context`
<FromGitter> <Blacksmoke16> in this case like `{user_id: @id}`
<FromGitter> <Blacksmoke16> deff possible
<FromGitter> <Blacksmoke16> maybe worth a forum post or something
<raz> hmm yea, i'm def gonna look into it first time i use it :)
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <sardaukar> hello all 👋
<raz> 👋
<FromGitter> <kingsleyh> I think I need to do something like this: ` fun ERR_print_errors(bio : LibCrypto::Bio)`
<FromGitter> <kingsleyh> but not quite sure how to make a Bio in Crystal
<FromGitter> <kingsleyh> ok I figured it out
<FromGitter> <kingsleyh> `fun ERR_print_errors(bio : LibCrypto::Bio*)` in the C binding
<FromGitter> <kingsleyh> and in the crystal code
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f5682f7699e1084e6ce4a]
_ht has quit [Remote host closed the connection]
<FromGitter> <bcardiff> @raz having context per fiber works better for eventual tracing. Local context per context are now easier https://github.com/crystal-lang/crystal/pull/9146 . As a use case exampleo, I would expect that the context could have a request_id set by the http server. Then along the way specific logs can be emitted, some with more context, some don't. But all with the same request_id value. So things can be traced.
<FromGitter> ... That might also help to reduce carrying a big context. ⏎ ⏎ Lucky's Dexter is taking the approach of a wrapper to the log module and manipulate the context. The code can be simpler after the mentioned PR, but the idea is the same https://github.com/luckyframework/dexter/blob/master/src/dexter/log.cr#L153-L164 . That might b ... [https://gitter.im/crystal-lang/crystal?at=5e9f689cbe86d031bef96bf9]
ur5us has joined #crystal-lang
<raz> bcardiff: hmm, yep, i'll have to look into that. thing is i find ctx-per-instance at least as useful as ctx-per-fiber. but i guess there's a trade-off between utility and making the stdlib logger too complex.
<FromGitter> <oprypin> https://youtu.be/eAzIAjTBGgU
<FromGitter> <oprypin> hmmm? gitter doesn't wanna embed
<raz> oprypin: my irc client did. 3 times :p
<FromGitter> <3n-k1> is there a reason this code (compiled with -Dpreview_mt) runs so much slower than its single-threaded counterpart? ⏎ multithreaded: https://pastebin.com/10kffZKH ⏎ single-threaded: https://pastebin.com/g0REPRwS
<FromGitter> <Blacksmoke16> i think you could rewrite that to be more efficient, sec
<FromGitter> <Blacksmoke16> essentially you're getting the overhead of MT but not using it to the best effect
<FromGitter> <Blacksmoke16> since you only have two fibers
<FromGitter> <3n-k1> any ideas how to rewrite it for efficiency? this is my first foray into both crystal and multithreading haha
<FromGitter> <Blacksmoke16> is related
<FromGitter> <Blacksmoke16> i would think you would want to split up the workload into more fibers in order to allow more than 2 cpus to work on it
<FromGitter> <Blacksmoke16> 2 cores*
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#7a0cdec (master - Log: Allow override context within logging calls (#9146)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/677901773
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9146 (Log: Allow override context within logging calls)
<FromGitter> <3n-k1> alright, i'll try that, thanks
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/guides/concurrency.html also read thru this if you havent
<FromGitter> <Blacksmoke16> would want to use channels to communicate values
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f6f74285b886ab88a7289]
<FromGitter> <Blacksmoke16> based on that thread, maybe at least batching up the work
<FromGitter> <Blacksmoke16> versus each number gets its own
<FromGitter> <Blacksmoke16> each core can handle say 1 fiber, so if you have 8 cores (16 with hyperthreading) then having more fibers allows saturating all cores
<FromGitter> <3n-k1> `Unhandled exception: Cannot allocate new fiber stack: Cannot allocate memory` that's a scary error
<FromGitter> <Blacksmoke16> checkout that thread i linked
<FromGitter> <Blacksmoke16> > based on that thread, maybe at least batching up the work
<FromGitter> <3n-k1> what do you mean by batching up the work?
<FromGitter> <Blacksmoke16> like maybe each fiber handling adding 1000 numbers or something
<FromGitter> <Blacksmoke16> reduce the total number of fibers, but still getting more parallelism
<FromGitter> <3n-k1> alright. is there a way to do that programmatically so I don't have to write out each fiber?
<FromGitter> <Blacksmoke16> hm used to be a batch method i remember
<FromGitter> <kinxer> Out of curiosity, does the standard library provide anything for working with memory-mapped files?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Enumerable.html#in_groups_of(size:Int,filled_up_with:U=nil)forallU-instance-method
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <3n-k1> alright, thanks for the help :)
zorp_ has quit [Read error: Connection reset by peer]
zorp has joined #crystal-lang
<FromGitter> <3n-k1> hmm, even with this code i still get that `Cannot allocate memory` error ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9f747d989acc6ab7a4eaf5]
<FromGitter> <Blacksmoke16> maybe try more than 1000?
<FromGitter> <Blacksmoke16> 1m or something :shrug:
<FromGitter> <3n-k1> memory leak, and it still takes longer than the single-threaded version
<FromGitter> <Blacksmoke16> granted what we're doing here isnt really computationally hard, so is possible that its just faster with a single thread since it doesnt have the overhead of MT
<FromGitter> <Blacksmoke16> https://crystal-lang.org/2019/09/06/parallelism-in-crystal.html maybe read thru this
<FromGitter> <3n-k1> i suppose. i'm writing a blog post about parallelism and i'm trying to find a simple example
<FromGitter> <Blacksmoke16> prob will be some in that blog post
<FromGitter> <3n-k1> looks like my post is dead in the water then lol
<FromGitter> <Blacksmoke16> xD
<FromGitter> <3n-k1> i dont' think i'll find anything computationally complex enough that's also easy to explain
<FromGitter> <watzon> Here's something I've never thought about, but find myself needing. How do you rescue an exception thrown by an iterator and allow the iteration to continue?
<oprypin> watzon, nobody wants an iterator to throw an exception
<oprypin> if u really want to continue, call next on it, but really the asnwer is dont do it
<FromGitter> <watzon> So just ignore exceptions in the iterator itself. Got it.
<FromGitter> <tenebrousedge> right
ur5us has quit [Ping timeout: 265 seconds]
<FromGitter> <watzon> Am I remembering right, or wasn't there someone talking about `.tl` files the other day?
<FromGitter> <watzon> I can't remember what the context was
zorp has quit [Ping timeout: 264 seconds]