ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.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
darkstardevx has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> right
ur5us has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> actually
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e780319ada7ae4f2e372a92]
<FromGitter> <Blacksmoke16> ?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7803519cc9d03f279e2977]
<FromGitter> <dscottboggs_gitlab> oh that works, nice
<FromGitter> <Blacksmoke16> always going to be 7 bytes so can specify that in the builder to save memory
ur5us has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> extra nice
alexherbo2 has quit [Ping timeout: 264 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
<watzon> @dscottboggs_gitlab you're probably right. I just ported some node code, but I like this better.
<FromGitter> <dscottboggs_gitlab> 🎉
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e781b31fa6bd733c7b1e7b5]
<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> <manveru> @securefab_gitlab `.to_json`
<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> <Blacksmoke16> should go tell this guy now https://forum.crystal-lang.org/t/no-lz4-tokyo-tyrant-bindings-for-crystal/1854/5
<FromGitter> <j8r> @naqvis !!! great job
<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> its as easy as ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ where `xx` is compression file format, and `XXX` are required shard [https://gitter.im/crystal-lang/crystal?at=5e78be8066919c3b2f836e58]
<FromGitter> <Blacksmoke16> neat
<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 :-)
yxhuvud has joined #crystal-lang
<FromGitter> <confact> @asterite trying to add enum support to avram (ORM). so that's why the class in the macro if you wondering :> https://gist.github.com/confact/aa9a88304ee1dc7babd93d058ecee5f5
<FromGitter> <confact> @asterite hehe, @paulcsmith from lucky asked me to ask here for the begin yield issue :)
<FromGitter> <confact> ah, now i understand what you mean @asterite :)
<FromGitter> <paulcsmith> 🎉
<FromGitter> <confact> thanks @asterite
DTZUZU2 is now known as DTZUZU
cloaked1 has joined #crystal-lang
<FromGitter> <farrza_gitlab> Guys, what is a good way to get POST params if what I have is HTTP::Server::Context.
<FromGitter> <farrza_gitlab> HTTP::Server::Context.request.body returns HTTP::ChunkedContent
<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
<watzon> If anyone cares :)
<yxhuvud> watzon: don't forget the link
<watzon> 2 minutes
<FromGitter> <wontruefree> logging on
<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> <Blacksmoke16> https://github.com/manastech/webmock.cr there is this for mocking that http request
<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> <smalls12> thanks :)
<FromGitter> <Blacksmoke16> would be another
<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> <smalls12> big article to link, but shows some stuff like EXPECT_CALL
<FromGitter> <smalls12> which appears to be what Spectator is trying to do
<watzon> Finishing my stream in 10 minutes
ht__ has joined #crystal-lang
ur5us has joined #crystal-lang
_ht has quit [Ping timeout: 246 seconds]
ht__ is now known as _ht
<FromGitter> <farrza_gitlab> Guys, I tried using
<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?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e791bd670a85655dfa14052]
<FromGitter> <Blacksmoke16> something like that
_ht has quit [Quit: _ht]
_ht has joined #crystal-lang
<FromGitter> <farrza_gitlab> Thanks m8.
alexherbo2 has quit [Ping timeout: 240 seconds]
_ht has quit [Quit: _ht]
darkstardevx has quit [Quit: Leaving]
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#0529032 (master - Log module (#8847)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/666079239
travis-ci has left #crystal-lang [#crystal-lang]
cloaked1 has quit [Ping timeout: 250 seconds]
<watzon> Woooo
<watzon> So I just learned something interesting about Ruby
<watzon> This `\M-\C-x` is a valid escape sequence
postmodern has joined #crystal-lang