<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:
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>
<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>
<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.
<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>
<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>
<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'
<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
<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>
<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.
<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>
<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> 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>
<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