RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.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
<travis-ci> crystal-lang/crystal#34b1101 (master - Add highlight to code tag in generated API docs (#5795)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/351549429
<DeBot> https://github.com/crystal-lang/crystal/pull/5795 (Add highlight to code tag in generated API docs)
That_Guy_Anon has joined #crystal-lang
<That_Guy_Anon> i installed crystal but when compiling i get the error "/usr/bin/ld: cannot find -levent"
<That_Guy_Anon> i know that i had to rename some library (or rather create a copy under a different name), but I cant recall wich eventlibrary it expects.
snsei has joined #crystal-lang
<RX14> That_Guy_Anon, you need to install libevent2-dev
<RX14> or whatever weird naming scheme your package manager uses
<That_Guy_Anon> yeah, that was it. and it was libevent-devel :P
<RX14> or libevent if you're on arch
<RX14> or libevent2-dev if you're on rhel
<RX14> it's insane
<FromGitter> <watzon> I'm having issues
<RX14> no not really I don't
<FromGitter> <watzon> Damn I was afraid of that haha
<That_Guy_Anon> consistent naming is overrated ^^
<RX14> with your scale of data you really really want to embed a binary representation of the data in the executable
<RX14> and then parse it
<RX14> or just parse it from a file
<RX14> either way using autogenerated literals for this is madness
<FromGitter> <watzon> I was just trying to port a library from Ruby, but yeah...
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <watzon> There is a library that does it by loading a series of YAML files as well
<RX14> well thats usually a bad start
<FromGitter> <watzon> Yeah probably. I can't really think of a better way to do it though. And I don't have the time or patience to create all those mappings myself
balduin has joined #crystal-lang
<FromGitter> <watzon> Where's the repo with needed shards again>
<That_Guy_Anon> aww.....i even opened my browser for this
<FromGitter> <watzon> Lol thanks anyway That_Guy_Anon
<FromGitter> <watzon> Thanks RX14
<FromGitter> <watzon> Oh and thanks @veelenga for promoting my post https://crystal-ann.com/announcements/158
<travis-ci> crystal-lang/crystal#112b02b (ci/use-build-images - Use crystallang/crystal-*-build docker images in ci): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/351571039
<travis-ci> crystal-lang/crystal#c4b5a8d (ci/use-build-images - Update previous crystal to 0.24.2): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/351576836
<FromGitter> <watzon> What would be the Crystal equivalent of `String.unpack("S*")`? I understand `unpack("C*")`, but I don't know how it can turn those 8 bit integers into 16, 32, and 64 bit integers
<FromGitter> <watzon> Thanks @bew. You always know where to look haha
qard has joined #crystal-lang
qard has quit [Quit: qard]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
qard has joined #crystal-lang
qard has quit [Remote host closed the connection]
qard has joined #crystal-lang
<crystal-gh> [crystal] bcardiff opened pull request #5796: Update previous crystal release & docker images for ci to 0.24.2 (master...ci/use-build-images) https://git.io/vAhxk
<balduin> I have the following code: https://paste.debian.net/1014058
snsei has joined #crystal-lang
<balduin> However, the code does not work, because I can't figure out the type for the iterator. LineIterator seems to be a private class.
hightower2 has joined #crystal-lang
<balduin> Initializing the @iterator variable using Nil does not work either.
<balduin> How can I initialize @iterator?
<FromGitter> <bew> maybe `@iterator : Iterator(String)` is enough?
hightower3 has quit [Ping timeout: 260 seconds]
<balduin> @bew thanks, that worked. You made my day :-)
<FromGitter> <bew> cool ;)
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <bew> Also @balduin I suggest you to not tie the knowledge of a File in your reader, but rather receive an IO object which is much more generic. And this way you can use any kind of IO (a File, a IO::Memory, etc...)
<FromGitter> <bew> And creating your Reader2 would look like: `Reader2.new File.new("the_file_to_read")`
<balduin> @bew thank you.
<FromGitter> <bew> you're welcome :)
<balduin> If I use `typeof(@iterator.next())` I get back: (Iterator::Stop | String). My question is how can specifically ask if I reached ´Iterator::Stop´? I want to do something like ´if @iterator.next() is Iterator::Stop then do something´?
<FromGitter> <bew> Did you read the language reference? It is documented in https://crystal-lang.org/docs/syntax_and_semantics/if_varis_a.html
<balduin> @bew yes I looked around, but thought the function is called either typeof or isinstance or instanceof. In short I looked for the wrong keywords.
<FromGitter> <bew> `typeof` will give you the compile time type of something, and `.is_a?` will allow condition on the actual type of a var at runtime (at runtime, a var can be only one of the types returned by typeof)
<balduin> @bew thank you for your explanation. Very helpful.
That_Guy_Anon1 has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 252 seconds]
<balduin> Are there any good frameworks for test- or behaviour driven development in Crystal?
<balduin> Are there any ORM mapping libraries for Crystal?
<FromGitter> <bew> you can look for shards at http://crystalshards.xyz/
<balduin> @bew sure, but shards does not tell me your preference.
andrewzah has quit [Quit: ""]
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
andrewzah has joined #crystal-lang
andrewzah has quit [Client Quit]
andrewzah has joined #crystal-lang
<FromGitter> <Blacksmoke16> o/
snsei has joined #crystal-lang
<FromGitter> <Blacksmoke16> here's a question, say i have a YAML file i want to parse into objects using YAML.mapping with the YAML structure like Array( itemID: Int32, itemName: String), i.e. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa369ede4ff28713a156d52]
<FromGitter> <Blacksmoke16> But im having some trouble figuring out how to setup the mapping
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <bararchy> @bew yeha what that guy said :)
<FromGitter> <bew> @Blacksmoke16 maybe try: `Array({itemID: Int32, itemName: String}).from_yaml(your_file_object)`
<FromGitter> <Blacksmoke16> `Array({itemID: Int32, itemName: String}).from_yaml(File.read(SDE + "/bsd/invNames.yaml"))`
<FromGitter> <bew> Or if you want a specific object in the array, create a class, with a mapping for the itemID & itemName, and do `Array(YourClass).from_yaml ...`
<FromGitter> <Blacksmoke16> thats what i had
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa36ea635dd17022e4143ec]
<FromGitter> <bew> And it's better to use `File.new` instead of `File.read`, as the latter will create a string first, and the former will directly read from the file
<FromGitter> <Blacksmoke16> rgr
<FromGitter> <bew> Can you show your code?
<FromGitter> <bew> The mapping and the from_json
<FromGitter> <Blacksmoke16> `Array({itemID: Int32, itemName: String}).from_yaml(File.new(SDE + "/bsd/invNames.yaml"))`
<FromGitter> <Blacksmoke16> where invNames.yaml is setup as in my first pic
<FromGitter> <Blacksmoke16> also tried
<FromGitter> <Blacksmoke16> ``` YAML.mapping( ⏎ itemID: Int32, ⏎ itemName: String ⏎ ) ⏎ end`````` [https://gitter.im/crystal-lang/crystal?at=5aa36f9435dd17022e414661]
<FromGitter> <Blacksmoke16> and then `yaml = Array(NameFile).from_yaml(File.new(SDE + "/bsd/invNames.yaml"))`
<FromGitter> <bew> well, it works for me https://carc.in/#/r/3p15
<FromGitter> <Blacksmoke16> :thnking:
<FromGitter> <bew> and using a class with mapping https://carc.in/#/r/3p16
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> moment
<FromGitter> <Blacksmoke16> strange, still get that error
<FromGitter> <Blacksmoke16> ok works in a new file so must be something to do with what else i got going on...
<FromGitter> <bew> can you give us the full error?
<FromGitter> <Blacksmoke16> that was, in the 2nd picture
<FromGitter> <bew> that was not the full output from the compiler, it's just the end
<FromGitter> <Blacksmoke16> oh shit, my bad
<FromGitter> <bew> ^^
<FromGitter> <Blacksmoke16> ;p
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa371a78f1c77ef3aa37c1c]
<FromGitter> <Blacksmoke16> hold on i just might be an idiot
<FromGitter> <bew> ok, can you show the full YAML.mapping call?
<FromGitter> <bew> with what's between the parenthesis
<FromGitter> <Blacksmoke16> it was me messing with the YAML.mapping like `YAML.mapping(Array(itemID: Int32, itemName: String ))` I'm still not used to the compile errors haha
<FromGitter> <bew> yeah, there is no need for a mapping if you have a top-level structure like a Hash or an Array
<FromGitter> <bew> the mapping is for an object
<FromGitter> <bew> with "mappings" between the object's fields and the class/struct's instance variables
<FromGitter> <Blacksmoke16> part of the issue is the content from file isnt getting parsed right when being passed to the from_yaml
<FromGitter> <bew> define "not parsed right"
<FromGitter> <Blacksmoke16> when using the string you defined it works perfect, but the whole file from File.new errors out
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa3738c35dd17022e415489]
<FromGitter> <bew> this has been fixed recently in #5774
<DeBot> https://github.com/crystal-lang/crystal/pull/5774 (Fix YAML core schema parses integer 0)
<FromGitter> <Blacksmoke16> ah nice
<FromGitter> <bew> but it's not yet release, it'll be in the next one
<FromGitter> <Blacksmoke16> so the issue is it trying to parse the 0, let me try removing that entry
<FromGitter> <Blacksmoke16> Expected String, not 6E-578 at line 32660, column 15 (YAML::ParseException)
qard has quit [Quit: qard]
<FromGitter> <Blacksmoke16> better :P
<FromGitter> <bew> that's weird
<FromGitter> <Blacksmoke16> but seems it doesnt like strings that start with numbers
<FromGitter> <bew> yes
<FromGitter> <bew> I think it should work, not crash
<FromGitter> <drosehn> aren't strings supposed to be (single or double) quoted?
<FromGitter> <Blacksmoke16> probably
<FromGitter> <Blacksmoke16> https://carc.in/#/r/3p19
<FromGitter> <Blacksmoke16> is strange since there are other items that start with numbers but its just the one that errors
<FromGitter> <bew> Simpler https://carc.in/#/r/3p1c :P
<FromGitter> <bew> yes but this one is recognized as a float number
<FromGitter> <Blacksmoke16> but doesnt explain why the other itemNames that start with a number do not error and just that one?
<FromGitter> <bew> because `6E-578` looks like a valid number: `6 * 10^578`
<FromGitter> <Blacksmoke16> ahh that would do it
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <Blacksmoke16> want me to file an issue for that?
<FromGitter> <bew> hmm yes maybe, I don't know the YAML format enough to tell you that your yaml file is invalid or if there is a bug in our parsing
<FromGitter> <Blacksmoke16> yea dunno either
<FromGitter> <Blacksmoke16> ill file an issue anyway just so it doesnt get lost
<FromGitter> <bew> 👍
<FromGitter> <Blacksmoke16> done
<FromGitter> <bew> good! can you add code highlighting by adding `cr` or `crystal` after the 3 backquotes starting a code block (in your issue)
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <faustinoaq> > I love this example: ⏎ ⏎ @bew 👍
<FromGitter> <faustinoaq> Interesting how Amber and Kemal don't require a web server or a platform like puma or unicorn to be fast
<FromGitter> <faustinoaq> https://www.techempower.com/benchmarks/#section=data-r15&hw=ph&test=fortune&f=zijx13-zik0zj-zik0zj-zik0zj-zhxjwf-zik0zj-gnbmym-cn3
<FromGitter> <bew> yay, compiled-language-power!!
<FromGitter> <bew> weird, I always thought amber was slower than kemal
<FromGitter> <Blacksmoke16> imma get to bed, thanks for the help o/
<FromGitter> <bew> you're welcome, good night!
<FromGitter> <faustinoaq> > weird, I always thought amber was slower than kemal ⏎ ⏎ Indeed, Kemal is faster than Amber in most tests 😅
<FromGitter> <faustinoaq> although, Fortunes is shown by default in TFB home page
<FromGitter> <watzon> How can I get the binary representation of a character?
<FromGitter> <bew> where do you want this representation to go? in which format?
<FromGitter> <watzon> Or better yet the binary representation of an entire string. Both MSB and LSB
<FromGitter> <watzon> Is there a built in way to do that?
<FromGitter> <bew> as an array of byte? (for example: `'→'.bytes` => `[226_u8, 134_u8, 146_u8]`)
<FromGitter> <watzon> As a binary string. Like `"Hello, world" => "000100101010011000110110001101101111011000110100000001001110111011110110010011100011011000100110"`
<FromGitter> <bew> ah, you can start with sth like `"abc".each_byte.each {|b| puts b.to_s 2}`
<FromGitter> <watzon> Well this works for MSB `str.bytes.reduce("") { |acc, cur| acc += cur.to_s(2) }`
<FromGitter> <watzon> I don't know how to flip it to do LSB though
<FromGitter> <watzon> Simplified `str.each_byte.map(&.to_s(2)).join`
<FromGitter> <watzon> These don't seem to be right though. Doing `str.unpack("B*")` gives a different output
<FromGitter> <watzon> In Ruby*
<FromGitter> <bew> yes, because `3.to_s 2` will give you `11` not `00000011`
<FromGitter> <watzon> Right
alex`` has joined #crystal-lang
<FromGitter> <watzon> Ok I made my `to_binary` method pad the binary with zeros and it works now
sz0 has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 260 seconds]
Ven`` has joined #crystal-lang
snsei has joined #crystal-lang
dragonkh has quit [Ping timeout: 248 seconds]
ua_ has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
ua has quit [Ping timeout: 256 seconds]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <r00ster91> is it not possible to override/define methods of a class from toplevel?
<FromGitter> <bew> hmm yes?
<FromGitter> <r00ster91> oh
<FromGitter> <bararchy> With all the peeps talking about preloading huge arrays as constants, this reminded it to me https://codeexplainer.wordpress.com/2018/01/20/how-dismantle-compiler-bomb
That_Guy_Anon1 has quit [Remote host closed the connection]
sz0 has quit [Quit: Connection closed for inactivity]
Papierkorb has joined #crystal-lang
Papierkorb has left #crystal-lang ["Konversation terminated!"]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
That_Guy_Anon has joined #crystal-lang
That_Guy_Anon has quit [Remote host closed the connection]
That_Guy_Anon has joined #crystal-lang
<17WAAXC1M> [crystal] RX14 pushed 1 new commit to master: https://git.io/vAjO6
<17WAAXC1M> crystal/master 92c3d42 Brian J. Cardiff: Update previous crystal release & docker images for ci to 0.24.2 (#5796)...
<18WAAL30W> [crystal] RX14 closed pull request #5796: Update previous crystal release & docker images for ci to 0.24.2 (master...ci/use-build-images) https://git.io/vAhxk
<DeBot> https://github.com/crystal-lang/crystal/pull/5796 (Update previous crystal release & docker images for ci to 0.24.2)
<DeBot> https://github.com/crystal-lang/crystal/pull/5796 (Update previous crystal release & docker images for ci to 0.24.2)
That_Guy_Anon has quit [Remote host closed the connection]
That_Guy_Anon has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
snsei has joined #crystal-lang
<travis-ci> crystal-lang/crystal#92c3d42 (master - Update previous crystal release & docker images for ci to 0.24.2 (#5796)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/351670502
<DeBot> https://github.com/crystal-lang/crystal/pull/5796 (Update previous crystal release & docker images for ci to 0.24.2)
snsei has quit [Ping timeout: 265 seconds]
<FromGitter> <faustinoaq> Hi, I just tried crystal 0.24.2 and looks amazing but bash blocking issue is still happening 😓 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5aa3d3b4458cbde5571a5103]
snsei has joined #crystal-lang
wojnar has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
alex`` has quit [Ping timeout: 256 seconds]
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
<FromGitter> <JonnyCodewalker> i get the following error when trying to use the qt5 binings, anyone any idea? https://pastebin.com/kGFbKeTx
<FromGitter> <faustinoaq> Papierkorb ^
<FromGitter> <r00ster91> @Papierkorb
<FromGitter> <faustinoaq> Someone have an idea if I can something similar to this in crystal: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ https://carc.in/#/r/3p35 [https://gitter.im/crystal-lang/crystal?at=5aa3e40b8f1c77ef3aa53566]
<FromGitter> <faustinoaq> I mean overwriting crystal tokens? ⏎ ⏎ I tried this: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5aa3e4cd888332ee3a1f8a96]
<FromGitter> <vlazar> > The generated code must be valid Crystal code, meaning that you can't for example generate a def without a matching end, or a single when expression of a case, since both of them are not complete valid expressions. ⏎ https://crystal-lang.org/docs/syntax_and_semantics/macros.html
<FromGitter> <faustinoaq> Oh you're right 😅 ⏎ ⏎ Then this works: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5aa3f255f3f6d24c685c31c2]
ua__ has joined #crystal-lang
ua_ has quit [Ping timeout: 245 seconds]
That_Guy_Anon has quit [Remote host closed the connection]
wojnar has quit [Remote host closed the connection]
daemonwrangler has quit [Quit: ZNC 1.6.5 - http://znc.in]
daemonwrangler has joined #crystal-lang
duane has joined #crystal-lang
davic has quit [Quit: ZNC - http://znc.in]
ilovezfs_ has quit [Ping timeout: 252 seconds]
jwaldrip has quit [Ping timeout: 240 seconds]
mroth has quit [Read error: Connection reset by peer]
mroth has joined #crystal-lang
jwaldrip has joined #crystal-lang
ilovezfs_ has joined #crystal-lang
davic has joined #crystal-lang
vivus has joined #crystal-lang
<FromGitter> <bew> But whyyy x)
vivus has left #crystal-lang ["Leaving"]
snsei has joined #crystal-lang
<crystal-gh> [crystal] bew opened pull request #5802: Restore STDIN|OUT|ERR blocking state on exit (master...restore-blocking-state-on-exit) https://git.io/vAjgx
ssvb has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
snsei has quit [Ping timeout: 256 seconds]
qard has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
snsei has joined #crystal-lang
Ven`` has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <JonnyCodewalker> for the glory of satan ofc
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
watzon has quit [Quit: removing from IRC because user idle on matrix for 30+ days]
Ven`` has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
crse[m] has quit [Quit: removing from IRC because user idle on matrix for 30+ days]
desdeux[m] has quit [Quit: removing from IRC because user idle on matrix for 30+ days]
<FromGitter> <faustinoaq> > But whyyy x) ⏎ ⏎ For fun? XD
<FromGitter> <faustinoaq> Hey community, WDYT about this comment? ⏎ ⏎ https://crystal-lang.org/2018/03/09/crystal-automated-release.html#comment-3796521859
logen[m] has quit [Quit: removing from IRC because user idle on matrix for 30+ days]
qard has quit [Quit: qard]
galstar[m] has quit [Quit: removing from IRC because user idle on matrix for 30+ days]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
duane has joined #crystal-lang
nifr91 has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
nifr91 has quit [Quit: Page closed]
hightower2 has quit [Ping timeout: 264 seconds]
duane has quit [Ping timeout: 256 seconds]
balduin has quit [Ping timeout: 240 seconds]
balduin has joined #crystal-lang