jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.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
DTZUZO has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
beepdog has quit [Ping timeout: 248 seconds]
dkowis is now known as beepdog
olbat[m] has quit [Ping timeout: 264 seconds]
<FromGitter> <watzon> Finished, just waiting for Hackernoon to review https://medium.com/@watzon/doing-crystal-1-dc441aabb791
<FromGitter> <Blacksmoke16> so i finished up a new feature, want to get some feedback
<FromGitter> <Blacksmoke16> check this out
<FromGitter> <Blacksmoke16> I implemented a DI service container
<FromGitter> <Blacksmoke16> *SO* what that means is there is not an easy way to share objects throughout a project
<FromGitter> <Blacksmoke16> for example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cd7792856271260f947e0ff]
<FromGitter> <Blacksmoke16> first can define a service by adding an annotation to a class/struct and inheriting from the proper parent
<FromGitter> <Blacksmoke16> then, anywhere you want access to this object, you would add ⏎ ⏎ ``` include Athena::DI::Injectable ⏎ ⏎ def initialize(@store : Store); end``` [https://gitter.im/crystal-lang/crystal?at=5cd779680824230a771cfb81]
<FromGitter> <Blacksmoke16> to whatever class you're in
<FromGitter> <Blacksmoke16> since you have access to the same object pretty much anywhere, you could inject the store into a HTTP handler to generate a requetID for a http request and set it on the object, then inject the store into some logger class to set that id on log that happen from that http request, or inject into a controller to add it to response headers
<FromGitter> <Blacksmoke16> are also some other things you can do but thats the general idea
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cd77b070f381d0a769edd20]
<FromGitter> <Blacksmoke16> can also register multiple services based on the same class
olbat[m] has joined #crystal-lang
Raimondi has quit [*.net *.split]
mps has quit [*.net *.split]
<FromGitter> <Blacksmoke16> as well as add tags to services and then get an array of services that have that tag. This would be useful for a param conversion type deal. i.e. have endpoint like `GET /syndication/partner/{partner_id}/feed`, define a custom param converter, get services tagged `feed_partner`, find the one that has that ID or throw an exception, then pass that obj into the controller
<FromGitter> <Blacksmoke16> adding new partners would just be adding another register annotation to that clas
<FromGitter> <watzon> Wait, did I miss Crystal adding decorators?
<FromGitter> <Blacksmoke16> Been around for a little while
<FromGitter> <Blacksmoke16> I can give you some links if you would like
<FromGitter> <watzon> Added sometime in the last 6 months?
<FromGitter> <watzon> I would love some haha
<FromGitter> <Blacksmoke16> about a year ago
<FromGitter> <Blacksmoke16> are one of the least documented features atm tho
<FromGitter> <Blacksmoke16> is more readable at least
<FromGitter> <watzon> That's pretty awesome. Could be very helpful for making classes JSON serializable.
<FromGitter> <watzon> Annotations would look much better than `JSON.mapping`
<FromGitter> <Blacksmoke16> the std lib's `JSON::Serializable` already uses them
<FromGitter> <watzon> It does??? :D
<FromGitter> <watzon> Omg how did I not know this
<FromGitter> <watzon> Gone for 6 months and the whole world changes
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer/tree/master/docs#example-usage also made a shard built on top of it with more features
<FromGitter> <Blacksmoke16> and annotation based validations
<FromGitter> <Blacksmoke16> that happen on deserialization
<FromGitter> <watzon> Crystal was already my favorite, but this just made it 100x better
<FromGitter> <Blacksmoke16> wouldn't happen to be wanting to make a JSON api would you? :P
<FromGitter> <watzon> But I don't know that the serializer would help me here. It would take a lot longer in this case.
<FromGitter> <Blacksmoke16> Was going to say, if so check out Athena. Annotation based API oriented framework
<FromGitter> <Blacksmoke16> Has some cool stuff
beepdog has quit [Quit: lol]
beepdog has joined #crystal-lang
<FromGitter> <watzon> I'll have to take a look
<FromGitter> <watzon> Hehe some wishful thinking here https://github.com/watzon/octokit.cr/blob/master/src/octokit/client/users.cr#L57
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Blacksmoke16> Good luck
<FromGitter> <watzon> Thanks :) starred for later
<FromGitter> <Blacksmoke16> 👍
mps has joined #crystal-lang
Raimondi has joined #crystal-lang
DTZUZU has quit [Ping timeout: 255 seconds]
DTZUZU has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang
dkowis has joined #crystal-lang
alexherbo2 has quit [Client Quit]
_whitelogger has joined #crystal-lang
faitswulff has joined #crystal-lang
<FromGitter> <watzon> ```code paste, see link``` ⏎ ⏎ Any help here? Apparently `JSON.mapping` can't accept `{all: Bool, participating: Bool, since: String, before: String}.merge(ListOptions::FIELDS)` because it's a Call? [https://gitter.im/crystal-lang/crystal?at=5cd7b2215a887e1cd9d2f4b6]
faitswulff has quit []
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
tdc has joined #crystal-lang
_whitelogger has joined #crystal-lang
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection timed out]
alexherbo2 has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
DTZUZO has joined #crystal-lang
waheedi has joined #crystal-lang
<FromGitter> <asterite> mapping is a compile time thing, but merge is a runtime thing
<FromGitter> <watzon> Ahh I see. So not possible then?
<FromGitter> <asterite> You can try to merge them at compile time, I don't know if that's possible
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
bars0 has joined #crystal-lang
bars0 has quit [Ping timeout: 244 seconds]
lucasb has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> @watzon the serializable stuff allows for inheritance, so that would allow you to share Fields
sz0 has joined #crystal-lang
<FromGitter> <Blacksmoke16> Or put them in a module and include it
dkowis has quit [Quit: lol]
tdc has quit [Ping timeout: 246 seconds]
<FromGitter> <pynixwang> does crystal hash function prevent hash flooding?
<Yxhuvud> What do you mean by hash flooding?
return0e has quit [Remote host closed the connection]
<FromGitter> <pynixwang> all keys on a bucket
<FromGitter> <pynixwang> all hash_function(key) is equal
<FromGitter> <pynixwang> hash become a link list
<FromGitter> <tenebrousedge> I would not expect Crystal's hash functions to be crytographically secure
<FromGitter> <tenebrousedge> definitely not `Object#hash` https://crystal-lang.org/api/0.28.0/Object.html#hash-instance-method
<Yxhuvud> tenebrousedge: Uh, that implementation just forwards it to Crystal::Hasher. (which lacks documentation, which is a bit sad(
<FromGitter> <tenebrousedge> @pynixwang from that page: (but it is certainly not cryptographic: I think attack with choosen plaintext and known hashsum will succeed with little effort)
<FromGitter> <pynixwang> SipHash is slow
<FromGitter> <pynixwang> rust也用了Sip
<FromGitter> <pynixwang> rust use sip
return0e has joined #crystal-lang
<FromGitter> <vladfaust> @https://forum.crystal-lang.org/t/how-to-easily-get-consistent-object-hash/314/16?u=vladfaust siphash is the fastest alternative to built-in hashing
<olbat> hello #crystal-lang :)
<FromGitter> <Blacksmoke16> o/
<FromGitter> <tenebrousedge> 🎵 ain't nobody here but us check-ins 🎵
<olbat> I'm working on a fix for https://github.com/olbat/libgen/issues/33, I made few tests and got this issue: https://pastebin.com/BWWJWK8D. I'm not sure if it's a packaging or compiler issue (and how to fix that), does anybody have an idea?
<FromGitter> <j8r> How can we use namedtuple with heredocs?
<FromGitter> <Blacksmoke16> assign it to a var first?
<FromGitter> <j8r> that's ugly
<FromGitter> <j8r> and unpractical, no better way?
<FromGitter> <tenebrousedge> @olbat it seems to be missing the VERSION file
<FromGitter> <tenebrousedge> copying that produces `crystal eval 'require "compiler/crystal/**"; print Config.default_target' ⏎ Error in line 1: undefined constant Config`
<FromGitter> <Blacksmoke16> not that i can think of
<olbat> Yup I saw that but relative to Crystal's install path on my system (Archlinux) this file would be located at /usr/lib/VERSION which does not seems right :)
<FromGitter> <tenebrousedge> @olbat I'm pretty sure it would be looking for it in `/usr/lib/crystal/VERSION`
<olbat> @tenebrousedge Oops, I guess I should call Crystal::Config.default_target
<olbat> readlink -f /usr/lib/crystal/compiler/crystal/../../../VERSION -> /usr/lib/VERSION
<FromGitter> <tenebrousedge> it still seems to find it under `/usr/lib/crystal/VERSION`
moei has joined #crystal-lang
bars0 has joined #crystal-lang
<olbat> I don't have any VERSION file in the /usr/lib/crystal directory, I only have the content of the src/ directory of git repo there
<olbat> not sure I explained it properly, this is what I meat: https://pastebin.com/C0HM1hKF :)
<olbat> (I installed Crystal from the official arch distrib)
bars0 has quit [Ping timeout: 246 seconds]
<FromGitter> <tenebrousedge> you may want to file a bug with the maintainers, then. The file is present in the source repository. In the meantime, you have the contents of the file available, and you can work around this error.
<olbat> Ok that makes sense :) Do you know if the core team is maintaining this specific package?
<FromGitter> <tenebrousedge> I do not
<olbat> Ok I'm going to check, thank you for your help and for your time! :)
<FromGitter> <tenebrousedge> yvw
<olbat> Erm, I tried to do the same test on Debian as well as with the official Docker image (which is Ubuntu based) and got the same issue... Either the DEB packaging is affected by this issue as well or there is something wrong with my test...
<FromGitter> <tenebrousedge> one or the other, for sure
sz0 has quit [Quit: Connection closed for inactivity]
<olbat> I tried to manually create the file but now I'm running into this issue: https://pastebin.com/TBvnrVZa... Still not sure this new problem is not also packaging-related :s
<FromGitter> <tenebrousedge> @olbat ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cd869435a1d435d462db36a]
<FromGitter> <valamorgon> can I access current index in each.do ||
<FromGitter> <valamorgon> .each do ||
<FromGitter> <tenebrousedge> @olbat the `require "llvm"` bit is not necessary, it seems
<FromGitter> <tenebrousedge> @valamorgon you probably want `each_with_index`, or probably something like `map_with_index`
<FromGitter> <Blacksmoke16> ^
<FromGitter> <Blacksmoke16> would be like `arr.each_with_index do |item, index|`
<FromGitter> <valamorgon> thanks @tenebrousedge and @Blacksmoke16 thats what I need
<FromGitter> <Blacksmoke16> np
<olbat> @tenebrousedge I've tested it on both Debian and Arch (with my version of LLVM ofc), I'm still running into the same compilation issue
<FromGitter> <tenebrousedge> try 4.0
<FromGitter> <kingsleyh> I’ve revamped my website - it’s got a big link to Crystal on it now https://sushichain.io
<olbat> LLVM4 is not available in my distro
<olbat> + Crystal is distributed with a "vendorized" LLVM6 right?
<FromGitter> <tenebrousedge> @kingsleyh neat. Why "SushiChain" ?
<FromGitter> <kingsleyh> Just because I Love Sushi :) and it’s a memorable name
<FromGitter> <tenebrousedge> @olbat LLVM4 works on Debian/Ubuntu. There are a fair number of open LLVM-related issues, I think
<FromGitter> <tenebrousedge> @kingsleyh that sounds like the best reason :) or at least the most delicious
<FromGitter> <kingsleyh> Hehe yeah and at expos around lunchtime people subconsciously drift over to my stand
<olbat> Well, sadly, not in recent versions of Debian/Ubuntu. I'm going to check the issues board to see if I can find something there :)
<FromGitter> <tenebrousedge> @olbat I'm running 18.04
<livcd> did you guys see some of the new rubykaigi videos?
waheedi has quit [Quit: waheedi]
<FromGitter> <mwlang> when writing Ruby gems, it's a best practice to include as first line of all source files the following: ```# encoding: utf-8``` Is this also a convention or practice with Cyrstal?
<FromGitter> <Blacksmoke16> i havent seen it so prob not
<FromGitter> <tenebrousedge> I don't think magic comments exist in Crystal ?
alexherbo28 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 244 seconds]
<FromGitter> <Blacksmoke16> kinda but not like that
<FromGitter> <Blacksmoke16> are some special things in comments, but they are mostly used for the docs command
<FromGitter> <Blacksmoke16> like `:nodoc:`
<FromGitter> <mwlang> ok, good to know. This on in Ruby controls the system-level encoding of strings, which primarily affects default encoding of strings read from file or IO objects.
<FromGitter> <Blacksmoke16> all strings in crystal are utf8 anyway
<Yxhuvud> mwlang: it used to be a best practice in ruby for a couple of versions, but then they changed the default to utf8 and made it redundant.
alexherbo285 has joined #crystal-lang
alexherbo28 has quit [Read error: Connection reset by peer]
<FromGitter> <r00ster91> is this anyhow possible? https://carc.in/#/r/6wly
<FromGitter> <Blacksmoke16> prob not when using a struct
<FromGitter> <r00ster91> aww I really don't want to use a class
<FromGitter> <Blacksmoke16> yea dunno, i dont have any ideas at least
<FromGitter> <tenebrousedge> definitely possible https://carc.in/#/r/6wmg
<FromGitter> <Blacksmoke16> but its still 2?
<FromGitter> <tenebrousedge> D:
<FromGitter> <r00ster91> still 1*
<FromGitter> <Blacksmoke16> yea my bad
<FromGitter> <tenebrousedge> ...
<FromGitter> <tenebrousedge> *pokes it*
<FromGitter> <r00ster91> what I want to do is I want to have special properties for an array inside of an array (two-dimensional) but I don't want to have that directly in the array with the other things because then I would iterate over it too and that would require something to make that not happen which will cost some speed. I already tried storing it out of bounds which worked somewhat but that also lead to a corrupted
<FromGitter> ... instruction once so it really is unsafe. Now I maybe just add these properties to `Array` directly instead of a struct with the properties and the array seperated
<FromGitter> <tenebrousedge> apparently this is possible https://carc.in/#/r/6wmp
<FromGitter> <r00ster91> That's because in that example you access the array and thats a class, not a struct like a number https://carc.in/#/r/6wmu
<FromGitter> <tenebrousedge> class v struct doesn't seem to matter: https://carc.in/#/r/6wn0
<FromGitter> <tenebrousedge> the `=` method is what's not working
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cd88de256271260f94f08e5]
<FromGitter> <Blacksmoke16> simple example of the DI working on sharing an object between two classes and top level
<FromGitter> <Blacksmoke16> pretty neat
waheedi has joined #crystal-lang
<FromGitter> <tenebrousedge> 👍
<FromGitter> <Blacksmoke16> now for the fun part of writing docs for all this :P
moei has quit [Quit: Leaving...]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang