ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.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> <ilanpillemer> where x is `val x = List.range(1, 10)`
<FromGitter> <tenebrousedge> I suppose that's the same sort of thing
<FromGitter> <tenebrousedge> but it executes slightly differently
<FromGitter> <ilanpillemer> I think Java uses `_` too
<FromGitter> <ilanpillemer> for the one variable lambda
<FromGitter> <ilanpillemer> not sure though
<FromGitter> <tenebrousedge> could be
<FromGitter> <tenebrousedge> :(
<FromGitter> <tenebrousedge> this stock is just not good enough. I'll have to find some gelatin. Maybe it will set up more when it's cooler, but so far it's quite disappointing -- a waste of 24 hours
<FromGitter> <ImAHopelessDev_gitlab> ^ = lmaoo
<FromGitter> <tenebrousedge> 😢
<FromGitter> <ImAHopelessDev_gitlab> stir in some bytes
<FromGitter> <ImAHopelessDev_gitlab> that will thicken it up
<FromGitter> <ImAHopelessDev_gitlab> remove boehm's GC, stir in some bytes, and add some slices of butter.
Nekka has quit [Read error: Connection reset by peer]
Nekka has joined #crystal-lang
<FromGitter> <tenebrousedge> > `Two days wrong!' sighed the Hatter. `I told you butter wouldn't suit the works!' he added looking angrily at the March Hare.
<FromGitter> <nsuchy> ☝️ October 7, 2019 2:02 PM (https://gitter.im/crystal-lang/crystal?at=5d9b7dc5fcf7602cc54b1933) ⏎ @tenebrousedge Following up from earlier, we build amber as root for use later inside the container, it only seems to affect build performance. This was adapted from Amber's image so certain things were copied and moved around. For example the node_module was just copied from amber, we'll rename that to
<FromGitter> ... node_modules though, nice catch. We can't use the USER command because boot.sh runs as root, it has to set OpenVPN Routes and Modify DNS as a privileged user, this is to allow our developers to run production on their laptops for testing purposes, it requires access to our intranet though through OpenVPN.
<FromGitter> <tenebrousedge> you can switch users as necessary
<FromGitter> <nsuchy> docker-compose uses the last user from the docker container for the run command, since we have to move it to a root only folder anyways, is makes more sense to build as root then switch for runtimd purposes?
Nekka has quit [Read error: Connection reset by peer]
Nekka has joined #crystal-lang
<FromGitter> <tenebrousedge> that depends on how many build root-owned build artifacts you're willing to leave in the local filesystem
<FromGitter> <tenebrousedge> personally I find that obnoxious
<FromGitter> <nsuchy> @tenebrousedge As long as the panel can read/write to necessary files I don't see the issue but I guess it's personal preference.
<FromGitter> <ImAHopelessDev_gitlab> i just thought of something awesome
<FromGitter> <nsuchy> I suppose we could reassign ownership afterwards
<FromGitter> <ImAHopelessDev_gitlab> i remember using https://github.com/phoboslab/Impact way back in the day, was the best html 5 engine. i wonder if i could port it (or just be inspired by its beautiful api) and create it in crystal with sdl2 as the canvas, instead of the html 5 renderer.
alex``` has quit [Ping timeout: 252 seconds]
<FromGitter> <ImAHopelessDev_gitlab> i swear, crystal's syntax and OOP is like perfect for a game engine
<FromGitter> <tenebrousedge> I guess that's what Godot thought too
<FromGitter> <Blacksmoke16> cept you dont use OOP much 😉
<FromGitter> <Blacksmoke16> coughabstractdefcough coughdelegatecough
<FromGitter> <tenebrousedge> we could consider not going there
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 LOL
<FromGitter> <ImAHopelessDev_gitlab> i use tons of classes, however i do pass my classes around in methods prob too much
<FromGitter> <ImAHopelessDev_gitlab> but i mean.. it makes sense to me and the compiler ain't complaining so i'mhappy hahaha
<FromGitter> <Blacksmoke16> whatever floats your boat :p
<FromGitter> <Blacksmoke16> write anymore tests?
<FromGitter> <ImAHopelessDev_gitlab> compiler is my test :)
<FromGitter> <Blacksmoke16> only helps so much
<FromGitter> <ImAHopelessDev_gitlab> true
<FromGitter> <Blacksmoke16> compiler makes sure you have a "valid" program, tests make sure you have a "correct" program
<FromGitter> <ImAHopelessDev_gitlab> this kind of nuance isn't comprehensional to my brain
<FromGitter> <Blacksmoke16> main reason i like it is i can be assured its working correctly, make changes and ensure it still works
<FromGitter> <Blacksmoke16> without manually testing everything every time
<FromGitter> <Blacksmoke16> plus TDD is also a thing that can help with development
<FromGitter> <Blacksmoke16> i used that a bit when making `oq`
<FromGitter> <ImAHopelessDev_gitlab> tdd?
<FromGitter> <Blacksmoke16> test driven development, i.e. you write the tests then the code
<FromGitter> <ImAHopelessDev_gitlab> wtf lol
<FromGitter> <Blacksmoke16> which is helpful for what i was doing in that you could define tests to make sure everything converters correctly, then iterate on the code until they all pass
<FromGitter> <ImAHopelessDev_gitlab> eh
<FromGitter> <ImAHopelessDev_gitlab> begin rescue is my friend
<FromGitter> <ImAHopelessDev_gitlab> if something fails, i rely on my exceptions
<FromGitter> <Blacksmoke16> example? exceptions are a valid way to handle errors. but if used wrong they can kill your perf
<FromGitter> <Blacksmoke16> as i found out first hand recently
<FromGitter> <tenebrousedge> usually you only want to throw if it's unavoidable
<FromGitter> <ImAHopelessDev_gitlab> https://crystal-lang.org/api/0.31.1/TCPServer.html throw in a `rescue e` inside `handle_client`
<FromGitter> <ImAHopelessDev_gitlab> super important
<FromGitter> <Blacksmoke16> and what do you do with the exception?
<FromGitter> <ImAHopelessDev_gitlab> crystal got shorthand rescues as well
<FromGitter> <ImAHopelessDev_gitlab> dont'e ven need `begin`
<FromGitter> <Blacksmoke16> log/report something back to the user?
<FromGitter> <ImAHopelessDev_gitlab> you know the client's socket got disconnected
<FromGitter> <ImAHopelessDev_gitlab> or that,yeah
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <ImAHopelessDev_gitlab> guard classes, exceptions, classes, hashes, to_json, namedtuples.. it's glorious
<FromGitter> <ImAHopelessDev_gitlab> guard clause ** 😆
<FromGitter> <ImAHopelessDev_gitlab> i really want to work on this simpel sdl2 thing, but i can't get a X11 thing running on Windows to display a Window
<FromGitter> <ImAHopelessDev_gitlab> i might just have to go to native linux.. i could use an old laptop
<FromGitter> <Blacksmoke16> get another harddrive and install it on that
<FromGitter> <Blacksmoke16> SSDs are pretty cheap these adys
<FromGitter> <ImAHopelessDev_gitlab> not a bad idea
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 you on linux?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <ImAHopelessDev_gitlab> i feel like i've went through conversation before, deja vu
<FromGitter> <ImAHopelessDev_gitlab> what OS?
<FromGitter> <Blacksmoke16> Debian
<FromGitter> <ImAHopelessDev_gitlab> Nice
<FromGitter> <ImAHopelessDev_gitlab> That's like a perfect dev environment for me, cause my VPSs that I use are on the debian server minimal
<FromGitter> <ImAHopelessDev_gitlab> don't you play that one game
<FromGitter> <ImAHopelessDev_gitlab> nvm, gaming on linux is a lot easier now
<FromGitter> <tenebrousedge> steam and playonlinux work well
<FromGitter> <tenebrousedge> even together
<FromGitter> <tenebrousedge> I use ubuntu because third-party repositories
<FromGitter> <Blacksmoke16> what game?
<FromGitter> <tenebrousedge> I generally prefer Debian but it's just not the "target Linux"
<FromGitter> <ImAHopelessDev_gitlab> spaceship one
<FromGitter> <Blacksmoke16> EVE?
<FromGitter> <ImAHopelessDev_gitlab> the one you created stuff with using your programming skillz
<FromGitter> <ImAHopelessDev_gitlab> i think so, yeah
<FromGitter> <Blacksmoke16> yea, was quite into it, not so much lately tho
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge yeah it's quite cool how far gaming has come on linux
<FromGitter> <ImAHopelessDev_gitlab> @Blacksmoke16 too much crystal? ;p
<FromGitter> <Blacksmoke16> just not enough time with work and side projects
<FromGitter> <ImAHopelessDev_gitlab> i heard eve requires immense amoutn of time
<FromGitter> <ImAHopelessDev_gitlab> like a job
<FromGitter> <Blacksmoke16> plus im endgame so nothing new is worth my time
<FromGitter> <Blacksmoke16> i.e. im not longer a new player with awe trying to find my way
<FromGitter> <ImAHopelessDev_gitlab> https://play.crystal-lang.org/#/r/7q7u/edit
<FromGitter> <ImAHopelessDev_gitlab> am i doing this correctly with `.select`?
<FromGitter> <tenebrousedge> I would use `select { |_, v|` if the key is not used within the loop, but that's just a naming convention
<FromGitter> <ImAHopelessDev_gitlab> good point
<FromGitter> <ImAHopelessDev_gitlab> this is where my loop was going to come into play. iw as going to do items.each do, and increment a variable if owner_id == xx. however, i can just use select, and call .size
<FromGitter> <tenebrousedge> why not use `count` ?
<FromGitter> <Blacksmoke16> ^
<FromGitter> <ImAHopelessDev_gitlab> when all i really need is just how many `owner_id==xx` there is in the hash.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7q84
<FromGitter> <ImAHopelessDev_gitlab> what' sthat
<FromGitter> <ImAHopelessDev_gitlab> count?
<FromGitter> <tenebrousedge> yup, it takes a block argument
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Enumerable.html#count(&block)-instance-method
<FromGitter> <ImAHopelessDev_gitlab> what happened to the key
<FromGitter> <ImAHopelessDev_gitlab> surely this is faster than returning an entire list of items
<FromGitter> <ImAHopelessDev_gitlab> right?
<FromGitter> <Blacksmoke16> prob better off using an array at this point
<FromGitter> <Blacksmoke16> or a better constructed hash where you could do `items[owner_id].size`
<FromGitter> <Blacksmoke16> and not have to iterate anything
<FromGitter> <ImAHopelessDev_gitlab> items need a unique identifier it's theri key
<FromGitter> <Blacksmoke16> are they stored in a database?
<FromGitter> <ImAHopelessDev_gitlab> yah
<FromGitter> <Blacksmoke16> then why not get them from there?
<FromGitter> <Blacksmoke16> `user.items`?
<FromGitter> <ImAHopelessDev_gitlab> this is for loot, items on the ground
<FromGitter> <Blacksmoke16> `select * from items where owner_id = ?`
<FromGitter> <ImAHopelessDev_gitlab> in a zone
<FromGitter> <ImAHopelessDev_gitlab> yeah, a player's inventory is already client.items
<FromGitter> <Blacksmoke16> each item could have a unique id
<FromGitter> <Blacksmoke16> but group them by owner before hand so you dont have to iterate?
<FromGitter> <ImAHopelessDev_gitlab> good idea
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7q8b
ua has quit [Excess Flood]
<FromGitter> <ImAHopelessDev_gitlab> ohh you used items.values
<FromGitter> <ImAHopelessDev_gitlab> i was thinking wtf
ua has joined #crystal-lang
<FromGitter> <tenebrousedge> @BLACKSMOKE16 used VALUES ⏎ It's super effective!
<FromGitter> <ImAHopelessDev_gitlab> benchmark time baby
<FromGitter> <tenebrousedge> keep in mind, if the code fears you, it will run better
ua has quit [Excess Flood]
<FromGitter> <ImAHopelessDev_gitlab> dunno if should be scared or confident
ua has joined #crystal-lang
<FromGitter> <nsuchy> @robacarp Is this still being maintained? https://github.com/robacarp/mosquito
<FromGitter> <nsuchy> I get the error "Error resolving redis (~> 2.2.0, *, ~> 2.1.1)" when I try to include it
<FromGitter> <tenebrousedge> looks like it needs updating
<FromGitter> <tenebrousedge> but given that the last update was 115 days ago, maybe, "Is this still being maintained?" is a little aggressive
<FromGitter> <Blacksmoke16> make a PR, pretty sure he's still around
<FromGitter> <Blacksmoke16> there just hasn't been much needing done to it until now it seems
<FromGitter> <nsuchy> I know he's still around, I don't know the fix though
<FromGitter> <Blacksmoke16> just have to update redis
<FromGitter> <Blacksmoke16> its locked to 2.1.1
<FromGitter> <Blacksmoke16> where something you have needs `2.2`
<FromGitter> <Blacksmoke16> could prob update the version to be `2.x.y`
<FromGitter> <ImAHopelessDev_gitlab> Alrighty, created a benchmark for select vs count vs .each https://github.com/girng/.selectVS.eachVS.count
<FromGitter> <Blacksmoke16> do count but without the .values
<FromGitter> <ImAHopelessDev_gitlab> how to do it with count, but still check .owner_id without .values?
<FromGitter> <Blacksmoke16> `.count do |k, v|`
<FromGitter> <ImAHopelessDev_gitlab> kk, testing
<FromGitter> <ImAHopelessDev_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bf05deac5612d22d353b6]
<FromGitter> <ImAHopelessDev_gitlab> yep, same
<FromGitter> <ImAHopelessDev_gitlab> nice
<FromGitter> <ImAHopelessDev_gitlab> i'll update
<FromGitter> <Blacksmoke16> think you got the wrong heading on it tho
<FromGitter> <Blacksmoke16> basically (afaik) it avoids allocating a new array on each iteration
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9bf097fcf7602cc54e2919]
<FromGitter> <tenebrousedge> without the `values`
<FromGitter> <ImAHopelessDev_gitlab> lesson from this benchmark is...
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 264 seconds]
<FromGitter> <ImAHopelessDev_gitlab> Don't use select if you need to JUST count the size of an array
<FromGitter> <ImAHopelessDev_gitlab> or hash, or whatever
<FromGitter> <Blacksmoke16> well yea
<FromGitter> <Blacksmoke16> :p
<FromGitter> <ImAHopelessDev_gitlab> updated final thoughts on repo
<FromGitter> <ImAHopelessDev_gitlab> thx for help
<FromGitter> <ImAHopelessDev_gitlab> nice benchmark.
<FromGitter> <Blacksmoke16> at this point you should just make one repo with a dir for each benchmark
<FromGitter> <ImAHopelessDev_gitlab> why didn't i think of that
<FromGitter> <tenebrousedge> I'd just make a gist for a benchmark like this
<FromGitter> <Blacksmoke16> that would also be sufficient
<FromGitter> <ImAHopelessDev_gitlab> so
<FromGitter> <ImAHopelessDev_gitlab> how to do save navigation operator with count
<FromGitter> <ImAHopelessDev_gitlab> https://play.crystal-lang.org/#/r/7q8v
<FromGitter> <tenebrousedge> with count and a hash? use `last` maybe
<FromGitter> <tenebrousedge> the values are yielded as tuples
<FromGitter> <ImAHopelessDev_gitlab> https://play.crystal-lang.org/#/r/7q8z
<FromGitter> <ImAHopelessDev_gitlab> like this? @tenebrousedge
<FromGitter> <tenebrousedge> yeah
<FromGitter> <ImAHopelessDev_gitlab> wtf why is returning a bool
<FromGitter> <tenebrousedge> https://play.crystal-lang.org/#/r/7q92
<FromGitter> <tenebrousedge> ask @ilanpillemer
<FromGitter> <ImAHopelessDev_gitlab> WTF
<FromGitter> <ImAHopelessDev_gitlab> Nice one
<FromGitter> <tenebrousedge> yeah the syntax can be ambiguous, which is why I always use `.==()` in that context
<FromGitter> <ImAHopelessDev_gitlab> i didn't know we needed a dot after ==
<FromGitter> <ImAHopelessDev_gitlab> i could have sworn this worked without a dot after == before
<FromGitter> <tenebrousedge> in some contexts I'm sure it does work
ua has quit [Ping timeout: 240 seconds]
<FromGitter> <ImAHopelessDev_gitlab> what's a good rule of thumb to know
<FromGitter> <ImAHopelessDev_gitlab> when to use the dot after == and not
<FromGitter> <tenebrousedge> if you're using `&.`, use `.==`
ua has joined #crystal-lang
ua has quit [Excess Flood]
<FromGitter> <nsuchy> @robacarp https://github.com/robacarp/mosquito/pull/37
ua has joined #crystal-lang
<FromGitter> <nsuchy> Updates the Crystal and Redis images to the latest as well :)
<FromGitter> <ImAHopelessDev_gitlab> grr that' sgonna be piss me off
<FromGitter> <ImAHopelessDev_gitlab> i swear i've done safe navigation operator on a hash before without needed that dot before `==`. trying to remember what it was for
<FromGitter> <tenebrousedge> it's not technically safe navigation; that's Ruby
<FromGitter> <ImAHopelessDev_gitlab> what's it called in crystal
<FromGitter> <tenebrousedge> in Crystal it's just "short one-argument syntax" https://crystal-lang.org/reference/syntax_and_semantics/blocks_and_procs.html
<FromGitter> <tenebrousedge> I'd be tempted to call it the "etc operator"
<FromGitter> <ImAHopelessDev_gitlab> aww ok
<FromGitter> <ImAHopelessDev_gitlab> maybe i was thinking of `&.[1].owner_id`
<FromGitter> <ImAHopelessDev_gitlab> &.[index]
<FromGitter> <ImAHopelessDev_gitlab> that's crazy
<FromGitter> <ImAHopelessDev_gitlab> syntax, but kinda cool
<FromGitter> <Blacksmoke16> just executing a method really
<FromGitter> <ImAHopelessDev_gitlab> yah but you have toa dmit
<FromGitter> <ImAHopelessDev_gitlab> &.[1] is a bit funky at first
<FromGitter> <ImAHopelessDev_gitlab> are classes Types?
ma__ has joined #crystal-lang
ma__ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
DTZUZO has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
chemist69 has quit [Ping timeout: 250 seconds]
chemist69 has joined #crystal-lang
ua has quit [Ping timeout: 240 seconds]
ua has joined #crystal-lang
ht_ has joined #crystal-lang
ht_ has quit [Quit: ht_]
ua has quit [Ping timeout: 245 seconds]
ua has joined #crystal-lang
absolutejam4 has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 264 seconds]
<FromGitter> <kingsleyh> morning - any got a recommendation for creating a binary that has a --version cli command that shows the circleci build number it was built with?
absolutejam4 has joined #crystal-lang
<FromGitter> <kaukas_gitlab> Put the build number into a VERSION file and then use `read_file` macro to read it and when compiling?
sagax has quit [Remote host closed the connection]
sagax has joined #crystal-lang
<FromGitter> <ilanpillemer> git commit hash is probably better than circle ci build no?
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter> <kingsleyh> thanks
absolutejam4 has quit [Ping timeout: 240 seconds]
<FromGitter> <gdotdesign> anyone know why these two libraries are needed when trying to build with the `--static` flag? `liblcms2` `liblqr-1` both them are installed (with dev as well) and have `.so` files and it cannot link them for some reason and I cannot find the source (a shard or maybe Crystal itself) so maybe someone has run into it before, the two shards that I know use libs which I use is
<FromGitter> <gdotdesign> what I figured out that it's somehow related to `magickwand`
absolutejam4 has joined #crystal-lang
alex``` has joined #crystal-lang
alex``` has quit [Ping timeout: 245 seconds]
ma_ has joined #crystal-lang
alex``` has joined #crystal-lang
alex``` has quit [Quit: WeeChat 2.6]
alex`` has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 276 seconds]
absolutejam4 has quit [Ping timeout: 265 seconds]
absolutejam4 has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <j8r> @gdotdesign you need `.a` archives
<FromGitter> <j8r> `find /usr/lib -name "*.a"`
ma_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <gdotdesign> thanks that's helpful!
<FromGitter> <gdotdesign> managed to compile it thanks @j8r
<FromGitter> <j8r> np @gdotdesign :)
<FromGitter> <ImAHopelessDev_gitlab> @gdotdesign how did you fix it?
<FromGitter> <ImAHopelessDev_gitlab> put the .a archives in folder?
<FromGitter> <gdotdesign> removed the shard but then `libz` was missing so I just added the `zlib-static` (on alpine) but probably I should be able to find the right packages
<FromGitter> <ImAHopelessDev_gitlab> thank you @gdotdesign
<FromGitter> <kinxer> @ImAHopelessDev_gitlab Nicely done on the raindrop exercise. :)
<FromGitter> <ImAHopelessDev_gitlab> @kinxer thank i tried to do it all from scratch without using built in methods. cause i felt like it wouldn't be learning
<FromGitter> <ilanpillemer> @ImAHopelessDev_gitlab flatten is nice one to use to learn, by not using the built in flatten.
<FromGitter> <ImAHopelessDev_gitlab> however, i use built in methods in my main codebase, so i guess i'm a hypocrite
<FromGitter> <ImAHopelessDev_gitlab> @ilanpillemer nice. i'll prob stumble upon another exercism that might need to use flatten
<FromGitter> <tenebrousedge> learning and using the standard library isn't worse than rewriting it all yourself
<FromGitter> <ImAHopelessDev_gitlab> not me, using built-in methods feels like cheating in certain aspects. for example, instead of understanding how to get factors of a # i could have just used divisible_by?
<FromGitter> <ImAHopelessDev_gitlab> without even knowing what factors are
<FromGitter> <ilanpillemer> @ImAHopelessDev_gitlab thats what I meant. There is an exercism for flatten
<FromGitter> <ilanpillemer> @ImAHopelessDev_gitlab standard libraries often have black magic optimisations that are nice to have less allocations based on dark knowledge of the compiler.
<FromGitter> <ilanpillemer> aslo sometimes the logic is so complex, you dont want to fight bugs in your own version of a well know algorithm.
<FromGitter> <ImAHopelessDev_gitlab> that's true. maybe this was a bad example cuz i don't understand math. i just felt like i needed to write my own method to get the factors cause i ddin't even know what factors were lol
DTZUZO_ has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> i did know they were a multiple of a #, but didn't now it had to go into numbers "EVENLY" w/o a remainder
<FromGitter> <ilanpillemer> yes. you *should* definitely learn these things
<FromGitter> <ilanpillemer> but not sure that needs to happen in production!
<FromGitter> <ImAHopelessDev_gitlab> true ahahah
<FromGitter> <ilanpillemer> on the other hand…
<FromGitter> <ImAHopelessDev_gitlab> well now, i will use divisible_by in my codebase
<FromGitter> <ilanpillemer> makes life more fun, and fun is important.
<FromGitter> <ImAHopelessDev_gitlab> if i ever need to handle factors.. which maybe not lol. i'm not going to be doing any math things in the fututure, unless it's exercism
DTZUZO has quit [Ping timeout: 264 seconds]
<FromGitter> <ilanpillemer> maths is everywhere
<FromGitter> <ImAHopelessDev_gitlab> yeah, it's rough
<FromGitter> <ImAHopelessDev_gitlab> ( for me )
hypercore has quit [Ping timeout: 260 seconds]
alex`` has quit [Quit: WeeChat 2.6]
alex`` has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 268 seconds]
ht__ has joined #crystal-lang
<FromGitter> <j8r> mps: I have setup a Drone CI for Crystal (https://github.com/j8r/crystal/tree/drone-ci ), I hope to improve the support state
alex`` has quit [Quit: WeeChat 2.6]
<FromGitter> <tenebrousedge> my stock ended up gelling nicely, thank goodness 😌 now to create a *sauce espagnole* and then finally the *demi-glace*
<repo> is it possible to globally define the source and branch of a nested dependency in the top most shard.yml?
<repo> so if my project A depends on project B but project B won't compile because it depends on project C which is broken and i've forked project C and fixed the issue.
<FromGitter> <watzon> This is probably a @Blacksmoke16 question: Is it possible with a macro to get all of the
<FromGitter> <Blacksmoke16> yes ofc
<FromGitter> <watzon> How would one do that?
<FromGitter> <Blacksmoke16> `{{MyBaseClass.all_subclasses}}`
<FromGitter> <Blacksmoke16> that includes children of children
<FromGitter> <Blacksmoke16> if you just want direct subclasses can do `.sublasses`
<FromGitter> <watzon> Ahh right! That works if they aren't defined within the parent class right? For instance: ⏎ ⏎ ```abstract class Parent ⏎ end ⏎ ⏎ class Child < Parent ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d9cbaaf3220922ffb4f0448]
<FromGitter> <Blacksmoke16> they would both return `[Child]`
<FromGitter> <watzon> Ok cool
<FromGitter> <Blacksmoke16> `all_subclasses` would return classes that inherit from `Child`, while `subclasses` only includes direct children of `Parent`
<FromGitter> <watzon> That's great. Thanks :)
<FromGitter> <Blacksmoke16> np
<FromGitter> <ImAHopelessDev_gitlab> i forgot what that shard was called, but i remember @bew mentioning a long time. it basically watches for any changes to a .cr file and re-runs your app
<FromGitter> <watzon> Sentinel or something?
<FromGitter> <ImAHopelessDev_gitlab> sounds familiar
<FromGitter> <Blacksmoke16> sentry
<FromGitter> <ImAHopelessDev_gitlab> 🤖
<FromGitter> <watzon> That's it
dwdv has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> 🤖 Your SentryBot is vigilant. beep-boop... haha this shard is awesome
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
<livcd> Do you guys have any predictions about Windows support ?
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<oprypin> let's get our tea leaves out
ma_ has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> hi @oprypin
ma_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <repromancer_gitlab> I was playing with the idea of modeling my domain without the notion of ID's (to start with), so I typed this: ⏎ ⏎ ```record Vendor, ⏎ parent : Vendor?, ⏎ affiliates : Array(Vendor)``` ⏎ ⏎ and got this error about a recursive definition (makes sense, I didn't think it would be possible): https://play.crystal-lang.org/#/r/7qn8 [https://gitter.im
<FromGitter> ... /crystal-lang/crystal?at=5d9cdf5037073b36a0932d12]
<FromGitter> <repromancer_gitlab> Does this seem idiotic in principle, or is this probably the next most Crystally way to define this sort of thing? https://play.crystal-lang.org/#/r/7qna ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9cdfed874aeb2d230ff910]
<FromGitter> <repromancer_gitlab> and then `parent` and `affiliates` would be methods on the struct which retrieve an actual `Vendor` or `Array(Vendor)` from a repo?
<FromGitter> <tenebrousedge> the latter seems fine
<FromGitter> <tenebrousedge> looks normal to me
<FromGitter> <repromancer_gitlab> thanks 👍
absolutejam4 has joined #crystal-lang
<FromGitter> <dburnsii> Hey guys, I'm currently looking to include a crystal project I'm working on in an embedded Linux distribution using Yocto, but I've been running into a few issues, and I'm wondering if anyone has any experience with this?
<FromGitter> <tenebrousedge> asking if anyone knows about a general topic < asking a specific question. Probably no one else is using Yocto, but we may be able to help anyway
<FromGitter> <ImAHopelessDev_gitlab> what is Yocto
<FromGitter> <ImAHopelessDev_gitlab> https://www.yoctoproject.org/
<FromGitter> <tenebrousedge> a way to work with embedded Linux
<FromGitter> <ImAHopelessDev_gitlab> eh, i'll take things i'll prob never do for $500, alex 😆
<FromGitter> <ImAHopelessDev_gitlab> @dburnsii i'm sure if its an error with crystal the community will help easily
<FromGitter> <ImAHopelessDev_gitlab> not sure about Yocto internals though
ma_ has joined #crystal-lang
<FromGitter> <dburnsii> Essentially, I just need to be able to wipe out all of the default paths and point only to library paths I specify. The issue I'm having right now is that when I build with the `--cross-compile` flag, it's still pointing to the libraries on my host machine.
<FromGitter> <tenebrousedge> probably you want to set `LD_LIBRARY_PATH`
<FromGitter> <ImAHopelessDev_gitlab> i swear, kai leahy knows everything
<FromGitter> <tenebrousedge> I'd have to disagree on that. Especially compared to the core devs
<FromGitter> <dburnsii> I'll give it a try and let you know what I come up with
<FromGitter> <ImAHopelessDev_gitlab> @tenebrousedge i mean it is a compliment, you are always helping
<FromGitter> <tenebrousedge> I appreciate the compliment; this particular issue is actually straying outside of my knowledge somehwat
<FromGitter> <tenebrousedge> @dburnsii there are other more knowledgeable persons here if you are having further issues
<FromGitter> <dburnsii> I will say, getting a solid way of using crystal in Yocto will definitely bring the language closer to being used more widely. A compiled language like Crystal is a great tool for an embedded distribution of Linux, especially with all the tools that are already available
<FromGitter> <absolutejam_gitlab> are you looking to statically compile @dburnsii ?
<FromGitter> <dburnsii> @absolutejam_gitlab To compile statically would also be great, but at the least I need to compile without using any of the libraries available on my machine. Yocto makes a point to import everything on it's own and put it in specific folders for the compiler to access
<FromGitter> <absolutejam_gitlab> One thing I found useful when compiling on macOS was to dump the link command that is generated and just override parts
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9ceb65940b4c2fc09ab41f]
<FromGitter> <bew> @repromancer_gitlab could work directly if you use a class instead of a struct (the `record` macro generates a struct)
<FromGitter> <absolutejam_gitlab> I have that in a build script because I had to force it to not use the system libs and only use the libs I had stored locally
<FromGitter> <tenebrousedge> @bew but wouldn't a struct be more appropriate here?
<FromGitter> <absolutejam_gitlab> and that was originally generated by adding `--cross-compile --target "x86_64-macosx-darwin"` to `crystal build`
<FromGitter> <absolutejam_gitlab> I'm not saying that command will help, but the `-L` was a key part
<FromGitter> <absolutejam_gitlab> `LD_LIBRARY_PATH` just wouldn't work for me
<FromGitter> <tenebrousedge> how were you using `LD_LIBRARY_PATH` ?
<FromGitter> <absolutejam_gitlab> was a while ago, I don't remember
<FromGitter> <absolutejam_gitlab> lot of frustratiom
<FromGitter> <tenebrousedge> hmm
<FromGitter> <absolutejam_gitlab> I really need to find a reason to write Crystal again
<FromGitter> <absolutejam_gitlab> unfortunately the move to Go has left me missing it
<FromGitter> <tenebrousedge> writing in Go would give me a sad :(
<FromGitter> <ImAHopelessDev_gitlab> Why did you move to Go? Switch that around, and then use that reason, to write stuff in Crystal
<FromGitter> <absolutejam_gitlab> Kubernetes and Docker libs mostly
<FromGitter> <absolutejam_gitlab> spent a bit too long yak-shaving with Crystal and needed to be productive
<FromGitter> <repromancer_gitlab> @bew That's interesting; I'll have to play around and see how that works.
<FromGitter> <absolutejam_gitlab> could look at writing my new side project in Amber
<FromGitter> <absolutejam_gitlab> but I'm trying to balance value and fun
<FromGitter> <Blacksmoke16> what ya making
<FromGitter> <absolutejam_gitlab> D&D 5e campaign helper
<FromGitter> <tenebrousedge> oh fun
<FromGitter> <absolutejam_gitlab> not sure if sarcasm, haha
<FromGitter> <Blacksmoke16> *nerd* :P
<FromGitter> <tenebrousedge> that should be fine to do in Crystal. What would the alternative be?
<FromGitter> <kinxer> @absolutejam_gitlab What kinds of features are you thinking of implementing?
<FromGitter> <absolutejam_gitlab> Laravel, purely because that's the stack I support at work
<FromGitter> <absolutejam_gitlab> or Phoenix because I like Phoenix & Elixir and the package ecosystem is a bit bigger at the moment
<FromGitter> <tenebrousedge> Laravel isn't bad, but I did have a full-body shudder at the idea of voluntarily working with PHP
<FromGitter> <absolutejam_gitlab> Yeah, Laravel itself is quite nice
<FromGitter> <absolutejam_gitlab> and the ability to familiarize myself a bit more would be nice
<FromGitter> <absolutejam_gitlab> plus there's a great GraphQL library
<FromGitter> <tenebrousedge> you'd use GraphQL?
<FromGitter> <absolutejam_gitlab> but PHP itself is the thing making me reconsider
<FromGitter> <ImAHopelessDev_gitlab> "full-body shudder" LOOOOOOL
<FromGitter> <absolutejam_gitlab> Yeah, I've kinda been designing it around GraphQL and Vuejs and a lot of the models would work well that way
<FromGitter> <tenebrousedge> huh
<FromGitter> <tenebrousedge> I would think that a document-oriented database would be a better fit
<FromGitter> <absolutejam_gitlab> @kinxer initially stuff for DMs; tracking locations, campaigns, NPCs, etc.
<FromGitter> <kinxer> So sort of organizational tools?
<FromGitter> <absolutejam_gitlab> then I'd like to move it into a companion for players too - Not really for use in-game because that's not what D&D is about, but just a companion for tracking progression, etc.
<FromGitter> <absolutejam_gitlab> yeah pretty much
<FromGitter> <absolutejam_gitlab> or DM to player tools as well
<FromGitter> <ImAHopelessDev_gitlab> that sounds cool
<FromGitter> <tenebrousedge> you've checked out the available 5e Discord plugins?
<FromGitter> <absolutejam_gitlab> I haven't actually
<FromGitter> <absolutejam_gitlab> A document DB could work for parts but I've honestly never worked with one
<FromGitter> <absolutejam_gitlab> and I think there'd be a lot of relational aspects
<FromGitter> <absolutejam_gitlab> and <3 postgres
<FromGitter> <tenebrousedge> you can embed documents in other documents
<FromGitter> <absolutejam_gitlab> do you have to denormalize though?
ht__ has quit [Quit: ht__]
<FromGitter> <tenebrousedge> to some degree, yes. But what are your queries going to be like? GraphQL seems...the best use for that that I've heard of yet is a company that optimized other company's supply chains
<FromGitter> <tenebrousedge> where each node was a city, with various routes between them
<FromGitter> <tenebrousedge> I'm not seeing how that sort of thing would translate to a D&D campaign
<FromGitter> <absolutejam_gitlab> and the GraphQL choice was also born of 'ooh shiney' and a possible move to using it at work. But I really like the paradigm
<FromGitter> <absolutejam_gitlab> well some of the models would be horizontally linked or vertically nested
<FromGitter> <dburnsii> As an update, I tried a few things and I'm thinking it's a matter of making sure both the libgc.a and libcrystal.a are accessible, and that gcc can find all the libraries it needs. Thank you guys for your help with this, hopefully I don't run into any more issues
<FromGitter> <absolutejam_gitlab> like locations within locations or adjacent locations
<FromGitter> <absolutejam_gitlab> etc.
<FromGitter> <absolutejam_gitlab> the kind of arbitrary linking you'd find in a wiki
<FromGitter> <ilanpillemer> I can't imagine using any computer at all for D&D. That's a game with dice, pens paper and loads of snacks.
<FromGitter> <ilanpillemer> It's like the opposite of a computer thing.
<FromGitter> <tenebrousedge> @dburnsii 👍
<FromGitter> <tenebrousedge> @absolutejam_gitlab the more complex your data model gets, the more of a pain it will be to query it
<FromGitter> <tenebrousedge> be careful
<FromGitter> <absolutejam_gitlab> it's specifically not for the game
<FromGitter> <ImAHopelessDev_gitlab> i used to play pokemon card games at wizards of the coast (tournaments), i could never play the gameboy version
<FromGitter> <absolutejam_gitlab> mostly world-building and some out of game tracking
<FromGitter> <absolutejam_gitlab> a big focus around making notes and stuff for DMs
<FromGitter> <absolutejam_gitlab> at the moment I keep getting swamped down in work projects though, so it keeps getting put off and rethought
<FromGitter> <absolutejam_gitlab> Yeah, thanks for the pointer @tenebrousedge
<FromGitter> <ilanpillemer> I havnt played D&D since 1991
<FromGitter> <tenebrousedge> oh dang. It's worlds different
ma_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <ilanpillemer> they brought monks back after getting of them for 2nd Edition?
<FromGitter> <tenebrousedge> yep, that was in 3rd edition
<FromGitter> <ilanpillemer> havent played since 2nd edition
<FromGitter> <ilanpillemer> played 1st and 2nd though
<FromGitter> <tenebrousedge> I played 2nd ed briefly, but 3rd ed was released in 2000, so it's pretty old by now
<FromGitter> <ilanpillemer> I see this also works
<FromGitter> <ilanpillemer> ```self.left = nil if left.not_nil!.value == v```
<FromGitter> <ilanpillemer> when should you use `try` and when `not_nil!`?
<FromGitter> <tenebrousedge> if `nil` is passed to `not_nil!` it raises an exception
<FromGitter> <tenebrousedge> so you should only use that if you want an exception to be raised if the value is ever `nil`
<FromGitter> <ilanpillemer> so its an assertion.
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> that makes sense.
<FromGitter> <absolutejam_gitlab> I've used it in places that I *know* `left` will not be nil as a way to satisfy the compiler
<FromGitter> <absolutejam_gitlab> as a guard clause
<FromGitter> <absolutejam_gitlab> probably not a good idea, but I had already validated it in a pre-validation step
<FromGitter> <ilanpillemer> why not `try`?
<FromGitter> <absolutejam_gitlab> was some early code but IIRC, I didn't like the semantics of try at the time
<FromGitter> <absolutejam_gitlab> I'd probably reconsider as it seems like the best option
dwdv_ has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> trying to find some actual examples as to why/where I used it now haha
<FromGitter> <absolutejam_gitlab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9cfdb13220922ffb50f1bf]
<FromGitter> <ilanpillemer> actually makes sense to panic if a token is missing
<FromGitter> <ilanpillemer> not sure you should panic if your print conflig flag is borked
<FromGitter> <absolutejam_gitlab> in the top example, I had a function that validated the flags before the main function ran
<FromGitter> <absolutejam_gitlab> so it couldn't get to the main function (in theory) without that passing
dwdv has quit [Ping timeout: 240 seconds]
<FromGitter> <absolutejam_gitlab> The alternative was guard clauses I guess
<FromGitter> <absolutejam_gitlab> but it seemed like needless guard clauses just to satisfy the compiler
<FromGitter> <ilanpillemer> does deletion in a binary tree require storing reverse links to parents?
ma_ has joined #crystal-lang
<FromGitter> <absolutejam_gitlab> That may be the completely wrong mindset
ma_ has quit [Client Quit]
ma_ has joined #crystal-lang
ma_ has quit [Client Quit]
<FromGitter> <kinxer> @ilanpillemer I don't think so, as long as you keep a local reference to the parent in the deletion function.
<FromGitter> <tenebrousedge> I don't think that's required either
<FromGitter> <ilanpillemer> let me try with that idea @kinker
absolutejam4 has quit [Ping timeout: 246 seconds]
<FromGitter> <tenebrousedge> the algo I read was, find the node and the rightmost node, replace the node's value with the rightmost, delete the rightmost
<FromGitter> <ilanpillemer> I am trying the T. Hibbard one
<FromGitter> <kinxer> @tenebrousedge That makes sense. It recurses properly if the right child has children?
<FromGitter> <ilanpillemer> I don’t think it guarantees a balanced tree
<FromGitter> <tenebrousedge> hmm, you're right @ilanpillemer
<FromGitter> <kinxer> From that link: `This different from BST deletion.`
<FromGitter> <tenebrousedge> right
<FromGitter> <ilanpillemer> the example also didnt return an ordered tree
blassin7 has quit [Quit: The Lounge - https://thelounge.chat]
blassin has joined #crystal-lang
<FromGitter> <tenebrousedge> @ilanpillemer success yet?
<FromGitter> <ilanpillemer> some progress… dealing with the two children part
<FromGitter> <tenebrousedge> I have a solution that passes, I'm not sure I like it. A few too many `not_nil!`s
<FromGitter> <ilanpillemer> including the iteratable section?
<FromGitter> <tenebrousedge> oh yes, that. Obnoxious in that it makes `each` return values and not nodes, but yes
<FromGitter> <ilanpillemer> I am about to finish the delete tests.. just need to get the root working
<FromGitter> <tenebrousedge> I needed to include a `parent` property
<FromGitter> <ilanpillemer> the just passed the parent as a reference
<FromGitter> <ilanpillemer> let me finish the root and I will show you. But its still needs tidying
alex`` has joined #crystal-lang
<alex``> someone here? :p
<FromGitter> <tenebrousedge> no
<alex``> x)
ma_ has joined #crystal-lang
dwdv_ has quit [Ping timeout: 240 seconds]
<FromGitter> <ilanpillemer> ok. I have the BST working.. but not the iterable section.
<FromGitter> <ilanpillemer> should I publish, even though I still need to do that?
<FromGitter> <ilanpillemer> as I am going to leave that for tomorrow evening
<FromGitter> <tenebrousedge> you can, if you want. No one will stop you :P
<FromGitter> <ilanpillemer> just feels wrong
<FromGitter> <tenebrousedge> you could also just stick it in a gist or pastebin
<FromGitter> <ilanpillemer> no will stop me running around outside dressed like a chicken and squawking as well.
<FromGitter> <ilanpillemer> but I probably shoudnt do that
<alex``> it's more a general question than crystal question, I would like to know a good name for `copy(parameter)`
<FromGitter> <tenebrousedge> like `to_clipboard(element)` ?
<alex``> I have mapped: y -> copy link url, Y -> copy link text and alt-y -> copy [text](url) of a set of selections (elements) or active element if none
<alex``> I hesitate between `copy(callback)` and `copy(map)`
<alex``> callback or map
<FromGitter> <tenebrousedge> `callback` preferably
<alex``> or a better suggestion
<alex``> if you have a good name
<FromGitter> <tenebrousedge> @ilanpillemer if you give it a .cr ending it will do that syntax highlighting thing, I think
<alex``> tenebrousedge why callback is preferably than map? (I'm not native english)
<FromGitter> <ilanpillemer> it did
<FromGitter> <Blacksmoke16> @bew `setter` defines an ivar, so you can just do `setter some_value : TheType`
<FromGitter> <tenebrousedge> `map` is used for other things, `callback` isn't
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9d1cbb92920c36a13691ae]
<FromGitter> <ilanpillemer> I dont use syntax highlighting anyway.. so I dont notice.
ma_ has quit [Ping timeout: 245 seconds]
<FromGitter> <tenebrousedge> @ilanpillemer I prefer using the spaceship operator for a lot of these things
<FromGitter> <ilanpillemer> what’s that?
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9d1d26b385bf2cc69a043d]
<FromGitter> <tenebrousedge> it returns `1` for greater-than, `-1` for less-than and `0` for equality
<FromGitter> <ilanpillemer> does it turn greater than, less than and equal into values?
<FromGitter> <tenebrousedge> I would also declare: `property left, right : Node?`
<FromGitter> <tenebrousedge> keeps the initializer signature from getting too long
<FromGitter> <ilanpillemer> gotcha.
<FromGitter> <tenebrousedge> `def replace(orig : Node?, replacement : Node?)`
<FromGitter> <ilanpillemer> that is tidier than `Node | Nil`
<FromGitter> <tenebrousedge> I see, passing the reference in `delete`
<FromGitter> <tenebrousedge> I'll have to think about that
<FromGitter> <ilanpillemer> trying to understand the iterable
<FromGitter> <tenebrousedge> it just needs `each` to be defined
<FromGitter> <ilanpillemer> and it mustn’t yield
<FromGitter> <tenebrousedge> I just did `traverse.each.map(&.value)`
<FromGitter> <ilanpillemer> what does that return?
<FromGitter> <tenebrousedge> `traverse` gets an array, `each` returns an iterator, `map` is lazily applied
<FromGitter> <tenebrousedge> I think
<FromGitter> <ilanpillemer> it doesnt work for me
<FromGitter> <ilanpillemer> how do you map something to itself so its applied lazily?
<FromGitter> <tenebrousedge> you need two `each` methods
<FromGitter> <ilanpillemer> each.each?
<FromGitter> <tenebrousedge> one with and one without a block
<FromGitter> <ilanpillemer> I have that
<FromGitter> <tenebrousedge> not in your gist
<FromGitter> <ilanpillemer> no not there
<FromGitter> <ilanpillemer> ``` def each ⏎ traverse.each.map { |v| v } ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5d9d1fd0eac5612d22dbf675]
<FromGitter> <ilanpillemer> this works
<FromGitter> <ilanpillemer> but I suspect there is something better
<FromGitter> <tenebrousedge> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9d1ff097358746731d97e9]
<FromGitter> <ilanpillemer> yes.. but your array is different
<FromGitter> <ilanpillemer> woot!
<FromGitter> <ilanpillemer> I have finished the BST
<FromGitter> <tenebrousedge> you're using `value`, so you can skip that bit
<FromGitter> <tenebrousedge> I think `traverse` should return `Array(Node)`
<FromGitter> <tenebrousedge> but it's six of one, half dozen of the other
<FromGitter> <ilanpillemer> that was fun.
<FromGitter> <tenebrousedge> `search` seems like it wants a spaceship
<FromGitter> <tenebrousedge> .o0O0o..o0O0o..o0O0o.`<=>`
<FromGitter> <ilanpillemer> updated to use a spaceship!
<FromGitter> <ilanpillemer> see how I just passed the parent as a reference?
<FromGitter> <tenebrousedge> yes
<FromGitter> <ilanpillemer> that was @kinxer ’s idea
<FromGitter> <tenebrousedge> I'm debating how I like it
<FromGitter> <tenebrousedge> it's necessarily recursive
<FromGitter> <ilanpillemer> like a binary tree