ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.2 | 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
<oprypin> Paulos33, 1. that's adumb vps then 2. you could probably bypass that
<Paulos33> It's vps cheap
<Paulos33> In retrospect, maybe I shouldn't have cheaped out on this
<Paulos33> :P
<oprypin> Paulos33, what's the price
<Paulos33> 11 Quarterly, $3 monthly
<oprypin> acceptable
<Paulos33> I thought I wouldn't need more than 1gb of ram because I could simply execute the pre compiled binary and it would just werk
<oprypin> what, you have 1GB of RAM? that's actually nice
<oprypin> i would expect most projects to compile under that
<Paulos33> Yeah 1gb ram, 50gb HDD, 1 IP, unlimited bandwidth
<oprypin> i have Arch on all my systems do I was able to copy stuff
<oprypin> so*
<Paulos33> I try to compile even a simple hello world and its out of memory
<oprypin> you need a comparable OS in terms of library versions and compiler versions
<oprypin> hmm that's strange
<oprypin> are you sure it's 1GB? :p
<Paulos33> Sucks that most cheap vps' don't use arch
<Paulos33> It says 1.5gb available but I dunno
That_Guy_Anon has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> @RX14 about #5743, and the `popcount` thing you talked about in the PR I think I understand how I can use that for flags enum, but not for normal enum. Can I even use that? or do I need to rely on something else?
sz0 has joined #crystal-lang
<FromGitter> <bew> I think I need to rely on sth else
Ven`` has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
commavir has quit [Remote host closed the connection]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
commavir has joined #crystal-lang
Yxhuvud has joined #crystal-lang
qard has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
qard has joined #crystal-lang
commavir has quit [Remote host closed the connection]
commavir has joined #crystal-lang
commavir has quit [Remote host closed the connection]
commavir has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
commavir has quit [Remote host closed the connection]
qard has quit [Client Quit]
commavir has joined #crystal-lang
moei has quit [Quit: Leaving...]
<FromGitter> <girng> hello friends. where can i read info about what the `<<-` syntax does. im looking in docs cant find it
<FromGitter> <girng> oh a heredoc
<FromGitter> <girng> coool!!
<FromGitter> <bew> you're welcome :)
qard has joined #crystal-lang
qard has quit [Client Quit]
qard has joined #crystal-lang
Paulos33 has quit [Ping timeout: 260 seconds]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
qard has joined #crystal-lang
heaven31415 has joined #crystal-lang
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
Yxhuvud has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
heaven31415 has quit [Ping timeout: 264 seconds]
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <bararchy> I can't find the right configuration for a raw IP (not TCP or UDP) socket in Crystal, can this even be achieved ?
<FromGitter> <bew> Try in C first maybe?
<FromGitter> <bew> When it works in C, convert to Crystal
<FromGitter> <bararchy> I think I got it, now just to figure how I do htons in Crystal @solisoft
<FromGitter> <bararchy> Damn, meant @bew
That_Guy_Anon has joined #crystal-lang
alex`` has joined #crystal-lang
<FromGitter> <bararchy> ok, got it to work
<FromGitter> <bararchy> whohohoho
<FromGitter> <bararchy> @bew @picatz ⏎ https://github.com/bararchy/sniffer :)
<FromGitter> <bararchy> there is something wrong with the IP level packet parsing, not sure what yet, I'll try and follow the logic
<FromGitter> <bararchy> is there a way to cast bytes into a struct ?
<FromGitter> <bew> iirc no
<FromGitter> <bararchy> it sounds like something that should exists no?
<FromGitter> <bew> actually I think there is one, but I don't recommand it at all
<FromGitter> <bararchy> why? if I have 10 bytes and a struc.size ==10 , and I know it should fill it ?
<FromGitter> <bararchy> it's better then ⏎ ⏎ ```struct.x = bytes[0, 1] ⏎ struct.y = bytes[1, 1]``` ⏎ ⏎ etc.. [https://gitter.im/crystal-lang/crystal?at=5ac1deea270d7d3708833e5c]
<FromGitter> <bew> true, but it's an obscure way to fill a struct by mapping memory like this
<FromGitter> <bew> the best way I can think of is to read field by field and populate the struct as you read
<FromGitter> <bararchy> @bew but then I get this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ac1df397c3a01610d9b50f0]
<FromGitter> <bararchy> which looks wierd
<FromGitter> <bew> or you can play with `.unsafe_as` but only for POCing
<FromGitter> <faustinoaq> @bararchy Did you check cannon? https://github.com/Papierkorb/cannon
<FromGitter> <bararchy> @faustinoaq for what ?
<FromGitter> <faustinoaq> nevermind, I guess I misunderstood the comments above 😅
<FromGitter> <bararchy> :)
<FromGitter> <bew> In the last 2 binary protocol I did, I have something like: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ac1e057e4ff28713a9b0d93]
<FromGitter> <bararchy> @bew yeha, it "works" in that it populates the struct but it wont figure out the endianess (figures) so not a good thing to do I guess
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> I can read endianess
<FromGitter> <bew> ?
<FromGitter> <bararchy> I didn't figure out I can get correct Endianess from the io read
<FromGitter> <bew> the endianness could be in a variable if that's what you meant
<FromGitter> <bew> ah ok
<FromGitter> <bew> btw, cannon uses a 'fast_decode' by reading directly in the type: https://github.com/Papierkorb/cannon/blob/master/src/cannon/serialisation.cr#L66-L72
<FromGitter> <bararchy> interesting
<FromGitter> <bew> @bararchy also, made a mistake, the raise is not necessary as it already does that in read_bytes somewhere (although it is needed if you have only 1 byte to read and you use `read_byte`)
p0p0pr37 has joined #crystal-lang
<crystal-gh> [crystal] bew opened pull request #5899: Use LibCrystalMain.__crystal_main directly (master...use-LibCrystalMain-directly) https://git.io/vx61m
<FromGitter> <sdogruyol> Morning and have a nice week everyone 👋
Jenz has joined #crystal-lang
leucos has joined #crystal-lang
<FromGitter> <bararchy> morning @sdogruyol :)
Jenz has quit [Quit: Lost terminal]
Papierkorb has joined #crystal-lang
<FromGitter> <faustinoaq> Hi @sdogruyol 🙋
<FromGitter> <faustinoaq> nice week for you as well 👍
<FromGitter> <girng> wow, i could have just done result = {data: "123"}, instead of result["data"] = "123" i dont need to create a hash... named tuples FTW
Groogy has joined #crystal-lang
<Groogy> Morning! o/
<Yxhuvud> \
<FromGitter> <girng> can i convert a tuple and strip the type definitions from it? for example: `[{4_i16, 6_i8}]` but only want [4, 6]
<Groogy> well the types will always be there, without i16 and so it just becomes an i32
<Groogy> do you mean you want a tuple that has any of the Int types in it?
<FromGitter> <girng> `to_json` works , but the data is going to another method that uses `to_json`, so then i get extra `\"'s` all over
<Groogy> arr = tup.map { |v| v.to_i } is that what you after?
<Groogy> I mean the types will always be there so, just literal without postfix becomes i32
<Groogy> actually can probably even write arr = tup.map &.to_i
<FromGitter> <girng> will that be ok even if it's let a int64 one?
<Groogy> yeah it will convert it to a i32 though
<FromGitter> <girng> oh lol
<Groogy> tup.map &.to_i64
<Groogy> will convert each member to a int 64
<Groogy> Int is a too unspecified type so it won't let you make Tuples/Arrays that contain any sort of Int
<Groogy> you have to be specific and choose one of the subclasses of Int
<FromGitter> <girng> well, thanks u answewered what i needed to do. i'm going to need to re-think this design a bit however
<FromGitter> <girng> cuz i really need to take advantage of to_json because it does so much good work for me, i cannot let it go
<FromGitter> <girng> is it bad toc ontinue to add more and more overloads to a hash?
<FromGitter> <girng> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ac1fd7927c509a774cb0e66]
<FromGitter> <girng> i'm doing something wrong aint i lol
<FromGitter> <girng> i mean, it works though... but every time i get overload error, the error tells me what i need to add, so i just do `| appendednewtypes` to the `msg_buffer` ⏎ but now, it seems like i'm creating too many...
Papierkorb has left #crystal-lang ["Konversation terminated!"]
<Groogy> eeeeh yeah
<Groogy> it means you keep assigning different types to it
<Groogy> you probably want to parse it all into one common type
<FromGitter> <girng> i don't think crystal devs intended for this to be used like that lol
<Yxhuvud> well, that is one way to do it. You need to ask yourself what you actually want to store in that hash, and make certain the stuff you put into it is of that type
<Yxhuvud> (or types, in case of union types)
<FromGitter> <girng> the thing is, `to_json` gets called on msg_buffer, and the msg_buffer changes depending what the player wants (data) from the server
<Yxhuvud> I suggest looking into JSON.mapping and to try to make a predictable structure that can be parsed without using to_json
<FromGitter> <girng> so theres diff data coming from all my code...
<FromGitter> <girng> returned from a db query.. a tuple, a hash, etc
<Yxhuvud> If you can, it may be a good idea to unify the API too. That saves you from future headaches.
<Yxhuvud> or make it into several different, more limited APIs.
<FromGitter> <girng> well, in comparison to this one liner and an entire "predictable data structure", i guess this will just have to work cuz i have no idea how to implement that lol
<FromGitter> <girng> but i mean, is this bad for performance? all these overloads? or is it negligible?
<Yxhuvud> I doubt it will matter for you.
<FromGitter> <girng> just little word cuz it's for the master game server. a lot of player classes gonna be used
<FromGitter> <girng> my boss said he doesn't care , but i'm unfortunately my boss so.. i'm just a bit worried
alex`` has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
<FromGitter> <girng> im going to make a module DynamicTypes and put all of them in theere
<crystal-gh> [crystal] MakeNowJust opened pull request #5901: Format: fix indentation after backslash newline (master...fix/crystal-format/indent-after-backslash-newline) https://git.io/vx67U
alex`` has quit [Ping timeout: 256 seconds]
alex`` has joined #crystal-lang
stone_ has joined #crystal-lang
<Groogy> girng don't bother about what costs performance or not at this point
<Groogy> focus on "what is good crystal code"
cremes has quit [Quit: cremes]
cremes has joined #crystal-lang
heaven31415 has joined #crystal-lang
<FromGitter> <girng> fair enough :D thx
<heaven31415> hi
<Groogy> hi
<FromGitter> <girng> hi
shalmezad has joined #crystal-lang
<FromGitter> <bararchy> So, whos gonna help me test the Crystal sniffer ? https://github.com/bararchy/sniffer
<FromGitter> <bararchy> does someone running Mac?
cremes has quit [Quit: cremes]
alex`` has quit [Quit: WeeChat 2.1]
heaven31415 has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
<FromGitter> <picatz> @bararchy Nice! <3
<FromGitter> <bararchy> :) @picatz do a quick try and let me know what you think
<FromGitter> <bararchy> I think I have a small bug somewhere, but can't figure out where
<crystal-gh> [crystal] MakeNowJust opened pull request #5902: Colorize: abstract colors and support 8bit and true color (master...feature/colorize/abstract-color) https://git.io/vx6NT
duane has joined #crystal-lang
alex`` has joined #crystal-lang
<Groogy> huh no idea what I did but somehow I'm crashing llvm when compiling?
<Groogy> as far as I can tell only thing I changed is that I added a third argument to an initializer :/
<Groogy> and now it just works?
<FromGitter> <bararchy> XD
<Groogy> oh know what it is, gonna see if I can get minimal example
<FromGitter> <unn4m3d> 😄
<Groogy> that crashes
<Groogy> seems to be because of the generic it seems
<Groogy> anyone recognize it if it's been reported already?
<FromGitter> <girng> dumb question but i might as well ask it
<FromGitter> <girng> is it possible to use `Any` as a type? and have it accept any data, like a `Variant`?
<Groogy> you could implement Variant yourself in Crystal yeah
<Groogy> but I wouldn't use YAML/JSON Any type for that
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
<FromGitter> <girng> basically, i want to pass a parameter to a method and have it accept anything. that bypasses the infamous `no overload matches` error
<FromGitter> <girng> i am willing and readingly to compile from source if need be
<Groogy> well then just write a method without any argument types and the compiler generates it for you
<Groogy> there's also some neat tricks with that, wait a second
<Groogy> gah can't remember exactly where I had that but I have in some places a method that takes any argument and then a specialized one for nil to unset the thing
<FromGitter> <girng> is it in the doc book maybe?
<Groogy> i.e instead of checking if "is the object nil, then do this" I just have a seperate method that does that
<FromGitter> <girng> wait, i can just pass the object by reference instead of trying to put into a hash right??
<Groogy> like this
<Groogy> objects are always by reference Girng
<FromGitter> <girng> thank you, i'll take a stab at it
<FromGitter> <girng> yah, just was thinking why am i passing data through my parameter. i should pass the object
<FromGitter> <girng> then ues the references object to create my hash.. so i dont hav to deal with all the no overload matches errors lol
<FromGitter> <bararchy> When the compiler compiles a program , does it create the whole binary in mem and then write it down at the end to the target path?
hightower2 has quit [Ping timeout: 248 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <girng> wow im idiot
<FromGitter> <girng> i need to STOP creating a damn HASH = {} of Type => Type.......... i just need to use a NAMED tuple. don't have to worry about all these no overload matches.. just pass the object and create the damn named tuple, then to .to_json rofl rofl
<FromGitter> <girng> got it all working now though, YAY!
<Groogy> if things are becomming uncomfortable to work with then you probably doing something wrong :P
<Groogy> applies to all programming
<FromGitter> <bararchy> @girng it was a mistake I was doing until recently, when a type becomes too complex just create a class/struct for it
moei has joined #crystal-lang
<Groogy> prefer to make classes and structs
<Groogy> anything else is just primitive obsession
<FromGitter> <j8r> The Crystal event loop is based on libevent, I see that Rust and Node.js use libuv and there is also libev. The 2 laters appear to be more efficient evolutions of libevent. Does someone have experience with them?
<FromGitter> <j8r> I was also wondering why libevent was chosen for Crystal...
<FromGitter> <girng> @bararchy coming from nodejs background i thought we had create a hash/key type for tuples.. lol little did i know, crystal has a damn NamedTuple built in!!!
benharri has quit [Quit: The Lounge - https://thelounge.github.io]
benharri has joined #crystal-lang
heaven31415 has joined #crystal-lang
<heaven31415> hi
<dom96> cześć
<FromGitter> <j8r> I've found this discussion about https://github.com/crystal-lang/crystal/issues/430
andrewzah has quit [Quit: ""]
heaven31415 has quit [Ping timeout: 260 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 256 seconds]
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 264 seconds]
heaven31415 has joined #crystal-lang
benharri has quit [Quit: The Lounge - https://thelounge.github.io]
benharri has joined #crystal-lang
benharri has quit [Client Quit]
benharri has joined #crystal-lang
heaven31415 has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
<FromGitter> <jwaldrip> Does the crystal_lib library still work?
<FromGitter> <jwaldrip> trying to generate binding for tar from this file… no such luck
<FromGitter> <jwaldrip> ```@[Include("libtar.h")] ⏎ @[Link("tar")] ⏎ lib LibTar ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ac26e781130fe3d36941f13]
<FromGitter> <bew> I never managed to make it work myself, but you can use https://github.com/olbat/libgen (which uses crystal_lib under the hood iirc)
<woodruffw> `crystal_lib` worked for me as of ~2 months ago, so it *should* still work...
<woodruffw> how are you invoking it?
<FromGitter> <jwaldrip> ```code paste, see link```
<woodruffw> yeah, that looks like what i did. is it spitting out an error?
<FromGitter> <jwaldrip> no error
<woodruffw> :(
<FromGitter> <jwaldrip> just spits out empty file
<FromGitter> <jwaldrip> @[Link("tar")] ⏎ lib LibTar ⏎ end
<RX14> @bew yeah popcount was only for flags enums
<RX14> in macros just check if its a flag enum
<RX14> if it is, popcount, else count unique
<woodruffw> @jwaldrip: are you sure it's `libtar.h`? going through the libtar sources, i see references to `tar.h`
<woodruffw> hmm, nvm, `libtar.h` exists too...
<FromGitter> <bew> @RX14 how do I count unique for normal enum? 'can't find a simple solution..
<RX14> not sure
<RX14> probably have an array and spit into it if it doesn't contain it
<RX14> I mean in macros
<RX14> then once you have the array take it's size
<FromGitter> <bew> problem is, from macros we don't have access to the values, only the name of each member
<RX14> what?
<RX14> really?
<FromGitter> <bew> at least from `TypeNode#constants`
<FromGitter> <bew> we 'could' make a `TypeNode#constant` for each name in `TypeNode#constants`, but we have another problem: an enum field can by an operation, so we'd need sth to eval the value, to verify we don't already have it
<RX14> well thats just opened up a whole new can of worms
<RX14> 1) enum values should be restricted to simple numerical expressions
<RX14> 2) we should be able to get their value from macros
<FromGitter> <bew> yeah definitely.. we need an isue to track this, can you do it? (or do I do it?)
<RX14> nah i'm super super tired
<RX14> been doing plumbing today of all things
<RX14> spent a lot of the day on my back inside my grandparents kitchen cabinet
<FromGitter> <bew> ok no prob'
shalmezad has quit [Quit: Leaving]
alex`` has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> @RX14 I did #5903 :)
<DeBot> https://github.com/crystal-lang/crystal/issues/5903 (Restrict Enum values to numerical expression & Allow value access from macro )
<RX14> thanks
<FromGitter> <bararchy> @jwaldrip you miss the prefix parts :)
<FromGitter> <jwaldrip> I put that in there.
<FromGitter> <jwaldrip> I need to figure out how to interact with those libraries… C is greek to me.
<FromGitter> <bararchy> Can you show full code you give to crystal lib?
<FromGitter> <jwaldrip> Its generated now
<FromGitter> <jwaldrip> ill share later today
alex`` has joined #crystal-lang
<FromGitter> <bararchy> Oh, OK :) as long as you got it working
alex`` has quit [Quit: WeeChat 2.1]
heaven31415 has joined #crystal-lang
That_Guy_Anon has quit [Quit: Leaving]
<FromGitter> <fridgerator> Anyone ever have with `each` blocks that include wrapped c funcs ? my index gets modified sometimes, and i'm not sure why
<FromGitter> <fridgerator> have issues*
duane has quit [Ping timeout: 256 seconds]
ashirase has quit [Quit: ZNC - http://znc.in]
return0e has quit [Ping timeout: 252 seconds]
return0e has joined #crystal-lang
<oprypin> fridgerator, y u no post code
<crystal-gh> [crystal] RX14 closed pull request #5893: Format: fix indentation in collection with comment after beginning delimiter (master...fix/crystal-format/indent-in-collection-literal-after-comment) https://git.io/vxKSn
<crystal-gh> [crystal] RX14 closed pull request #5159: Prevent invoking `method_added` macro hook recursively (master...fix/crystal/prevent-invoking-method-added-recursively) https://git.io/vdbS7
<FromGitter> <bew> @fridgerator I don't understand the question either, do you have an example?
<travis-ci> crystal-lang/crystal#e17823f (master - Format: fix indentation in collection with comment after beginning delimiter (#5893)): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/361399608
<DeBot> https://github.com/crystal-lang/crystal/pull/5893 (Format: fix indentation in collection with comment after beginning delimiter)
heaven31415 has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/vxixR
<crystal-gh> crystal/master 60f675c TSUYUSATO Kitsune: Format: fix indentation after backslash newline (#5901)...
<crystal-gh> [crystal] RX14 closed pull request #5899: Use LibCrystalMain.__crystal_main directly (master...use-LibCrystalMain-directly) https://git.io/vx61m