<FromGitter>
<j8r> i don't endorse the use fo inheritance here (I think composition is better here)
<FromGitter>
<j8r> we may have `include Kemal` and use everything as we used to
<FromGitter>
<proyb6> I see, it could be possible when we write from scratch
ashirase has joined #crystal-lang
rohitpaulk has joined #crystal-lang
livcd has quit [Ping timeout: 244 seconds]
<FromGitter>
<vladfaust> @j8r what are real use-cases of multiple servers in one app?
akaiiro has quit [Remote host closed the connection]
<FromGitter>
<j8r> a reverse proxy à la Nginx in crystal for example
<FromGitter>
<j8r> to listening on 80 & 443, or more
<FromGitter>
<j8r> or else, multiple application/APIs in one single binary.
<jokke>
i love how effortless c bindings are <3 Just checked out nats.io/cnats and wrote crystal bindings for the stuff i need in no time. added a little makefile that builds the clib, added it to post_install and voilá
rohitpaulk has quit [Ping timeout: 268 seconds]
livcd has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
ua has quit [Ping timeout: 250 seconds]
ua has joined #crystal-lang
rohitpaulk has joined #crystal-lang
ua has quit [Ping timeout: 268 seconds]
ua has joined #crystal-lang
<FromGitter>
<vladfaust> Is there a way to capture `STDOUT` and put *both* into terminal *and* file? I'd like to make `puts` in a Job in a Resque-like worker to put both in terminal and into a file.
<FromGitter>
<j8r> capture stdout?!
<FromGitter>
<j8r> I suppose you want to do this on the code, you can have a logger than append to a file and print to STDOUT
<FromGitter>
<j8r> I don't recommend to replace `puts`. Add another method, or better, a `struct` like `Log.puts`
greengriminal has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<FromGitter>
<j8r> have you already experienced `Unhandled exception: getcwd: No such file or directory (Errno)` inside Docker?
<jhass>
sounds like your working directory is set to something none-existant
<jhass>
for example mkdir tmp; cd tmp; rmdir ../tmp; ls should throw you a similar error
<FromGitter>
<j8r> I'm on linux, not really same problem, but the `getcwd`call fails too for me
<FromGitter>
<j8r> interesting, I also have `configuraration error: Error opening file '../config.ini' with mode 'r': No such file or directory (Exception)`
<FromGitter>
<j8r> What's strange is this was working this last hour, but now my specs fails
<FromGitter>
<j8r> Everything directory related fails in fact
<FromGitter>
<Blacksmoke16> running `$PWD` for me on Debian returns `bash: /home/user/dev/git/direcotry: Is a directory`
<FromGitter>
<Blacksmoke16> try replacing it with the full path
<FromGitter>
<Blacksmoke16> as i dont think that would resolve correctly, hence why stuff fails
<FromGitter>
<j8r> yes I have `Error running at_exit handler: getcwd: No such file or directory`
<FromGitter>
<tripl3dogdare> Having a bit of an issue I don't understand; I have the following class definition, but even though it doesn't define any type parameters, when I try to extend it I get a `wrong number of type vars for Channel(T)` error... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bd9d0c85905a919553166aa]
<FromGitter>
<tripl3dogdare> The only thing I could think of was that maybe `type` is a keyword and that was messing with things, but changing it doesn't get rid of the error.
<z64>
`type` is a keyword, but only applies inside `lib` definitions (c bindings)
<FromGitter>
<r00ster91> you cant name it "Channel". Try renaming it
<FromGitter>
<tripl3dogdare> Ah, thank you, that fixed it =)
<FromGitter>
<tripl3dogdare> I should have thought of that.
<FromGitter>
<vladfaust> Huh, couldn't find a way to do it. Given an array `[1, 2, 3, 4, 5, 6]`, how to split it to two arrays: `[1, 3, 5]` and `[2, 4, 6]` based on their *index, not value* (could be anything)?
<FromGitter>
<vladfaust> I.e. elements with odd indices go to one array, and with even - to another
<FromGitter>
<vladfaust> Yes, of course, that a thing, but I'm looking for solution without types
<FromGitter>
<vladfaust> I.e. `select_with_index`, which is not here
<FromGitter>
<vladfaust> On the other side, it's enough for my usecase, thanks
<FromGitter>
<vladfaust> Why there is no `select_with_index` in the language?!
<FromGitter>
<Blacksmoke16> make a pr :)
thews has quit [Ping timeout: 245 seconds]
<z64>
there were other `_with_index` methods at one point iirc, but it was decided to remove them
<z64>
would research that before you do
thews has joined #crystal-lang
<FromGitter>
<vladfaust> Yup
<FromGitter>
<vladfaust> `[1, 2, 3, 4, 5, 6].map_with_index { |e, i| e if i.odd? }.compact` does the job assuming `nil` is not an expected value in the array, but what if it is?
<FromGitter>
<vladfaust> Thanks, @z64, this should work. However, it's a monster :)
<FromGitter>
<j8r> (not optimized)
<FromGitter>
<vladfaust> @j8r nope.
<FromGitter>
<j8r> why?
<z64>
wdym a monster lol. its from the stdlib, i just added two lines for the index tracking
<FromGitter>
<vladfaust> A monster to apply it as a custom extension in an application
<FromGitter>
<vladfaust> A monster to be a monkey patch, I mean that
<FromGitter>
<vladfaust> But I have no choice, I guess
<z64>
i mean, you dont have to monkey patch it
<FromGitter>
<vladfaust> Really?
<FromGitter>
<vladfaust> Adding a method to `Enumerable(T)` is a monkey patch, isn't it?
<z64>
yes it is
<z64>
if you have something that `include Enumerable(T)`, you can just add that method
<FromGitter>
<vladfaust> Yeah, an `Array` :D
<z64>
then yes indeed, if you want to change a standard type, patching is what you have to do. i dont see anything wrong with this - its a "good" patch that doesn't add anything use-case (business logic) specific
<z64>
i thought by "custom extension" you meant you has some custom type that `include Enumerable`
<z64>
i mean i wouldn't even call it a patch, since you're not changing anything, just adding a method - i.e. some other shard you add won't break because you added it
<FromGitter>
<vladfaust> I agree
<z64>
had to work with a ruby library that change `#==` on `String` before.. *that* is a nightmare lol
<FromGitter>
<vladfaust> `define true false` :)
<jhass>
nah, the nightmare is to redefine it something like rand(1000) == 0 ? super : rand(1000) == 0
<jhass>
eh vice versa in the ternary, anyway...
<FromGitter>
<vladfaust> @jhass wtf where this code could be even used?