<FromGitter>
<Blacksmoke16> got callback constraints now
<FromGitter>
<Blacksmoke16> for oneoffs or whatever
<FromGitter>
<Blacksmoke16> payload is just arbitrary data associated with a constraint. I.e. could be used in a server rendered view to specify a CSS class on a form. Like to differentiate between an error or warning
ur5us has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
alexherbo2 has joined #crystal-lang
_ht has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter>
<kingsleyh> hey - this library is broken in crystal 0.33.0 - something to do with the spawn - any idea why it's having a spawn error? https://github.com/tbrand/tokoroten/issues/2
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter>
<manveru> Is there any reason why you can sort `Time::Span` but not `Time::MonthSpan`?
<FromGitter>
<manveru> `(1..2).map(&.minute).sort` vs `(1..2).map(&.year).sort`
<FromGitter>
<securefab_gitlab> Hello. Is there a good way to get a String in JSON format from JSON::Any object ?
<FromGitter>
<securefab_gitlab> The ```.to_s``` method print JSON with "=>" instead of ":"
<yxhuvud>
manveru: looks like an oversight in the api.
<FromGitter>
<securefab_gitlab> @manveru That's better, thank you :)
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 250 seconds]
alexherbo2 has joined #crystal-lang
alexherbo20 has quit [Ping timeout: 250 seconds]
mistergibson has joined #crystal-lang
mistergibson has quit [Quit: Leaving]
<FromGitter>
<Blacksmoke16> @kingsleyh you would prob be better off trying out the experimental MT mode crystal has built in atm
<FromGitter>
<dscottboggs_gitlab> sure, if you want segfaults
<FromGitter>
<Blacksmoke16> hence why it's called *experimental* MT mode :p
<FromGitter>
<dscottboggs_gitlab> turned that on on a highly parallel performance intense project I was trying to do the other day and immediately got NPE
<FromGitter>
<dscottboggs_gitlab> on the bright side, that inspired me to take another look at D... and oh boy did I gauge that wrong when I first saw it
<FromGitter>
<Blacksmoke16> deff still some improvements to make yet
<FromGitter>
<dscottboggs_gitlab> in crystal or D?
<FromGitter>
<Blacksmoke16> crystal
<FromGitter>
<dscottboggs_gitlab> ah
<FromGitter>
<dscottboggs_gitlab> yes, a few. It's still great for a lot of cases.
<FromGitter>
<Blacksmoke16> mhm
<FromGitter>
<naqvis> Just published Crystal LZ4 (https://github.com/naqvis/lz4.cr) compression bindings. LZ4 is lossless compression algorithm, providing compression speed > 500 MB/s per core (>0.15 Bytes/cycle). *I haven't run any benchmark though* 😆
<FromGitter>
<j8r> You are damn good for algorithms like that
<FromGitter>
<j8r> to implement them in Crystal
<FromGitter>
<naqvis> @j8r thanks 😆
<FromGitter>
<Blacksmoke16> imagine it would be nice if there was a standard for them, i.e. some interface each one could apply to allow supporting any alg
<FromGitter>
<j8r> I was also thinking of this
<FromGitter>
<j8r> a simple as a `unzip` or `tar -zxf` commands
<FromGitter>
<naqvis> I've been following Crystal approach for all compression formats i've developed for Crystal. They are kind of drop-in replacement
<FromGitter>
<Blacksmoke16> 💯
<FromGitter>
<naqvis> one need to know how to perform IO, and that's all
<FromGitter>
<j8r> imo it is simple enough, but one can create helpers on top quite easily
<FromGitter>
<naqvis> be it tar, xz, zip, gzip, bz2, brotli, snappy, lz4
<FromGitter>
<j8r> agree, but it could be a one-liner
<FromGitter>
<naqvis> my understanding is that is the idiomatic crystal way of dealing with such things and I might be wrong :)
<FromGitter>
<naqvis> but I got this from crystal standard library as that comes with zip, gzip implementation
<FromGitter>
<j8r> you're right
<FromGitter>
<j8r> that's not the role of this libraries to be more higher level than that
<FromGitter>
<j8r> a bit like `File.read` and `File.write`
<FromGitter>
<j8r> which are wrappers on top of `File.open`
<FromGitter>
<naqvis> true and I believe being able to abstract away at such level, should be more than sufficient
<FromGitter>
<confact> Hi everyone, I am trying to use enum in a macro but it fails as yield put a begin in it. So now it fails like this: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Anyway to get around the begin? [https://gitter.im/crystal-lang/crystal?at=5e78ce7f2a141d3c62b16563]
<FromGitter>
<asterite> What's the source code?
<FromGitter>
<asterite> (Though probably the answer is no)
yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter>
<asterite> There's a way, check the Lucky channel :-)
<FromGitter>
<stronny> what do you mean by post params? application/x-www-form-urlencoded?
<FromGitter>
<asterite> I think you can do: `HTTP::Params.parse(context.request.body.gets_to_end)`
<FromGitter>
<Blacksmoke16> yea ^
<FromGitter>
<Blacksmoke16> will want to make sure body is not nil first
<FromGitter>
<asterite> I wouldn't mind adding a `body_params` to the request which would return `HTTP::Params | Nil`, since it's probably very convenient
<FromGitter>
<Blacksmoke16> 👍
<watzon>
Gonna be streaming me attempting to port a Ruby lib to Crystal in 5 minutes or so
<FromGitter>
<smalls12> anyone tried mocking for a c binding in crystal before ?
<FromGitter>
<smalls12> I have my `.cr` file that wraps the C API ⏎ the spec file will include that `.cr` file so it would have access to the real wrapper
<FromGitter>
<smalls12> im thinking I could made a `.mock.cr` file for the spec, but that might duplicate the code
<FromGitter>
<Blacksmoke16> is that not what you would want? To test the crystal lib using the actual c lib?
<FromGitter>
<smalls12> yes and no, I would want to mock out some of the calls to force errors to see what the crystal wrapper does
<FromGitter>
<Blacksmoke16> cant just cause the error normally?
<FromGitter>
<smalls12> and if the call is some cpu intensive thing, or makes an http connection somewhere, I would want to mock that away so as to not need to actually establish that http connection
<FromGitter>
<smalls12> poor example on my part as I'm not actually using http, but that repo might shed some light on some more general purpose mocking
<FromGitter>
<Blacksmoke16> from my experiences crystal doesnt have a good mocking shard yet
<FromGitter>
<Blacksmoke16> i mainly rely on just creating types that implement a given interface to use in the specs
<FromGitter>
<Blacksmoke16> as a form of mocking
<FromGitter>
<Blacksmoke16> not sure how that would work with a c lib tho
<FromGitter>
<smalls12> ive complicated it since this is a c binding as well
<FromGitter>
<smalls12> but from what you said
<FromGitter>
<smalls12> I could make a small shim interface infront of the bindgins
<FromGitter>
<smalls12> and then mock that out
<FromGitter>
<smalls12> purely in crystal
<FromGitter>
<smalls12> do you have a small example @Blacksmoke16 ?
<FromGitter>
<stronny> I don't think there's an easy way to mock C bindings
<FromGitter>
<smalls12> typical C
<FromGitter>
<smalls12> nothing is easy
<FromGitter>
<smalls12> but fun : )
<FromGitter>
<stronny> maybe take an .h and generate empty function bodies? but that won't work very well
<FromGitter>
<smalls12> well I was thinking of generating bindings for cmocka
<FromGitter>
<smalls12> into crystal
<FromGitter>
<stronny> so yeah, mock crystal wrappers
<FromGitter>
<smalls12> but cmocka relies on calling --wrap on gcc
<FromGitter>
<smalls12> not sure how I would systematically get that working
<FromGitter>
<stronny> what is it that you're testing really?
<FromGitter>
<stronny> that you didn't mix up some C types in `fun` lines?
<watzon>
You may be able to use Spectator to do mocking like that
<watzon>
Haven't tried, but it has pretty powerful mocks and doubles like RSpec
<FromGitter>
<smalls12> well a very basic example would be like if the bindings reported an error, I would use the mock to generate the error, and then prove the crystal side also reports the error to the user
<FromGitter>
<smalls12> I should clarify, the binding is used internally inside my crystal wrappers that also perform some other functionality to make the experience easier
<FromGitter>
<smalls12> I guess im something that would do something like gmock
<FromGitter>
<farrza_gitlab> HTTP::Params.parse(context.request.body.gets_to_end) as Ary suggested. It throws an error because body is IO | Nil during compile time.
<FromGitter>
<Blacksmoke16> right, you'll need to make sure there is a body before reading from it
<FromGitter>
<farrza_gitlab> I tried getting around with an if statement but still the same issue. Any idea what is going on?