<FromGitter>
<Blacksmoke16> accepts optional format and location, otherwise uses rfc_3339
<FromGitter>
<Blacksmoke16> figured it would be one of the more common ones
<FromGitter>
<dougty_twitter> hi, new to crystal, is there any way to change the values of a struct in an array while iterating the array? i can post an example of what i'm trying to do if that's okay
<FromGitter>
<bararchy> "Bar" keys is always 0 when `.get`
<FromGitter>
<naqvis> `Atomic` is `Struct` so you get a value back, `add` is performed on copy, but not the one stored in `Hash`. You would need to re-assign the value of hash after modification. Something like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ed4aaa12c49c45f5ab59779]
<jhass>
short of using a full type (see the record macro) for your named tuple and defining <=> like that on it
<jhass>
but think about it, you gotta still specify how to sort the items in case last_read indeed is nil
<FromGitter>
<bararchy> I just had to increase the default timeout for no output in CircleCI as we passed 10min of compile time when running --release XD
<FromGitter>
<bararchy> 🎉
<FromGitter>
<jaredlt> gotcha, thanks jhass, really appreciate it
<jhass>
the "checksum" thing is my "per_domain_key" idea exactly. You just made it a O(n) lookup by storing stuff in an array instead of a hash using the "checksum" (I'd still like to call it compound key) as key
zorp_ has quit [Ping timeout: 264 seconds]
<FromGitter>
<emanzx> yes. I have thinking about the checksum also. so I can search based on checksum and get the specific array based on the checksum. but this need to run tru all the data.. and search per specific checksum.. does it better than using hash like what I did before in term of speed
<jhass>
you lost me, is there a question?
<jhass>
if the .find call is faster than your previous solution, then only because Hash#== and Hash#hash was more costly than it. String#== and String#hash are a lot faster, so using a hash for lookup with "checksum" as key will be even faster
<FromGitter>
<emanzx> okay
<FromGitter>
<emanzx> data = {} of String => Hash(String, Hash(String,String))
<FromGitter>
<emanzx> and my hash should populate {<domain> => {<checksum> => {view => <view_name>, action => <action>, rpz_zone => <rpz_zone>, client_ip => <client_ip>, count => <count>}}}
<jhass>
for example, yeah
<FromGitter>
<emanzx> so to update the count I just data[<domain>][<checksum>][<count>] = 3
<jhass>
for a complex data structure like this I would use explicit types like I showed, but yeah
<jhass>
yeah
<FromGitter>
<emanzx> ok this is easier for my level of understanding
<FromGitter>
<emanzx> sorry for the trouble
<jhass>
personally I'd probably also keep the metadata and data separate, so another level of {meta: ..., count: 0}, but ymmv
<FromGitter>
<emanzx> so I just replace the hash I used as key to checksum of the hash and add the hash to the value
<jhass>
yeah
<FromGitter>
<emanzx> oh. that would be good too
<jhass>
the checksum is what I've been calling a compound key
<FromGitter>
<emanzx> thanks for the idea
<jhass>
it's functionally the same to what I've been using per_domain_key for in my example
<FromGitter>
<emanzx> it came to me.. but I was why I need to get extra step as you said I can to_json the hash
<FromGitter>
<emanzx> haha
zorp_ has joined #crystal-lang
<FromGitter>
<emanzx> yes. but from the example I loose some important meta data info
<FromGitter>
<emanzx> like the action and rpz_zone
<FromGitter>
<emanzx> anyway I get the main idea
<jhass>
you could still make to_json your key derivation function technically, but it's not very good because it's not stable, meaning it might return different results for {:a => 1, :b => 2} and {:b => 2, :a => 1}
<jhass>
yeah I just couldn't be bother to reimplemnt the parser, partly because I was also lacking some context on how to do so
<jhass>
it was meant to show a possible structure, not be equally featured
<FromGitter>
<emanzx> okay
<FromGitter>
<emanzx> I think I get the idea from per_domain_key and hash the value of the meta data to create a uniq key
<FromGitter>
<DRVTiny> @naqvis , thank you, it is exactly what i need. I misunderstood official documentation (reference guide) : i think, Cfoo = 5 mean: Cfoo (and only Cfoo) will be 5.
<FromGitter>
<naqvis> ywc
<repo1>
hi! i have the following problem: when trying to parse a json with a serialized enum i get this error: Unknown enum Trackmap::JobStatus::State value: 1 (ArgumentError)
<FromGitter>
<emanzx> Error: undefined method 'to_i' for Hash(String, String) (compile-time type is (Hash(String, String) | String))
<FromGitter>
<Blacksmoke16> the value you're calling `.to_i` on is a union of `Hash(String, String)` and `String`
<jhass>
it means your variable can either be a hash or a string. Hash#to_i is not a thing, so you need to check you have a string before you can call to_i
<FromGitter>
<Blacksmoke16> of which `Hash` doesn't have a `.to_i` method
<oprypin>
how can i tell compiler to print AST of a program before trying to turn it into LLVM IR? because I know for sure that e.g. it turns `$1` into $~.not_nil![1]?` so where can i see that mid-flight?
<oprypin>
xmonader, i dont know but you shouldnt be messing with "read_blocking" and stuff ,thats for sure
<oprypin>
there's very likely some deadlock here, anyway
<jhass>
oprypin: I don't think that really exists :/
<FromGitter>
<xmonader> @oprypin well yeah I need the pipes for communications (even some continuous communication) with some unix processes via stdin/stdout
<FromGitter>
<xmonader> do I report it as a bug in crystal?
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
<FromGitter>
<naqvis> > *<oprypin>* how can i tell compiler to print AST of a program before trying to turn it into LLVM IR? because I know for sure that e.g. it turns `$1` into $~.not_nil![1]?` so where can i see that mid-flight? ⏎ ⏎ you might be disappointed, but above cited tool shows the AST of `$1` as `$~[1]` ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ed530edd13751370432dc60]
<FromGitter>
<Blacksmoke16> since `io` is first argument, wouldnt it be more ideal to yield the `io` first as well?
<FromGitter>
<Blacksmoke16> eh nvm
<FromGitter>
<xmonader> @Blacksmoke16 would you be so kind to check my problem and tell me if i should report it upstream?
<FromGitter>
<Blacksmoke16> im not super familiar with it
<FromGitter>
<Blacksmoke16> sorry :/
<FromGitter>
<xmonader> no problem thank you so much ^__^
<FromGitter>
<asterite> oprypin: right before codegen, maybe you can print the AST but instead of outputting nodes as is, if they have an `expanded` property you should inspect that. There's an `Expandable` module but I think not all nodes with `expanded` have it. Then I didn't try this, it might work. I'm not sure why you need it, though.
<FromGitter>
<jwoertink> I don't get any errors, but I'm also not sure if it's happening in some other thread that may mask any errors I could be getting
<oprypin>
jwoertink, yea it's referring to the same variables totally normally
<FromGitter>
<jwoertink> sweet
<FromGitter>
<jwoertink> thanks!
darkstardevx has joined #crystal-lang
darkstardevx has quit [Remote host closed the connection]