RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.1 | 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
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6dqc
<FromGitter> <Blacksmoke16> issue was when you were defining the @@commands type/return type
<FromGitter> <Blacksmoke16> since it would be a union then since it also gets inherited
<FromGitter> <Blacksmoke16> @botanicus
<FromGitter> <botanicus> @Blacksmoke16 wow, thanks! It does work. I'm still failing to understand why though. I don't understand where is the union coming from?
<FromGitter> <Blacksmoke16> `self.class`
ua has joined #crystal-lang
<FromGitter> <Blacksmoke16> since that method also gets inherited the compiler doesnt know which class it is referring to. at least thats what im thinking
<FromGitter> <Blacksmoke16> but if you define the type statically, it will always be that type, vs something that can change depending on where it was called
<FromGitter> <botanicus> That makes sense. Thanks!
<FromGitter> <Blacksmoke16> np
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> how to use BigInt? https://play.crystal-lang.org/#/r/6dql
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6dqn :magic:
<FromGitter> <dscottboggs_gitlab> FFS
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
faitswulff has joined #crystal-lang
faitswulff has quit [Remote host closed the connection]
faitswulff has joined #crystal-lang
jemc has quit [Ping timeout: 246 seconds]
f1refly has quit [Ping timeout: 250 seconds]
f1refly has joined #crystal-lang
<FromGitter> <whitenoiseoss> hi, if anyone is skilled with the C bindings of Crystal, perhaps you can enlighten me to something
<FromGitter> <dscottboggs_gitlab> what's the issue
<FromGitter> <whitenoiseoss> here is the lua_State struct in lstate.h: https://www.lua.org/source/5.3/lstate.h.html#lua_State
<FromGitter> <whitenoiseoss> here it is defined in a Go struct for a Go Lua compiler: https://github.com/yuin/gopher-lua/blob/ca850f594eaafa5468da2bd53b865e4ee55be18b/value.go#L203
<FromGitter> <whitenoiseoss> in the only Crystal sort-of version I can find, here's what's done
<FromGitter> <whitenoiseoss> and I don't know why
<FromGitter> <whitenoiseoss> why does LState there just go to a Void*?
<FromGitter> <whitenoiseoss> also where can I find a list of these C types this person seems to be using? LibC::SizeT, Void*, LibC::Char* etc
<FromGitter> <dscottboggs_gitlab> you can view all types with the output of `crystal docs` in the shard root
<FromGitter> <whitenoiseoss> I feel like there's something fundamental I'm missing about how Crystal approaches this
<FromGitter> <dscottboggs_gitlab> `Void*` is like C or LLVM's "any" type... so this is relying on the crystal compiler to hanlde type enforcement.
<FromGitter> <whitenoiseoss> ahhh
<FromGitter> <whitenoiseoss> and it just doesn't need to bother with defining its fields and such inside of Crystal
<FromGitter> <dscottboggs_gitlab> not sure, I guess so
<FromGitter> <whitenoiseoss> yet it does for the Debug struct
<FromGitter> <whitenoiseoss> the piece that's weird to me is that any sort of definition for it is just...not there
<FromGitter> <whitenoiseoss> Thus, a type declaration is useful for opaque types that are created by the C library you are wrapping.
<FromGitter> <whitenoiseoss> there it is
<FromGitter> <whitenoiseoss> well
<FromGitter> <whitenoiseoss> I guess that at least answers why that code would work
<FromGitter> <whitenoiseoss> I'm going to try to play around with this some
<FromGitter> <dscottboggs_gitlab> 👍
<FromGitter> <whitenoiseoss> thanks for your looking
<FromGitter> <dscottboggs_gitlab> np glad to help
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c7761224a65f754733c0186]
<FromGitter> <Blacksmoke16> welp, apparently it wants to be nil
<FromGitter> <dscottboggs_gitlab> lol wtf
<FromGitter> <Blacksmoke16> yea i dunno, is just for this one, the others that do like legit the same thing are fine
<FromGitter> <whitenoiseoss> $ crystal run mdma_lua.cr ⏎ Pointer(Void)@0x558cc41c73c8
<FromGitter> <whitenoiseoss> what do you know.
jemc has joined #crystal-lang
<FromGitter> <Blacksmoke16> night
<FromGitter> <whitenoiseoss> o/
jemc has quit [Client Quit]
okami has joined #crystal-lang
faitswulff has quit [Remote host closed the connection]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 255 seconds]
<FromGitter> <rishavs> Just added my lunch money on BountySource. Need Windows support so I can start on sweet sweet games and abandon it after a few months :3
DTZUZO has joined #crystal-lang
<FromGitter> <bararchy> XD
<livcd> rishavs: something big will be announced for ruby in April
<FromGitter> <drum445> How exciting
<FromGitter> <bararchy> for Ruby? not for crystal? :)
<livcd> yeah
ashirase has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
<hightower3> What could it be!
<hightower3> bararchy: maybe livcd is preparing us for April 1st :)
<FromGitter> <bararchy> hahahha
<FromGitter> <bararchy> TBH we (NeuraLegion) got something planned for the Crystal community, but it's also a bit soon to talk about it
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<livcd> RubyMotion will be opensourced
ternarysolo has joined #crystal-lang
faitswulff has joined #crystal-lang
mntmn has joined #crystal-lang
<FromGitter> <j8r> Hi, anyone interested on a part-time job on a Crystal Web project?
<hightower3> j8r not me but just asking out of interest, is any framework used?
<FromGitter> <j8r> that's a new project - you are free to use any framework to build the API server like Kemal, Onyx or other. (but Amber and Lucky would be overkill for this)
<FromGitter> <j8r> on the client side, you're free to - React, Vue.js or other :)
Creatornator has joined #crystal-lang
lucasb has joined #crystal-lang
<FromGitter> <mehmetc> what is the difference between the first c and the second c definition? I’m getting an "no overload matches” error if I use the first. ⏎ `#c = {} of String => Array(String) | Array(Hash(String, String)) ⏎ c = {} of String => Array(String | Hash(String, String)) ⏎ d = [] of String | Hash(String, String) ⏎ d << "1" ... [https://gitter.im/crystal-lang/crystal?at=5c77f1674a65f754733fb8e3]
<FromGitter> <dscottboggs_gitlab> I think that could be a bug
<FromGitter> <cserb> Is there a convenience macro to not have to write the initialize method? Similar to JSON.mapping that would also generate a `.new` constructor? ⏎ So instead of: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c77f45ee8ea1437378c9bcb]
<FromGitter> <mehmetc> @dscottboggs_gitlab can I/we do something to be sure?
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> iirc i dont think it is, is just how unioned arrays work?
<FromGitter> <Blacksmoke16> i remember having to deal with something like that, but maybe post something on the forums?
<FromGitter> <mehmetc> will do!
<FromGitter> <mehmetc> Do you remember how you worked around this?
<FromGitter> <Blacksmoke16> prob just use the 2nd?
<FromGitter> <Blacksmoke16> id have to mess around with it more
<FromGitter> <j8r> the two aren't similar
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <j8r> The first defined an Union of two different types of Array, the second one type of Array, that includes an Union
Creatornator has joined #crystal-lang
jemc has joined #crystal-lang
<jokke> hey
<jokke> how would one implement a http(s) proxy server in crystal? i want to be able to set it either system wide or from a browser so all http and https traffic goes through the server
<jokke> the server should then be able to determine what protocol, host and path was requested, request the content with HTTP::Client and modify it before sending it forward to the client
<hightower3> jokke: I would say that HTTP::Server (which must be client-facing side of this proxy) has very elegant options to accept incoming client connections and process them through Handlers. After that, how are you going to service those requests, is up to the code you would add, of course
<jokke> yeah sure
<jokke> but how would i tell firefox (or any other browser) to use that as a proxy?
<jokke> also how would it deal with the different protocols? http/https
<FromGitter> <Blacksmoke16> @cserb https://crystal-lang.org/api/0.27.0/toplevel.html#record(name,*properties)-macro
<FromGitter> <Blacksmoke16> might be helpful
<hightower3> jokke: you can do this in preferences -> advanced -> network proxy. Alternatively you might check whether they respect the http_proxy environment variable, and or you can see if they have a command line option for this
<hightower3> jokke, regardin http/https, if you set a proxy to be http://your-proxy, then all requests will go to your proxy using http, like you specified, and you can handle from there
<hightower3> jokke and regarding e.g. forcing all traffic to go through proxy, you could either do some iptables manipulation to do this, or you can look into Linux distributions like cubes and subgraph which approach the issue by having virtual hosts which handle network, and they route all traffic through them
<jokke> hightower3: ah okay nice
<jokke> but how how do i know if the client requested HTTPS?
<hightower3> I wouldn't know -- and on a second thought I'm not even sure if proxy is a http listener, or it has something to do with SOCKS etc.
<jokke> yeah :/
<jokke> thought so
<jokke> SOCKS is a bit more complicated
<hightower3> jokke, I also advise you check the good/old Squid proxy. Maybe it has all the features you need and you can replace your programming task with a squid configuration task
<jokke> definitely not :D
<jokke> i need to do dom manipulation
<FromGitter> <cserb> @Blacksmoke16 awesome! thanks
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
RX14 has quit [Ping timeout: 245 seconds]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> i refactored how exception handling works in athena
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ `/article` would return a 400 error because it catches the divisionbyzero error in the custom exception handler. ⏎ `/user` would return a 500 now because it is unhandled. ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5c781e6e8a7def0752f023f0]
<FromGitter> <Blacksmoke16> Provides a pretty flexible way to manage errors
<FromGitter> <Blacksmoke16> actually could prob make it cleaner by not having to pass in `ctx`...WIP :P
ua has quit [Ping timeout: 255 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
RX14 has joined #crystal-lang
Creatornator has joined #crystal-lang
Creatornator has quit [Ping timeout: 250 seconds]
ua has joined #crystal-lang
jemc has quit [Ping timeout: 244 seconds]
hightower3 has quit [Ping timeout: 244 seconds]
<FromGitter> <dscottboggs_gitlab> 💯
jemc has joined #crystal-lang
ternarysolo has quit [Ping timeout: 245 seconds]
marmotini_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> rethought of some of it, will now be passing the exception and action name thru, then add a `raise` or something similar method to replace the `halt`
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c784e482ca5ec547456f838]
<FromGitter> <Blacksmoke16> more like that
<FromGitter> <dscottboggs_gitlab> fair enough
<FromGitter> <Blacksmoke16> where the `raise` method will be a protected method on `Athena::Routing::StructController` that can just call `get_response` to set response body/code
<FromGitter> <Blacksmoke16> cleans it up a bit
marmotini_ has quit [Ping timeout: 255 seconds]
<FromGitter> <Blacksmoke16> future iteration could be passing an `Action` object thru, so you would have access to like action/controller name, params etc
hightower2 has joined #crystal-lang
<FromGitter> <bararchy> @j8r how about posting it in crystal jobs?
<FromGitter> <j8r> already done @bararchy
ternarysolo has joined #crystal-lang
moei has quit [Quit: Leaving...]
ternarysolo has quit [Ping timeout: 244 seconds]
ternarysolo has joined #crystal-lang
ternarysolo has quit [Ping timeout: 244 seconds]
jemc has quit [Ping timeout: 255 seconds]