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
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 250 seconds]
_ore has joined #crystal-lang
ua has quit [Excess Flood]
bazaar has quit [Ping timeout: 252 seconds]
_ore has quit [Ping timeout: 252 seconds]
non-aristotelian has quit [Quit: non-aristotelian]
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 268 seconds]
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 250 seconds]
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 240 seconds]
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 240 seconds]
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 252 seconds]
bmcginty has quit [Ping timeout: 252 seconds]
Yxhuvud has quit [Ping timeout: 264 seconds]
bmcginty has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <proyb6> I need more idea on when and what use case we will use
<FromGitter> <proyb6> StaticArray
<FromGitter> <proyb6> and what is “uninitialized”
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <j8r> @vladfaust for kemal you can't have several serev$$
<FromGitter> <proyb6> U
rohitpaulk has quit [Ping timeout: 252 seconds]
ua has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> @j8r Add iptables rules to send all traffic from 0-65535 => 443/80 :)
<FromGitter> <j8r> @bararchy but you can only have one serve for one backend then
<FromGitter> <j8r> the point is to have multiple endpoints listening on several ports in a single application https://github.com/kemalcr/kemal/pull/378
rohitpaulk has quit [Ping timeout: 252 seconds]
Raimondii has joined #crystal-lang
ashirase has quit [Ping timeout: 244 seconds]
<FromGitter> <proyb6> @j8r Something like this?
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
<FromGitter> <proyb6> Will fork work ask I think I have tried with success
<FromGitter> <j8r> @proyb6 sort of, without multiprocess
<FromGitter> <j8r> you can have use `spawn`
<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 do ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5bd9cb65076992347a9472ff]
<FromGitter> <j8r> and this is working outside docker
<FromGitter> <j8r> May be a Docker bug
<FromGitter> <Blacksmoke16> are you sure the directory exists where you're calling it from?
<FromGitter> <j8r> or that Docker handle this mounted directory differently, and doesn't update when i perform changes inside
<FromGitter> <Blacksmoke16> it should
<FromGitter> <Blacksmoke16> try changing your `$PWD` to the actual full path
<FromGitter> <j8r> I have never had this problem without Docker
<FromGitter> <Blacksmoke16> is it installed?
<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> <r00ster91> the stdlib already defines it: https://crystal-lang.org/api/0.26.1/Channel.html
greengriminal has quit [Quit: Leaving]
<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> <Blacksmoke16> https://play.crystal-lang.org/#/r/5efl
<FromGitter> <Blacksmoke16> oh
<FromGitter> <vladfaust> So
<FromGitter> <r00ster91> @vladfaust https://play.crystal-lang.org/#/r/5efu
<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> Achually
<FromGitter> <vladfaust> https://crystal-lang.org/api/0.26.1/Enumerable.html#partition(&block)-instance-method
<z64> oh woops, i remembered wrong - i guess there still is a lot of `_with_index` API, i'm just thinking of some discussion about removing it..
<FromGitter> <vladfaust> Nope, partition works with elements, and I need indices
<z64> so, you want partition_with_index?
<z64> https://play.crystal-lang.org/#/r/5egf is easy enough to add that from parition's source
<FromGitter> <j8r> Or simply https://carc.in/#/r/5egk
<FromGitter> <j8r> ```arr = [1, 2, 3, 4, 5, 6] ⏎ puts arr[0..arr.size/2], arr[arr.size/2..-1]``` [https://gitter.im/crystal-lang/crystal?at=5bd9d7b626be6b5979491da5]
<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?
<jhass> anything that returns bool
<FromGitter> <vladfaust> Ah, I get it
<FromGitter> <vladfaust> /r/programmer_humor topic
<FromGitter> <vladfaust> There once was a week of nightmare redefs
<FromGitter> <vladfaust> Happy Halloween, btw 🎃
<jhass> or Time.now.to_i % 42235 == 0 ? false : super
akaiiro has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
DTZUZU has joined #crystal-lang
akaiiro has quit [Ping timeout: 272 seconds]
Yxhuvud has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
akaiiro has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
_ore has joined #crystal-lang
Raimondi has joined #crystal-lang
akaiiro has quit [Ping timeout: 268 seconds]
_ore has quit [Ping timeout: 252 seconds]
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 252 seconds]
_ore has joined #crystal-lang
_ore has quit [Ping timeout: 240 seconds]
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 244 seconds]
druonysus has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
akaiiro has joined #crystal-lang