RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.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
GoldenBear has quit [Ping timeout: 240 seconds]
GoldenBear has joined #crystal-lang
Philpax has joined #crystal-lang
<FromGitter> <faustinoaq> ^^ Interesting
zachk has quit [Read error: Connection reset by peer]
<FromGitter> <tgwilliams63> So I have what is most likely a pretty stupid question... I'm trying to do ``` if typeof(solution) == Array(Float64) ⏎ ⏎ ```if solution.size > 0 ⏎ all_solutions.push(solution) ⏎ end``` ⏎ ⏎ end``` where the compile time types of "solution" are "Array(Float64) | Bool | Nil". I was kind of expecting the "if typeof" statement to keep me from getting the error about size being an undefined
<FromGitter> ... method for Bool, but it's still erroring out with exactly that. Any suggestions on how to work around or refactor the code to get past that? [https://gitter.im/crystal-lang/crystal?at=5b285ed77da8cd7c8c5455ce]
<FromGitter> <faustinoaq> @S-YOU `88947023 requests / 15 seconds = 5929801.533333333 RPS` (h2o.cr is even faster than h2o 🎉 )
<FromGitter> <S-YOU> cheers xD
<FromGitter> <S-YOU> It could be faster if I inline h2o functions, heehee
<FromGitter> <faustinoaq> h2o is `73214969/15 = 4880997.933333333`
<FromGitter> <faustinoaq> @S-YOU Thank you! 😄 ✨
<FromGitter> <faustinoaq> > It could be faster if I inline h2o functions, heehee ⏎ ⏎ hehe 😉
ashirase has joined #crystal-lang
<FromGitter> <faustinoaq> fasthttp (go): `105269216/15 = 7017947.733333333 RPS`
<FromGitter> <faustinoaq> @S-YOU Yeah, you're right, the top limit seems to be 7 million RPS 😅
<FromGitter> <S-YOU> It make sense actually, maximum packet per seconds for 10G NIC is, 14.x Mpps, with Tcp there is ack, so it is basically half
<FromGitter> <S-YOU> or if there is some tricks xD
<FromGitter> <faustinoaq> 👍 😄
ashirase has quit [Ping timeout: 256 seconds]
ashirase has joined #crystal-lang
<FromGitter> <faustinoaq> lol interesting name :)
<FromGitter> <reiswindy> @tgwilliams63 You could try something like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b286505aeb8fa0c07271ae7]
<FromGitter> <tgwilliams63> Hmmmm! That definitely makes sense since I only what to do that when the solution is an array. I did a bit more reading and ended up doing ``` ⏎ if solution.is_a?(Array) ⏎ ⏎ ```for now``` [https://gitter.im/crystal-lang/crystal?at=5b286556467bd7268c1b6882]
<FromGitter> <reiswindy> Yup, that works too!
<FromGitter> <tgwilliams63> Thank you for the answer @reiswindy! I really appreciate you taking the time to respond
<FromGitter> <S-YOU> lol
rocx has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
return0e has quit [Remote host closed the connection]
<FromGitter> <bew> @tgwilliams63 the `is_a?` is the best one for this
<FromGitter> <tgwilliams63> Thanks @bew! Good to know for future reference
ashirase has quit [Quit: ZNC - http://znc.in]
woodruffw has quit [Ping timeout: 256 seconds]
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
woodruffw has joined #crystal-lang
snsei has joined #crystal-lang
ua has quit [Ping timeout: 240 seconds]
punteek has joined #crystal-lang
punteek has quit [Client Quit]
WA9ACE has left #crystal-lang [#crystal-lang]
rohitpaulk has joined #crystal-lang
Yxhuvud has quit [Remote host closed the connection]
Yxhuvud has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
troligtvis has joined #crystal-lang
<FromGitter> <bendietze_twitter> While on work ... IO / HTTP::Server / kemal: is there a way to ouput the full unparsed HTTP request string? Like you would get if you just bind socket with C? :) I need the raw incoming data, just to look at if some parsing looks bad - but the parsing (after output) should going on :)
snsei has quit [Ping timeout: 260 seconds]
<FromGitter> <aisrael> I just stumbled upon https://www.peterbe.com/plog/rust-go-python-parse-millions-of-dates-in-csv ⏎ ⏎ So I tried to make a "naive" port of the Go code here (https://github.com/mostlygeek/go-csv-gz-test) ⏎ ⏎ And where Go took just a little under a minute to process 31,521,045 lines across 86 files, Crystal (0.25.0) took nearly *30 minutes*. Here's a gist of my code
<FromGitter> <S-YOU> how many files are you trying to load? @bendietze_twitter
<FromGitter> <aisrael> @S-YOU I used the same data set downloaded by the `download.sh` in the Go rep. 86 `.csv.gz` files (containing 31 million lines)
<FromGitter> <S-YOU> @bendietze_twitter , may be overwrite, HTTP::Request from_io, for last resort, if there is no way.
ua has joined #crystal-lang
<FromGitter> <bendietze_twitter> @S-YOU :) i thought too, but maybe i overlooked something in API
<FromGitter> <S-YOU> It does not seems to save raw headers as string, as far as I read. May be because copying string has overhead.
<FromGitter> <bendietze_twitter> @aisrael nice try :) your Go code has to many lines for a quick look, but Crystal code is very short - have you --release?
<FromGitter> <S-YOU> Go seems to be processing each file on each cpu (likely in parallel), that could be big difference., @aisrael
<FromGitter> <yxhuvud> ah yes, the crystal code happens in serial. Put every processing in a separate fiber
<FromGitter> <aisrael> The Go code can run serially and in parallel. My Crystal port is just doing sequential also. While concurrent/parallel *will* speed up overall—from quick testing Crystal takes 30x longer than Go at processing even a *single* .csv.gz file
<FromGitter> <S-YOU> I will try to write that to use C function only on Crystal and run on each cpu core in parallel.
<FromGitter> <aisrael> I'm so bothered by this that I'll probably try to isolate each one in turn: Gzip, CSV, and `Time.parse_rfc3339`
<FromGitter> <bendietze_twitter> @aisrael how does your go code run in sequentiell? Another version?
<FromGitter> <aisrael> No the Go code checks the env var `GOPAR` if set. If not, it picks the "One file at a time" strategy.
<FromGitter> <bararchy> @asterite could you remind me how you did the memory profiling to a Crystal program?
<FromGitter> <S-YOU> -p -s?
<FromGitter> <bendietze_twitter> @aisrael i didnt know env gopar and cannot find as i am on work, have you a quick link?
<FromGitter> <bararchy> that's just compile profiling, not runtime
<FromGitter> <S-YOU> Runtime, i see. valgrind could do?
<FromGitter> <yxhuvud> memprof should work I suppose
<FromGitter> <codenoid> hi
<FromGitter> <codenoid> i have 151M of sql row
<FromGitter> <codenoid> it's taking about 9m to do select where
<FromGitter> <codenoid> btw, i can't connect to my postgres database, ⏎ ⏎ ```PG.connect_listen("postgres://user:pw@30.30.30.21:5432/db", "a", "b")``` [https://gitter.im/crystal-lang/crystal?at=5b28b463467bd7268c1c01b7]
troligtvis has quit [Remote host closed the connection]
troligtvis has joined #crystal-lang
<FromGitter> <codenoid> but it's connect when i use python ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b28b4f8ad21887018c6b2c0]
<FromGitter> <aisrael> @bendietze_twitter It's just an environment variable that the Go code itself checks to choose which strategy (serial or parallel) to use. See filter.go:51 (https://github.com/mostlygeek/go-csv-gz-test/blob/master/filter.go#L51)
troligtvis has quit [Ping timeout: 260 seconds]
<FromGitter> <bendietze_twitter> Ok, but Crystal is single-threaded at this time - Go is always multithreaded, the scheduler organizes a threadpool, you can lastly only change between one core or parallel (gomaxxprocs > 1) so if you run at least one goroutine it is concurrent while Crystal is not at this time ;) we are on the road to concurrency ;)
troligtvis has joined #crystal-lang
<FromGitter> <j8r> @bendietze_twitter you mean parallelism
<FromGitter> <bendietze_twitter> 😄 yes, too :)
<FromGitter> <bendietze_twitter> But concurrency must, parallel were nice ;)
<FromGitter> <bendietze_twitter> parallelism
<FromGitter> <vladfaust> Why hasn't https://play.crystal-lang.org been updated to 0.25 yet?
<FromGitter> <j8r> https://crystal-lang.org/docs/guides/concurrency.html it is said Crystal has concurrency support but not parallelism
snsei has joined #crystal-lang
<FromGitter> <bendietze_twitter> Yes, but we have no threadpool - real parallelism is when you can choose for example between a for-loop and a parallel-for-loop
<FromGitter> <bcardiff> @vladfaust it's a resource maintained by jhass. it's already in his plate. But I don't have an ETA
<FromGitter> <vladfaust> Alright then
snsei has quit [Ping timeout: 265 seconds]
<FromGitter> <vladfaust> Could someone explain me this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b28b9c86ceffe4eba188616]
<FromGitter> <vladfaust> BTW, `record` doesn't allow to auto-cast initialization arguments
<FromGitter> <bendietze_twitter> Go isnt true parallel, because the scheduler organizes the processor context, you cannot choose between go-cpu1 and go-cpu2 for example. But the scheduler is able to move goroutines between threads and those between cores, so you are limited parallel in go - but parallel
<FromGitter> <bcardiff> @vladfaust structs are value types. `a.last` resturn anoterh instance of a point.
<FromGitter> <bew> @vladfaust when you do `a.last` you get a copy of the last Point, then you modify the copy. The Point in the array didn't change
<FromGitter> <vladfaust> @bcardiff, @bew I don't get why `point` variable is able to handle changes, while referencing a value within array isn't. Shouldn't `point` be immutable as well?
<FromGitter> <vlazar> Isn't it not `a.last` that returns a copy, but `a.last.x = 43` makes a copy which can be changed?
<FromGitter> <bew> @vladfaust you are not referencing a value within the array
<FromGitter> <bcardiff> that is why `point.x = 42` works.
<FromGitter> <bew> `a.last.x = 42` is the same as `point_copy = a.last; point_copy.x = 42`
<crystal-gh> [crystal] straight-shoota opened pull request #6218: Add missing JSON field to docs generator output for constants (master...jm/fix/6202) https://git.io/fJKws
<FromGitter> <vladfaust> So struct arrays hold values instead of references?
rocx has quit [Ping timeout: 260 seconds]
<FromGitter> <vladfaust> If so, why can't one mutate one of its values? How to access that exact instance of Point within an array and modify it?
<FromGitter> <bew> Yes, structs are always passed by value
<FromGitter> <vladfaust> An API example makes sense. Thanks for your time, guys, I think I got it
<FromGitter> <bew> #6069 could fix that I think
<DeBot> https://github.com/crystal-lang/crystal/issues/6069 ([RFC] Always return a special reference for inlined value type instead of copy)
<FromGitter> <bew> (I'm kinda biased as I'm the author of this possible solution ^^)
<troligtvis> Agree.. I don't see the reason why :>
<FromGitter> <bararchy> I want to do somethnig like that: https://play.crystal-lang.org/#/r/4bog ⏎ while keeping the same Array and not calling `a[0] = a[0] += 1`
return0e has joined #crystal-lang
<FromGitter> <bew> Are you looking for Array#map! ?
yopp has quit [Ping timeout: 265 seconds]
troligtvis has quit []
<FromGitter> <bararchy> I want to be able to pass a Pointer(Int32), and somehow do `ptr.value += 1` , and I managed to explain that terribly lol
<FromGitter> <Captainfleppo_twitter> So you don’t want to iterate through an array? You only want to +1 the value at the specific pointer adress?
<FromGitter> <bew> @bararchy https://carc.in/#/r/4bon :)
<FromGitter> <bararchy> @bew Yey!
<FromGitter> <bararchy> how comes your's is working and mine not? https://play.crystal-lang.org/#/r/4boo
<FromGitter> <bew> because by doing `pointerof(i)` you get a pointer on the local variable `i`, not on the value in the array
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> i see
<FromGitter> <aisrael> Aha! The good news is that `crystal run --release` brought it down to 11 mins, but still 10x slower than the Go implementation
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 244 seconds]
Raimondii is now known as Raimondi
<FromGitter> <bew> @aisrael you'd better compile first, then run
<FromGitter> <bew> So `crystal build --release file.cr` then `./file`
<FromGitter> <aisrael> I just assumed that’s pretty much what `crystal run —release` did (build to a temp file then run that). Let me check
<crystal-gh> [crystal] sdogruyol pushed 1 new commit to master: https://git.io/fUqdi
<crystal-gh> crystal/master 5c22fb3 O_o: Serializable, remove version conditions (#6209)
<FromGitter> <Grabli66> Maybe you should try parallel your program's logic with process fork? I think you can deliver parser logic to child processes.
<FromGitter> <aisrael> Yes, just `Time.now`
<FromGitter> <aisrael> (Also, `crystal build —release` first didn’t really do much: still 11 minutes.)
<FromGitter> <S-YOU> I think read the file by chunks, parse gzip as stream, and parse and callback csv as string would be fastest for that purpose, and not much memory allocation happened.
<crystal-gh> [crystal] straight-shoota opened pull request #6219: Add support for multiple Etags in If-None-Match header (master...jm/feature/etag-multi) https://git.io/fUgv9
<travis-ci> crystal-lang/crystal#5c22fb3 (master - Serializable, remove version conditions (#6209)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/394016000
<FromGitter> <Captainfleppo_twitter> I'm trying to do a simple JSON.mapping (https://crystal-lang.org/api/0.24.1/JSON.html#mapping-macro) but I get this error and can’t see why. ⏎ ⏎ https://play.crystal-lang.org/#/r/4bp1 ⏎ ⏎ I also tried with the same result ... [https://gitter.im/crystal-lang/crystal?at=5b28d2198a53ca283129f307]
<DeBot> https://github.com/crystal-lang/crystal/pull/6209 (Serializable, remove version conditions)
marius has quit [Quit: baj]
<FromGitter> <bew> @Captainfleppo_twitter https://play.crystal-lang.org/#/r/4bpj
<FromGitter> <bew> you can't make nested mapping the way you did it, you need another object
<FromGitter> <bew> I separated the Response from the actual Joke
<FromGitter> <Captainfleppo_twitter> thanks. hmm but in the docs they do it nested?
<FromGitter> <bew> where?
<FromGitter> <Captainfleppo_twitter> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b28d66521895a3865779fba]
<FromGitter> <Captainfleppo_twitter> or maybe it aint nesting.. it is just a parameter to make it nilable?
<FromGitter> <bew> yes
<FromGitter> <Captainfleppo_twitter> great. Make sense
<FromGitter> <bew> if you look at the example JSON you'll see
marius has joined #crystal-lang
<FromGitter> <Captainfleppo_twitter> @bew : I saw that you removed the return type from the method. And then return only if it `success`. By removing it will the compiler then now that it might return something? Like an optional. Or is there an optional type ? `: Joke?` or something.
<FromGitter> <Captainfleppo_twitter> for example I use fiber and want to return an Array of `Joke`. Will it work the same way?
<FromGitter> <fgimian> Dear guys, I'm attempting to change the behaviour of the `Process` class. Sadly I can't subclass it because in many places, the class references methods using its own class name (e.g. `Process.fork_internal`). ⏎ ⏎ So I've tried to add my own `initialize` method which has 2 extra paremeters and first calls the original `initialize` method ⏎ ⏎ `````` [https://gitt
<FromGitter> ... er.im/crystal-lang/crystal?at=5b28da3cad21887018c71413]
<FromGitter> <fgimian> But this throws an invalid memory access error
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b28da5a960fcd4eb90c4455]
<FromGitter> <fgimian> any ideas?
<FromGitter> <bendietze_twitter> @aisrael sorry i had not much time to read the code, but you are running goroutines, so why you don't spawn the Crystal version? The main fiber is 86.times waiting for IO? In this Crystal code you didn't do something while blocking?
<FromGitter> <bew> @Captainfleppo_twitter yes, it will return a union type, between Joke and Nil, which can be written as `Joke | Nil` or `Joke?`
<FromGitter> <fgimian> If I change the call to `Process.initialize`, then I end up with `this 'initialize' doesn't explicitly initialize instance variable '@pid' of Process, rendering it nilable`
<FromGitter> <fgimian> perhaps I need `previous_def` actually
<FromGitter> <bew> @Captainfleppo_twitter if you want `get_joke` to return `Joke` only, you need to handle the case where `response.type` is not `"success"`, with an `else` clause, and either a raise, or a dummy joke, or something else
<FromGitter> <Captainfleppo_twitter> yes yes, that I understand :)
Jenz has joined #crystal-lang
<FromGitter> <Captainfleppo_twitter> @bew sry to bother you. But in this case. IF i would get a `nil` from the response. How can I filter that out so I can return `Array(Joke)` ?
<FromGitter> <Captainfleppo_twitter> https://play.crystal-lang.org/#/r/4bpo
<FromGitter> <sdogruyol> @bendietze_twitter can you open an issue in Kemal repo?
<FromGitter> <bendietze_twitter> @sdogruyol yes i will do next time, but tonight i am dreaming of a possible Windows WSL error - i forgot to do all of this on linux 😟 😄 on Windows i lastly got two errors: HTTP::Multipart.parse(env.request) runs into kemal 500 error EOF reading delimeter close_delimeter , and iterating over the env.params.files hash only possible via curl uploads, because input multiple from browser is only one
<FromGitter> ... image tag name... Which one do you prefer? Or whats the correct way to do? :)
<FromGitter> <bendietze_twitter> Because of that i am searching for an solution to look at the unparsed raw http post request thats incoming to Crystal to check things like boundary and rnrn and all data from browser to clear the things up (yeah, i know, the browser should be correct, but its the first step in my mind: look whats true incoming ;)
<FromGitter> <sdogruyol> @bendietze_twitter I'm not sure
<FromGitter> <sdogruyol> I believe, multiple images can be an array or under different names
<FromGitter> <bendietze_twitter> @sdogruyol yes, i assume, i will try to get closer next time
Philpax has quit [Ping timeout: 256 seconds]
<FromGitter> <bendietze_twitter> BTW, in my opinion it would be e great benefit to Crystal if we have an solution to view the incoming raw network content to ensure everything is ok - its the only unknown ressource, so while erroring the programmer would be able to check the data :) till now i didn't found one but maybe i haven't looked at all...
<FromGitter> <bendietze_twitter> I know this comes in chunks, but its just needed for debugging, so its ok to output the data after complete parsing (like in kemal: post ... do ..) - at this time all kinds of requests are done and raw data is completed too, so its just a one time slice :)
<FromGitter> <bararchy> It seems `dup` got broken for JSON? ⏎ ⏎ 1) 24.2 => https://play.crystal-lang.org/#/r/4br0 ⏎ 2) 25.0 => https://play.crystal-lang.org/#/r/4br2 [https://gitter.im/crystal-lang/crystal?at=5b28f233479ca2668968745f]
<FromGitter> <fgimian> @bararchy I don't think you're modifying the actual JSON object in 0.25.0 there
<FromGitter> <fgimian> You're retrieving a hash and modifying that
<FromGitter> <fgimian> hmm maybe I'm wrong actually, just tried it and my idea didn't work
<FromGitter> <fgimian> carry on 😄
<FromGitter> <bararchy> :)
<FromGitter> <bendietze_twitter> But the second there is the first json wrong?
<FromGitter> <bararchy> @bendietze_twitter the problems is that `json` shouldn't change because json2 is a dup (copy) not a referance
<FromGitter> <bendietze_twitter> Yes @bararchy json = JSON.parse({bar: "foo"}.to_json) becomes bar bazz??
<FromGitter> <bararchy> yeha, that's the issue
<FromGitter> <bararchy> it shouldn't have changed
<FromGitter> <bendietze_twitter> Totally confusing
<FromGitter> <fgimian> hmm I'm not following this either
<FromGitter> <fgimian> json2 doesn't change, that's the problem isn't it @bendietze_twitter ?
<FromGitter> <bararchy> no no
<FromGitter> <fgimian> oh i see json changes with json2
<FromGitter> <fgimian> yep gotcha
<FromGitter> <bendietze_twitter> But not a ref
<FromGitter> <bararchy> example in 0.24.2 is good, the 0.25.0 is faulty
<FromGitter> <bararchy> yeha, which means it's a copy
<FromGitter> <fgimian> that's what I would have thought too 😆
<FromGitter> <bararchy> and it worked like that in 0.24.2
<FromGitter> <bararchy> and before
<FromGitter> <fgimian> ``crystal
<FromGitter> <fgimian> this works 😄
<FromGitter> <fgimian> duplicating at the hash instead of the json object
<FromGitter> <bararchy> lol, it might but it means that JSON.dup is still broken haha
<FromGitter> <bararchy> it's hash.dup that works
<FromGitter> <fgimian> hehehe
<FromGitter> <bararchy> Also, how would you handle other valid JSON like ⏎ `["1"]`
<FromGitter> <bararchy> :)
<FromGitter> <bararchy> it's can't be as_h
<FromGitter> <bararchy> XD
<FromGitter> <fgimian> true
<FromGitter> <fgimian> but then `as.a.dup`?
<FromGitter> <fgimian> still I'm not sure why `dup` doesn`t work on the JSON object personally
<FromGitter> <fgimian> probably relates to how the object is now implemented, the structure has changed significantly in 0.25.0
rohitpaulk has quit [Ping timeout: 276 seconds]
<FromGitter> <sdogruyol> Just sent Crystal Weekly http://crystalweekly.com/ Issue 40 🚀 Be sure to check your email everyone 👍
<FromGitter> <bendietze_twitter> Yes i got it some minutes before 👍
<FromGitter> <crisward> @sdogruyol just got it... think it may need a name change, the last one I got was august 2017 😉
<FromGitter> <sdogruyol> haha you're right @crisward
<FromGitter> <fgimian> @bararchy so I can see why this is happening exactly now mate
<FromGitter> <fgimian> in the new implementation, we have a instance variable named `@raw` storing all the data
<FromGitter> <fgimian> here's a simple repro
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b28fa03fc6062038064f441]
<FromGitter> <sdogruyol> btw long time no see @crisward , how 's it going?
<FromGitter> <fgimian> @bararchy in this case, because a Hash is mutable, when a shallow copy is done, it will create another instance of the class an assign the new instance variable to the old one, which is essentially going to pass over its memory address. As such, it is actually shared. ⏎ ⏎ Compare this with an immutable type like a String and you'll see the difference: ⏎ ⏎ ``````
<FromGitter> <fgimian> So ultimately, what I suggested is your best way forward, simply run `dup` on the Hash itself
<FromGitter> <fgimian> 😄
<FromGitter> <fgimian> hope this helps, it was annoying me too which is why I went looking into the source
<FromGitter> <fgimian> I'm sure if we dug up the implementation in 0.24.2, we would know why that worked differently
<FromGitter> <bararchy> @fgimian thanks for taking the time, I'll try to monkey patch it in the source
<FromGitter> <fgimian> You may need to overload the `dup` method or similar I guess mate
<FromGitter> <fgimian> good luck!
<FromGitter> <bendietze_twitter> Sorry, am i wrong? Second @var over first @var is against encapsulation? I am confused
<FromGitter> <bararchy> @fgimian as simple as ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b28fc4ed2abe4668871030f]
<FromGitter> <fgimian> @bararchy Just one final note. I just looked at the source of JSON in 0.24.2 and ultimately, it does use a similar mechanism to 0.25.0 so I suspect it's another change in the language itself that changed this behaviour. Maybe it would be worth raising an issue on? (FYI I'm still a new guy to Crystal, so perhaps someone else here can confirm if it's worth doing)
<FromGitter> <fgimian> oh haha nice
alex`` has joined #crystal-lang
<FromGitter> <fgimian> Here's my newest little "patch" to add functionality
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b28fcec14805602858e7f36]
<FromGitter> <fgimian> 😄
<FromGitter> <fgimian> was kinda surprised there wasn't a way to just grab a hash of the environment variables out of the box
duane has joined #crystal-lang
<FromGitter> <Grabli66> Hi! How to check parent class of class? https://play.crystal-lang.org/#/r/4bsg
alex``` has joined #crystal-lang
<FromGitter> <Grabli66> Better example. https://play.crystal-lang.org/#/r/4bsj
alex`` has quit [Ping timeout: 276 seconds]
<FromGitter> <fgimian> try `.class`
<FromGitter> <bendietze_twitter> typeof or .class == .class i am not sure :)
alex```` has joined #crystal-lang
<FromGitter> <Grabli66> It does not work. classtype.class always returns "class". https://play.crystal-lang.org/#/r/4bsw
alex```` has quit [Client Quit]
<FromGitter> <fgimian> hold up, I've got it going
<FromGitter> <fgimian> actually what you had was correct
<FromGitter> <fgimian> the reason you always get an exception is because ... well ... you have nothing to stop that happening
<FromGitter> <fgimian> does that help?
alex``` has quit [Ping timeout: 256 seconds]
<FromGitter> <Grabli66> Almost. But i want to check by parent class One
<FromGitter> <fgimian> ooh gotcha
<FromGitter> <fgimian> sorry
<FromGitter> <fgimian> my brain is not working well today, been a long day ... 😫
<FromGitter> <fgimian> hehehe
<FromGitter> <crisward> @sdogruyol ok... Not been around here much since we decided to hold off on pushing Crystal in production until it hits a stable release. We have a handful of simple marketing sites using it with a 'proto-type' of a crystal version of our content management system. It works ok, but the immature eco-system around crystal means fewer off the shelf solutions to problems, and a few too many unknowns right now. I'd
<FromGitter> ... like to run both versions in parallel, but that means double the bugs to fix and confusion over support. Good to see a new release come out, hoping it becomes a less rare sight.
<FromGitter> <fgimian> i think you need to use Macros @Grabli66
<FromGitter> <fgimian> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2904b8ad21887018c77e74]
<FromGitter> <fgimian> hmm but that won't work at runtime
<FromGitter> <fgimian> ehhh
<FromGitter> <yxhuvud> heh, cute. Now I have a segfault that disappears when I add a `puts` to the first place of my method.
<FromGitter> <Grabli66> @fgimian May be there is better way to create instance of class in method by it's type?
<FromGitter> <fgimian> hmm well I do have one idea mate
<FromGitter> <fgimian> it's a bit dodgy, but I know it will work
<FromGitter> <Daniel-Worrall> @Grabli66 see #3875
<FromGitter> <fgimian> yep that's what you want
<FromGitter> <fgimian> my solution was in the ballpark but much dodgier
<FromGitter> <fgimian> I used the `inherited` macro, but this solution provided above is the right one
<FromGitter> <fgimian> ok i'm off to bed, take care guys
<FromGitter> <Daniel-Worrall> o/
<FromGitter> <Grabli66> Something's going wrong :) https://play.crystal-lang.org/#/r/4btg
<FromGitter> <Grabli66> The example from PR does not work
<FromGitter> <Grabli66> Ooops. Bad example. Need to use superclass, not superclasses
<FromGitter> <Daniel-Worrall> ah
<FromGitter> <Daniel-Worrall> superclasses was supposed to be in that pr
<FromGitter> <Daniel-Worrall> Nevermind, they excluded superclass on basis of naming schemes and ancestors doing the "same" job
<FromGitter> <Grabli66> Good :)
<FromGitter> <Grabli66> I found a cheat way :) And i think it's faster than to check ancestors https://play.crystal-lang.org/#/r/4bux
<RX14> shards 0.8.1 which fixes the shards regression was released on arch repos today
Jenz has quit [Ping timeout: 260 seconds]
rocx has joined #crystal-lang
<crystal-gh> [crystal] r00ster91 closed pull request #6176: Finish the \a escape sequence (master...finishescapesequence) https://git.io/vhVnv
<crystal-gh> [crystal] r00ster91 opened pull request #6221: Finish the \a escape sequence (master...escapesequence) https://git.io/fLbYd
snsei has joined #crystal-lang
<FromGitter> <Daniel-Worrall> I have no idea what use case you have there Grabli
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Jenz has joined #crystal-lang
hightower2 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
tax has joined #crystal-lang
hightower2 has quit [Ping timeout: 256 seconds]
<FromGitter> <straight-shoota> Currently 11,111 stars
<FromGitter> <straight-shoota> Cheers ⭐
<FromGitter> <faustinoaq> ✨ 👏
<FromGitter> <faustinoaq> Hey, I'm getting an error with `puts {a: 1}.to_json` on v0.25.0: `Syntax error in eval:3: expecting token 'CONST', not '1'`
<FromGitter> <faustinoaq> https://carc.in/#/r/4bw2 (0.25.0)
<FromGitter> <straight-shoota> you need to wrap the argument in parenthesis in order to distinguish the named tuple literal from a block argument
<FromGitter> <faustinoaq> Oh, https://carc.in/#/r/4bwf (without `puts`)
<FromGitter> <straight-shoota> And that's not specific to 0.25.0
<FromGitter> <bendietze_twitter> 1) 111 🎉
<FromGitter> <faustinoaq> @straight-shoota You're right, Thank you! 👍
Jenz has quit [Ping timeout: 265 seconds]
<FromGitter> <Daniel-Worrall> Is it intended that Module#class returns class?
rohitpaulk has quit [Ping timeout: 260 seconds]
Jenz has joined #crystal-lang
<FromGitter> <hmans> Here is everyone's <3 for today. <3!
<FromGitter> <meraxes_twitter> This may be a ridiculous question but here goes: https://play.crystal-lang.org/#/r/4bwj ⏎ ⏎ In a parent class I define a class. var with an array of class `Property`. Within child classes, I override the class var with subclasses of `Property`. This blows up. Can I define the parent classes class_var in such a way that it can contain any subclass of `Property`? Or is it even possible to override
<FromGitter> ... class_vars? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2925c8a645d134ab0bf0fc]
<FromGitter> <meraxes_twitter> ( I have not used strong typing in about… 20 years… so be gentle)
<FromGitter> <bcardiff> @meraxes_twitter you are missing `.new` after One and Two.
<FromGitter> <meraxes_twitter> yes. I wanted to store the class, not instances of them.
<FromGitter> <meraxes_twitter> OH
<RX14> then the arrays need to be of Property.class
<RX14> or veave off `of`
<RX14> leave*
<RX14> then the compiler will figure it out
<RX14> well maybe
<FromGitter> <meraxes_twitter> hrm.
<FromGitter> <meraxes_twitter> Excellent. thanks muchly
<FromGitter> <faustinoaq> Hey, an Amber Cookbook (https://docs.amberframework.org/amber/cookbook) is now available, inspired by Kemal Cookbook, thanks @sdogruyol 🎉
<FromGitter> <meraxes_twitter> Interesting. So in the subclasses if I don’t add the `of Property.class` it complains about redefinition.
<FromGitter> <meraxes_twitter> Gotcha.
<RX14> yeah because they'll be different types
<RX14> because the compiler sees [ Property::One ] and types it as Property::One.class
<RX14> because the compiler sees [ Property::One ] and types it as Array(Property::One.class)
<FromGitter> <meraxes_twitter> Yeah. I’d thought it would figure it from the parent but I guess it needs some help. Fair.
<RX14> which isn't an Array(Property.class)
<FromGitter> <meraxes_twitter> indeed
<RX14> crystal's type inference algorithm is "constants outwards"
<FromGitter> <meraxes_twitter> good to know. Thank you both.
<RX14> so it always types literals like the array first, then checks the types
<FromGitter> <bcardiff> Nice @faustinoaq! how are you branding the gitbook? Are you getting feedback with the faces at the bottom?
<RX14> never takes the parent type to type the literal
<RX14> the very first instance of that changing actually landed in 0.25.0
<RX14> but the typing algorithm is pretty hard to change
<RX14> so if stuff changes in that respect it'll be slowly over time
<RX14> for now you always have to think literals outwards
<FromGitter> <meraxes_twitter> Yeah. I don’t doubt. Well over my head. Thanks for the clarification.
<RX14> np
<FromGitter> <meraxes_twitter> I’m trying to implement the MQTTv5 spec as a learning exercise. It is non-trivial. :)
<RX14> i dont doubt
<FromGitter> <faustinoaq> @bcardiff Yeah, new GitBook works pretty nice, we have received a ton of new feedback and contributions 😄
<FromGitter> <faustinoaq> Now, we can see what things are missing in Amber documentation 🎉
Jenz has quit [Ping timeout: 256 seconds]
wontruefree has joined #crystal-lang
hightower2 has joined #crystal-lang
<FromGitter> <paulcsmith> The new shards 0.8.1 fixes the update command, but is there a way to get the new version of shards or does it require a new version of Crystal?
<FromGitter> <straight-shoota> you can manually install the latest shards
<FromGitter> <straight-shoota> see readme
<FromGitter> <paulcsmith> Ah, thank you!
<RX14> if you run osx the formula can be updated
<RX14> release a pkgver 2 with the new shards
<RX14> i dont have an osx machine to do it
<RX14> but it's just homebrew
<RX14> if you can send a PR you can update shards
<FromGitter> <paulcsmith> I'm not sure I understand. A PR to Crystal?
<RX14> no
<RX14> to homebrew
<FromGitter> <paulcsmith> I use macOS but I'm not familiar with the Crystal or Shards release process
<FromGitter> <paulcsmith> I'll look into it
<RX14> homebrew is just a git repository of recipies to install stuff
<RX14> the crystal core team doesnt have more say than you over what happens with homebrew
<RX14> as for the linux packages...
<FromGitter> <paulcsmith> The one problem I see with updating the homebrew package is that people that already have crystal 0.25 would need to reinstall it.
<RX14> no
<FromGitter> <paulcsmith> But it's a start
<RX14> no they wouldnt
<FromGitter> <paulcsmith> Oh, ok
<RX14> you'd bump the package release to 2
<RX14> and everyone would update
<FromGitter> <j8r> for those that have followed the libc project, it's modifier to autobind https://github.com/j8r/autobind
<RX14> every package manager has a version and then a minor release which is specific to the packaging
<FromGitter> <paulcsmith> I thought brew would only look at 0.25 but if there is some other version it's using under the hood, then even better
<RX14> one upstream release may have several different packages with different pkgrel/pkgvers
<RX14> you get 0.25.0-1
<RX14> you'd ujust release 0.25.0-2
<RX14> then eventually 0.25.1-1
<RX14> they just append a version number to the upstream version
<FromGitter> <paulcsmith> Ok I'll try to make a PR for it
<FromGitter> <paulcsmith> Won't have any time today so if someone else is free now and wants to take a crack at it, here is the formula https://github.com/Homebrew/homebrew-core/blob/master/Formula/crystal-lang.rb
<FromGitter> <paulcsmith> Updating to shards 0.8.1 would be wonderful because it fixes a critical bug: https://github.com/crystal-lang/shards/issues/211
<FromGitter> <paulcsmith> Who usually handles making a new homebrew release, or is it automated somehow?
<RX14> no you just send in a pr
<RX14> change the url
<RX14> update the hashes
tax has quit [Quit: Leaving]
<RX14> bump the pkgrel
<RX14> or whatever homebrew does
<FromGitter> <paulcsmith> Yeah I get that, I was just curious how the normal release process goes. I assume someone from the core team typically handles it.
<FromGitter> <paulcsmith> Or is there an automated process?
<RX14> nah
<RX14> well its sometimes someome from the core team
<FromGitter> <paulcsmith> Really what I'm wondering is whether there is a way to streamline releases
<RX14> oh yeah look, you just add `revision 1`
<RX14> like he removed in that commit
<RX14> what is there to streamline?
<FromGitter> <paulcsmith> Ideally there should be a script you run that releases a new version of Crystal
<RX14> its mostly automated
<FromGitter> <paulcsmith> Oh ok. I was just curious what that process was or if there was a script. For example I've got this https://github.com/luckyframework/homebrew-lucky/blob/master/bin/generate and https://github.com/luckyframework/homebrew-lucky/blob/master/generate.cr that makes releasing new Lucky versions easier with homebrew. So I have some familiarity with Homebrew but I did not know you could do new "revisions" which is
<FromGitter> ... pretty cool!
<FromGitter> <paulcsmith> So for example, in cases like this, I think it would be cool if a core team member could run `bin/release mac_os` or something and it would generate rewrite the formula with the newest versions of Crystal and shards, run the tests, and then you just need to open a PR when you're ready
<FromGitter> <paulcsmith> That way anyone on the core team could release regardless of what OS they are on
<FromGitter> <paulcsmith> Anyway, not necessarily a priority, but an idea for the future
<RX14> i mean I could release
<RX14> i just cant test it
<RX14> maybe I will
<RX14> yeah i'll just do it they have CI anyway
<FromGitter> <paulcsmith> Good point!
<FromGitter> <paulcsmith> And thank you :)
<FromGitter> <bcardiff> @paulcsmith that script is neat 😎
Jenz has joined #crystal-lang
<FromGitter> <paulcsmith> Glad you like it :) Feel free to steal it if you find it helpful
<FromGitter> <paulcsmith> It made releasing new versions of Lucky way less error-prone and much faster
<FromGitter> <meraxes_twitter> And it’s bacK. nvm
wontruefree has quit [Quit: bye]
<rocx> silly newb question: does Process need to be require'd in order to use Process#chroot? i keep getting an error that it's an "undefined method 'chroot' for Process:Class".
<RX14> what version of crystal
<RX14> chroot was 0.25.0
<rocx> (crystal 0.24.1)
<rocx> ...oh.
<rocx> what unfortunate timing for me to check the API.
<rocx> the commit added it back in april so i though it would've still been 0.24.*.
<RX14> 0.24.1 was released a loong while ago
<RX14> 0.24.2 was even released before 0.25.0
<RX14> why aren't you on latest version?
<rocx> it's the only version in the void linux repos.
<rocx> think i'll go ahead and upgrade now.
<RX14> yeah
<RX14> if its void should be easy to update it yourself
<RX14> honestly if void was a serious distro you wouldn't have to ask the maintainers to update...
<RX14> the arch maintainers for crystal are always on it and watching for releases#
<FromGitter> <LVMBDV> maintainer for the crystal package on void here
<FromGitter> <LVMBDV> my void install came tumbling down the night before a local ctf so i had to get a new environment working quickly so i switched to debian
<RX14> yeah but 0.25.1
<RX14> 0.25.2 has been hout for... 3 months?
<RX14> 0.24.2*
<RX14> and 0.24.1*
wontruefree has joined #crystal-lang
<rocx> man i am waaaaaaay behind on the release cycle. i literally just caught that there was a package a couple of days ago.
<rocx> not a fan of the bootstrapping imo but guess it's cool to get it to work like that.
<FromGitter> <LVMBDV> i was working on a void package dev workflow using docker but other things came up
<FromGitter> <LVMBDV> could you update the package rocx
<rocx> i think i can get to it.
dragonkh has joined #crystal-lang
* rocx remembers the pain it was to update the adobe-flash-player package for void.
<RX14> crystal should be a lot easier
<dragonkh> hey guys - sorry I don't come here that much - but I'm super focused on SushiChain crypto project at the moment - but I just wanted to say well done on the 0.25 Crystal release - great work :)
<dragonkh> I should have said hey people - sorry ladies
<FromGitter> <LVMBDV> rocx: just try to update the version variables and see where that takes you
<FromGitter> <LVMBDV> or i could do that and use the CI to debug
<crystal-gh> [crystal] straight-shoota opened pull request #6222: Fix heredoc start + comma formatter (master...jm/fix/6197) https://git.io/fmita
<rocx> i presume `loop do` is no longer valid syntax as well?
<RX14> yes it is
<rocx> maybe i falsely remember a PR about getting rid of it.
<RX14> loop do works fine
<RX14> its the argument to the block
<RX14> loop do |i| no longer works
<rocx> wait wtf was i doing for there to be an "error instantiating method loop()"?
<rocx> now it works.
<FromGitter> <LVMBDV> i will try to get the package up to date within this week rocx
<rocx> i'm on it. just taking a while to get the repo set back up.
<Yxhuvud> you can do Int64::MAX.times if you need the block argument anyhow. (or hmm. I wonder if UInt64 would work too or loop infinitely)
<wontruefree> is there an issue or any docs on what it would take to get to static compilation?
<RX14> yeah, rewriting glibc and openssl
<FromGitter> <kingsleyh> @girng maybe you would consider using our blockchain project to hook up a real economy using tokens or whatever :)
<RX14> luckilly someone already did it for us
<RX14> called it musl and libressl
<RX14> and then made a distro based on them called alpine
<FromGitter> <LVMBDV> lol
<RX14> which is why the only thing crystal supports static linking on is alpine
<wontruefree> I was looking up that yesterday from some of the conversation
<wontruefree> I dont understand why a rewrite is necessary is it a licensing issue
<wontruefree> or an issue with those libraries
<crystal-gh> [crystal] bcardiff opened pull request #6223: [WIP] Arithmetic with Overflow (master...feature/checked) https://git.io/fmbTP
<RX14> >30 commits
<RX14> that'll be a hell of a PR to review
<FromGitter> <bcardiff> It's >30 for making the review easier actually.
<RX14> i'm looking forward to reviewing it actually
<RX14> or lt least looking forward to merging it
<RX14> and then looking much much more forward to making checked the default
<FromGitter> <bcardiff> I thought that you most of all would like how the commits are divided.
<FromGitter> <bcardiff> 👍
<RX14> debug should always be checked imo
<RX14> and release should have the option
<RX14> ah well thats minor
<FromGitter> <bcardiff> Of course the CI complains a bit in the first round :-P
<Yxhuvud> the only thing I don't like about that is that unchecked/checked doesn't betray intention all that well. Newbies will have no idea what it is about without having to google it
<RX14> my browser's too busy crashing to see what the CI broke over
<RX14> every time I open circleci my whole browser ctrashes
<RX14> I don't know how they did it
<RX14> but they have
Jenz has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<FromGitter> <meraxes_twitter> friends don’t let friends write javascript
<FromGitter> <LVMBDV> i wrote a javascript "script" to precalculate a kerning table to embed into a crystal app yesterday
<RX14> i'll be glad if I have the time to write my own CI server for crystal like i've always wanted
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <LVMBDV> it was in javascript because npm has this cool package pdfkit
<FromGitter> <meraxes_twitter> as in, you can precalculate what width the text will be?
<FromGitter> <LVMBDV> exactly
<FromGitter> <LVMBDV> only letters and diagrams were enough tho
<FromGitter> <bararchy> RX14 that sounds like an interesting Project
<RX14> i have some ideas
<FromGitter> <bararchy> where does it stand priority wise between your 9000 other projects?
<FromGitter> <bararchy> hahahahahah
<FromGitter> <bararchy> don't get swamped
<FromGitter> <bararchy> I'm stil waiting on PCHANNEL
pwned has joined #crystal-lang
<pwned> hi, are there any shards similar to three.js ?
<pwned> that makes it very easy to visualize some of the neuroevolution stuff I want to program
<FromGitter> <bararchy> Woot neuroevolution
<pwned> I wrote a working prototype in ruby but it is kinda slow
<FromGitter> <bararchy> can you link? sounds interesting
<pwned> It is just a local repo at the moment but I followed this paper here: http://nn.cs.utexas.edu/downloads/papers/stanley.ec02.pdf
<FromGitter> <LVMBDV> @meraxes_twitter the kerning thing is here if you are interested https://gitlab.com/Ata/badger
<FromGitter> <bararchy> as in, how did you see it's being slow? and it what parts of the network?
<FromGitter> <bararchy> pwned btw I don't know if you saw but our network here: https://github.com/NeuraLegion/shainet is biomimicry neural network
<pwned> it's dog slow during mutations and crossovers
<pwned> I wanted to switch to crystal to see if it helps with the speed a little bit
<FromGitter> <Captainfleppo_twitter> The api im using are having the keys as capitalize. `“Title” : “Jurrassic Park”` is there a way to use `JSON.mapping` or do I have to do a workaround? ⏎ ⏎ ```Syntax error in main.cr:6: expecting token ')', not ':' ⏎ Title: String``` [https://gitter.im/crystal-lang/crystal?at=5b294568a645d134ab0bf1a9]
<pwned> bararchy I'm looking
<FromGitter> <bararchy> pwned we got massive improvments
<FromGitter> <bararchy> also started from Ruby
<FromGitter> <bararchy> and went to Crystal both memory went down, and speed went up crazy
<pwned> I don't need much, just 30x is enough :-)
<FromGitter> <bararchy> hahah
<pwned> I like shainet
<FromGitter> <bararchy> Thanks :)
<FromGitter> <bararchy> We added ES optimizer -> https://github.com/NeuraLegion/shainet#evolutionary-optimizer-example
<FromGitter> <LVMBDV> @Captainfleppo_twitter JSON.mapping can take a hash literal instead of named parameters, see the doc while i whip up an example: https://crystal-lang.org/api/0.24.2/JSON.html right under usage
<FromGitter> <Captainfleppo_twitter> aah ok! `Hash(String, String).from_json` ?
<FromGitter> <LVMBDV> that would work but you can still use `JSON.mapping`
<FromGitter> <LVMBDV> ``````
<FromGitter> <LVMBDV> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b294701fc6062038065cef1]
<FromGitter> <LVMBDV> like this, @Captainfleppo_twitter
<FromGitter> <Captainfleppo_twitter> @LVMBDV cool thx :)
<pwned> this took like 100 lines of code in ruby, I'd like to find something similar in crystal https://image.ibb.co/ktif5J/Screenshot_from_2018_06_19_21_01_32.png
<pwned> just draw some primitives and move them around in a loop
<FromGitter> <bararchy> it looks like fish :)
<pwned> in ruby I used mittsu https://github.com/jellymann/mittsu which is a threejs-like drawing library
<pwned> yes that was intended bararchy
<FromGitter> <bararchy> pwned take a look at CRSFML
<FromGitter> <bararchy> it might be good for that
<FromGitter> <bararchy> https://github.com/oprypin/crsfml
<pwned> it does set me up with a context window and gives me a way to loop on input
<pwned> however, crsfml doesn't have 3d drawing primitives
<pwned> (neither does sfml)
<FromGitter> <bararchy> that's true
<pwned> I'd have to write my own "primitive group" logic
<pwned> I would ahve to write a scene graphs and do transforms on those manually
<pwned> which takes away all the fun from focusing on the actual algorithm
wontruefree has quit [Quit: bye]
zachk has joined #crystal-lang
zachk has joined #crystal-lang
<rocx> @LVMBDV "Error: you've found a bug in the Crystal compiler. Please open an issue..." yeah it might be a bit more involved than upping the values. appears that i ran out of memory in that compiling.
<pwned> this looks somewhat promising https://github.com/nya-engine/nya/tree/master/src/nya
<FromGitter> <confact> Hi again guys. I am new with crystal as you guys probably already know. I have problem to call a macro method: compare_versions. i just get `undefined method 'compare_versions'`
<FromGitter> <LVMBDV> @rocx i'll take a look then
dragonkh has joined #crystal-lang
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 256 seconds]
<FromGitter> <bew> @confact you need to call it from a macro
<pwned> @confact maybe you want this https://github.com/j8r/semantic_compare
<FromGitter> <reiswindy> @Grabli66 About checking if a class inherits from another, you can use `<`or `>`. ⏎ https://crystal-lang.org/api/0.25.0/Class.htmlhttps://play.crystal-lang.org/#/r/4bxk
wontruefree has joined #crystal-lang
<FromGitter> <Grabli66> @reiswindy Cool. Thanks.
<crystal-gh> [crystal] sdogruyol pushed 1 new commit to master: https://git.io/fY1ox
<crystal-gh> crystal/master 750258d Johannes Müller: Add tempfile and datapath helpers to specs (#5951)
bmcginty has quit [Ping timeout: 260 seconds]
bmcginty has joined #crystal-lang
<FromGitter> <confact> thanks @pwned
<FromGitter> <confact> just want I wanted.
<FromGitter> <confact> Any good way to do something like `Hash.from_xml` in crystal?
<RX14> XML doesn't have the concept of hashes
<RX14> the datamodel is incompatible
<FromGitter> <confact> these are simple xml, with just key and values. so it should work. It does in Ruby.
<pwned> oh yeah, ruby had that
<oprypin> xml doesnt even have "keys"
<oprypin> ruby is insane
<wontruefree> is that in the stdlib or a gem?
<pwned> ruby can convert <root id="x"><node>something</node><node>else</node></root> -> { "root"=> { "id"=> "x", "node"=> ["something", "else"] } }
<FromGitter> <confact> key maybe was bad wording.
<oprypin> pwned, i'm noticing it says /rails/
<wontruefree> pwned I think that is from rails then
<pwned> ooo yeah it's active_support
<wontruefree> lol
<wontruefree> yeah
<pwned> now I remember
<oprypin> ok nevermind then, rails is insane
<pwned> "do that thing I don't care how many undefined things you end up with"
<FromGitter> <confact> Yea, I am rails-hurt.
<RX14> activesupport is terrible honestly
<FromGitter> <confact> I guess I can't get away from awful xml nodes then.
<RX14> no, you can't get away from dealing with how XML actually works
<RX14> if you want to serialize hashes and strings... thats what JSON is for
<oprypin> confact, i mean, you could implement an equivalent method as well..
<pwned> json is specified as utf-8 right
<oprypin> i think so
<pwned> or maybe not
<pwned> so we don't know the encoding. Madness ensues
<oprypin> i'm not sure if there is any well regarded json spec
<oprypin> encoding shouldn't matter, anyway
<oprypin> it can be handled at an earlier stage
<FromGitter> <confact> Sorry for being a person who want to avoid anything to do with XML, I don't care about the attributes here, as these XML dont have attributes. I will try to port the XMLConverter to crystal.
<pwned> would be courteous to mention encoding when you are transmitting through the wire
<oprypin> confact, maybe you don't want to deal with everything having the type Hash | Array | String
<oprypin> if you can even define that (it's also not recommended cuz recursive aliases might be deprecated)
<oprypin> there has to be a better way
<oprypin> turning into Hash is definitely not it
<oprypin> though it might work with enough force
<pwned> generate class from schema!
<pwned> or use delphi
<FromGitter> <LVMBDV> rocx i have tried to get xbps running in a chroot then tried a docker image, both failed, i give up for now
<RX14> crystal's XML tooling isn't that mature
<FromGitter> <confact> I just want to get data from XML's like these: http://radio.zuluhosting.net:8007/stats?sid=1
<pwned> I wonder if there is an embedded database engine with the xpath capabilities of mssql
<Yxhuvud> the from_hash method on xml in activesupport is probably legacy to support providing hashes in a structure meant for nested sql records. remember, rails is old enough to be from the time where it wasn't obvious yet that json would win out.
<pwned> then you could embed and use a query instead of re-inventing xml
<oprypin> confact, then just use Crystal's XML classes
<FromGitter> <LVMBDV> I would love to have someone review my Kemal project btw: https://gitlab.com/Ata/badger
<FromGitter> <straight-shoota> it's really not that complicated
<FromGitter> <straight-shoota> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b295f880168e70c08d40f9f]
pwned has quit [Ping timeout: 245 seconds]
<travis-ci> crystal-lang/crystal#750258d (master - Add tempfile and datapath helpers to specs (#5951)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/394255146
<DeBot> https://github.com/crystal-lang/crystal/pull/5951 (Add tempfile and datapath helpers to specs)
<oprypin> confact, https://carc.in/#/r/4by3
<oprypin> aw
<FromGitter> <schoening> @bendietze_twitter was on a trip to Amsterdam for a week so no progress ^^, and moving apartment right now.. AND got a freelance project I have to try and finish in the next 4 weeks. So it'll be a while ... 😟
<rocx> lvmbdv: closed some other things out too. no longer getting out-of-memory issues, but some other vauge error. "undefined reference to `LLVMInitializeInstCombine'"
<wontruefree> it looks like shoutcast has a json format but you might have to enable it on the server
<FromGitter> <schoening> But one thing I will do in the next few days is make an example repo to get help from all the smart people here to help me stop getting broken pipe errors in my websockets because unless that gets done no game will ever be made.
moei has quit [Quit: Leaving...]
akaiiro has joined #crystal-lang
<FromGitter> <Daggerron> Is there a way to do something like this easily in crystal ? ⏎ ⏎ ```def exemple(someValue, Type) ⏎ puts someValue.as(Type) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5b2964c4960fcd4eb90dc275]
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
dragonkh has joined #crystal-lang
<FromGitter> <Daggerron> without doing something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2965b859799e70172b6139]
dragonkh has quit [Client Quit]
<FromGitter> <faustinoaq> @LVMBDV Nice project, stared! 👍
<FromGitter> <faustinoaq> > <bararchy> @asterite could you remind me how you did the memory profiling to a Crystal program? ⏎ ⏎ @bararchy Try https://github.com/Groogy/trashman
<oprypin> @Daggerron, no, there is no way
<oprypin> Daggerron, woops there is https://carc.in/#/r/4bys
hightower2 has quit [Ping timeout: 265 seconds]
<FromGitter> <BenDietze> @schoening no hurry, good luck 👍
<FromGitter> <Daggerron> @oprypin Oh thanks !
<oprypin> no idea what you want to achieve with this but w/e
<FromGitter> <Daggerron> @oprypin It's an handler for my db so that I can read a specific type and make a more general function rather than one for every type
<oprypin> Daggerron, or maybe you should make one for every type
rohitpaulk has joined #crystal-lang
<oprypin> ... with **macros**
<FromGitter> <Daggerron> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b297075960fcd4eb90ddf35]
<FromGitter> <Daggerron> @oprypin i have that for now
<oprypin> well hopefully you secure your queries from bobby tables
rohitpaulk has quit [Ping timeout: 256 seconds]
duane has quit [Ping timeout: 256 seconds]
snsei has quit [Ping timeout: 260 seconds]
dragonkh has joined #crystal-lang
That_Guy_Anon has joined #crystal-lang
dragonkh has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<FromGitter> <forkev_twitter> @oprypin ; a classic. https://xkcd.com/327/ , lol
<That_Guy_Anon> good ol' bobby
<That_Guy_Anon> always up for trouble
<FromGitter> <forkev_twitter> i'm super cheap. I usually just replace all instances of ' to '' and call it a day for internal projects for sql sanitation. I know my risks, but I don't trust *SOME* data formats.
That_Guy_Anon has quit [Quit: Leaving]
snsei has joined #crystal-lang
frank_ has joined #crystal-lang
<frank_> hello
<FromGitter> <faustinoaq> frank_ Hi 😄
<FromGitter> <faustinoaq> @forkev_twitter lol
frank_ has quit [Ping timeout: 260 seconds]
maxpowa has quit [Quit: Ahh! My head is on fire!]
maxpowa has joined #crystal-lang