RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.1 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <ohenepee> @j8r Your *if statement assignment* is nice... however concerning the `media` variable I fixed it by setting the type to `nil`... and no more compiler errors.
<FromGitter> <S-YOU> @proyb6, malloc itself is already defined in crystal standard library (GC_malloc for default bohem GC), but basically like this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bb81158435c2a518e5b0b7d]
akaiiro has joined #crystal-lang
moei has quit [Quit: Leaving...]
<FromGitter> <proyb6> @S-YOU I did malloc it work but read_lines seems to be available for WinAPI, not exist in macOS?
akaiiro has quit [Ping timeout: 244 seconds]
DTZUZO has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
moei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
akaiiro has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
lemur is now known as baweaver
<FromGitter> <r00ster91> After I've set a read or write timeout for an IO, how do I remove the timeout again? Do I need to do `io.read_timeout = 999999` (so it's never reached) or is there a better way?
<FromGitter> <bew> just set it to nil?
<FromGitter> <r00ster91> oh thank you that works
Groogy1 has joined #crystal-lang
ashirase has quit [Ping timeout: 244 seconds]
ashirase has joined #crystal-lang
<FromGitter> <ohenepee> @bew Is it wrong that I set it to `nil` ?
Groogy1 has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> what?
rohitpaulk has quit [Ping timeout: 245 seconds]
<jokke> is it possible to respond to a request with a 100 status code before receiving the body?
<FromGitter> <straight-shoota> jokke, sure. why not?
<jokke> but how?
<FromGitter> <straight-shoota> you don't need to read the body at all
<jokke> sure but i want to read the body
<jokke> but the client is sending Expect: 100-continue
<jokke> afaik just setting the status code doesn't yet pass it to the socket
<FromGitter> <straight-shoota> exactly
<jokke> i would have to set it twice
<FromGitter> <straight-shoota> you need to either write something to the response or simply close it
<FromGitter> <straight-shoota> both will make sure the headers are sent
<jokke> yeah but as soon as i write to the response i can't write any further headers/status codes
<jokke> which is what i would have to do
<FromGitter> <straight-shoota> What?
DTZUZO has joined #crystal-lang
<jokke> that's what 100 status code is for
<FromGitter> <straight-shoota> Send a second response over the same socket?
<jokke> kind of
<jokke> it helps you check creds for example before accepting some huge file upload
<FromGitter> <straight-shoota> ah yes
<FromGitter> <straight-shoota> I don't think `Response` can do that.
<jokke> yeah :/
<jokke> it would be pretty great if it did though
<FromGitter> <straight-shoota> It's designed to only server one response for each request
<jokke> yeah. this is a special case though
<jokke> i see if i can patch that in
<FromGitter> <straight-shoota> you could probably just send the subsequent headers as payload
<jokke> yeahhh
<FromGitter> <straight-shoota> then you'd just need to convince it to send the first headers without closing it
<FromGitter> <straight-shoota> maybe `#flush` could call `ensure_headers_written`
DTZUZO has quit [Ping timeout: 272 seconds]
<FromGitter> <straight-shoota> or just hijack the connection using `#upgrade`
DTZUZO has joined #crystal-lang
<jokke> i haven't run the tests though... still building llmv35
<jokke> *llvm
<jokke> ahh i'm so stupid :D
<FromGitter> <straight-shoota> :D
<jokke> i was pulling and pulling and wondering why the code is so outdated (MemoryIO, include IO etc)
<FromGitter> <straight-shoota> just rebase on master
<jokke> well duhh if i'm pulling from my fork
<jokke> is it possible to just run a single spec from the std in crystal?
<jokke> i tried just running bin/crystal path/to/spec.cr
<jokke> but that didn't work
<FromGitter> <vladfaust> Try `bin/crystal spec path/to/spec.cr`
<jokke> yeah i tried that
<jokke> oh it _does_ work
<jokke> thanks :D
<FromGitter> <vladfaust> :)
<FromGitter> <bew> You can even specify a line with `path/to/spec.cr:line` iirc
DTZUZU has quit [Quit: WeeChat 1.9]
return0xe has quit [Remote host closed the connection]
return0xe has joined #crystal-lang
return0xe has quit [Ping timeout: 252 seconds]
_whitelogger has joined #crystal-lang
druonysus has quit [Ping timeout: 252 seconds]
<FromGitter> <ohenepee> Hello everyone, in NodeJS there's an even we listen on just in case your app closes as a result of an unhandled exception its used to mostly perform clean-ups and prevent data loss (e.g. closing a DB) ⏎ ⏎ This is it `process.on("uncaughtException", functionHere)` ⏎ ⏎ How do I do something similar in Crystal, mind you this is not SIGTERM or SIGINT. [https://gitt
<FromGitter> ... er.im/crystal-lang/crystal?at=5bb8dabc64cfc273f9a5cb6e]
<FromGitter> <j8r> Wrap your code in a `begin...; rescue; end`?
raz has joined #crystal-lang
return0e has joined #crystal-lang
<FromGitter> <Prutheus> > Is there anything I should look out for, or be concerned about, if I have a web endpoint, and I throw a `spawn` in like this? ⏎ ⏎ Has someone an answer to that question?
<FromGitter> <Prutheus> > ``` ⏎ get "/jobs/generate_sitemaps" do ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5bb8e81cef4afc4f282b0dc4]
<FromGitter> <ohenepee> @j8r Will that work with Kemal's route handlers? That's what my actual problem is... if wrapping my entire code can catch exceptions from the route handlers
<FromGitter> <mikejohnduran> Hello, I am interested in adding Crystal syntax highlighting for a text editor that currently doesn't support it, and could use some feedback on what the best approach would be. I thought about basing it from the existing Ruby one as a starting point and making modifications as I go. Does anyone have a better idea on how to go about this?
<FromGitter> <vladfaust> @mikejohnduran take existing implementations for other editors and learn from them I guess?
<FromGitter> <vladfaust> @ohenepee take a look at https://crystal-lang.org/api/0.26.1/HTTP/ErrorHandler.html
<FromGitter> <ohenepee> ```code paste, see link``` ⏎ ⏎ I need help. This code keeps telling me `app_config` is Nil [https://gitter.im/crystal-lang/crystal?at=5bb8efed271506518dc849ae]
<FromGitter> <ohenepee> @vladfaust Yeah I seen this one (your reference) but I'm looking for something that can let me close my DB in the even of a fatal exception
<FromGitter> <vladfaust> For compiler, there is no guarantee that *any* line within `begin` block would be run, therefore it assumes that no `read_file = ` is ever run
<FromGitter> <vladfaust> Overcome is to do `puts app_config.not_nil!["head"]`
<FromGitter> <vladfaust> Is there a way to make commented line work? /cc @asterite @RX14 @straight-shoota @bew sorry it's recursive types topic
<FromGitter> <proyb6> Web framework need Dos Detector or rate limiter. A similar example: ⏎ https://github.com/matsumotory/http-dos-detector
<FromGitter> <vladfaust> @ohenepee fatal exception which crashes the program? There is no way to rescue it
<FromGitter> <vladfaust> @proyb6 see https://crystal-lang.org/api/0.26.1/HTTP/Handler.html, you can implement a limiter yourself with Redis or in-memory storage like simple Hash
<FromGitter> <ohenepee> @vladfaust Whew!! That was a close one to programmer suicide 😫 Vlad saved the day 😆
<FromGitter> <proyb6> I see, will look at it!
<FromGitter> <vladfaust> 👍
<FromGitter> <straight-shoota> @proyb6 I think https://github.com/rogeriozambon/http-protection has a rate limiter
<FromGitter> <straight-shoota> @vladfaust You could add an overload to `Halt.new` which accepts an untyped `payload` argument and casts it to `Payload`
<FromGitter> <proyb6> @straight-shoota Great find!
<FromGitter> <straight-shoota> It's all on the awesome list https://github.com/veelenga/awesome-crystal
<FromGitter> <vladfaust> @straight-shoota I've edited the code with my trials: https://carc.in/#/r/564v
<FromGitter> <straight-shoota> `payload.transform_values { |value| Payload.new(value) }`
<FromGitter> <bew> 'just discovered https://carbon.now.sh which supports Crystal <3
<FromGitter> <bew> only 'bad' thing is that it looks like macos ^^
<FromGitter> <vladfaust> @straight-shoota ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bb8f927ef4afc4f282b725a]
<FromGitter> <proyb6> Interesting numbers: filter gists in Github on golang from Jan 2018 till present, what I found ⏎ Go has 9,340+ gists ⏎ Rust has 40K gists ⏎ Scala has 4.5K gists ⏎ C# has 45K gists ... [https://gitter.im/crystal-lang/crystal?at=5bb8f932600c5f64236370af]
<FromGitter> <vladfaust> @proyb6 why are they interesting?
<FromGitter> <vladfaust> @straight-shoota updated the carc: https://carc.in/#/r/565k
<FromGitter> <straight-shoota> You need to wrap the resulting has in `Payload.new` as well
<FromGitter> <straight-shoota> https://carc.in/#/r/565n
<FromGitter> <straight-shoota> If you want more fun, take a look at https://github.com/straight-shoota/crinja/blob/master/src/runtime/value.cr#L53
<FromGitter> <proyb6> I was looking for treasure trove of code :) but it's very few compare to other languages until more devs adopt Crystal.
<FromGitter> <proyb6> @vladfaust
<FromGitter> <vladfaust> Oh nice, thanks again, @straight-shoota!
<FromGitter> <vladfaust> > more fun ⏎ ⏎ No fun at all for me :(
rohitpaulk has joined #crystal-lang
<FromGitter> <proyb6> There is a need for startups or organizations to adopt and backed Crystal for it to grow.
<FromGitter> <vladfaust> Chicken-egg problem, right?
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter> <HarrisonB> Is there a more elegant way to get a `nil` literal to be outputted as such from a macro? E.g. ⏎ ⏎ ```foo = {% if bar %}{{ bar }}{% else %}nil{% end %}``` [https://gitter.im/crystal-lang/crystal?at=5bb904f8271506518dc8c6f3]
<FromGitter> <HarrisonB> just kidding... using an explicit `nil` literal works.
robacarp has quit [Read error: Connection reset by peer]
<FromGitter> <vladfaust> Hilarious :)
pabs has joined #crystal-lang
emilsp has quit [Read error: Connection reset by peer]
<FromGitter> <bew> @HarrisonB what's the type of bar? Can't you do `{{ bar }}`
<FromGitter> <bew> ?
Heaven31415 has joined #crystal-lang
<Heaven31415> Hi
<FromGitter> <HarrisonB> @bew in the event that `bar` is `nil`, `{{ bar }}` does not result in any ASTNode. Perhaps this is a bug I should report? But my guess is it's intentional
<FromGitter> <bew> How did you get bar in this case?
<FromGitter> <HarrisonB> oh actually, I believe you're right
<FromGitter> <HarrisonB> it's because it's coming from `TypeDeclaration#value`
<FromGitter> <HarrisonB> so it's a `Nop`
<FromGitter> <bew> Ohok, i don't remember how nop behaves
<FromGitter> <HarrisonB> it outputs an empty string at compile time
non-aristotelian has joined #crystal-lang
return0e has quit [Quit: Leaving]
<oprypin> HarrisonB, well done figuring this out. i forgot about this detail
<FromGitter> <HarrisonB> @oprypin thanks! :)
<FromGitter> <cschiewek> I'm trying to get crystal up on Mojave, and I keep getting ssl errors. Specifically: `ld: library not found for -lssl (this usually means you need to install the development package for libssl)`. Is there homebrew package or config I'm missing?!
<FromGitter> <cschiewek> Also, Hi! 👋
<Heaven31415> Hi
<Heaven31415> That is strange, I was doing a fresh install of Crystal on Mojave yesterday and everything worked fine in terms of ssl. However, maybe you should try this? https://formulae.brew.sh/formula/openssl@1.1
<FromGitter> <cschiewek> Yeah, installing 1.1 and manually adding the LD paths to my zsh config fixed it
<FromGitter> <cschiewek> Ty very much !
emilsp has joined #crystal-lang
<Heaven31415> Cool, you are welcome.
return0e has joined #crystal-lang
return0e has quit [Ping timeout: 252 seconds]
return0e has joined #crystal-lang
<raz> hmm. when i run 'shards build --production' it doesn't actually build production binaries (it neither adds --release nor --no-debug to the 'crystal build' invocation)
<raz> anyone know what might be wrong?