deavmi has quit [Read error: Connection reset by peer]
chachasmooth has quit [Ping timeout: 240 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 245 seconds]
chachasmooth has joined #crystal-lang
<FromGitter>
<naqvis> should be pretty straight-forward to implement IO for this use-case and use-case is quite valid to have a Rotating Fixed Size IO
<FromGitter>
<naqvis> unlike `IO::Memory` which expands when needed, this implementation should be a fixed size and perform rotation when capacity reached
<yxhuvud>
depending on usecase, for the case when rotating isn't wanted but rather to block if not consumed, a pipe could be relevant.
<yxhuvud>
as for what you'd get, it would be `llo`, as the implementation should keep track of where the start is.
hendursa1 has joined #crystal-lang
<FromGitter>
<naqvis> > e.g. an `IO::Memory` that stores at most n bytes, removing the earlier ones ⏎ ⏎ my understanding of this sentence was FIFO, so with the presence of `hel`, adding two chars `lo` should remove `he`
hendursaga has quit [Ping timeout: 240 seconds]
<FromGitter>
<naqvis> next addition of char should replace the 3rd char and continue from the start
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<yxhuvud>
naqvis: That would be how it would be stored, sure. But why would anyone want gets_to_end to not be position aware?
<FromGitter>
<naqvis> it should be position aware, but i didn't include `io.rewind` in my contrived scenario :P
<yxhuvud>
Right. It might be worth having separate writers and readers then. :)
<FromGitter>
<naqvis> :P
HumanG33k has quit [Quit: Leaving]
HumanG33k has joined #crystal-lang
Nekka has quit [Ping timeout: 246 seconds]
Nekka has joined #crystal-lang
hendursa1 has quit [Ping timeout: 240 seconds]
hendursa1 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang
<FromGitter>
<cut3_gh0st_twitter> Hello everyone, I have a question that may not be related to Crystal Lang but I need help. I have made a small custom HTTP server written in Crystal, now I need to set it up on AWS EC2 instance and I need to get traffic to it. Does anyone here have a similar experience with this, they would love to share? Any links related to this topic would be appreciated. :D
<FromGitter>
<Blacksmoke16> not including what needs done in AWS itself ofc tho
<FromGitter>
<naqvis> i believe question was how to generate traffic to his hosted webserver
<FromGitter>
<Blacksmoke16> prob would be resources related to running a Go server, should handle the AWS side of things id imagine
alexherbo2 has quit [Ping timeout: 268 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter>
<naqvis> @Blacksmoke16 for RotatingIO should you expect it to decline to overwrite once buffer is full and nothing has been read? or it should overwrite silently?
<FromGitter>
<Blacksmoke16> maybe have it be configurable via a bool. overwrite silently or raise an exception
<FromGitter>
<Blacksmoke16> but i imagine the latter would be the default. Like if you write more to it than is allowed, would really only keep the the last n
<FromGitter>
<naqvis> @Blacksmoke16 re that CircularIO, suppose with overwrite mode: ⏎ ⏎ ```io = CircularIO.new(3) ⏎ io << "hello"``` ⏎ ⏎ though buffer is of size 3, but writer would have written 5 bytes and buffer would contain `lol`, so invoking a read, would you expect it to read how many times a write was made? or cap it to buf length? [https://gitter.im/crystal-lang/crystal?at=60996c8820d4f02631b36f99]
<FromGitter>
<naqvis> Question i'm trying to pose is, as `write` is circular, so does the read would be
<FromGitter>
<naqvis> don't know if i'm making any sense :P
<FromGitter>
<jwoertink> Yup. I'm running on ElasticBeanstalk (EC2). @cut3_gh0st_twitter
<FromGitter>
<jwoertink> Thanks for the mention @Blacksmoke16
<FromGitter>
<jwoertink> I'm around on the Crystal Discord if y'all have any questions.
<FromGitter>
<cut3_gh0st_twitter> @jwoertink I will hit you on Discord then, thank you
<FromGitter>
<alex-kampa> Hello everyone! I have a question about reusing parts of a json data structure to construct a new data structure. What is the best/easiest way to do this?
<FromGitter>
<Blacksmoke16> deserialize the data into objects an work with those
<FromGitter>
<Blacksmoke16> working with `JSON::Any` and/or a `Hash` like that isnt great
<FromGitter>
<alex-kampa> @Blacksmoke16 the reason I'm asking is that I only need to check a single field of the received JSON object, and then return a large part of the json as-is. So was hoping I could avoid the deserialising / rebuilding / reconverting back to json by just using a json structure that is in fact already there.
<FromGitter>
<Blacksmoke16> naw, you have a `String`, whether you deserialize it into an object via `.from_json` or `JSON::Any` via `JSON.parse`, it'll have to be parsed regardless
<FromGitter>
<Blacksmoke16> you prob could get away with `JSON::Any` to avoid needing to define types for the whole structure but might be a bit painful
<FromGitter>
<alex-kampa> Hi @Daniel-Worrall yes so far so good. But response["InternalTransactionReceipts"] is clearly an Array, and not a String as the error message suggests
<FromGitter>
<Daniel-Worrall> The error is saying you have not taken into consideration the case where the value could be a String.
<FromGitter>
<Daniel-Worrall> The Hash value could be a string since you have a String as one of the values, so it is `Array(Foo) | String`
<FromGitter>
<Daniel-Worrall> Of course, in runtime, it will never be a String, but that is not the case in Compile time
<FromGitter>
<alex-kampa> Hi @Daniel-Worrall thanks for your suggestion - your code snippet works but when applied to my data structure (again surprisingly) it does not. But I did learn something ... and have found a workaround in the meantime: constructing the Array first and only then plugging into the Hash.
<FromGitter>
<alex-kampa> > working with hashes like this is a pity ⏎ ⏎ Hi @Blacksmoke16 maybe not elegant but explicit. I like seeing my data structures :-)
<FromGitter>
<Blacksmoke16> less explicit than using actual objects where you'd know the type of each property and suchh