jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.7 | Fund Crystals development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Philpax has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 244 seconds]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
Oliphaunte has joined #crystal-lang
ome has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
snsei has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 264 seconds]
Oliphaunte has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 260 seconds]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
ome has quit [Quit: Connection closed for inactivity]
pawnbox has quit [Remote host closed the connection]
Oliphaunte has joined #crystal-lang
andrewdotnich has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 246 seconds]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
Raimondi has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
soveran has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
pawnbox_ has quit [Remote host closed the connection]
bjz has joined #crystal-lang
mark_66 has joined #crystal-lang
bjz_ has joined #crystal-lang
Oliphaunte has joined #crystal-lang
bjz has quit [Ping timeout: 246 seconds]
bjz__ has joined #crystal-lang
pawnbox has joined #crystal-lang
bjz_ has quit [Ping timeout: 276 seconds]
Oliphaunte has quit [Ping timeout: 276 seconds]
justinmcp has quit [Quit: No Ping reply in 180 seconds.]
bjz__ has quit [Ping timeout: 272 seconds]
justinmcp has joined #crystal-lang
andrewdotnich has quit [Ping timeout: 250 seconds]
<jhass> RX14: seems like it is
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
qard has quit [Client Quit]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
snsei has quit [Remote host closed the connection]
trapped has joined #crystal-lang
snsei has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
snsei has quit [Ping timeout: 252 seconds]
trapped_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
trapped_ has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
bjz has joined #crystal-lang
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
mark_66 has quit [Remote host closed the connection]
mark_66 has joined #crystal-lang
pawnbox has joined #crystal-lang
Raimondi has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Oliphaunte has joined #crystal-lang
Oliphaunte has quit [Ping timeout: 258 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
soveran has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
<FromGitter> <jmoriau> hi, does anyone know where I can find in the documentation the list of macros like `property` `getter` etc. ? Thanks!
<jhass> they should be on Object
<FromGitter> <jmoriau> they are indeed!
<FromGitter> <jmoriau> thanks
<jhass> yw
<FromGitter> <jmoriau> they don't show up in the search though
<FromGitter> <jmoriau> but they're there that's all that matters :D!
<jhass> yes, nothing non-type does yet
<jhass> (so methods or constants do not either)
<FromGitter> <jmoriau> ok thanks!
buggs1 is now known as buggs
ponga has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
alsm has joined #crystal-lang
Raimondii has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Oliphaunte has joined #crystal-lang
Raimondii is now known as Raimondi
<alsm> Hey, if I have an instance variable (of a struct) in an abstract class, how do I address it to access/modify from a class that inherits from the abstract?
<alsm> or am I doing it all wrong
<RX14> alsm, you should just eb able to use @var like suual
<RX14> usual*
<RX14> can you provide an example?#
<alsm> abstract class ControlPacket
<alsm> @fixed_header : FixedHeader = FixedHeader.new(0_u8, 0_u8, false, false)
<alsm> end
<alsm> class Connect < ControlPacket
<alsm> def initialize
<alsm> @fixed_header.packet_type = PacketType::Connect.value
<alsm> end
<RX14> pastebin next time please alsm
trapped has quit [Ping timeout: 260 seconds]
<RX14> or gist
<alsm> sorry
<alsm> compiler complains Error: instance variable '@fixed_header' was used before it was initialized in one of the 'initialize' methods, rendering it nilable
<RX14> you might need to call super in the inheriting class?
<alsm> I'd thought by declaring it and it's initial value inline in the abstract class it would be instantiated for every inheriting class
<alsm> your suggestion worked, thanks
<RX14> did it?
<RX14> it's not for me
<RX14> oh no
<RX14> ignore me
<RX14> yep
<RX14> alsm, basically using @instance_var = x in the root of a class is sugar for doing the same in each constructor
<alsm> ahh ok, makes sense
<RX14> so you need super
<RX14> it might be a little more complex than that but then i havent read the compiler source
pawnbox has quit [Remote host closed the connection]
<alsm> moves me forward :)
ponga has quit []
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<asterite> RX14: it's actually a bug :-)
<RX14> asterite, well at least it has an easy workaround
<RX14> "super"
<RX14> also did you see https://carc.in/#/r/132m
<RX14> there's another, more major bug
<jhass> yeah, surprising it didn't surface before
<asterite> RX14: I don't know why it works with super, it's part of the same bug... it's a workaround that might break any time
<RX14> asterite, well is "@var = x" in the class top level desugared into constructors?
<RX14> if thats the case then it's obvious why super works
<asterite> RX14: no, it's done in the allocate method of the object, so happens before an initialize
<RX14> huh
<RX14> interesting
<asterite> there's no bug report for https://carc.in/#/r/132m ?
<RX14> nope
<jhass> (allocate is the true constructor, initialize is an initializer called by it)
<RX14> it was 1am
<asterite> Hahaha :)
<RX14> and i just wanted to hit the bed
<asterite> I'll add one
<RX14> if there was one it would just have been pretty empty with just that link
<asterite> No worries
<RX14> asterite, by the way that bug goes away if you seperate the inline Slice[] stuff into seperate variables
<jhass> asterite: while you're logging issues, do you agree we should implement https://github.com/crystal-lang/crystal/issues/2792, then drop Random and rename SecureRandom to Random?
<asterite> RX14: yeah, it's very strange... it might even be a parser bug
<RX14> asterite, thats what I thought
<RX14> asterite, yeah Random is completely useless compared to SecureRandom
<asterite> Ummm... I think Random and SecureRandom have different purposes
<asterite> sometimes you need a random value and you don't need it to be secure
<asterite> and secure often means slower
<RX14> yes, but urandom isn't THAT slow
<asterite> but I don't know much about the subject, so my opinion is not very strong
<jhass> also can you even define the difference between "randomness" and "secure randomness"?
<asterite> but mersene twister is supposed to be very fast, I think
<RX14> 6.9MB/s
<RX14> on a shitty celeron M
<RX14> seriously
<asterite> Sure, secure means you can't predict it, and if someone predicts it they can compromise your program
<RX14> let mersenne twister be a shard
<asterite> but not all random events in your program need to be secure
<RX14> if you need more then 10MB/s of random then you should use a shard
<asterite> but I'd like to know waj's opinion, I'm sure he has a strong opinion on this
<asterite> in any case, maybe we should open an issue and discuss it
<RX14> yeah, i'm not a crypto expert, but they all seem to say "Just use urandom"
<RX14> at the very least random should have some sensible way to generate a load of random bytes
<FromGitter> <sdogruyol> nice article
<RX14> instead of just an integer
<RX14> because i just want a damn random base64 string for multipart boudnaries
<jhass> asterite: the question really is, is /dev/urandom fast enough. Let's face it, most people can't judge whether they need a CSPRNG or a regular PRNG is enough. So using a CSPRNG by default is the saner choice. If you actually know it's too slow for you, you're deep enough into the topic anyway
<RX14> and writing my own 10 line method to get bytes from Random so I don't have to require secure_random just to use multipart is just shit
<jhass> and know how to use a faster PRNG that might not be a CSPRNG
<jhass> however having a CSPRNG by default can't do any harm
<RX14> ^
Oliphaunte has joined #crystal-lang
<RX14> and 7MB/s on a celeron M singlecore laptop which was mid-range in 2005 is more than enough random for 99.99% of people
<jhass> mh, I get about 5M/s
<RX14> huh
<RX14> dd if=/dev/urandom of=/dev/null bs=4k count=10000
<RX14> exactly 7MB/s
<jhass> used a bigger buffer
<jhass> but same otherwise, exactly 5
<RX14> huh
<RX14> you using linux?
<jhass> yes
<RX14> what kernel?
<jhass> 4.6.3
<RX14> well
<RX14> thats surprising
<FromGitter> <sdogruyol> i get around 13.5 MB/s on OS X
<FromGitter> <sdogruyol> i7 though
<jhass> I mean it's still enough
<RX14> how on earth
<jhass> yeah, 2010 or 11 i7 here too
<RX14> how on earth is your computer slower lol
<FromGitter> <sdogruyol> lol yeah slower than a celeron
<jhass> maybe I have more parallel consumers
<asterite> I can't find the conversation, but in https://github.com/l3kn/raytracer-crystal the guy told me "Rust is slower... I don't know why, maybe the default random algorithm is slow"
<asterite> So slow by default is not good. And you don't need a secure random for a raytracer, and I guess in games you don't either
<asterite> like generating terrain
<RX14> then they should use FastRandom
<RX14> but the default should be secure
<RX14> not insecure
<FromGitter> <sdogruyol> i also think that default should be secure than being fast
<RX14> there should be both
<FromGitter> <sdogruyol> balanced*
<RX14> but if fast is the default, the worst case is vunerabilities
<RX14> if secure is the default, the worst case is slowness
<RX14> which one is preferable?
<asterite> So for example if you do [1, 2, 3, 4].sample, that should be secure or fast?
<RX14> fast, but thats the stdlib so it can be modified to use FastRandom
<RX14> in some cases you want that to be secure
<RX14> but I believe that SecureRandom and Random should have the same interface at least
pawnbox has quit [Remote host closed the connection]
<RX14> and I would strongly advocate that the default Random be secure
<RX14> that's what ruby does, is it not?
<jhass> sadly, it's not
<RX14> ah
pawnbox has joined #crystal-lang
<jhass> Ruby's SecureRandom/Random is a pretty sad story altogether
<jhass> https://bugs.ruby-lang.org/issues/9569 is a depressing read
<RX14> it's basically the ruby devs saying that they trust the kernel manpage over thousands of cryptographers
<jhass> yep
<FromGitter> <sdogruyol> haha 'maybe openssl should die' is everyone's choice :smile:
<RX14> I would personally use getrandom, then fall back to urandom for the default
<RX14> because using urandom means we have to do an IO read, which is more expensive, especially with evented IO, than a syscall
pawnbox has quit [Remote host closed the connection]
Philpax has quit [Ping timeout: 252 seconds]
pawnbox has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
<RX14> libsodium seems pretty nice itself to be honest
<RX14> nice docs at least
<jhass> yeah seem to be competent people with the right focus
<FromGitter> <sdogruyol> i'm just curious about using `StringBuilder` over this and logging out to STDOUT ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=577bc8fc3ac2a2dc1445a830]
<FromGitter> <sdogruyol> Does it worth the effort?
<jhass> string interpolation is actually syntax sugar for String.build
<FromGitter> <sdogruyol> so it reuses the same io?
<jhass> the same io as?
<jhass> anyway, you only get better by something like time.to_s(io); io << ' '; context.response.status_code.to_s(io) ....
<jhass> where io is STDOUT, your logfile or so
<FromGitter> <sdogruyol> hmm let me benchmark it
<RX14> i would go with the io << values approach myself
<jhass> ah right I always somehow forget that io << foo is just foo.to_s(io)
<RX14> io << time << ' ' << context.response.status_code << ' ' << context.request.method etc.
<RX14> it's really quite neat and the ebst performance you will get
<RX14> not quite as readable as string interp but pretty damn good
<jhass> where's that io percent literal discussion anyway
<RX14> hmmn?
<FromGitter> <sdogruyol> nearly the same but builder seems like a little bit slower
<FromGitter> <sdogruyol> Normal String 2.420000 3.390000 5.810000 ( 3.755092) ⏎ Builder 2.520000 3.260000 5.780000 ( 3.834266)
<RX14> it truly pleases my mind
<jhass> RX14: read on, it has a couple of issues
<RX14> yeah i guess
<RX14> sucks
<RX14> io percent literal seems fine I guess
<RX14> but i really think io << x << y << z is fine
<jhass> yeah
<RX14> it would be nice for the compiler to have some specialoptimisations which don't treat all types the same
<FromGitter> <sdogruyol> WDYT? Is there any ways to optimize that String::Builder
<RX14> well you can make it a hell of a lot cleaner
<FromGitter> <sdogruyol> like?
<RX14> try replacing single-byte string with chars
<RX14> well chaining <<
<RX14> is the first thing I would do
<FromGitter> <sdogruyol> ah that's true
<jhass> sdogruyol: it's the same, the difference is within tolerance
<RX14> to get it all on one line like the string literal
<jhass> it's literally the same
<FromGitter> <sdogruyol> yeah indeed it seems like so
<jhass> interpolation is rewritten to String.build which just yields you a String::Builder
<RX14> but the difference comes when writing to an IO
<jhass> yes
<RX14> (always use String.build not String::Builder, it's cleaner)
<RX14> (in most cases)
<RX14> @sdogruyol, why are you using 10_000_000.times instead of Benchmark.ips?
<FromGitter> <sdogruyol> dunno
<FromGitter> <sdogruyol> :P
<RX14> man how did i ever survive before vim
<FromGitter> <sdogruyol> meanwhile
<FromGitter> <sdogruyol> nvm
<FromGitter> <sdogruyol> let me check it
<FromGitter> <sdogruyol> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=577bce75f06cda5d0990d840]
<RX14> well
<RX14> thats an easy fix
mark_66 has quit [Quit: Leaving.]
<FromGitter> <sdogruyol> yup
<FromGitter> <sdogruyol> just renamed it :P
<RX14> it's faster
<RX14> way way faster
<RX14> 3.5x faster
<jhass> well, obviously
<FromGitter> <sdogruyol> format type
<FromGitter> <sdogruyol> typo*
<FromGitter> <sdogruyol> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=577bcef93ac2a2dc14461e73]
<RX14> i wish FromGitter would send me a link to just the code instead of gitter
<RX14> because gitter takes a while to load
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> meanwhile whats MemoryIO.new(100)
<FromGitter> <sdogruyol> you initialize it with capacity?
<RX14> yep
<RX14> make sure it doesn't resize, because why not
<RX14> there's no harm of setting it to 100 bytes
<RX14> it removes one more thing from the benchmark
<FromGitter> <sdogruyol> yeah but in real world that would be a bummer
<RX14> ?
<RX14> in the real world that would eb a socket
<FromGitter> <sdogruyol> if the uri path is long like 200 or so it's gonna be a problem right?
<RX14> and have no size
<FromGitter> <sdogruyol> yeah
<RX14> but its not
<FromGitter> <sdogruyol> but still an interesting idea there
<RX14> so i made it large
<RX14> so it would act like a socket
<RX14> in not having tor esize
<RX14> the buffered socket is like 8k buffer i bet
<RX14> yup
<FromGitter> <sdogruyol> not sure about that
<RX14> 8k
<RX14> so it'll be like that
<RX14> a large MemoryIO is very like a buffered socket for small reads and writes
<FromGitter> <sdogruyol> in my case the IO is STDOUT
<jhass> it has to allocate less, it'll be faster
<RX14> which flushes on newline
<jhass> there's not much to discuss here
<RX14> jhass, yep
<RX14> malloc is slow
<RX14> even with GC
<RX14> 0-copy is king
<FromGitter> <sdogruyol> this is what i'm trying to get rid of / optimize https://github.com/sdogruyol/kemal/blob/master/src/kemal/common_log_handler.cr#L22
<RX14> @sdogruyol what's the "write" method for, it does the same thing right?
<FromGitter> <sdogruyol> yeah practically
<RX14> well why have both?
<FromGitter> <sdogruyol> one is for file handler
<RX14> they're both IO
<RX14> they make no difference
<RX14> just call print
<FromGitter> <sdogruyol> meanwhile writing to stdout is really slow ..
<RX14> yeah well you flush on every line
<RX14> i'm not surprised
<jhass> it does make sense to do that for logging
<jhass> it's just slow
<RX14> jhass, no but .print is literally EXACTLY the same as .write string.to_slice
<jhass> sure
<RX14> so there's no need to use an if
<jhass> not debating that?
<RX14> @sdogruyol have you benchmerked writing to STDOUT when you do > /dev/null
<FromGitter> <sdogruyol> what if channel that to dev/null
<RX14> 99% of the "slowness" of writing to stdout is your termainl rendering fonts
<FromGitter> <sdogruyol> yep
<FromGitter> <sdogruyol> for better performance i just turn off logging
<RX14> or write to a file
<FromGitter> <sdogruyol> yes
paulcsmith_ has joined #crystal-lang
kulelu88 has joined #crystal-lang
snsei has quit [Remote host closed the connection]
mgarciaisaia has quit [Quit: Leaving.]
paulcsmith_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
alsm has quit [Ping timeout: 276 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia has left #crystal-lang [#crystal-lang]
soveran has quit [Remote host closed the connection]
paulcsmith_ has joined #crystal-lang
paulcsmith_ has quit [Client Quit]
paulcsmith_ has joined #crystal-lang
paulcsmith_ has quit [Client Quit]
trapped has joined #crystal-lang
Oliphaunte has quit [Remote host closed the connection]
<FromGitter> <sdogruyol> Thanks @RX14 it's much simpler now https://github.com/sdogruyol/kemal/commit/ae25d0a7742c4b2fd95d0a0b1acffe59bf388e91
<FromGitter> <sdogruyol> and free performance <3
<RX14> @sdogruyol, does that work? the rewind shouldn't work
<FromGitter> <sdogruyol> why not?
<RX14> the rewind is only needed because I was using a memoryIO
<FromGitter> <sdogruyol> it's working pretty weel
<FromGitter> <sdogruyol> well it didnt cause any problem
<RX14> if I used the memoryIO without rewind it would grow in memory usage massively because it would store every iteration
<RX14> the rewrind is only for the benchmark
<RX14> you shouldn't use it on stdout
<FromGitter> <sdogruyol> yeah
<FromGitter> <sdogruyol> let me check it
<FromGitter> <sdogruyol> seems like you are right it's not needed. Thanks again :+1:
<crystal-gh> [crystal] asterite pushed 4 new commits to master: https://git.io/vKktQ
<crystal-gh> crystal/master 2a014f6 Ary Borenszweig: Removed unused `to_fd_io` method
<crystal-gh> crystal/master 5bd34d6 Ary Borenszweig: File and IO::FileDescriptor inspect
<crystal-gh> crystal/master ff3733e Ary Borenszweig: compile -> build
<travis-ci> crystal-lang/crystal#dd15c0e (master - Regex: use `try` instead of `not_nil!` in docs. Related to #2879): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/142521420
Oliphaunte has joined #crystal-lang
<RX14> jhass, should HTTP::Multipart::Parser/Generator be structs?
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has joined #crystal-lang
<jhass> I think as a general rule use structs unless you need the properties of a class
<jhass> so the question, do they have mutable state?
<RX14> no
<RX14> well
<RX14> yes
<RX14> internally
<RX14> they both use a finite state machine of sorts
<jhass> then they have to classes, very likely
<jhass> *to be
<RX14> ah yes they do
<RX14> had a brain fart
<FromGitter> <GuneshRaj> Hi, Could anyone point me a way to declare an Array of a Hash?
qard has joined #crystal-lang
<FromGitter> <GuneshRaj> eg. temp = [] of String => String
<jhass> looks good
<FromGitter> <GuneshRaj> ops, temp = {} of String => String
<FromGitter> <GuneshRaj> temps = [] of Array( {} of String => String ) # this is an error.
<RX14> yes you want Hash(String, String)
soveran has quit [Ping timeout: 264 seconds]
<jhass> tmp = [] of Hash(String, String)
<RX14> {} of String => String instantiates the hash
<jhass> I wonder whether we should allow the first
<RX14> Hash(String, String) is the type signature
<jhass> could be confusing I guess
<RX14> well {} of x to y is a special weird case anyway
<RX14> I would have just told people to use Hash(x, y).new and skip that syntax
<jhass> yeah we could even argue to drop the of stuff I guess
<RX14> it's more confusing and just wacky really
<FromGitter> <GuneshRaj> ok, Il try that.
<FromGitter> <GuneshRaj> great, that works: thanks jhass
<FromGitter> <GuneshRaj> Would it be better; performance wise to have an Array of a Struct or an Array of a Hash?
<FromGitter> <GuneshRaj> Would Struct be created at heap and therefore faster ?
<jhass> it depends.
<jhass> an array of hashes is an array of references
<jhass> an array of structs is an array of elements as big as the biggest struct
<jhass> it depends on how often you create or destroy things, how big they are, how often you "get" an element out of the array onto the stack etc
<jhass> in doubt, benchmark ;)
<jhass> for your real usage that is, not some minimal thing you think reflects anything
<jhass> benchmarking some pseudo array of hashes vs array of struct stuff here is quite useless
<FromGitter> <GuneshRaj> Yes, I thought so, just wanted to know whats the best practice if both Hash (String, String) and A Struct with the same data / params are interchangeable, which would be better.
<jhass> and there's no general answer to that
<RX14> @GuneshRaj is this for a set, specific set of keys?
<FromGitter> <GuneshRaj> yes. much like a struct.
<RX14> if so, use a struct/record. Hashes should only really be used for actual "dictionary" uses in crystal, because their values can only have one type. The alternative is a record or named tuple, which can have different types for different keys.
<RX14> only use a hash when you don't know the set of keys beforehand, although this is a rule meant tio be broken
<RX14> but in general don't use hashes in exactly the same way they are used in ruby
<FromGitter> <GuneshRaj> aha
<RX14> aside from the performance issues, it breaks type checking
<FromGitter> <GuneshRaj> I would rather declare a Hash of String => Types::Something
<FromGitter> <GuneshRaj> Anyway, thanks, I am going to investigate :)
<RX14> what exactly is the usecase? are the keys different types? if so, why would you prefer doing that?
paulcsmith_ has joined #crystal-lang
<FromGitter> <GuneshRaj> I am experimenting with data structures and models, getting data from a table as a array of hashes where the values must conform to a specific sql type.
<FromGitter> <GuneshRaj> I am finding alternatives in terms of performance (as well as best practices to follow)
<RX14> the best way to do that is with an array of structs, see the crystal postgres gem
paulcsmith_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
paulcsmith_ has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 3 new commits to master: https://git.io/vKkBu
<crystal-gh> crystal/master a52faf2 Ary Borenszweig: Don't expand `require` before everything else. Related to #2710
<crystal-gh> crystal/master bd01fb2 Ary Borenszweig: Replace all `ifdef x` in code with `{% if flag?(:x) %}`. Related to #2710
<crystal-gh> crystal/master 104c9b9 Ary Borenszweig: Formatter: automatically convert `ifdef x` to `{% if flag?(:x) %}`. Related to #2710
trapped has quit [Read error: Connection reset by peer]
kulelu88 has quit [Ping timeout: 272 seconds]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 260 seconds]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vKkEB
<crystal-gh> crystal/master 993bda1 Ary Borenszweig: Fiber#run: use STDERR again, and give better error message
paulcsmith_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<travis-ci> crystal-lang/crystal#104c9b9 (master - Formatter: automatically convert `ifdef x` to `{% if flag?(:x) %}`. Related to #2710): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/142548013
<crystal-gh> [crystal] asterite pushed 2 new commits to master: https://git.io/vKkzF
<crystal-gh> crystal/master 2a3be51 Ary Borenszweig: Compiler: move core_ext method to util (simpler)
<crystal-gh> crystal/master acd6a76 Ary Borenszweig: Some fixes related to the ifdef -> flag? change
paulcsmith_ has joined #crystal-lang
<travis-ci> crystal-lang/crystal#993bda1 (master - Fiber#run: use STDERR again, and give better error message): The build was broken. https://travis-ci.org/crystal-lang/crystal/builds/142554676
paulcsmith_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
paulcsmith_ has joined #crystal-lang
<FromGitter> <jwaldrip> Aw man, I thought for sure you guys made the second goal last month
Oliphaunte has quit [Remote host closed the connection]
hamdiakoguz has joined #crystal-lang
<travis-ci> crystal-lang/crystal#acd6a76 (master - Some fixes related to the ifdef -> flag? change): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/142557529
paulcsmith_ has quit [Ping timeout: 260 seconds]
hamdiakoguz has quit [Ping timeout: 250 seconds]
Oliphaunte has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 3 new commits to master: https://git.io/vKkKC
<crystal-gh> crystal/master 1e9625a Ary Borenszweig: Fixed #2955: require relative doesn't work inside macros
<crystal-gh> crystal/master 5dc17bc Ary Borenszweig: Fixed #2954: use percent variables in `Slice#[]`
<crystal-gh> crystal/master 9897488 Ary Borenszweig: Fixed #2953: Compile error accessing an instance variable that was initialized
kulelu88 has joined #crystal-lang
kulelu88 has quit [Changing host]
kulelu88 has joined #crystal-lang
<FromGitter> <sdogruyol> @jwaldrip yeah we did it
<FromGitter> <jwaldrip> Just have to get the total monthlys up!
<FromGitter> <sdogruyol> what do you mean
paulcsmith_ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<travis-ci> crystal-lang/crystal#9897488 (master - Fixed #2953: Compile error accessing an instance variable that was initialized): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/142570502
qard has quit [Quit: Textual IRC Client: www.textualapp.com]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
pawnbox has quit [Remote host closed the connection]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vKkdi
<crystal-gh> crystal/master 6fb51a8 Ary Borenszweig: Merge pull request #2802 from crystal-lang/feature/fix_heredoc...
paulcsmith_ has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
Oliphaunte has quit [Remote host closed the connection]
Sija has joined #crystal-lang
<Sija> hi @ll!
<Sija> i'll start with question if that's ok (;
<Sija> how to print Pointer<UInt8> to STDOUT knowing it contains binary data (JPG in this case)?
<Sija> i'd be most gr8ful for a solution, thx!
<Sija> it could be Slice<UInt8> too since i have size of the data
<jhass> Sija: you want to print the raw data to stdout or some base64 or hex encoding?
<Sija> i want 'em raw pkz
<Sija> plz
<jhass> Sija: then just construct the slice and pass it to STDOUT.write
<Sija> IO::Buffered#write to the rescue indeed!
<Sija> muito obrigado!
<Sija> works like a charm
soveran has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> man i've been working on this damn mutipart for like 2 weeks now
<RX14> i've dome quite a bit of work though i guess
bjz has joined #crystal-lang
<Sija> i feel your position bro! who does serialport tho'?
pawnbox has joined #crystal-lang
soveran has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 260 seconds]
kulelu88 has quit [Quit: Leaving]
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vKILR
<crystal-gh> crystal/master e8b1b84 Ary Borenszweig: Merge pull request #2793 from crystal-lang/feature/local_var_assign_shadow...
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
Philpax has joined #crystal-lang