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
<FromGitter> <confact> @RX14 How do I get Client's get method to use my method then?
wontruefree has joined #crystal-lang
<FromGitter> <aemadrid> @mjago thx! I’ll give that a try
<FromGitter> <constXife> Hi! How can I make a binding to this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c425a960fcd4eb9182405]
snsei has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <constXife> Probably it should look like that. Thank, I will try. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c46535862c35f47bc963f]
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
zachk has quit [Quit: Leaving]
<FromGitter> <adamgotterer_twitter> I have a websocket server / client setup. I'm curious why the context on_close method (sent to HTTP::WebSocketHandler.new) can't detect a client disconnect? If the server hangs up my client knows the socket was closed. But it doesn't seem to work in the reverse. Any ideas how I can detect a client disconnect from the server?
wontruefree has quit [Read error: Connection reset by peer]
wontruefree has joined #crystal-lang
<FromGitter> <adamgotterer_twitter> Some code: https://gist.github.com/adamgotterer/2330b2dd05be28279b9dda0889ec8e91
wontruefree has quit [Quit: bye]
<FromGitter> <fridgerator> if there is an unexpected disconnect from the client, then the server doesn't know about it
<FromGitter> <fridgerator> you have to implement heartbeats and stuff like that
<FromGitter> <adamgotterer_twitter> That's unfortunate. Thanks.
<FromGitter> <fridgerator> thats not specific to crystal either
<FromGitter> <fridgerator> it works that way with websockets in any language
<FromGitter> <adamgotterer_twitter> Any suggestion for the best place to put a heartbeat?
<FromGitter> <adamgotterer_twitter> Should I throw it in a fiber once the session is created and every second send a PING?
<FromGitter> <adamgotterer_twitter> Btw, I didn't setup a heartbeat on the client side and it detects the hang up without issue
wontruefree has joined #crystal-lang
akaiiro has joined #crystal-lang
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <faustinoaq> @S-YOU Oh, awesome! 🎉 Are those companies in this list (https://github.com/crystal-lang/crystal/wiki/Used-in-production)?
<FromGitter> <S-YOU> No, one is DMM. https://inside.dmm.com/entry/2018/05/30/crystal-lang
<FromGitter> <faustinoaq> BTW, would be possible to use `h2o.cr` as `HTTP::Server` replacement for crystal frameworks like Kemal/Amber/Raze/Lucky?
<FromGitter> <S-YOU> h2o run on its own eventloop, so it is kind of tricky with Fiber/Scheduler and GC
<FromGitter> <faustinoaq> @S-YOU Thanks for the link! 👍
<FromGitter> <faustinoaq> @S-YOU Oh, I see you disabled most crystal stdlib `-Dgc_none -D... -Dextreme` etc 😅
<FromGitter> <S-YOU> True, it is basically C
<FromGitter> <faustinoaq> Oh ok 😄 👍
<FromGitter> <faustinoaq> Still very impressive ✨
<FromGitter> <S-YOU> It is ok to turn on most of them, I just don't use any for C bindings.
<FromGitter> <S-YOU> There is little overhead on bound checks with exception handling, GC is okay to include as long as you don't trigger it.
<FromGitter> <S-YOU> Also it is very easy to see llvm-ir or assembly without them, because by default you get like 50k lines of LLVM-IR, but without them, it is like 500 lines.
<FromGitter> <faustinoaq> @S-YOU Well, we can try a immix GC as well: https://github.com/ysbaddaden/gc
<FromGitter> <S-YOU> Yeah, but within hot loop, triggering GC is not a good choice. h2o has its own mempool, which never return to system but can reuse, if there is a need to allocate.
<FromGitter> <faustinoaq> > Also it is very easy to see llvm-ir or assembly without them, because by default you get like 50k lines of LLVM-IR, but without them, it is like 500 lines, same level as C. ⏎ ⏎ Yeah, I saw your tweet, without stdlib, the LLVM-IR generated by crystal looks pretty clean 👍
<FromGitter> <faustinoaq> @S-YOU Yeah 👍
<FromGitter> <faustinoaq> Thank you for your collaboration with crystal community, very appreciated! 😄
<FromGitter> <S-YOU> I am very happy to meet with them :)
<FromGitter> <S-YOU> I met MakeNowJust in person too 😄 , showed as part of the crystal lexer, which I am trying to learn.
<FromGitter> <codenoid> i was success to solve my problem
<FromGitter> <codenoid> now how i can split 1 number into 3 number in array with random division
<FromGitter> <codenoid> i have x : 200, how to split x into list of number (in array) with random division ⏎ ⏎ example: ⏎ ⏎ ```1. [2,5,3] # x : 10 ⏎ 2. [7,1,2] # x : 10 ⏎ 3. [8,5,7] # x : 20``` [https://gitter.im/crystal-lang/crystal?at=5b2c70640168e70c08e27bc0]
<FromGitter> <Daniel-Worrall> @codenoid here's some bad code https://carc.in/#/r/4cic
<FromGitter> <Daniel-Worrall> https://carc.in/#/r/4cid or I could not do pointless allocations
<FromGitter> <codenoid> thank you so much @Daniel-Worrall
<FromGitter> <Daniel-Worrall> as long as it's not homewokr
<FromGitter> <codenoid> i was think about ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but it's more complicated [https://gitter.im/crystal-lang/crystal?at=5b2c7abc7d3bca737affba7c]
<FromGitter> <codenoid> part of learning/wJob xD
<FromGitter> <Daniel-Worrall> rand(int) gives an int 0->(int-1)
<FromGitter> <Daniel-Worrall> so you just add your starting value
<z64> @Daniel-Worrall OOB if you're lucky :) https://carc.in/#/r/4cie
<FromGitter> <Daniel-Worrall> yeah, I called it bad code for a reason >_>
<z64> and i think you would want to use Array.new(size, &block) for this
<FromGitter> <Daniel-Worrall> fixed the bounds issue
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c7f4059799e7017371da8]
rohitpaulk has joined #crystal-lang
<FromGitter> <Daniel-Worrall> bad code -> less bad code
<FromGitter> <Daniel-Worrall> @codenoid if you're actually going to use my bad code, use this one ^
<FromGitter> <codenoid> thank you @Daniel-Worrall
moei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <codenoid> hi
<FromGitter> <codenoid> (4, 341) -> [87, 93, 62, 35] # total 277
<crystal-gh> [crystal] Daniel-Worrall opened pull request #6240: Fix HTTP::Server example in Playground About (master...bug-fix/playground-about) https://git.io/f87sO
<FromGitter> <Daniel-Worrall> ah
<FromGitter> <Daniel-Worrall> change it to splits - 1
<FromGitter> <Daniel-Worrall> on the `n == splits `
<FromGitter> <codenoid> done
<FromGitter> <Daniel-Worrall> you know what, that doesn't work either
<FromGitter> <Daniel-Worrall> I just have broken code and that's all there is to it
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c9af2d2abe466887eea80]
<crystal-gh> [crystal] Daniel-Worrall closed pull request #6240: Fix HTTP::Server example in Playground About (master...bug-fix/playground-about) https://git.io/f87sO
Ven`` has joined #crystal-lang
<FromGitter> <bew> what are you trying to do @Daniel-Worrall ?
<FromGitter> <Daniel-Worrall> I was trying to assist codenoid
<FromGitter> <Daniel-Worrall> > i have x : 200, how to split x into list of number (in array) with random division ⏎ ⏎ example: ⏎ ⏎ ```1. [2,5,3] # x : 10 ⏎ 2. [7,1,2] # x : 10 ⏎ 3. [8,5,7] # x : 20``` [https://gitter.im/crystal-lang/crystal?at=5b2c9e77aeb8fa0c073607f9]
<FromGitter> <bew> ah ok, fun
Ven`` has quit [Read error: Connection reset by peer]
Ven` has joined #crystal-lang
Ven` has quit [Read error: Connection reset by peer]
Ven`` has joined #crystal-lang
<FromGitter> <faustinoaq> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2ca98a6ceffe4eba278d08]
<FromGitter> <faustinoaq> is `ld-musl` statically or dynamically linked?
rohitpaulk has quit [Ping timeout: 260 seconds]
<crystal-gh> [crystal] icyleaf opened pull request #6241: add .new and .empty? to HTTP::Params (master...feature-http-params) https://git.io/f4Kxx
<crystal-gh> [crystal] icyleaf opened pull request #6242: Featues/raise exception use class and message (master...featues/raise-exception-use-class-and-message) https://git.io/f4PYt
That_Guy_Anon has joined #crystal-lang
rohitpaulk has joined #crystal-lang
Ven` has joined #crystal-lang
Ven`` has quit [Read error: Connection reset by peer]
<crystal-gh> [crystal] icyleaf closed pull request #6242: Featues/raise exception use class and message (master...featues/raise-exception-use-class-and-message) https://git.io/f4PYt
DTZUZO has quit [Ping timeout: 276 seconds]
Raimondii has joined #crystal-lang
Raimondii is now known as Raimondi
Ven` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <rishavs> Generic question about JWT; Do i need to decrypt them on every single server call to get the userid and exp date? If yes, then isn't that going to add a whole lot to the server overhead?
<FromGitter> <aisrael> Well, it's either that or you lookup the session token/user id from a central store (e.g. Redis), which is *definitely* a lot of overhead.
<FromGitter> <S-YOU> we use to verify the header hash, not the payload
<FromGitter> <S-YOU> dynamically linked but linked to none, would be my answer.
Raimondii has joined #crystal-lang
Ven`` has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
prutheus has joined #crystal-lang
<prutheus> I have an array byte_90 = [false, 0] , now, i want to do byte_90[1] + 1 at some point in my code, but there the error comes: undefined method '+' for Bool (compile-time type is (Bool | Int32))
<prutheus> how to solve that?
<That_Guy_Anon> can you do a bool.to_i ? not sure if that is applicable. but basically since the values in the array can either be boolean or int you have to make ure that it is an int when using +
<That_Guy_Anon> i think there is a function for checking if something is an int.
<That_Guy_Anon> b.is_a?(Number)
<prutheus> yes that works
<prutheus> sure
<prutheus> but the compiler still errors on b[1] + 1
<prutheus> `byte_90[1] + 1 if byte_90[1].is_a?(Number)` results in undefined method '+' for Bool (compile-time type is (Bool | Int32))
<That_Guy_Anon> you gotta do an else
<FromGitter> <aisrael> Have you tried `b[1].as(Int) + 1`?
<That_Guy_Anon> so you can ise b[1].is_a?(Number) ? b[1] = b[1] +1 : (nothing here)
<That_Guy_Anon> that might work aswell, but i am not sure if you can use as(int) on bool. i don'T know the language that well after all :D
<prutheus> as int is the solution, thanks
<That_Guy_Anon> nice to know that as(int) works on bool :D
<FromGitter> <rishavs> > dynamically linked but linked to none, would be my answer. ⏎ @S-YOU can you elaborate a bit? I keep my userid and expiry in the payload. If I don't verify the payload, I can't make auth work
<FromGitter> <aisrael> It doesn't quite "work" on `Bool`. It assumes the value is an `Int` and casts/treat it as such. If you try `b[0].as(Int)` it'll compile but you get a run-time exception
prutheus has quit [Quit: Page closed]
<That_Guy_Anon> so is my solution better?
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
gewo has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <vladfaust> Any way to get https://crystal-lang.org/api/0.25.0/Crystal/Macros/Def.html of a method a macro was called within?
<FromGitter> <vladfaust> Where can one get a list of all macro instance variables?
<FromGitter> <vladfaust> TIL: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Cool! [https://gitter.im/crystal-lang/crystal?at=5b2ccf9aad21887018d4481a]
rohitpaulk has joined #crystal-lang
<FromGitter> <laginha87> Hi yesterday posted the second part for my post Crystal is not Ruby (https://revs.runtime-revolution.com/crystal-is-not-ruby-pt-2-7c3d988aa9a1)
<FromGitter> <codenoid> https://cdn-images-1.medium.com/max/1600/1*FKeVrXDNC7Nnq5uD70YX8Q.jpeg
<FromGitter> <codenoid> is there any built-in function todo ⏎ ⏎ ```a = {"Xacxc" => 251, "cawf" => 150} ⏎ a.some_func # => 401 / sub hash value``` [https://gitter.im/crystal-lang/crystal?at=5b2cd6006ceffe4eba27fba9]
<FromGitter> <codenoid> *sum hash value
<FromGitter> <bew> You can try
<FromGitter> <bew> You can try `a.each_values.sum`
<FromGitter> <bew> Hmm no, there is no `Iterator#sum`, you have to do `a.values.sum`
<FromGitter> <bew> @vladfaust there is `@def`
<FromGitter> <vladfaust> Thanks, @bew
<FromGitter> <yxhuvud> I do wonder a bit why iterator doesn't have sum.
wuehlmaus has joined #crystal-lang
<FromGitter> <codenoid> thankyou @bew
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <faustinoaq> > dynamically linked but linked to none, would be my answer. ⏎ ⏎ @S-YOU Ok, thank you! 😄 👍
<FromGitter> <S-YOU> @rishavs, ah, that comment about dynamic link is to faustinoaq's question regarding ld-musl.
<FromGitter> <S-YOU> And yeah, user_id and expiry should be encrypted, so if they are in payload, I think there is not much choice without encrypting payload.
rohitpaulk has quit [Ping timeout: 276 seconds]
Ven`` has joined #crystal-lang
snsei has joined #crystal-lang
Ven`` has quit [Read error: Connection reset by peer]
Ven`` has joined #crystal-lang
<FromGitter> <S-YOU> Thanks @laginha87, Nice post.
duane has joined #crystal-lang
Ven` has joined #crystal-lang
snsei has quit [Read error: Connection reset by peer]
snsei has joined #crystal-lang
Ven`` has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <asterite> Iterator includes Enumerable, so it trivially has sum
TCZ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 256 seconds]
rocx has joined #crystal-lang
<rocx> is there a standard way to do a main()-like function in an app besides a `fun main(...)` ?
rohitpaulk has joined #crystal-lang
<rocx> seems like putting much of anything into fun main without everything into the module will compile fine then segfault when the app is run.
<RX14> why are you trying to do a main function?
<rocx> standalone app.
<RX14> what do you mean by that
<rocx> i ran `crystal init app` to more or less get started on that and all the code really generates is a bit of boilerplate with the module.
<RX14> you don't write a main function in crystal
<rocx> it's all toplevel?
<RX14> you just write code at the top level
<RX14> yes
<RX14> it'll segfault because you're overriding `main`, the main function is provided by the stdlib and it calls the top-level code and initializes constants etc
<rocx> ah.
* rocx did bad and looked at the crystal source for that.
rohitpaulk has quit [Ping timeout: 256 seconds]
TCZ has quit [Quit: Leaving]
<rocx> alright think i'm getting the swing of it. thanks.
Ven` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
snsei has quit [Remote host closed the connection]
<FromGitter> <n00ax> Was annoyed trying to cross-compile to arm64, so I built a set of shell scripts that run docker containers to automate the whole process (p.s, I'm no shell wizard so it's pretty bad... :) ) https://github.com/n00ax/crystal-arm-crosscompile
snsei has joined #crystal-lang
<FromGitter> <sdogruyol> thank you @n00ax 🙏
<crystal-gh> [crystal] bcardiff closed pull request #6221: Finish the \a escape sequence (master...escapesequence) https://git.io/fLbYd
<FromGitter> <sdogruyol> I'd really love to have a toolchain helper for Crystal, just like rustup
<FromGitter> <j8r> and change the directory name from dppm-static to whatever, and run at the top level `./build-static x86-64, arm64`
<FromGitter> <j8r> @n00ax Why have you simply not used Alpine:edge :)
rohitpaulk has joined #crystal-lang
<FromGitter> <rvelez83> Hello Everyone, new to Crystal, for some time now I've been testing out various languages, I appreciate Crystal's best of both worlds nature. Started playing with it recently and wanted to share my first hiccup, building a static executable, is there a straightaway way of doing it?
DTZUZO has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <vladfaust> ```code paste, see link``` ⏎ ⏎ How do I check if a Union is nilable in macros? [https://gitter.im/crystal-lang/crystal?at=5b2d05360168e70c08e3f306]
<FromGitter> <vladfaust> 1) the very first `type` is `TypeDeclaration` here
Ven`` has joined #crystal-lang
<FromGitter> <vladfaust> This solution `type.type.types.any? { |t| "#{t}" == "::Nil" }` is ugly as hell
<travis-ci> crystal-lang/crystal#e806c95 (master - Finish the \a escape sequence (#6221)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/395475002
<DeBot> https://github.com/crystal-lang/crystal/pull/6221 (Finish the \a escape sequence)
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<FromGitter> <j8r> @n00ax note that only musl based distributions are supported for static linking
<FromGitter> <j8r> @rvelez83 you can use https://hub.docker.com/r/jrei/crystal-alpine/ :)
snsei has quit [Ping timeout: 265 seconds]
<FromGitter> <rvelez83> @j8r Thanks for the resource. Is there any info I can follow on how to make building static executables work on my system? I'd like to learn how to solve the issue myself.
<FromGitter> <bcardiff> @vladfaust TypeNode has nilable?, but is a bit ugly to get the information of a union due to how the ast is parsed. but depending on your use case it might be enough to ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2d091dce3b0f268d38a3a6]
<FromGitter> <vladfaust> `undefined macro method 'Union#type_vars'` kek. Looks like this `Union` is different from your `Union`
<FromGitter> <vladfaust> And no, I haven't got any monkey patches or namedspaced Unions
<FromGitter> <vladfaust> But nevermind, I already got used to `{ |t| "#{t}" == "::Nil" }`
<crystal-gh> [crystal] bcardiff opened pull request #6243: Spec: allow --link-flags to be used (master...feature/spec-link-flags) https://git.io/f4DNT
That_Guy_Anon has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter> <j8r> @rvelez83 There isn't really a good reason to do it on your PC, unless you have time to spend. For dev, dynamically linked is enough. When you release a new version, you can compile it statically with optimization flags. ⏎ For static linking, you'll need `dev` packages wich must have `.a` archives bundled. If you are on macos, this isn't possible
<FromGitter> <rvelez83> @j8r I'm on Linux. What I'd like to do is be able to build on one system binaries that I can have copied over to another(Linux as well) and run.
snsei has quit [Ping timeout: 276 seconds]
<robacarp> are stacktraces broken on crystal 25?
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] bcardiff opened pull request #6244: Allow p! pp! macros to be used with tuples (master...fix/pp-tuples) https://git.io/f4Dx6
<FromGitter> <j8r> @rvelez83 yes totally. Unless you are on Alpine Linux, the most straight forward way is to use a Docker image
<FromGitter> <rvelez83> @j8r I am on ubuntu but I recently discovered Alpine and have a system with it installed (running Edge).
<FromGitter> <j8r> that's perfect, you can install this packages (https://github.com/j8r/dockerfiles/blob/master/crystal-alpine/Dockerfile)(you can remove some) and you are ready to go with `crystal build --static`
<FromGitter> <HCLarsen> Yo folks, got a question about Macros. Is it possible to see the code generated by my Macro to ensure that I'm getting what I want?
<FromGitter> <j8r> with `{% debug %}`you can see this
<FromGitter> <j8r> you can put it anywhere in the code
<FromGitter> <HCLarsen> So I put it anywhere in my code, and when it runs, I'll see the generated code?
<FromGitter> <j8r> I think it have to be in the macro
<FromGitter> <HCLarsen> Ahh, ok.
akaiiro has joined #crystal-lang
<FromGitter> <HCLarsen> Works rather weird from inside a loop.
<FromGitter> <rvelez83> @j8r Thanks a lot, I've successfully built my first Crystal static "Hello World" binary :)
<FromGitter> <j8r> 🎉
akaiiro has quit [Ping timeout: 248 seconds]
<FromGitter> <HCLarsen> Welcome to the Crystal family.
<FromGitter> <rvelez83> @HCLarsen Thanks Mr. Larsen
<FromGitter> <hmans> @laginha87 You know why it's &:foo in Ruby, right?
<FromGitter> <vlazar> is there an easy way to run Crystal on Raspberry Pi yet?
<FromGitter> <HCLarsen> Somewhat easy.
<FromGitter> <HCLarsen> Yes, there is.
<RX14> there was http://public.portalier.com/raspbian/ but im not sure its updated
<FromGitter> <elorest> In the past I had to cross compile it and there’s a stack overflow on it.
<FromGitter> <HCLarsen> Those instructions worked the last time I tried.
<RX14> you can always just install http://public.portalier.com/raspbian/ and then boostrap up off there
<FromGitter> <HCLarsen> I had to get Julien to update something, but he is on top of it.
<RX14> yeah im sure they work
<RX14> but they might install 0.23.5 or sth lol
<RX14> oh
wontruefree has joined #crystal-lang
<FromGitter> <vlazar> would running something instead of raspbian be a better idea?
<RX14> no
<FromGitter> <vlazar> :(
<RX14> why are you said
<RX14> there's a repo to use
<FromGitter> <HCLarsen> As far as I know, that build only works on Raspbian.
<FromGitter> <HCLarsen> damn.
<FromGitter> <HCLarsen> We really need to get all the RaspPi people together, so we can work on that all together, instead of depending on Julien for everything.
<RX14> PRs to generate armhf debs for the official tools would be welcome
<RX14> then the debian instructions for officcial packages could work on reaspbian
pwned has joined #crystal-lang
akaiiro has joined #crystal-lang
<FromGitter> <HCLarsen> That would be good.
rohitpaulk has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
<FromGitter> <j8r> @vlazar if your raspberry pi is on ARM64, no problem
akaiiro has joined #crystal-lang
<FromGitter> <j8r> this means => you are on RPi3 without Raspbian
<FromGitter> <vlazar> will alpine work?
<FromGitter> <j8r> You have multiple solutions here
<FromGitter> <vlazar> I'm not a linux guy, anything that's easy enough would work for me, do you have any preferences?
<RX14> why not use rasbian?
<RX14> if raspbian works fine why not use it?
<FromGitter> <vlazar> I'm fine with raspbian too as long as it has lates Crystal
<RX14> then your best bet is using that repo
<RX14> and then compiling latest crystal using that compiler
<RX14> then pinging ysbaddaden
<FromGitter> <vlazar> ok, thanks guys, will try
<RX14> that is - if it's not up to date
<RX14> compiling the latest crystal should be fairly easy
<RX14> "should be"
<FromGitter> <vlazar> :)
<FromGitter> <vlazar> famous last words
<FromGitter> <vlazar> btw, is Crystal 0.25.1 around the corner?
<RX14> yes
<FromGitter> <vlazar> 🎉
<FromGitter> <vlazar> will play with TFB then
<FromGitter> <j8r> @vlazar the simplest, try https://alpinelinux.org/downloads/ generic arm64. if it works, `apk add --update crystal shards g++ gc-dev libc-dev libevent-dev libxml2-dev llvm llvm-dev llvm-libs llvm-static make openssl openssl-dev pcre-dev readline-dev yaml-dev zlib-dev` and you are done
<FromGitter> <vlazar> thanks again @j8r
akaiiro has quit [Remote host closed the connection]
akaiiro has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
<crystal-gh> [crystal] bcardiff opened pull request #6246: Docs: Prevent virtual types reaching docs generator (master...fix/docs-virtualtype) https://git.io/f4yIb
<FromGitter> <rishavs> Hmmm... protecting a route with jwt really ins't as heavy as I was worried. A protected route (Routing + DB call + JWT Decode) takes 280 ms and an unprotected route for the same resource took 254 ms.
<FromGitter> <vladfaust> ```code paste, see link``` ⏎ ⏎ Fails with `wrong number of block arguments (given 1, expected 0)`. Could you please help me defining it in a valid way? [https://gitter.im/crystal-lang/crystal?at=5b2d2b3a7d3bca737a018e17]
<FromGitter> <vladfaust> Fixed with `&block : {{type.type}} -> _`, sorry.
<wontruefree> Why does HTTP::Server bind to multiple addresses? I am just curious what the usecase is
<FromGitter> <n00ax> @j8r What do you define as not supported, Crystal executables link and run fine (at least as far as my experience goes up to this point) with GLIBC statically linked
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter> <vladfaust> Is there a standard way to return an Iterator for hash *values* by *key* Iterator? E.g. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I need this select with only one argument, which is a key. [https://gitter.im/crystal-lang/crystal?at=5b2d34a3d2abe4668880a144]
<FromGitter> <bew> @vladfaust sth like that: `hash.each.select { |(k, *)| k >= 42 }.map { |(*, v)| v }`
rocx has quit [Remote host closed the connection]
sz0 has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
prutheus has joined #crystal-lang
<FromGitter> <hmans> What’s going on, Crystallizers… okay, I’m beginning to sound lame
<FromGitter> <vladfaust> @bew, `select` should be with a single argument
<oprypin> so it is
<FromGitter> <vladfaust> That's my current implementation, how can it be improved for performance? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2d483f960fcd4eb91a9f39]
prutheus has quit [Quit: Page closed]
<oprypin> what bew said
<FromGitter> <bew> @vladfaust did you tried what I said? It works for pe
<FromGitter> <vladfaust> @bew I don't want to write `User.select_by_age { |a, _| a > 18 } `
lvmbdv1 has joined #crystal-lang
<FromGitter> <bew> then don't: https://carc.in/#/r/4cnt
<FromGitter> <bew> @vladfaust ^
<FromGitter> <vladfaust> Oh way. Where to get all these knowledge 😄 Thanks again, @bew
<FromGitter> <vladfaust> BTW, does `_` improve performance?
<FromGitter> <bew> Don't think so
<FromGitter> <drum445> Anybody know where I can suggest a change request to allow you to be able to set the defualt TIME_ZONE for mysql to use in the offical library? ⏎ https://github.com/crystal-lang/crystal-mysql/blob/master/src/mysql.cr
<FromGitter> <drum445> or maybe you already can and I'm not aware
prutheus has joined #crystal-lang
<prutheus> "can't cast YAML::Any to Array(Int32)" .... I have a array of Int32 | Array(Int32) dumped by YAML and want to recover it via parsing the string now. Then, I want to apply .to_json to the parsed yaml, but there it complains no overload matches 'YAML::Any#to_json' with type JSON::Builder ... so I want to convert the YAML parsed stuff to an Array ... oh man what is crystal doing with the types?
<prutheus> Any Idea how I can achieve my goal?
<FromGitter> <vladfaust> In this cases I randomly try `to_a`
<FromGitter> <vladfaust> Sometimes it helps
<prutheus> nope
<prutheus> undefined method 'to_a' for YAML::Any (did you mean 'to_s'?)
<FromGitter> <vladfaust> If it doesn't help I pray to God and curse asterite (not really)
<prutheus> What?
<FromGitter> <vladfaust> I'm high level guy and Crystal types is always challenging for me. I haven't worked neither with JSON nor YAML so close, so I'm out of help here, sorry
<prutheus> Oh shit. I thought switching from ruby to crystal would be a nice choice, but the type stuff is really strange at some points
<prutheus> i need to fix my issue, please ....
<jeromegn> prutheus: there's .as_a
<prutheus> yes right
<prutheus> i was misstyping it, but still an error
<jeromegn> https://crystal-lang.org/api/0.25.0/YAML/Any.html#as_a%3AArray%28Any%29-instance-method
<prutheus> no overload matches 'YAML::Any#to_json' with type JSON::Builder Overloads are: - Object#to_json(io : IO) - Object#to_json()
<jeromegn> can you show the code you're executing?
<jeromegn> I might be able to help :)
<prutheus> yes, one moment
rohitpaulk has joined #crystal-lang
<jeromegn> also: do you know the structure the YAML will have? or is it arbitrary
<prutheus> jeromegn: I know the structure
<FromGitter> <hmans> Anyone else running into problems with fetching sentry via shards?
<FromGitter> <bew> @prutheus did you tried to use a YAML.mapping ?
<jeromegn> I was gonna say :)
<prutheus> I dont understand mapping yet
<jeromegn> and then also add a JSON.mapping, so you can parse the YAML and serialize to JSON. I'm assuming that's what you want to do
<prutheus> But I dont understand those mapping stuff. Could you show me please?
That_Guy_Anon has quit [Remote host closed the connection]
<prutheus> I mean I just have arrays in my yaml stored
<prutheus> and single numbers, but the layout is fixed
<jeromegn> your yaml is an array at the root level?
That_Guy_Anon has joined #crystal-lang
<FromGitter> <bew> prutheus https://carc.in/#/r/4cnv
<FromGitter> <bew> is it close to want you want?
<jeromegn> oh nice
<wontruefree> hmans: did you clear the cache
<FromGitter> <hmans> @wontruefree - yeah
<FromGitter> <hmans> It looks like it's confused by the sentry repository having a (dead?) 1.0.0 tag
<FromGitter> <hmans> I'll try to dig deeper.
<prutheus> bew, awesome
<prutheus> thanks.
<prutheus> didn't know that this is working. can you explain please.
<wontruefree> are you running the new 0.25.0 and the new shards version?
<prutheus> FromGitter: bew, can you explain please?
<FromGitter> prutheus, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<FromGitter> <hmans> wontruefree: yeah, the one that shipped with it -- 0.8.0 -- maybe this is the regression that 0.8.1 fixed? (Speaking of which, is there a way to use a newer shards?)
<FromGitter> <crash2burn_twitter> yea u need to upgrade, shards are screwed with .0
<FromGitter> <hmans> @crash2burn_twitter - but how? I was assuming shard releases are tied to crystal releases
<FromGitter> <hmans> My project is using the 0.25.0 docker image
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <bew> prutheus: what you don't understand?
<prutheus> What exactly happens if I write down the type it should be and then apply .from_yaml ?
<prutheus> The Type is an object, but huh?
wontruefree has quit [Quit: bye]
zachk has joined #crystal-lang
zachk has quit [Changing host]
zachk has joined #crystal-lang
<FromGitter> <hmans> Now my CI build is failing, too. https://circleci.com/gh/hmans/crankypants/291
_whitelogger has joined #crystal-lang
<FromGitter> <hmans> This could be a borked cache, tho.
<FromGitter> <hmans> It wasn't. :(
<FromGitter> <hmans> So, is there going to be an updated docker image with 0.25.0 but shards 0.8.1?
wontruefree has joined #crystal-lang
<FromGitter> <phalcondroid> Hi there, im sorry about this questing i think a lot people ask to the same, what is a better crystal web framework to learn?
rohitpaulk has quit [Ping timeout: 256 seconds]
Jenz has joined #crystal-lang
<FromGitter> <hmans> @phalcondroid What do you want to get out of it?
<FromGitter> <hmans> None of them will make you super-productive right now, since things keep changing so much.
<FromGitter> <hmans> I've forked the sentry repository and removed the offending 1.0.0 tag. It works now.
prutheus has quit [Quit: Page closed]
pwned has quit [Ping timeout: 264 seconds]
<FromGitter> <infinitary_twitter> Hi all, first timer here. Migrating some Ruby program of mine that needs to resolve user (and group) names from user (and group) ids. Ruby has an Etc module that somehow does the magic (on the Mac this is not in /etc/passwd). Any ways to get this info simply (and efficiently)?
<FromGitter> <infinitary> Hi all, first timer here. I am porting some Ruby program of mine that needs to resolve user (and group) names from user (and group) ids. Ruby has an Etc class that does this somehow (on the Mac this info is not in /etc/passwd). Is there a way to get this info simply (and efficiently) in Crystal?
lvmbdv has joined #crystal-lang
<FromGitter> <drum445> @phalcondroid Kemal
<FromGitter> <hmans> Am I the only person who stumbled over the many unexpected routing bugs in the routing library used by Kemal?
<FromGitter> <hmans> With apologies to Serdar, I did not have a good time with Kemal. (Though it was mostly radix' fault.)
<FromGitter> <rishavs> @hmans what kind of bugs?
<robacarp> hmans: radix caused me a lot of pain
<robacarp> that pain resulted in amber_router
duane has quit [Ping timeout: 256 seconds]
<FromGitter> <rishavs> How do I define a function which can take arguements which may or may not exist? for eg. `def myfunc(xxx)` and `def myfunc()` should both be valid
<robacarp> you can define both and let the compiler decide which to use
<robacarp> you can also make the argument nilable, like this: `def myfunc(xxx = nil)` but I recommend avoiding that
snsei has joined #crystal-lang
<FromGitter> <rishavs> thanks
snsei has quit [Ping timeout: 276 seconds]
<FromGitter> <hmans> @rishavs eg. https://github.com/luislavena/radix/issues/25
<FromGitter> <hmans> The quality of bugs like that + last commit on radix was almost 1 year ago = no hope
<FromGitter> <rishavs> :/
Jenz has quit [Ping timeout: 245 seconds]
duane has joined #crystal-lang
<FromGitter> <phalcondroid> @hmans @drum445 Thank you guys
<FromGitter> <confact> Why am I getting error on this: ⏎ ⏎ ``` request_headers = HTTP::Headers.new ⏎ request_headers["Icy-MetaData"] = 1``` [https://gitter.im/crystal-lang/crystal?at=5b2d6baf0168e70c08e50cca]
<FromGitter> <confact> Also get errors on the HTTP::Headers{}
<FromGitter> <hmans> @phalcondroid Amber, Lucky and Kemal are definitely worth watching/learning from.
<FromGitter> <hmans> If your goal is to eventually attain some level of productivity, I'd say Lucky and Amber are the safer bets.
<FromGitter> <girng> LOL glad to see @OvermindDL1 in the godot repo
<FromGitter> <girng> I was like.. i recommend that username!
<FromGitter> <girng> remember*.. fail
duane has quit [Ping timeout: 240 seconds]
<OvermindDL1> Lol
<FromGitter> <girng> although, i'll never use typed gdscript, but it was interesting to read over that issue ;)
<FromGitter> <paulcsmith> @hmans wasn’t just you. Lucky used radix for a bit but I ran into show stopper bugs pretty early and wrote a different router to get around it
<FromGitter> <paulcsmith> Routing is hard to get right! So many edge cases
<FromGitter> <hmans> @paulcsmith Whenever I end up writing some sort of microframework for a project -- like it just happened with my Crystal project -- I like to stick to the routing tree approach (without a separation of "routes" and the code they map to.)
<FromGitter> <paulcsmith> @phalcondroid welcome to Crystal! I’d say if you’re looking for a full stack solution Amber or Lucky would be a good fit. Kemal is fantastic for APIs and smaller projects. Amber and Lucky are both for full stack dev and APIs. Both are pretty full featured. Amber takes a more familiar approach that makes it easy to get started. Lucky has a few new ideas that require a bit of learning but make it so that
<FromGitter> ... Crystal can catch more bugs at compile time than in the other frameworks.
<FromGitter> <paulcsmith> I’m the author of Lucky but I’m trying to be unbiased :)
<FromGitter> <hmans> (also see https://github.com/soveran/toro for an actually released shard someone pointed me towards. Not terribly complete though.)
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
<FromGitter> <bew> @prutheus if you look at https://github.com/crystal-lang/crystal/blob/master/src/yaml/from_yaml.cr you can see that `from_yaml` is defined on `Object` (so for all types), and will create a `new` object of your type, by calling a constructor that receives a `YAML::ParseContext` and `YAML::Nodes::Node`. In this file you can also see that this constructor exists for all basic types of Crystal, like numbers, Array,
<FromGitter> ... Hash, Enum, etc.. So as soon as your type has this constructor, you can call `from_yaml` on it. Also note that the `YAML.mapping` macro is a helper to generate this constructor for you (it also generates a `to_yaml` method)
<FromGitter> <sancarn> Anyone have any ideas how easy it'd be to build unit tests specifically looking for compile exceptions, without the whole script failing?
<FromGitter> <sancarn> I.E. can you handle compile errors with something akin to begin ... rescue ... end
<FromGitter> <sancarn> E.G. Rescue this: https://play.crystal-lang.org/#/r/4cr4
<FromGitter> <bew> No you can't rescue a compile error
<FromGitter> <sancarn> Sad times
<FromGitter> <sancarn> So I guess, write the data to a string, try to compile and read stdout it is...
<FromGitter> <bew> Yeah, you can build with `crystal build --no-codegen --format json <your_file.cr>` to make the reading easier and avoid building a binary
faustinoaq has joined #crystal-lang
<FromGitter> <asterite> You shouldn't need to test that something doesn't compile
<FromGitter> <paulcsmith> I've seached the docs and the Google and I can't find a way to check if an incoming HTTP request is via SSL. There doesn't seem to be a `protocol` method and inspecting the `HTTP::Request` object didn't reveal anything
<FromGitter> <paulcsmith> FWIW I'm trying to build a middleware that redirects to the SSL version of the request resource
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]