<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
<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>
<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>
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´?
<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?
<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> 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>
<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> 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>
<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>
<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
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