ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.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
dingenskirchen has quit [Ping timeout: 250 seconds]
<FromGitter> <Blacksmoke16> yea think this is going to work
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7ae7
<FromGitter> <Blacksmoke16> requires some code i have locally but would output `#<Partner:0x7faf53e7cee0 @id=2, @name="FACEBOOK">`
<FromGitter> <Blacksmoke16> also the tagged thing is hard coded, but shouldnt be too bad to implement
<FromGitter> <Blacksmoke16> you get the idea
<FromGitter> <Blacksmoke16> also has the benefit of being all built at compile time, so should be quire performant
_whitelogger has joined #crystal-lang
laaron has joined #crystal-lang
<FromGitter> <watzon> Ok I don't know if my brain just isn't working or what. What would be the best way to do this? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Basically I want to add a DSL to Tourmaline that would allow you to define commands from inside a class like you would normal methods rather than having to do it all inside of the initializer. The regular command methods can be found here
<FromGitter> ... (https://github.com/watzon/tourmaline/blob/master/src/tourmaline/bot/handlers/command_handler.cr#L22). All I need to do is either call one of those command methods from inside the macro, or duplicate the functionality in the macro. [https://gitter.im/crystal-lang/crystal?at=5d392f9c2718c760ee4aa201]
<FromGitter> <watzon> Seeing as @Blacksmoke16 has been doing a lot of macro stuff today maybe you'll know what to do
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
absolutejam2 has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
sorcus has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Is that some pattern matching I see?!
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 246 seconds]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
ht_ has joined #crystal-lang
alex`` has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
flaviodesousa has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
<FromGitter> <j8r> kind of, Tuple matching
<FromGitter> <j8r> very useful
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <andrius> I am confused regarding forward_missing_to, I want to fetch hash value (`e.foo => e.hash["foo"]` and `e.foo? => e.hash["foo"]?`) More here: https://stackoverflow.com/questions/57198212/it-is-possible-to-somehow-use-forward-missing-to-to-fetch-set-hash-values
alex`` has quit [Ping timeout: 245 seconds]
gangstacat has joined #crystal-lang
dingenskirchen has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <asterite> forward_missing_to will forward the method as a. method call, not as a Hash accesor
<FromGitter> <asterite> what you want to do is impossible in Crystal
alex`` has joined #crystal-lang
duane has quit [Ping timeout: 245 seconds]
duane has joined #crystal-lang
<jokke> asterite: why is it impossible? should be easy with method_missing macro
<jokke> oh wait what?
<jokke> method_missing macro is gone?
<jokke> why? :(
<jokke> was it ever there? :D
<jokke> i'm confused
<FromGitter> <tenebrousedge> it's still there?
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> @watzon that isnt going to work since ivars cant be used on top level
<FromGitter> <Blacksmoke16> could you make commands a class var?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7ain
duane has quit [Ping timeout: 246 seconds]
<FromGitter> <asterite> well, it wasn't impossible
dingenskirchen has quit [Ping timeout: 250 seconds]
lucasb has joined #crystal-lang
dingenskirchen has joined #crystal-lang
dwdv has joined #crystal-lang
<FromGitter> <tenebrousedge> yay for valve oil and practice space
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<jokke> is it somehow possible to "stream" json from an io? i'm getting messages written to the io and would like to deserialize it from it
<jokke> *them
<jokke> (without reading to a string first)
<FromGitter> <Blacksmoke16> :0
<FromGitter> <Blacksmoke16> json to what format?
<jokke> json to a struct
<FromGitter> <Blacksmoke16> thats essentially what i did in https://github.com/Blacksmoke16/oq/pull/18
<FromGitter> <asterite> `SomeStruct.from_json(io)`
<jokke> asterite: yes that works but only if the io _only_ contains that one struct
<FromGitter> <asterite> what else does it contain?
<jokke> multiple, concatenated
<jokke> as in multiple per line
<FromGitter> <asterite> read line per line and then deserialize, I guess
<jokke> yeah but that would entail reading the whole line as a string first
<FromGitter> <Blacksmoke16> could he do something with pull parser, read until finished then new up, and repeat?
<FromGitter> <asterite> how big is the struct?
<jokke> big
<FromGitter> <asterite> I'm pretty sure there's no need to optimize it at that level
<FromGitter> <asterite> yes, with pull parser it's possible but tedious
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <asterite> we could change pull parser to not error if there's still stuff on the IO, with a flag
<FromGitter> <asterite> but it will make the API a bit harder, I think
<jokke> not sure how it would work with a pull parser though
<jokke> still errors
<FromGitter> <Blacksmoke16> where is the data coming from?
<jokke> a socket
<jokke> tcp
<jokke> i mean i guess i could write somekind of custom IO which wraps the socket and is EOF when it encounters a \n
<jokke> but that sounds overkill
<jokke> i'll go with from_json(String) then... :/
<FromGitter> <Blacksmoke16> could you not use https://crystal-lang.org/api/master/IO.html#each_line%28%2Aargs%2C%2A%2Aoptions%2C%26block%3AString-%3E%29%3ANil-instance-method ?
<FromGitter> <Blacksmoke16> should work directly on an IO?
<jokke> yeah but it still gives me line as a string
<FromGitter> <Blacksmoke16> ah i see
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/IO/Delimited.html what about this?
<FromGitter> <Blacksmoke16> wrap the main IO, delimiter to `\n`, `from_io delimited`, re new up delimited io with current state of the main io
<FromGitter> <meltheadorable> my understanding was that there were multiple json documents per line, so that wouldn’t help, did i misinterpret?
<FromGitter> <Blacksmoke16> could make delimiter to like `}{`?
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Blacksmoke16> but it would prob consume that and would be invalid then :/
return0e has quit [Ping timeout: 248 seconds]
<jokke> no getting them per line wouldn't be a probelm
<jokke> *problem
<jokke> but it seems i have other issues :(
<FromGitter> <Blacksmoke16> :(
<jokke> there's no working kafka lib
<jokke> although there are 3 of them
<FromGitter> <Blacksmoke16> rip
<jokke> the ones that use the c lib have some kind of threading issue which causes deadlocks
<jokke> probably because the c lib isn't using evented io
<FromGitter> <asterite> Something like this works: https://play.crystal-lang.org/#/r/7aj1 . The tricky part is knowing when EOF is reached, with a socket I don't think the `peek` trick will work so it's better to just rescue on parse failure and break
<jokke> oh wow i didn't know about IO::Delimited
return0e has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<jokke> asterite: does this read to you like it won't play nice with the crystal scheduler? https://github.com/edenhill/librdkafka/blob/master/INTRODUCTION.md#threads-and-callbacks
<jokke> because i'm pretty sure it is causing dead locks in my program
sorcus has quit [Ping timeout: 250 seconds]
sorcus has joined #crystal-lang
ua has quit [Excess Flood]
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
<FromGitter> <asterite> no idea, sorry
<jokke> mmh :/
ua has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> Anyone used
<FromGitter> <absolutejam_gitlab> https://github.com/psykube/pyrite?
<FromGitter> <absolutejam_gitlab> Can you stream an IO atm?
<FromGitter> <Blacksmoke16> meaning consume it without reading it all as a string or something?
<FromGitter> <Daniel-Worrall> how do I cross-compile to ARM?
<FromGitter> <Daniel-Worrall> Aiming at rpi4
<FromGitter> <absolutejam_gitlab> Yeah @Blacksmoke16, like a generator
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang
dostoyevsky has quit [Client Quit]
dostoyevsky has joined #crystal-lang
<FromGitter> <watzon> @Blacksmoke16 making commands a class var wouldn't be good
<FromGitter> <Blacksmoke16> yea, then might have to think of a diff approach.
absolutejam2 has joined #crystal-lang
alex`` has quit [Ping timeout: 258 seconds]
alex`` has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 248 seconds]
absolutejam2 has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
alex`` has quit [Ping timeout: 258 seconds]
sorcus has quit [Ping timeout: 264 seconds]
<FromGitter> <absolutejam_gitlab> @jwaldrip Any chance of a few examples for Pyrite (https://github.com/psykube/pyrite)?
<FromGitter> <absolutejam_gitlab> Looks super interesting to me
<FromGitter> <Blacksmoke16> duuuude this is cool
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d3a243af3e76e132708a2ee]
<FromGitter> <Blacksmoke16> "!partner` tells it to inject all services that have that tag
<FromGitter> <Blacksmoke16> which allows you to then have another service that can be injected into controllers or param converters
<FromGitter> <Blacksmoke16> which could for example, resolve/return the correct obj based on id
<FromGitter> <Blacksmoke16> ie. `GET /partners/GOOGLE`
<FromGitter> <Blacksmoke16> and if you want to add a new one just add another `@[Register("YAHOO", "Yahoo", name: "facebook", tags: ["partner"])]`
<FromGitter> <Blacksmoke16> and everything just works
<FromGitter> <watzon> That's pretty awesome
<FromGitter> <watzon> Creating a DI shard?
<FromGitter> <Blacksmoke16> more of a refactor
<FromGitter> <Blacksmoke16> had some trouble with with before, so it currently doesnt work
<FromGitter> <watzon> Can you use the DI module all by itself?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> `require "athena/di`
<FromGitter> <Blacksmoke16> by default it defines the container on the main fiber
<FromGitter> <Blacksmoke16> using it within a web framework, i.e. http request context is a bit tricker but i could walk you though how to handle that
<FromGitter> <Blacksmoke16> since you want each request to have its own container
<FromGitter> <watzon> Thats cool :)
<FromGitter> <Blacksmoke16> athena uses it for the request context
<FromGitter> <Blacksmoke16> so have access to it anywhere you want
<FromGitter> <Blacksmoke16> but sadly that example depends on some code that is still in PR, prob wont be merged in time for 0.30.0 :(
teardown has quit [Ping timeout: 258 seconds]
<FromGitter> <Blacksmoke16> waiting for releases isnt that bad on linux as you can just use the edge channel on snap
<FromGitter> <Blacksmoke16> works quite well
gangstacat has quit [Quit: Ĝis!]
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <Blacksmoke16> think i might make a blog post later about some useful DI patterns like that
<FromGitter> <Daniel-Worrall> welp, I don't seem to be able to build master with llvm7
<FromGitter> <Daniel-Worrall> WSL Ubuntu
<FromGitter> <Blacksmoke16> got the latest commits?
<FromGitter> <Blacksmoke16> was one that was merged like the other day to support 7
absolutejam2 has quit [Ping timeout: 258 seconds]
<FromGitter> <Daniel-Worrall> ye
<FromGitter> <Blacksmoke16> whats the error?
<FromGitter> <watzon> I don't think llvm7 is supported, is it?
<FromGitter> <Daniel-Worrall> there was a recent PR merged
<FromGitter> <Blacksmoke16> it is now https://github.com/crystal-lang/crystal/pull/7986
<FromGitter> <Blacksmoke16> did you do a `make clean`?
<FromGitter> <Blacksmoke16> also prob might not hurt to clear cache
<FromGitter> <Daniel-Worrall> yup
<FromGitter> <Blacksmoke16> `rm -rf ~/.cache/crystal`
<FromGitter> <Daniel-Worrall> still a flood of error
<FromGitter> <Blacksmoke16> hm dunno, maybe add a comment to the fails to build on llvm7 issue?
<FromGitter> <Blacksmoke16> could be somewthing WSL specific
<FromGitter> <Daniel-Worrall> could be, I was going to try docker next
<FromGitter> <Daniel-Worrall> my pi has llvm7 so I was looking to get crystal built on 7 so I could crosscompile