ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.32.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
<FromGitter> <jaydorsey> good afternoon. was wondering if anyone could point me in theright direction for manipulating some parsed YAML. i’m trying to merge some data into an exact parsed yaml file
<FromGitter> <jaydorsey> example snippet: https://play.crystal-lang.org/#/r/8bs0
<FromGitter> <Blacksmoke16> whats the goal
<FromGitter> <Blacksmoke16> ?
<FromGitter> <jaydorsey> so, in ruby i could convert the yaml into a hash, and jam some other data into the YAML
<FromGitter> <jaydorsey> end goal is to merge 2 YAML files together, but I’m also just looking at general “how can I jam another key/val pair under ‘bar’"
<FromGitter> <jaydorsey> I have 2 YAML files, both have same top level key, different subkey, and I just wanted to load & merge them together so i could look in 1 place for lookups
<FromGitter> <Blacksmoke16> is the structure of the data known beforehand?
<FromGitter> <Blacksmoke16> or static i should say
<FromGitter> <jaydorsey> sort of? i’m using the yml files from the ruby faker gem to build a crystal version to teach myself some crystal
<FromGitter> <jaydorsey> the files all have a similar top level key(s), then it deviates pretty wildly across file(s) from there
<FromGitter> <Blacksmoke16> and you want to merge multiple files into one object essentially?
<FromGitter> <jaydorsey> yeah, kidn of as an aside. i don’t think I really need to jam them all into one data structure (and probably dont’ want to), i just wanted to see if i could so i could learn some more about how i could do it in crystal
<FromGitter> <Blacksmoke16> id check out
<FromGitter> <Blacksmoke16> or do something like https://play.crystal-lang.org/#/r/8bsf
<FromGitter> <Blacksmoke16> working with `YAML::Any` directly is kinda a pita if you're not doing real simple stuff
<FromGitter> <jaydorsey> thanks, that’s actually reassuring to hear. i thought it should have been simple but i’m finding it isn't
return0e has joined #crystal-lang
<FromGitter> <PenguinOwl> heya
<FromGitter> <PenguinOwl> ive been trying to update the alpine linux package for crystal from 0.31.1 > 0.32.1, but building the binary crawls to a stop while building, usually around the codegen step
hpyc9 has quit [Remote host closed the connection]
hpyc9 has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
alex has quit [Ping timeout: 260 seconds]
<FromGitter> <PenguinOwl> is there a approx. minimum amount of memory that building the compiler takes?
ur5us has joined #crystal-lang
<FromGitter> <Blacksmoke16> how much do you have?
<FromGitter> <PenguinOwl> on my metal server, 2gb
<FromGitter> <Blacksmoke16> yea thats prob not enough
<FromGitter> <PenguinOwl> sounds about right
<FromGitter> <PenguinOwl> vm time
<FromGitter> <watzon> Yeah building the compiler takes a good amount of memory. You probably need 2.5-3 GB minimum
<FromGitter> <PenguinOwl> any idea on the rough amount though?
<FromGitter> <PenguinOwl> oh k
<FromGitter> <PenguinOwl> i built on my 8gb machine a while ago
<FromGitter> <PenguinOwl> just didnt know the rough estimate
<FromGitter> <PenguinOwl> thanks!
<FromGitter> <watzon> I'd probably use a machine with 4 just to be safe, but it shouldn't need much more than that
<FromGitter> <PenguinOwl> k great
dwdv has quit [Ping timeout: 265 seconds]
<FromGitter> <randiaz95> hey guys, is there a performance loss if I were to buffer a file reader to line by line instead of reading the entire file to memory?
<FromGitter> <Blacksmoke16> could benchmark it
<FromGitter> <randiaz95> ok I see a couple of methods:``` ⏎ ⏎ Instance methods inherited from module IO::Buffered ⏎ buffer_size, buffer_size=, close, flush, peek, read, read_buffering=, read_buffering?, rewind, sync=, sync?, unbuffered_close, unbuffered_flush, unbuffered_read, unbuffered_rewind, unbuffered_write, write ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5e0d6f14833c373f4d9582eb]
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <stnluu_twitter> @randiaz95 if whatever you are using is extending "Buffered", I suspect it does not matter
<FromGitter> <stnluu_twitter> what likely happens is, the implementation reads a set amount every time, and keep it in the buffer. This is to align with the disk cluster/block size
<FromGitter> <stnluu_twitter> For example, even if you're reading just one char at a time, it might just always read a block of up to 1024 chars, and then give you back one char and keep track of where it is internally
<FromGitter> <stnluu_twitter> double check tho. i didn't look at the underlying implementation, but highly *suspect* that's what it is doing
<FromGitter> <stnluu_twitter> it's a common practice
<FromGitter> <stnluu_twitter> on the other note, the delta in perf may be negligible depending on what you're actually doing
Chioque has joined #crystal-lang
Chioque has quit [Quit: WeeChat 2.7]
<FromGitter> <PenguinOwl> not sure if im doing something wrong, but building crystal release for alpine is taking an indefinite amount of time on `[12/13] [0/1] Codegen (bc+obj)`
ur5us has joined #crystal-lang
sorcus has quit [Ping timeout: 246 seconds]
sorcus has joined #crystal-lang
<mps> PenguinOwl: it builds in single thread, so yes takes time
<mps> it takes time on our official builders (Alpine linux) with a lot of RAM and CPUs also
ht_ has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
asterite has quit [Ping timeout: 250 seconds]
jhass has quit [Ping timeout: 245 seconds]
asterite has joined #crystal-lang
jhass has joined #crystal-lang
<FromGitter> <btihen> @stnluu_twitter & others interested in Channels and Fibers - I have a very Simple example - with two questions: ⏎ 1) Whats the best wait to wait for all Fibers to finish sending messages (all Channels are empty) and how would that scale with a large chat room? ⏎ 2) Why does switching user who sends the message trigger Fiber switching? ⏎ 3) Would something like this be helpful for the Docs? ⏎ ...
_whitelogger has joined #crystal-lang
dwdv has joined #crystal-lang
tankf33der has joined #crystal-lang
_whitelogger has joined #crystal-lang
<repo> i'd say you'd need a status channel. once you break out of the loop you'd send nil to a status channel that was passed to the constructor. Then you just call `USER_COUNT.times { status_channel.receive }`
<repo> (instead of the sleep
<repo> (obviously you'd also need to close the channels)
<FromGitter> <repomaa> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e0dec24eaa2cd096fe03ff7]
<FromGitter> <repomaa> you could also do something more elaborate with the status channel, like making it a `Channel(Exception?)` and sending `nil` to it but rescuing exceptions and then sending them to the channel if they occur.
<FromGitter> <repomaa> this way you can rescue exceptions that happen in a fiber
<FromGitter> <repomaa> if the amount of users is dynamic, you'd have to set up a separate status channel for each user and then receive on those
Human_G33k has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 268 seconds]
<raz> ^ i have a quiz for the macro wizards
<raz> any way to reflect on the calling method name inside a macro?
gangstacat has quit [Quit: Ĝis!]
<raz> (with "calling" i mean the method in which the macro is invoked)
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> could do something at runtime, but i dont know of a way to do that
<FromGitter> <Blacksmoke16> that approach would work ^
<raz> the heck, i could've sworn i had tried this before
<raz> thanks! :)
<repo> the backslash is key
<repo> you might've tried without it
<raz> yes, i probably messed up the escaping with my various "commented out" macro attempts
<repo> :)
gangstacat has joined #crystal-lang
<repo> why is Array#clear not Array#clear!
<repo> it clearly (pun intended) mutates the object
<repo> same could be asked for #delete and #fill and so on
<FromGitter> <tenebrousedge> these are good questions
<repo> i guess there is some consistency though: it seems ! is only used if there is both a mutating and a non-mutating version of the method
<FromGitter> <tenebrousedge> hmmm
<repo> if ! is used too strictly it would also mean that []= would have to be []!= or something :P
<FromGitter> <tenebrousedge> D:
<repo> maybe that's a bad example, but i see how it could get out of hand
<FromGitter> <Blacksmoke16> heres a question, working on moving some of my shards into an org
<FromGitter> <Blacksmoke16> like `myorg/config`, `myorg/logger` etc
<FromGitter> <Blacksmoke16> however since shards dont get grouped by org, `logger` for example would conflict with other loggers and the stdlibs logger
<FromGitter> <Blacksmoke16> so my options are like 1) call it `myorg-logger`, or give it a more unique name?
<repo> i'd call it myorg-logger
<repo> doesn't mean that the repo would have to be named like that
<FromGitter> <Blacksmoke16> true true
<repo> but it would result in a top level namespace Myorg
<repo> which is nice imo
<FromGitter> <Blacksmoke16> exactly, thats the plan :)
<repo> also: if you'r project's name is something like foo_bar. then name the shard myorg-foo_bar
<repo> so it results in Myorg::FooBar
<repo> i've done it like this also for rubygems
<repo> it's a bit work though, because you'll have to rename the shard after creating it with crystal init lib
<repo> oh wait
<repo> no you don't
<repo> just the repo
<FromGitter> <Blacksmoke16> yea repo would be `myorg/logger`
<repo> exactly
<repo> i'm betting the bigger frameworks already do this
<repo> lucky for example has a lot of sub-shards
<repo> hm no
<repo> they have "avram"
<FromGitter> <Blacksmoke16> yea, they have unique names
<repo> i'd prefer namespacing it though
<repo> depending on how tightly they're coupled maybe
<FromGitter> <Blacksmoke16> now im thinking what to do with the ones that are unique enough, like `event_dispatcher` should it really be like `myorg-event_dispatcher`
<FromGitter> <Blacksmoke16> i suppose it doesnt really hurt anything
<FromGitter> <Blacksmoke16> consistency and shows multiple shards come from the same "source"
<repo> yeah
<FromGitter> <Blacksmoke16> i could live with that
<FromGitter> <Blacksmoke16> nice, esp since i can setup `crystal/docs` to build docs for the shards too
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <tenebrousedge> has anyone written a guide on avoiding "gotchas" in benchmarking Crystal? e.g. cases where calculations will be discarded if the return value is unused, or values will be allocated in an unexpected way
<sorcus> Blacksmoke16: Hi :-)
<FromGitter> <Blacksmoke16> hey
<sorcus> Blacksmoke16: oh, you commented my review. I'm worried and happy. Haha.
<FromGitter> <Blacksmoke16> yea reminded me i need to handle `HEAD` requests
<FromGitter> <Blacksmoke16> i.e. if the user defines a `GET` request, define a `HEAD` one behind the scenes that just skips the handler
<sorcus> Blacksmoke16: too bad i can't help :-( X-)
<FromGitter> <Blacksmoke16> all good, you can try it when its done and see if you find any bugs 😉
<FromGitter> <kingsleyh> in a yaml file - can I put crystal code? like: `time: #{Time.utc}`
<FromGitter> <kingsleyh> do I need interpolation?
<FromGitter> <Blacksmoke16> can process the file via ECR
<FromGitter> <Blacksmoke16> interpolation is another option yes
<FromGitter> <kingsleyh> It's not working :(
<repo> what did you try?
<FromGitter> <kingsleyh> I've got a struct with ```timeout: Time::Span``` and then in my yaml file: ``` timeout: #{Time::Span.new(0, 1, 0, 0, 0)}```
<repo> yeah
<FromGitter> <kingsleyh> but it says: Error: wrong number of arguments for 'Time::Span.new' (given 2, expected 0, 3, 4, 5)
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/cr
<repo> you can't just interpolate things on runtime
<repo> you'd need ecr
<FromGitter> <Blacksmoke16> might be able to use `sprintf`
<FromGitter> <Blacksmoke16> i think thats more so an issue that `Time::Span` isnt supported in `from_yaml`
<FromGitter> <kingsleyh> can I get a Time::Span from a string somehow?
<FromGitter> <Blacksmoke16> could use a custom converter to parse a string or something yea
<repo> yeah
<repo> something like that maybe
<FromGitter> <btihen> @repomaa - thanks. After a bit of playing and experimenting it all works. I assume the call-back on closing is the preferred way - I also realized (after reading your post) I could do: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ But I assume that's a bit sloppy. ... [https://gitter.im/crystal-lang/crystal?at=5e0e1b88833c373f4d9a0824]
<FromGitter> <btihen> @repomaa - would the `delivered?` tell me if there are any messages in the queue before closing? How do I make the channels a bit more `thread-safe`?
Nicolab has joined #crystal-lang
<FromGitter> <kingsleyh> @Blacksmoke16 thanks :) just what I needed
<FromGitter> <PenguinOwl> im back, still having a few problems building release. looking at the log it seems like the massive linker command is running in the wrong directory <https://gist.github.com/PenguinOwl/e89782a51e201290befd2569c69768e6>
<sorcus> PenguinOwl: `make: crystal: Command not found` - are you sure the crystal installed?
<FromGitter> <PenguinOwl> an old binary is in the path
<FromGitter> <PenguinOwl> from 0.31.1
<mps> sorcus: this 'make' is not fatal
<sorcus> mps: sadly :-(
<mps> you reminded me to fix this in next push
<mps> but first want to drop aarch64 from pkg
Nicolab has quit [Ping timeout: 240 seconds]
<FromGitter> <PenguinOwl> hm yes very cool
<FromGitter> <PenguinOwl> crystal not being in path is frying my brain
<mps> PenguinOwl: look at build() in APKBUILD
<FromGitter> <PenguinOwl> the above make is basically all that is in there
<FromGitter> <PenguinOwl> plus the path checks out so i cannot see a reason why crystal cant be found
alex`` has quit [Quit: WeeChat 2.7]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <PenguinOwl> nvm fixed that problem
<mps> probably shell
<FromGitter> <PenguinOwl> nah its just maintainer prob had crystal installed systemwide on their dev machine
tankf33der has left #crystal-lang [#crystal-lang]
<FromGitter> <PenguinOwl> path was being passed to make instead of being set as env i guess?
<mps> no
<mps> it builds on clean alpine builders, so no crystal installed
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
Nicolab has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter> <btihen> It was mentioned that `Records` aren't mentioned in the Crystal Git book. So I made a pull request with that added: https://github.com/crystal-lang/crystal-book/pull/379 - if you have ideas or feedback -- I'd be glad to hear from you.
<raz> hm, does crystal spec have something like "let()"? how would i declare a var in before_each so it can be used by the corresponding tests
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Max SendQ exceeded]
JuanMiguel has joined #crystal-lang
<FromGitter> <watzon> raz: The built in spec library is pretty bare bones. Personally I really like spectator for when I need to do anything that's not super basic.
<raz> thx, yep, working around it rn
JuanMiguel has quit [Quit: This computer has gone to sleep]
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Quit: This computer has gone to sleep]
JuanMiguel has joined #crystal-lang
JuanMiguel has quit [Ping timeout: 240 seconds]
ht_ has quit [Ping timeout: 248 seconds]
Nicolab has quit [Quit: Leaving.]
alexherbo2 has joined #crystal-lang
<FromGitter> <wontruefree> we will be hosting a talk about the state of AI in Crystal in 30 min if people are interested in joining
<FromGitter> <lbarasti> @btihen from your comment on the code snippet above ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I suspect you might have misunderstood what `#receive?` does. Just like `receive`, `#receive?` will still block the fiber until a message is available, but it will return `nil` rather than throwing a `Channel::ClosedError` when the channel is closed [https://gitter.im/crysta
<FromGitter> ... l-lang/crystal?at=5e0e7e38cbd2c97eff7e18ea]
<FromGitter> <wontruefree> I got a sneak peak at the slides and it looks like it will be a good talk
<FromGitter> <wontruefree> chicagocrystal.org/events/clzwlrybccbdb/
<FromGitter> <wontruefree> if you have messed around with https://github.com/NeuraLegion/shainet I think you will like the talk
<FromGitter> <wontruefree> here is a link to the video
<FromGitter> <wontruefree> https://zoom.us/j/3541015445
<FromGitter> <lbarasti> Thanks @wontruefree, I was thinking of joining, but it's almost midnight here in the UK, and I'm close to collapsing :D ⏎ Will definitely checkout the recording 👍
<FromGitter> <wontruefree> sounds good it should be posted soon