<FromGitter>
<sirikon> Is it possible that an `Error writing to socket: Broken pipe (IO::Error)` affects other IO pipes?
<yxhuvud>
uh, it shouldn't. But it is not impossible that the same reason one socket dies is the reason another die. Think network disconnect or similar.
<FromGitter>
<sirikon> My issue currently is: ⏎ ⏎ I have a process running, with stdout connected to a IO.pipe() writer. ⏎ Then I have an open http request, sending the bytes to the client as they come from stdout (each byte is written and flushed to the http response). [https://gitter.im/crystal-lang/crystal?at=5f201472d7efe5438f27e98b]
<FromGitter>
<sirikon> It works fine. But if the http connection closes (because I reload the web page, for example, and the XHR request gets cancelled): ⏎ ⏎ 1) - I can't detect that the response already closed, so flushing it raises an exception ⏎ 2) - Even If i rescue that exception, the IO that reads the process stdout just stops receiving bytes [https://gitter.im/crystal-lang/crystal?at=5f2014cce90668200521d225]
<FromGitter>
<sirikon> And there aren't any other exceptions being raised, at least not shown in terminal (there isn't any `rescue`, just the one in the request handler that rescues if `response.flush` fails)
<FromGitter>
<sirikon> Ok... I think I fixed it but not sure why. Moved everything IO-related initialization or reading to a new `spawn` block and it doesn't happen anymore.
oddp has joined #crystal-lang
oddp has quit [Client Quit]
<FromGitter>
<sirikon> Ok, I didn't realize that during the process' stdout IO consumption and `response.flush`, everything was on the same fiber. `spawn`ing a new fiber for `response.flush` prevents failures
<FromGitter>
<sirikon> It's weird, still, because even if the exception gets rescued, it ends up affecting other IO on the same fiber?
<FromGitter>
<sirikon> It would be way cleaner if each template file could define it's own function, but looks like the first thing in the generated code is always `io << ""`, even if the function starts with `<%- whatever -%>`, so, can't put it outside of a class in that way
<FromGitter>
<Blacksmoke16> imo i dont see the problem with what you had before with the `render` method and just having a method for each
<FromGitter>
<sirikon> That doesn't scale well when layouts are involved, too much copy-paste for me
<FromGitter>
<sirikon> > but looks like the first thing in the generated code is always io << "", even if the function starts with <%- whatever -%> ⏎ ⏎ Okat that's WRONG, I had a mistake when gave it a try. Now can simplify the macro a lot. ⏎ ⏎ If i'm too spammy just say it people [https://gitter.im/crystal-lang/crystal?at=5f204208d7efe5438f28748a]
<FromGitter>
<Blacksmoke16> wouldnt it be easier to look into one of the other templating engines
<FromGitter>
<Blacksmoke16> that support this kind of stuff
<FromGitter>
<sirikon> Better a little code than a little dependency :D
<FromGitter>
<Blacksmoke16> i mean does it really matter
<FromGitter>
<sirikon> I prefer to have a little piece of code that does something, instead of involving a whole new package, with it's own release cycles and every detail involved ⏎ ⏎ The extreme opposite of "better a little code than a little dependency" is the `left-pad` issue in the Node community.
<FromGitter>
<Blacksmoke16> yea but this isnt a little code
<FromGitter>
<ImAHopelessDev_gitlab> one line ifs are so nice
v2px__ is now known as zorp
<FromGitter>
<dscottboggs_gitlab> @ImAHopelessDev_gitlab so true
<FromGitter>
<dscottboggs_gitlab> although I wish we had one line `if ... then ... else` instead of that ugly c-style ternary operator
<FromGitter>
<j8r> @dscottboggs_gitlab or like python `somethig if some_cond else do_that`?
<FromGitter>
<dscottboggs_gitlab> yeah, that would be better than `:?` but it always felt awkward to read those to me
<FromGitter>
<sardaukar> hello!
<FromGitter>
<sardaukar> right now, I exit from my command line utility if a `TEST` env var is set to run my specs - is there an established best practice around this?
<FromGitter>
<sardaukar> (so that I don't get a command line usage error, exit and therefore abort the specs)
<FromGitter>
<dscottboggs_gitlab> The encouraged pattern for this is to have your CLI in a separate file, and not include that file in the specs.
<FromGitter>
<wontruefree> managing content is a lot of work but I appreciate the help
ryanprior has quit [Ping timeout: 244 seconds]
ryanprior has joined #crystal-lang
<FromGitter>
<ImAHopelessDev_gitlab> nice podcast
<FromGitter>
<ImAHopelessDev_gitlab> still listening
<FromGitter>
<asterite> @bararchy 1 <= x <= 10
<FromGitter>
<ImAHopelessDev_gitlab> @dscottboggs_gitlab u don't like the old c style ternary?
<FromGitter>
<dscottboggs_gitlab> no it's not very clear or readable, especially next to the rest of Crystal's elegance
<FromGitter>
<dscottboggs_gitlab> sure once you know what it means it's fine but you shouldn't have to figure that sort of thing out when you could just use words and be self-expressive, you know?
<raz>
i'm torn on them. i love to write them but hate to read them
<FromGitter>
<dscottboggs_gitlab> that's a fair point
<FromGitter>
<dscottboggs_gitlab> I like to have editor features for ease of writing and language features for ease of reading though. That's a personal preference though, I know some people prefer a more plain text editor
<raz>
yup. they can improve readability for simple cases
<FromGitter>
<wontruefree> thanks @ImAHopelessDev_gitlab ! I had fun recording it
<raz>
but unfortunately the cases often don't stay simple
<raz>
once you have a nested method call on both sides of the : it's usually better to split it out over multiple lines
<FromGitter>
<Blacksmoke16> eh, would be kinda painful to do every release, esp given the docs say "something like"
<FromGitter>
<dorianmariefr> BTW I'm following a book and I would like to write "doubly-linked list of heap-allocated strings." in Crystal, any pointers (haha) of how I could do that?
<FromGitter>
<dorianmariefr> yeah that's what i was thinking, in C you have to implement it yourself but in Crystal it's already implemented with an array, thanks
<FromGitter>
<dorianmariefr> a little issue i have with crystal is i keep going to some old documentation when searching something on google, maybe the documentation could always link to the last one (like apidock does for rails)?
<FromGitter>
<Blacksmoke16> best option is to just keep a tab open with the latest
<FromGitter>
<dscottboggs_gitlab> yes, there is `/api/latest`, but search results are often pinned to a specific out-dated version
<FromGitter>
<Blacksmoke16> there are some issues related to that, not sure the current state of things tho
<FromGitter>
<dscottboggs_gitlab> I just have the reference bookmarked
<FromGitter>
<Blacksmoke16> i just use `/api/master` and all it a ay
<FromGitter>
<Blacksmoke16> a day*
<FromGitter>
<dorianmariefr> i just so used to googling things, nobody beats google for search :)
<FromGitter>
<Blacksmoke16> there is the version dropdown now, prob still some improvements that an be made for sure
<FromGitter>
<Blacksmoke16> that method doesnt exist for the module you defined
<FromGitter>
<Blacksmoke16> how did you run the specs?
<FromGitter>
<dorianmariefr> the thing is i didn't change that part, I just added a new spec that is quite simple and doesn't use pending_win32. i did `crystal spec spec/compiler/crystal/tools/init_spec.cr`
<FromGitter>
<Blacksmoke16> `./bin/crystal spec spec/compiler/crystal/tools/init_spec.cr` try that
<FromGitter>
<dorianmariefr> oh, I added `require "../../../support/win32"` and it looks better now, not sure where it's called though
<FromGitter>
<dorianmariefr> also i get `Program received and didn't handle signal TRAP (5)` when i put `debugger` in the code, i have gdb and lldb installed so it should work, the documentation seems to be for visual code studio but i use vim
<FromGitter>
<dscottboggs_gitlab> when debugging you have to compile the app then run it with a debugger like `gdb path/to/exe -- arg1 arg2`
<FromGitter>
<dorianmariefr> hmm i thought gdb would be simpler, i read a cheat sheet and doesn't have anything working :D anyway, puts debugging to the rescue :D my test correctly fails now but i can't run it with the fixed version of crystal, i will push that to the build server :D
<FromGitter>
<dorianmariefr> so if anybody has an idea about the prelude error that would be nice, i just used `make` to compile the compiler and then it's in `.build/crystal` but i get:
<oprypin>
dorianmariefr, u cant use .build/crystal
<oprypin>
if u want u have to replicate environment variables that bin/crystal sets
<oprypin>
importantly, CRYSTAL_PATH
<FromGitter>
<dorianmariefr> oh okay, i see, bin/crystal actually uses .build/crystal so that's the correct way to do it (my spec is still not passing :D)
<FromGitter>
<Blacksmoke16> should that actually be `id : String`?
<FromGitter>
<Blacksmoke16> because im pretty sure that would try to define another `id` column
<FromGitter>
<watzon> Just realized I fucked up haha
<FromGitter>
<watzon> It should be `scooter_id`
<FromGitter>
<Blacksmoke16> that would do it
<FromGitter>
<watzon> Is it intended that using the `create!` method doesn't work when passing in models? For instance, I can't do `Models::ScooterAlert.create!(user: user, scooter: scooter, alert_type: "alert")` it has to be `Models::ScooterAlert.create!(user_id: user.id, scooter_id: scooter.id, alert_type: "alert")`
zorp has quit [Ping timeout: 264 seconds]
<FromGitter>
<Blacksmoke16> im not sure, prob not?
<FromGitter>
<Blacksmoke16> what happens if you do like
<FromGitter>
<Blacksmoke16> i dont like all these implicit constructors
<FromGitter>
<Blacksmoke16> IMO an ORM shouldn't be responsible for parsing values out of some random hash to create a model instance, just define an initializer like you would any other object
<FromGitter>
<watzon> I think that would be perfectly acceptable
<FromGitter>
<Blacksmoke16> mhm
<FromGitter>
<watzon> I like the idea of replacing the `column` macro with annotations too
<FromGitter>
<Blacksmoke16> to be clear `column` is just a warpper around that
<FromGitter>
<Blacksmoke16> wrapper
<FromGitter>
<Blacksmoke16> defines your ivar, applies the annotation, and defines some constructors
<FromGitter>
<Blacksmoke16> making any progress on your orm? :p
<FromGitter>
<watzon> Nah haha. I haven't been doing a ton of Crystal lately. Been searching pretty hard for a job.
<FromGitter>
<watzon> Might have something next week
<FromGitter>
<Blacksmoke16> ah, gl
<FromGitter>
<dscottboggs_gitlab> shit you're looking for a job? You're so much better than me I'm so screwed... :(
<FromGitter>
<watzon> Lol I've been looking for a while
<FromGitter>
<watzon> Got a baby on the way now, so it's urgent
<FromGitter>
<dscottboggs_gitlab> oh jeeze dude. best of luck to you ❤️
<FromGitter>
<watzon> Thanks!
<FromGitter>
<Blacksmoke16> if you're near Pittsburgh we're looking for another engineer
<FromGitter>
<dscottboggs_gitlab> holy shit, @Blacksmoke16 you're near PGH?
<FromGitter>
<Blacksmoke16> yes
<FromGitter>
<dscottboggs_gitlab> that's crazy we've been chatting for years on here and I had no idea
<oprypin>
so im dealing with a library that wants everything in °degrees, but crystal's Math wants everything in radians. what would you suggest to make this less annoying? insisting on radians isn't going great for me btw
<FromGitter>
<Blacksmoke16> you from around there as well?
<FromGitter>
<dscottboggs_gitlab> yeah I live in avalon
Human_G33k has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> `Degrees` type and have overloads that internally converts to radians and back to degrees?
<FromGitter>
<Blacksmoke16> ah nice :p
Human_G33k has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> that sounds frustrating, oprypin
<FromGitter>
<dscottboggs_gitlab> I'm sure it's not too hard to convert between deg and rad so you could just define a `#to_rad` on `Float`
<FromGitter>
<Blacksmoke16> or a method that converts to radians? :shrug:
<oprypin>
that method is of course what i have
<oprypin>
the library has storage with getters & setters in degrees
<FromGitter>
<dscottboggs_gitlab> @Blacksmoke16 who's the "we" who's looking for an engineer? I thought you did PHP professionally
<FromGitter>
<Blacksmoke16> we meaning the company i work for yea
<FromGitter>
<dscottboggs_gitlab> damn I don't know PHP for shit
<FromGitter>
<Blacksmoke16> to be fair i didnt either when i started :S
<FromGitter>
<Blacksmoke16> was more familiar with ruby at that point
<FromGitter>
<Blacksmoke16> oprypin: i dont suppose you could extend `Float` or something along those lines?
<oprypin>
O_o
<FromGitter>
<Blacksmoke16> leaning to the right on hackiness scale tho imo
<FromGitter>
<watzon> Yeah no where near Pittsburgh for me. I'm all the way in the Salt Lake Valley, Utah
Human_G33k has quit [Ping timeout: 240 seconds]
<FromGitter>
<dscottboggs_gitlab> oof I visited SLC one time and I couldn't breathe. atmosphere is weird there
<FromGitter>
<chasestory> I live there as well.. definitely heavier here..
<Rounin>
oprypin: Hehe, well, 1) I don't use Github, and 2) IRC only has a set number of colour codes, after all, so you don't get nice pastels or anything
<FromGitter>
<plainas> I accidentally had press enter before finished...
<FromGitter>
<plainas> why doesn't b resolve?
<oprypin>
in which situation
<FromGitter>
<watzon> Modules can't be instantiated, and `def b` crates an instance method. If you want to be able to call `b` you have to include the module in a class