<kodo[m]>
although I guess that only works at compile time. I can't read that as data like you said
<FromGitter>
<bew> yes
Renich__ is now known as Renich
<Renich>
Guys, I have a config file in yaml. I want to be able to access it's values as config.credentials.service.key, for example.
<Renich>
How would you do it?
<Renich>
Also, I am interested in bootstraping properly. If anyone can offer any pointers, it would be good. Basically, I need t o initializa logging and read the config file.
<FromGitter>
<bew> I think it could be interesting to have this `LazyIterator` in the stdlib (maybe under another name)
bew78 has quit [Quit: WeeChat 1.7]
<FromGitter>
<elorest> I figured out my issue with sockets and fibers. Apparently within the fiber it was referring to the same socket so when I closed it it closed all of them. I fixed it by passing it into a proc. https://gist.github.com/elorest/95256e5cb450e3b25ccf28a2fc5707e4
<FromGitter>
<bew> server.cr#L7 should be `name = sock.gets`
<FromGitter>
<elorest> excellent point. I'm surprised it worked.
<FromGitter>
<bew> I don't think you 'need' a Proc here
<FromGitter>
<bew> try without, maybe there was a typo that you fixed by trying with a Pro
<FromGitter>
<bew> Proc
<FromGitter>
<elorest> the reason i think I do is that if I close it for one fiber it closes it for all fibers and all of my other clients to error. Look at screen shots above. I would love to do it without a proc though if possible.
<FromGitter>
<bew> yes, for a given client, if you close the socket somewhere, it'll be unavailable in the other fibers which has a reference to this specific clint
<FromGitter>
<bew> client*
<kodo[m]>
Anyone know a qr code lib? Don't see one on awesome crystal
<FromGitter>
<elorest> @bew What I did was started the server then ran the client in 2 different terminal windows. After entering my name in one, the other one caused the server to throw a Closed Stream IO::Error
<FromGitter>
<elorest> @bew if possible i would love to do it without procs but I just removed it and now it errors if I have more than one call to it at once.
<FromGitter>
<bew> @elorest `sock.close`, closes only `sock` not all opened sockets, can you share the code?.. you can know if a socket is closed or not with `sock.closed?`
<FromGitter>
<elorest> I've revised the gist above with procs commented out. I'm just starting one server and then 2 clients before entering the name to either of them. Entering it on one breaks the other.
<FromGitter>
<bew> you haven't commented the `end` of the proc
<FromGitter>
<elorest> I was hoping you looked after I fixed that lol. That's not the error I meant though.
<FromGitter>
<elorest> Not sure if a socket is different somehow due to not being an Int32...
<FromGitter>
<bew> ok I got it to crash
<FromGitter>
<bew> every time
<FromGitter>
<bew> I think you're right
<FromGitter>
<bew> @elorest
<FromGitter>
<elorest> @bew. Dang it I hate being right. I guess using a proc isn't that bad though.
<FromGitter>
<bew> hate being right ? why ? the proc is good then, yes
<FromGitter>
<elorest> @bew it just would have made for a bit simpler code if you were right in this case. Yeah it's fine though. Thanks for your help.
<kodo[m]>
How do I get least significant bit of a byte?
<kodo[m]>
ah looks like .bit
<kodo[m]>
how do I 30644080 * 30644080 without overflowing?
<kodo[m]>
ah to_u64
carbonage has quit [Quit: Leaving]
greengriminal has quit [Quit: This computer has gone to sleep]
<domgetter>
bew: awesome! I'll go play with the LazyIterator a little bit
<FromGitter>
<bew> domgetter: see #4198 I posted a better version of it :)
<FromGitter>
<asterite> The macro expands to that, but it's expanded outside struct Int...
skinkitten has joined #crystal-lang
<domgetter>
ah okay. I thought it was placing the result inside the Int struct
<RX14>
it might just be that being single-threaded is killing crystal because their CPU has terrible singlecore performance
<RX14>
they have 80 threads
<RX14>
but terrible singlecore
snsei has quit [Read error: Connection reset by peer]
<RX14>
and we still get 50k
snsei has joined #crystal-lang
Qchmqs has quit [Ping timeout: 240 seconds]
<crystal-gh>
[crystal] bcardiff pushed 1 new commit to master: https://git.io/vStKE
<crystal-gh>
crystal/master 6a45e08 TSUYUSATO Kitsune: Flate: try to inflate even if @stream.avail_in is 0 (#4193)...
<crystal-gh>
[crystal] bcardiff closed pull request #4193: Flate: try to inflate even if @stream.avail_in is 0 (master...fix/flate/reader-believe-stream-end) https://git.io/vSky1
sz0 has joined #crystal-lang
skinkitten has quit [Read error: Connection reset by peer]
mark_66 has quit [Remote host closed the connection]
Kug3lis_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Raimondi has quit [Read error: Connection reset by peer]
<rmosolgo>
Hi, I'm hoping to express "the number of times something can happen", something like Range(Int, Int), but _infinity_ is a possible option. The only INFINITY I could find in Crystal was `Float64::INFINITY`, does this mean I should use `Range(Float64, Float64)` in this case?
Raimondi has joined #crystal-lang
<rmosolgo>
Oh, I think Int32::MAX will do the job :)
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
domgetter has quit [Ping timeout: 260 seconds]
snsei_ has quit [Remote host closed the connection]
gloscomb1 has quit [Ping timeout: 260 seconds]
gloscombe has joined #crystal-lang
Renich__ has joined #crystal-lang
emancu has joined #crystal-lang
Renich has quit [Ping timeout: 256 seconds]
Renich__ is now known as Renich
Renich has quit [Quit: Renich]
<kodo[m]>
Crystal has made me start toying with c seriously for the first time. I'm quickly discovering why pointers are evil. Heh you get an object back Everytime but where it points is anyone's guess
<kodo[m]>
Makes it super hard to debug
emancu has quit []
<kodo[m]>
Debugging shared libraries for crystal is a serious pain
<kodo[m]>
Heh
* kodo[m]
goes back to his corner
domgetter has joined #crystal-lang
domgetter has quit [Quit: Leaving]
sz0 has quit [Quit: Connection closed for inactivity]
akwiatkowski has joined #crystal-lang
Renich has joined #crystal-lang
<Papierkorb>
kodo[m]: Mh? Pointers are in every language out there
<RX14>
Papierkorb, the implication is raw pointers/pointer arithmetic
rmosolgo has quit []
<Yxhuvud>
Papierkorb: Pointers that can maybe not point to something is definitely not in every language
<Renich>
Personas, do we have pretty print in crystal?
<Renich>
don't worry, I just wanted to know if it was possible
<RX14>
crystal play is probably your best bet
<RX14>
as for JSON, you need to use HTTP::Client
<RX14>
the JSON module only deals with json
<Renich>
RX14: got it. Maybe I just have to get my head around it
<Renich>
RX14: Thanks again, man!
<RX14>
something like HTTP::Client.get("url") do |response|; JSON.parse(response.body)...; end
<RX14>
and eventually you'll probably want to use JSON.mapping
<Renich>
RX14: btw, crystal-icr has commits on Jan 14... just sayin'
<RX14>
thats practically unmaintained at crystal pace
<Renich>
RX14: yeah, I will probably
<RX14>
for something which depends on the compiler
<Renich>
RX14: yeah, you're right ;)
<Renich>
RX14: you're very kind. Thanks a lot for the help
<RX14>
no problem
<FromGitter>
<dmitryck> the new site of crystal-lang has been published today?
<FromGitter>
<mverzilli> no, on Thursday IIRC
<FromGitter>
<jwoertink> Has anyone written any tutorials or posts about how to read a .h file and pull that in to crystal?
<FromGitter>
<dmitryck> @mverzilli got it
<FromGitter>
<elorest> I'll work on that. I've been doing a ton with c libs in the last few weeks. so writing down what I've learned would be a good idea.
<FromGitter>
<KCreate> Is it possible to dynamically get the number of bytes a class takes up? For example `Int32 : 4` `Int64 : 8` `Int8 : 1`
<FromGitter>
<elorest> Ok. So I guess you're saying that I don't want to close it. I'll remove that and try. thanks
<RX14>
no, you want to close it
<RX14>
can you show me the code with that error message
<FromGitter>
<elorest> in that gist that I sent over if you comment out the proc and proc.call it will error if you start two clients, send the name to one and then try to send it to the other.
<FromGitter>
<elorest> <RX14> So if you start the server... then open two more terminal/tmux windows and run client in both of them at the same time, then send the name through one, it doesn't error on the server side when you send it through on the second?
<RX14>
nope
<RX14>
there does seem to be a bug with variable binding though
<FromGitter>
<jwoertink> I see some that say `typedef struct Whatever {` then list a bunch of declarations inside those curly braces, but in this case, there's no curly braces. I assume it's actual definition is probably somewhere else....
<FromGitter>
<jwoertink> Ok, so that makes sense for the ones that declare things, but what about ones that don't? Like if it were `typedef struct _Person Person;`
<Renich>
What are those {% ... %} things? Compiler logic?
<Renich>
I am trying to consume an API so, maybe, I could do something similar for all the actions I can take
<FromGitter>
<elorest> <Renich> Those are macro calls.
<FromGitter>
<jwoertink> Ok, cool. I guess this struct is actually defined somewhere else, I just gotta find that code
<FromGitter>
<fridgerator> I'm assuming there is a method to url encode a string but I'm not finding it in the api docs, does anyone know what it is off the top of their head?
<Renich>
@elorest: OK. I'll read into macros
<Renich>
what about the getter keyword at the top. Does that, really, generate a getter?
<FromGitter>
<elorest> @jwoertink yep. I've ran into that a few times too. Just grep the .h and .c files.
<RX14>
@fridgerator you want URI.escape
<FromGitter>
<jwoertink> :thumbsup: sweet.
<FromGitter>
<fridgerator> there it is, thanks @RX14
<FromGitter>
<elorest> <Renich> Yep.
<Renich>
@elorest: awesome. Thanks
<FromGitter>
<jwoertink> Yeah, I'd love to see some sort of "cheat sheet" guide for doing a 1 to 1 mapping between a C lib and writing a Lib in Crystal
<RX14>
well
<RX14>
to be honest, if you don't know C I wouldn't recommend binding
<FromGitter>
<jwoertink> lol
<RX14>
there's lots more to bindings than syntax
<RX14>
to call C you need to know C semantics
<RX14>
and things not to do, like dangling pointers
<FromGitter>
<jwoertink> true. There's definitely a lot to learn.
<FromGitter>
<jwoertink> I picked up Java by porting a bunch of a Java libs over to JRuby. I was hoping this could be my gateway in to learning C
<kodo[m]>
I spent 8 hrs trying to bind a c library for fun
<kodo[m]>
was horrible and awesome at the same time
<FromGitter>
<elorest> I've pretty much just taken my C++ skills and deleted most of them and relearned pointers.
<kodo[m]>
learned a lot about c
<kodo[m]>
the #1 thing it did was make me really thankful for crystal
<FromGitter>
<jwoertink> Unfortunately I have no C++, C, or any other single letter programming language skills.
<FromGitter>
<elorest> Sometimes I write c and think wow if ruby ever dies and crystal doesn't replace it I'll probably just do c. Not that I'm an expert but it really doesn't seem that bad.
<FromGitter>
<jwoertink> If Ruby dies and Crystal doesn't replace it, I'm opening a taco truck and pulling a _why
<RX14>
hah
<FromGitter>
<elorest> lol
<FromGitter>
<elorest> Foxes.
<FromGitter>
<ltran> Anyone here played with protobuf3?
<FromGitter>
<jwoertink> chunky bacon
<FromGitter>
<ltran> my company is moving towards it and i want the option to write my scripts in crystal ;D
<kodo[m]>
jwoertink: amen LOL
<FromGitter>
<matrixbot> `kodo 🌍` Test
<FromGitter>
<matrixbot> `kodo 🌍` woo hoo my own private gitter bridge on matrix heh
<FromGitter>
<tjgillies> the gitter native client is kinda nice though
kodo[m] has left #crystal-lang ["User left"]
<RX14>
oh great
<RX14>
<FromGitter> <matrixbot> `kodo 🌍` Test
<RX14>
thats readable
<FromGitter>
<elorest> It's like xml
<FromGitter>
<matrixbot> `kodo 🌍` xml is like violence, if it's not working you're not using enough
<FromGitter>
<matrixbot> `Dybbuk` Wait...what is this chat thing?
<FromGitter>
<matrixbot> `kodo 🌍` Dybbuk: This is the crystal language gitter matrix bridge. I drugged you and brought you here against your will. You're welcome
<FromGitter>
<matrixbot> `Dybbuk` I wish I could say that was the first time a Crystal had done that to me.
<FromGitter>
<elorest> Does something exist similar to a formatter that could add variable types if they're missing? Theoretically this is possible since the compile knows and inserts them at compile time if they're missing.
<RX14>
@elorest argument types are inferred from every call of the method so you'd need code that calls it and you couldn't be sure it's correct
<RX14>
if you don't want to write the argument types just don't write them
<RX14>
i rarely write them
<FromGitter>
<elorest> K
<FromGitter>
<jwoertink> I see some examples in this header file that have something like `int x` which is translated in crystal as `x : LibC::Int`. I then saw something that said `y Uint8` so I assumed that was `LibC::UInt8`, but that throws a `undefined constant LibC::UInt8`...
<FromGitter>
<jwoertink> Would I just use the normal `UInt8` constant for that?
<FromGitter>
<elorest> UInt8 is great for an 8bit unsigned int. usually they seem to be used for chars*
<FromGitter>
<jwoertink> Yeah, there's a few that are used like that, but not all of them (in this case at least)