<FromGitter>
<naqvis> if you need base64 just change last line to `dio.base64digest`
<FromGitter>
<roduquen> Thank you :)
<FromGitter>
<naqvis> np :)
<FromGitter>
<roduquen> And there is a RSA encryption module in Crystal ?
<riffraff169>
re: aliases....that always confused me too...never was sure which one was the preferred way, and which one might suddenly be deprecated (with warnings) or even entirely disappear...most times i would use reduce, but other times, umm, which ever option was the same (cant remember now)
<riffraff169>
depends on which doc i was following
<FromGitter>
<andrewc910> Is it possible to serialize a proc to json or some other easy to work with format? I tried the stdlib JSON::Serializable, blacksmoke's CrSerializer & jdr's Crystalizer with no success.
<FromGitter>
<naqvis> what's your use-case? Crystal neither have RTTI nor any reflection
<FromGitter>
<Blacksmoke16> yea how would you do that :p
<FromGitter>
<andrewc910> Use case: Some objects get serialized, stored in an html doc, websocket connection is made, state of object is sent back, deserialized. Certain frontend actions trigger a websocket call, which invokes a method on that deserialized object. ⏎ ⏎ All that is working. I would like to be able to pass procs allowing components downstream to invoke methods upstream. The problem is that proc needs to be
<FromGitter>
... serialized for it to "return" after deserialization in the later steps.
<FromGitter>
<andrewc910> I have no idea how that would work! That's why i just tried a couple nice libraries and then came to ask if it was possible :shrug:
<FromGitter>
<Blacksmoke16> yea idk how that would work, hence why no serializer implementation supports doing that with procs
<jhass>
do these procs capture state or are there mere method references?
<FromGitter>
<andrewc910> I am just thinking method references right now
<jhass>
then just define an enum
<jhass>
and have a case/when dispatcher or such
<FromGitter>
<andrewc910> Hmm, sounds tedious but ill try and see how it looks! Thanks :)
<jhass>
you can picture it as serializing a method name and a basic form of RPC
<jhass>
if you got the enum and have a good convention between the enum and method names going, some macro code can DRY it up
<jhass>
and/or you can use a lookup hash etc
<FromGitter>
<andrewc910> For that to work, the downstream object would need a reference to the upstream object, right? Or am i not understanding.
<jhass>
maybe? I'm talking very generally since I don't see what you already got :)
<FromGitter>
<andrewc910> Thats fair. I will at least take a look! Thanks :)
<FromGitter>
<Dan-Do> Hi everyone. Is there "jump to" statement in crystal-lang? I don't want to repeat the code.
lunarkitty has quit [Ping timeout: 260 seconds]
<FromGitter>
<Blacksmoke16> I don't think. Got an example in what you need it for?
<FromGitter>
<Dan-Do> My context is not like triable. It must jump to start and do the steps in order to parse the expected result.
<FromGitter>
<Blacksmoke16> is that not what the example was doing?
<FromGitter>
<Blacksmoke16> invokes the block on error, calling the block multiple times based on #retries
<jhass>
Dan-Do: the basic pattern is as demonstrated in the example above, you put your code into a loop and break the loop as needed. I believe there's formal proofs that this is equivalent to goto, it certainly is for 95% of usecases. Of course in practice often a much nicer solution can be found, but is then very domain specific
<FromGitter>
<Dan-Do> How about just want to jump to STEP2, not from the START?
<FromGitter>
<Blacksmoke16> ofc `rest` would be like `" blah"`
<FromGitter>
<Blacksmoke16> could split on `": "`?
<riffraff169>
yeah, there will be a space, although im going to be splitting the second part further, so...
<FromGitter>
<Blacksmoke16> 👍
<riffraff169>
how about a regex? /^(..):(.*)/.match(line), how to assign multiple match groups to multiple vars at the same time, or is an array better (like s = )
<riffraff169>
maybe i should use ";" instead of /;/
<riffraff169>
nope
<FromGitter>
<Blacksmoke16> ah yea, there is no promise that the named captures would have a value of rthat
<oprypin>
riffraff169, `data1.named_captures["code"].not_nil!` is just `data1["code"]`
<riffraff169>
thing is, when i puts desc1.class the result is String, not String|Nil
<oprypin>
riffraff169, thats normal. the runtime type will always be just one type
<riffraff169>
and without the `.not_nil!`, it gives me this error `Error: undefined method 'named_captures' for Nil (compile-time type is (Regex::MatchData | Nil))`, another Nil...
<riffraff169>
ah...hmm
<oprypin>
`typeof(desc1)` for compile tiem type
<oprypin>
riffraff169, no you're misreading my advice
<riffraff169>
so what would be the best way to split on a non-existent `;`, so there will be 1 or more items in the list
<FromGitter>
<Blacksmoke16> the reasoning why there was the `nil` option is because of ⏎ ⏎ > When this regex has an optional group, result hash may contain a `nil` if this group is not matched.
<FromGitter>
<Blacksmoke16> and that affects the whole hash
<riffraff169>
hmmm....and im doing the not_nil because i know for a fact my data will never have that problem
<FromGitter>
<Blacksmoke16> correct
<FromGitter>
<Blacksmoke16> another way to do it would be like