RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.0 | 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
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
thews has quit [Ping timeout: 245 seconds]
thews has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
jemc has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <fastcona> Who knows there are request errors across Crystal web frameworks? It look quite bad and need fixing especially spider-gazelle too ⏎ https://www.techempower.com/benchmarks/#section=test&runid=5191fd86-6a2a-405b-b326-f160fc6781b7&hw=ph&test=fortune
<FromGitter> <fastcona> Probably fixing those errors is utmost priorities right now.
<FromGitter> <sam0x17> @straight-shoota thanks for the info about the alpine package -- any idea when 0.27.1 will happen?
<FromGitter> <Blacksmoke16> is there a way to exclude specific ivars from being displayed when doing `pp`?
<FromGitter> <Blacksmoke16> like https://play.crystal-lang.org/#/r/5hjc
<FromGitter> <Blacksmoke16> the `val` ivar in this case
<FromGitter> <pitosalas> gitter question: is there a way to search for threads that you are named in within this channel?
marmotini_ has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
rohitpaulk has joined #crystal-lang
jemc has quit [Ping timeout: 252 seconds]
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
marmotini_ has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer published version `0.2.0` offers a more customization syntax as well as choice and size assertions
<FromGitter> <Blacksmoke16> next up will be custom assertions :)
<FromGitter> <sam0x17> in a crystal spec, what is the best way to assert that an object is of a particular type?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.27.0/Spec/Expectations.html#be_a%28type%29-macro
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <sam0x17> omg, that's what I wanted it to be
<FromGitter> <sam0x17> thx
<FromGitter> <Blacksmoke16> np
return0e has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
_whitelogger has joined #crystal-lang
WA9ACE has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
<WA9ACE> Is there a way to define some compile time flag for a shard?
<WA9ACE> I'd like to change to `@[Link("sqlcipher")]` based on some shard.yml config the user may or may not have set
<WA9ACE> essentially I want to make a PR into `crystal-sqlite3` allowing for a user to select building with either sqlite or sqlcipher
<FromGitter> <WA9ACE> Some person, just on Gitter as well
<FromGitter> <codenoid> so, how to get time difference in minutes
ua has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
ua has joined #crystal-lang
marmotini_ has joined #crystal-lang
marmotini_ has quit [Read error: Connection reset by peer]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
ashirase has quit [Ping timeout: 268 seconds]
ashirase has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
DTZUZO has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <bararchy> how can I check what is my local IP (eth0 for example) from crystal?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
ua_ has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
ua has quit [Ping timeout: 272 seconds]
devil_tux has joined #crystal-lang
<devil_tux> hi guys, anyone tried `crecto` shard with 0.27.0?
<devil_tux> I'm having troubles with defining models as such: class User < Crecto::Model
<devil_tux> with response expecting token ']', not '::': @[JSON::Field(ignore: true)
<devil_tux> so be4 I write gh issue, a little help would be appreciated
<oprypin> devil_tux, something is wrong, looks like your crystal version is something old, not actually 0.27.0
<devil_tux> oprypin: you are right, seems like I havent rebuilt docker image
<devil_tux> lmc, brb
<FromGitter> <petoem> @bararchy you can get the interface address using `getifaddrs()` function. See: http://man7.org/linux/man-pages/man3/getifaddrs.3.html
<devil_tux> oprypin: that was it ugh :>
<devil_tux> ty
<FromGitter> <petoem> iirc, there was another way using ioctl.
<FromGitter> <petoem> let me google
<devil_tux> what happened to hash.key?
<FromGitter> <j8r> You mean `Hash#keys` ?
<devil_tux> have you meant to tag me?
<FromGitter> <j8r> Yes devil_tux , talking to you
<devil_tux> ah, you are using gitter chat, its a proxy, sorry couldnt comprehend the irc log
<devil_tux> j8r: I remember using SomeHash.key(1) and it would give me value of the key 1
<FromGitter> <j8r> You can do `Hash#[index : Int32]`
<devil_tux> when was this introduced tho?
<FromGitter> <j8r> The value of `Hash` has always been indexed, AFAIK. This comes from`Indexable`
<devil_tux> I mean, when was .key(x) removed? Haven't tried anything beside < 0.25.*
ua_ has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
emilsp has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 250 seconds]
rohitpaulk has joined #crystal-lang
<Yxhuvud> The information you seek is probably possible to find in the changelong
<Yxhuvud> *log
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<devil_tux> Yxhuvud: strange; I can swear I compiled codebase w/ Hash#key on 0.25.*
<devil_tux> welp, there it is
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 252 seconds]
ua has joined #crystal-lang
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <kingsleyh> hi - is there an equivalent in Crystal to this? "Idiosyncrätic".unpack("V*") # => [1869177929, 1668184435, 1956954994]
<FromGitter> <kingsleyh> a signed integer per 4 bytes
<Yxhuvud> kingsleyh: unpack doesn't exist, as it isn't necessary. do `to_slice` on it and work from there.
<FromGitter> <kingsleyh> ok thanks - and what about pack?
<FromGitter> <kingsleyh> in this case: `pbkdf2_blocks[(i+1) * 2 * r * 16 - 16, 16].pack("V*")`
<FromGitter> <kingsleyh> just `.bytes`
<FromGitter> <kingsleyh> ?
<FromGitter> <kingsleyh> or to string or something
<FromGitter> <kingsleyh> e.g.
<FromGitter> <kingsleyh> `[1869177929, 1668184435, 1956954994].pack("V*") # => "Idiosyncr\xC3\xA4t"`
<Yxhuvud> `String.new`
<FromGitter> <kingsleyh> ah nice!
<Yxhuvud> but it must be a slice, not an array.
<FromGitter> <kingsleyh> ah great - works thanks :)
<FromGitter> <bajro17> Can someone help me with granite migrations I cant find is there way to declare unique field?
<FromGitter> <fridgerator> @bajro17 Did you try the amber channel?
<FromGitter> <schoening> Trying to debug my kemal server here. Just a simple CRUD app. But it does not get any parameters on my json object :/ ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Is there a kemal specific chat? ... [https://gitter.im/crystal-lang/crystal?at=5be83617e0fd6b4360d82b56]
<FromGitter> <fridgerator> When you use postman, you see the json params?
<FromGitter> <schoening> No, sorry, bad explaination. ⏎ I use postman for testing. No params. But when I send the same request to postman-echo.com/post it returns with params just fine
<FromGitter> <fridgerator> do you get anything in `env.params.body` ?
<FromGitter> <bajro17> @fridgerator I write but there is little slow to get answer then I want see if someone here use it :)
<FromGitter> <schoening> @fridgerator :o I do! ⏎ *name=test&email=test%40test.com&cellphone=12345678* which are my parameters.. but I did not create a GET request..
<FromGitter> <fridgerator> in postman, are you setting the content type?
<FromGitter> <schoening> Was about to say: adding *Content-Type application/json* in postman sorta breaks it for both the postman-echo.com/post and kemal. Which I find confusing..
<FromGitter> <schoening> That is the return data when I enable content-type
<FromGitter> <schoening> And Kemal throws an error
<FromGitter> <schoening> *Exception: Unexpected char '-' at 1:2 (JSON::ParseException)*
<FromGitter> <fridgerator> can you pass simpler json? whats all that extra stuff?
<FromGitter> <schoening> My json is simple, that stuff is the return data from postman-echo.com/post ⏎ My json looks like this:
<FromGitter> <fridgerator> oh ok
<FromGitter> <fridgerator> so thats form-data, not json
rohitpaulk has joined #crystal-lang
<FromGitter> <schoening> omg
<FromGitter> <schoening> Well, thx man. I only just downloaded postman. Now it works.. Derp
<FromGitter> <fridgerator> 👍
rohitpaulk has quit [Ping timeout: 245 seconds]
<oprypin> Yxhuvud, omg don't recommend those horrible hacks as if they're the best solution (this is regarding `unpack` vs slice)
<oprypin> kingsleyh, please don't use the previously recommended `to_slice` and `String.new` solutions. this is an imlpementation-specific hack. the proper solution is here: https://crystal-lang.org/api/IO/ByteFormat.html
<oprypin> as you're looking specifically for LittleEndian, and not just "whatever the current CPU decides to do"
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
devil_tux has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
Jenz has joined #crystal-lang
<Jenz> Moin
<Jenz> What have I misunderstood in here: https://play.crystal-lang.org/#/r/5hpf <---
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5hph
<FromGitter> <Blacksmoke16> wait so it literally has to be `T`
* Jenz :O
<FromGitter> <Blacksmoke16> right, so it matches with the parent generic
<FromGitter> <Blacksmoke16> that makes sense
<Jenz> (Not to me)
<Jenz> (the 5hpj one)
<Jenz> Thanks oprypin, @Blacksmoke16
rohitpaulk has quit [Ping timeout: 246 seconds]
<FromGitter> <Blacksmoke16> i think its because the abstract def says it should be of type `T`, i.e. whatever generic you pass the parent class
<FromGitter> <Blacksmoke16> and since you had it typed as `String` that wouldnt match up with if you did `Around(Bool)` for example, so by setting it to T it knows to use whatever generic the parent class is passed
<FromGitter> <Blacksmoke16> also anyone else notice their `toplevel.html` isnt being created
<FromGitter> <Blacksmoke16> i can search for the method name and it shows up in list but 404s when clicking on it, ill file an issue
<FromGitter> <Blacksmoke16> only happens when macro is only thing on toplevel
_whitelogger has joined #crystal-lang
Jenz has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
<oprypin> makes sense that there would be bug in such an area :)
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 245 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <dscottboggs_gitlab> @oprypin thanks for letting me know about `String.new` and `to_slice` being a hack, but I don't see what you mean about using IO::ByteFormat on Strings?
<oprypin> who said about strings
<Yxhuvud> oprypin: the whole thing as about going to and from string representation.
<oprypin> well you can encode to bytes and decode
<FromGitter> <dscottboggs_gitlab> yes the question is how
<oprypin> well, `String.new` seems to be the right way to convert from bytes to text
<oprypin> but the context was about 32-bit integers, not bytes
<FromGitter> <dscottboggs_gitlab> oh so you're saying to convert from `"string".to_slice` to an array of integers rather than from string to bytes in general.
<Yxhuvud> oprypin: well, ruby don't have proper bytes, so there you have to go to and from integer arrays instead.
* FromGitter * dscottboggs_gitlab cringes
<FromGitter> <vladfaust> I'm not awaiting for a much help, but maybe you could paw me the way. I have this example: https://carc.in/#/r/5hpr. What I want is get a valid JSON without double brackets and to make it as performant as possible (i.e. avoid reading from IO to string). One way is to modify `.to_json` (actually, I'm allowed to use any other method, e.g. `.to_bracketless_json`), but maybe there is a more obvious way?
<FromGitter> <vladfaust> 1) My use-case is lots of Foo's, which are Action objects in a web application
<oprypin> .to_json(response) ??
<FromGitter> <vladfaust> No, that's not what I want. I actually want `@payload` to be a variable containing a value for further processing. I cannot use `NamedTuple` for this, therefore I consider `IO` being the best alternative
<FromGitter> <vladfaust> The thing is that I want this `@payload` to be decorated in the future, e.g. wrap in another JSON
<FromGitter> <vladfaust> Yeah, can I somehow remove those brackets from the `@payload` without reading from it? :D
<FromGitter> <vladfaust> 1) `{foo: 42}.to_json(@payload)` without brackets ⏎ 2) Remove brackets from the end and the beginning of `@payload`
<FromGitter> <vladfaust> Sorry if being to noisy
<FromGitter> <vladfaust> Okay, nevermind, it's too deep, sorry for disturbing!
<FromGitter> <dscottboggs_gitlab> no disturbance, sorry we couldn't help
hightower4 has joined #crystal-lang
<hightower4> Hey @Papierkorb, I just realized your 'cannon' repo is not listed in either crystalshards.org or .xyz
<FromGitter> <vladfaust> This is what I came with, btw: https://carc.in/#/r/5hpw
<FromGitter> <vladfaust> This is what I came with: https://carc.in/#/r/5hpw
<FromGitter> <kingsleyh> is it possible to convert Bytes in to an UInt32 Array? if so could someone give me a hint?
<FromGitter> <vladfaust> `Slice` has `.to_a` method
<FromGitter> <vladfaust> And `UInt8` can be converted to `UInt32`
<FromGitter> <kingsleyh> how to convert?
<FromGitter> <vladfaust> https://crystal-lang.org/api/0.27.0/UInt8.html#to_u32%3AUInt32-instance-method
<FromGitter> <vladfaust> `bytes.map(&.to_u32)`?
<FromGitter> <kingsleyh> ah great that's what I was missing
<FromGitter> <kingsleyh> hmm not quite working as expected
<FromGitter> <kingsleyh> In Ruby this gives me an Array of Fixnum from Bytes : `b = bytes.unpack("V*")`
<FromGitter> <kingsleyh> the size of the Array is 4096
<FromGitter> <kingsleyh> the Bytes size is 16384
<FromGitter> <kingsleyh> in Crystal - the Bytes size is 16384 - the same
<FromGitter> <kingsleyh> but `bytes.map(&.to_u32).size` gives me 16384 as it's mapping - so not what I want
<FromGitter> <kingsleyh> I want 4096
<FromGitter> <vladfaust> That's because you need to `bytes.to_a.map(&.to_u32).size`
<FromGitter> <vladfaust> `.map` returns Slice, whilst `.to_a` converts it to an Array
<FromGitter> <kingsleyh> don't see how that could make any difference
<FromGitter> <vladfaust> Me too
<FromGitter> <Blacksmoke16> can you use enums in macros?
<FromGitter> <vladfaust> The truth is that I'm a web guy, I'm afraid of Bytes 😅
<FromGitter> <kingsleyh> It could be that for Crystal I can't follow the same path as the Ruby lib I'm porting
<FromGitter> <vladfaust> @Blacksmoke16 if they're defined in the outer scope - yes?
<FromGitter> <vladfaust> Enums are types
<FromGitter> <kingsleyh> I was told that Crystal doesn't need pack/unpack - but I don't really understand why
<FromGitter> <Blacksmoke16> well more specifically, compare the value off an annotation to an enum
<FromGitter> <vladfaust> @Blacksmoke16 sorry, had no experience, but I can assume that thus there is no Enum AST node, you cannot do that Enum-specific stuff
<FromGitter> <Blacksmoke16> `cann[:exclusion_policy].resolve == CrSerializer::ExclusionPolicy::ExcludeAll` works for me
<FromGitter> <Blacksmoke16> specs pass, ill take it 👌
<FromGitter> <vladfaust> Marvelous
<FromGitter> <vladfaust> Turns out a enum value is a Type itself
<FromGitter> <kingsleyh> 1 int = 4 bytes = so I guess if I have a byte array that is 16384 - I need to chunk it into 4's and do to_u32 on the chunk
<FromGitter> <kingsleyh> I think
<FromGitter> <vladfaust> Makes sense! But how to convert four UInt8 to a single UInt32? :thinking:
<FromGitter> <vladfaust> Just `.to_u32` on an array?
<FromGitter> <vladfaust> Highly doubt so
<FromGitter> <vladfaust> But it's a Slice
<FromGitter> <vladfaust> So maybe possible
<FromGitter> <vladfaust> But not very safe
<FromGitter> <kingsleyh> well this works
<FromGitter> <kingsleyh> `bytes.in_groups_of(4).map{|chunk| chunk.map{|v| v.not_nil!.to_u32} }.size`
<FromGitter> <kingsleyh> maybe flat_map could work
<FromGitter> <kingsleyh> hmm actually no - that would flatten away the 4
<FromGitter> <kingsleyh> anyway it seems to work
<FromGitter> <kingsleyh> hmm no it doesn't work :/
<oprypin> kingsleyh, so i guess you skipped my message
devil_tux has joined #crystal-lang
<FromGitter> <kingsleyh> oh I didn't see it
<devil_tux> how to hide logger output if creating dinamically?
<devil_tux> Log = ::Logger.new(STDOUT)
<FromGitter> <kingsleyh> oprypin - sorry I don't understand your comments
<FromGitter> <kingsleyh> I think you are saying in Crystal - we should not convert between Byte array and UInt32 Array?
<FromGitter> <kingsleyh> I should convert it to a string? and then to UInt32 Array?
<oprypin> that's fine, just see the documentation I linked
<oprypin> I'm saying the opposite
<FromGitter> <kingsleyh> oh I see - you are recommending encode/decode instead
<FromGitter> <kingsleyh> how do you deal with the Nil cases? ` bytes.in_groups_of(4).map{|chunk| IO::ByteFormat::LittleEndian.decode(UInt32, chunk) }`
<FromGitter> <kingsleyh> the chunk returns Array(UInt8 | Nil)
<oprypin> i think you could skip the manual chunk splitting
<FromGitter> <kingsleyh> I don't think so - as the decoder only gives back a single UInt32
<oprypin> use IO#read_bytes
<oprypin> but you'll probably still run into trouble with the right boundary
<oprypin> what is it supposed to do when there are less than 4 bytes remaining?
<FromGitter> <kingsleyh> throw an exception
<oprypin> well perfect then
<FromGitter> <kingsleyh> the size has to be exactly 4096 as well - so if the size is not exactly 4096 or if there are not enough or too many bytes then it should throw an exception
<oprypin> that's what IO.read_bytes does
<FromGitter> <kingsleyh> I need to create an IO? like a IO::Memory and put the bytes in it - and then read them out again ?
<oprypin> yes
<FromGitter> <kingsleyh> seems like a long way around since I already have the bytes
<FromGitter> <kingsleyh> pity there is no bytes.to_memory_io
<FromGitter> <vladfaust> Which is better - annotations or custom DSL? https://carc.in/#/r/5hq4
<FromGitter> <kingsleyh> I still only get a single UInt32 from that
<FromGitter> <kingsleyh> ```io = IO::Memory.new(bytes) ⏎ p io.read_bytes(UInt32, IO::ByteFormat::LittleEndian)``` [https://gitter.im/crystal-lang/crystal?at=5be8980a9600d10e64951b94]
<FromGitter> <kingsleyh> I think I will still have to chunk up the array
<FromGitter> <vladfaust> You need to read until the bytes end :/
<FromGitter> <kingsleyh> read_bytes should read all the bytes?
<oprypin> usually bytes seems like a long way around since you already have the io
<FromGitter> <dscottboggs_gitlab> on one hand the annotations make a nice API. But on the other hand, crystal's annotations syntax is super ugly and I don't have any idea how to make it less so. *Porque no los dos?*
<oprypin> where did the byte slice come from?
<oprypin> call it in a loop
<FromGitter> <kingsleyh> `bytes = Crypto.pbkdf2_sha256(password.to_s, salt, 1, p * 128 * r)`
<FromGitter> <kingsleyh> which is
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be898c3bb88787474b397a3]
<FromGitter> <vladfaust> > on one hand the annotations make a nice API. But on the other hand, crystal's annotations syntax is super ugly and I don't have any idea how to make it less so. *Porque no los dos?* ⏎ ⏎ You know, it's ugly because it's compared to other Crystal syntaxes, which try to avoid special symbols - brackets etc. In Go this would look natively
<oprypin> kingsleyh: IO is a stream, it advances the position, so i guess you can do `Array.new(1024) { io.read_bytes(...) }`
<FromGitter> <dscottboggs_gitlab> that's true. I also wish crystal had the `or`, `and`, and `not` keywords. The one thing I found confusing about annotations is they seem to be applicable to instance vars and coming from python where they could only be applied to methods that definitely confused me. I should spend a little time learning how they work in crystal.
<FromGitter> <kingsleyh> @oprypin this works thanks: `Array.new(4096) { io.read_bytes(UInt32, IO::ByteFormat::LittleEndian)}`
<FromGitter> <vladfaust> Annotations allow composition, that's a strong point
<FromGitter> <vladfaust> I.e. multiple annotations on a single variable
<FromGitter> <Blacksmoke16> i dont see how you think annotations are ugly
<FromGitter> <Blacksmoke16> compared to java maybe, but has to be unique syntax, not much you can do about it without a lot of work i imagine
<FromGitter> <kingsleyh> @oprypin what is the equivalent in Crystal of `b.pack("V*")` where `b` is the Array(UInt32) of size 4096 - is it converting it back into Bytes?
<FromGitter> <vladfaust> Could someone *please* help me with that? https://carc.in/#/r/5hqb
<FromGitter> <Blacksmoke16> has to be within a method
<FromGitter> <vladfaust> https://carc.in/#/r/5hqg
<oprypin> kingsleyh, well like the opposite operation
<oprypin> kingsleyh, https://crystal-lang.org/api/0.27.0/IO/ByteFormat.html Encode to bytes
<oprypin> but don't use that uninitialized stuff lol
<oprypin> assume you already have a slice
<oprypin> actually Encode to IO
<oprypin> kingsleyh, just make an empty IO::Memory and write everything to it and get a slice *then*
<FromGitter> <kingsleyh> ok I'll try that thanks
<FromGitter> <vladfaust> @Blacksmoke16 could you please come up with an example?
<oprypin> if you're interested in a small performance improvement, you can actually create IO::Memory with an initial size
<FromGitter> <Blacksmoke16> sec
<FromGitter> <vladfaust> I'm trying to replicate JSON::Serializable
<FromGitter> <kingsleyh> @oprypin how do I write into the IO::Memory - I have Array(UInt32) and IO only seems to take bytes in write_bytes
<devil_tux> what does this mean: Error resolving kemal-session (0.10.0, 0.11.0)
<devil_tux> when `shards update` on fixed shard.yml
<devil_tux> the given version (0.11.0) is available and released on @github
<oprypin> kingsleyh, https://crystal-lang.org/api/0.27.0/IO/ByteFormat.html Encode to IO - how is that bytes
<oprypin> call that in a loop (.each)
<FromGitter> <kingsleyh> It doesn't like it - `undefined method 'to_io' for Array(UInt32)`
<FromGitter> <kingsleyh> Array(UInt32) can't be converted to IO like that it seems
<FromGitter> <kingsleyh> oh you mean loop around the Array(UInt32) calling io_write_bytes on each item
<FromGitter> <Blacksmoke16> @vladfaust https://carc.in/#/r/5hrj
<FromGitter> <Blacksmoke16> however im not sure you can do what you were trying to there
<devil_tux> also tried branch: master flag but it's sitting on 0.10.0 version, (will not update)
<FromGitter> <vladfaust> Isn't that a bug?
<FromGitter> <Blacksmoke16> not afaik, let me see if i can find it
<FromGitter> <vladfaust> Cannot use `.instance_vars` in method definition
<FromGitter> <vladfaust> Thanks, btw
<devil_tux> anyone?
<FromGitter> <Blacksmoke16> > Instance var information is only available inside methods. At the top level you never know when more instance vars are going to be added, and the compiler keeps them all and eventually solves them in one go considering all the type hierarchy
<FromGitter> <Blacksmoke16> @vladfaust ^
<FromGitter> <vladfaust> Could you give me a link to that, @Blacksmoke16
<FromGitter> <vladfaust> @devli_tux gonna check
<devil_tux> vladfaust: I think it's my "host" Crystal version, which is lower then dependencies
<devil_tux> let me upgrade to 0.27.0 outside of docker and Iwll let u know
<FromGitter> <vladfaust> Hah, docker, that could be an issue as well
<devil_tux> the project is not in docker atm
<FromGitter> <vladfaust> @Blacksmoke16 nice, thank you
<FromGitter> <Blacksmoke16> np, as i tried something similar and was saddened :p
<devil_tux> im pushing fixes to lib
<FromGitter> <vladfaust> Should be added to docs btw
<FromGitter> <vladfaust> To https://crystal-lang.org/api/0.27.0/Crystal/Macros/TypeNode.html#instance_vars%3ACrystal%3A%3AMacros%3A%3AArrayLiteral%28MetaVar%29-instance-method
<FromGitter> <Blacksmoke16> prob
<FromGitter> <vladfaust> This makes impossible to plug and track changes on an object
<FromGitter> <vladfaust> Nevermind
<FromGitter> <vladfaust> And unable to define methods base on var names :(
<FromGitter> <vladfaust> I.e. I have a nice macro in my ORM https://carc.in/#/r/5hrt
<FromGitter> <vladfaust> And if I wanted to go annotations-way, i.e. get rid of `MODEL_ATTRIBUTES` data-constants, which @RX14 says are bad, I cannot define `@changes = HashOfInstanceVariablesTypes`
<devil_tux> @vladfaust: can you try perhaps, pls?
<devil_tux> the initial problem is on @crecto/crecto-admin (.25 support)
<devil_tux> here is the fork: https://github.com/exploitd/crecto-admin
<FromGitter> <vladfaust> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be8a86e6b9822140d1617b2]
<FromGitter> <vladfaust> Works nicely
<devil_tux> hmm, cant figure it out for the sake
<FromGitter> <Blacksmoke16> whats the issue?
moei has quit [Quit: Leaving...]
<devil_tux> vladfaust: can you try shard update on the fork above?
<devil_tux> Blacksmoke16: I'm having troubles upgrading shard (kemal-session) based on latest shard.yml version/branch
<FromGitter> <Blacksmoke16> `rm -rf ~/.cache/crystal ~/.cache/shards` then try again
<devil_tux> Blacksmoke16: will do
<FromGitter> <Blacksmoke16> if they already installed will have to do `shards update`
<FromGitter> <Blacksmoke16> or also rm your projects `libs` folder and `shards.lock`
<devil_tux> Blacksmoke16: I think lock has not been replaced
<FromGitter> <Blacksmoke16> then try a `shards install`
<devil_tux> Tried rm on libs
<devil_tux> the amove rm rf did not help
<devil_tux> let me try lock
<FromGitter> <Blacksmoke16> `shards update` will update the lock
<FromGitter> <Blacksmoke16> install will not, and will install based off lock file
<devil_tux> Blacksmoke16: removing lock does not help
<FromGitter> <vladfaust> Sorry, @devil_tux, but I have to go
<FromGitter> <Blacksmoke16> whats your `shards.yml` look like?
<devil_tux> vladfaust: np, ty anyway
<devil_tux> Blacksmoke16: https://pastebin.com/raw/8upSvBTz
<devil_tux> for some reason, it's overwriting to 0.10.0 instead of latest hash
<FromGitter> <Blacksmoke16> well yea
<FromGitter> <Blacksmoke16> you have `version: 0.10.0`
<FromGitter> <Blacksmoke16> so its going to use that
<FromGitter> <Blacksmoke16> :p
<devil_tux> Blacksmoke16: :p
<devil_tux> on serious side tho
<devil_tux> what might be the reason
<devil_tux> why does it ignore "master" branch
<FromGitter> <Blacksmoke16> that bottom part is from your `shards.yml`?
<devil_tux> no, the bottom part is my shard.lock, as per `cat` rules
<FromGitter> <Blacksmoke16> ah, and what is the `shards.yml` say?
<devil_tux> Blacksmoke16: it's in oneliner at the 2nd prompt
<devil_tux> cat shard.yml | grep -R "kemal-session" -C 3
<devil_tux> (standard input)- github: kemalcr/kemal-csrf
<devil_tux> (standard input)-
<devil_tux> (standard input)- kemal-csrf:
<devil_tux> (standard input): kemal-session:
<devil_tux> (standard input): github: kemalcr/kemal-session
<devil_tux> (standard input)- branch: master
<FromGitter> <Blacksmoke16> ooo ok
<FromGitter> <Blacksmoke16> i gotcha
<FromGitter> <Blacksmoke16> yea i dunno man `rm -rf ~/.cache/crystal ~/.cache/shards shard.lock lib/ && shards install` should totally do it
<devil_tux> Blacksmoke16: yup, it makes absolutely no sense
<devil_tux> have you tried to exec shards command on the fork?
<FromGitter> <Blacksmoke16> i have not
<devil_tux> Blacksmoke16: may I ask you for a favor to do so?
<devil_tux> it will greatly contribute to my debugging
<FromGitter> <Blacksmoke16> https://github.com/exploitd/crecto-admin this one?
<devil_tux> Blacksmoke16: indeed
<FromGitter> <Blacksmoke16> well shit
<FromGitter> <Blacksmoke16> `Installing kemal-session (0.10.0)`
<devil_tux> Blacksmoke16: uh, are you on crystal latest?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5be8ad0e6b9822140d162dc0]
<FromGitter> <Blacksmoke16> yup
<FromGitter> <Blacksmoke16> installing it from other project installs `0.11.0`, strange
<devil_tux> Same here, except MacOS
<devil_tux> I'm sure something is wrong with shard but I can't figure it out for the life
<devil_tux> I meant yaml file
<devil_tux> maybe deps incompatibility?
<FromGitter> <Blacksmoke16> i know
<FromGitter> <Blacksmoke16> sec
<devil_tux> oO
<FromGitter> <Blacksmoke16> `kemal-csrf` defines session as a dependency that is locked at `0.10.0`
<devil_tux> awh, shit
<devil_tux> hate having forks open, these are two atleast
<FromGitter> <Blacksmoke16> so that one must override the version
<devil_tux> Blacksmoke16: it's kinda funny how parent deps have higher privilege
<devil_tux> cant we force from base shard.yml
<FromGitter> <Blacksmoke16> yea, can maybe file an issue on the shards lib?
return0e has quit []
<devil_tux> Blacksmoke16: will do, thanks for a hand :>
<FromGitter> <Blacksmoke16> np
return0e has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer now supporting custom assertions plus much better up to date docs!