<FromGitter>
<elorest> Dbus seems quite a bit slower when searching for available devices. Definitely an option though. Also DBUS is still just an interface for bluez. So it's not really a question between bluez or dbus. Either way it's bluez.
Heaven31415 has quit [Quit: Leaving]
sevensidedmarble has joined #crystal-lang
<woodruffw>
is there anything like `scanf`/`fscanf` for crystal's `IO`?
<woodruffw>
(i'd like to read an ASCII-formatted length-prefixed string)
non-aristotelian has quit [Quit: non-aristotelian]
Vexatos has quit [Ping timeout: 246 seconds]
vikaton has quit [Quit: Connection closed for inactivity]
<FromGitter>
<bajro17> I have question
<FromGitter>
<bajro17> I want just try make my own router
<FromGitter>
<bajro17> how to do something like /something/:thisisimportant
<FromGitter>
<bajro17> to take this like parameter
DTZUZO has quit [Remote host closed the connection]
DTZUZO has joined #crystal-lang
akaiiro has quit [Ping timeout: 272 seconds]
akaiiro has joined #crystal-lang
akaiiro has quit [Ping timeout: 252 seconds]
akaiiro has joined #crystal-lang
rohitpaulk has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> crystal doesnt have threads atm anyway so yolo? :p
<FromGitter>
<jgaskins> Well, it does, but they're undocumented. :-)
<FromGitter>
<Blacksmoke16> touche :p
<FromGitter>
<jgaskins> If coroutines can't preempt other fibers, I'm happy to recommend we use that library because it's quite small and simple, but I'm just curious if (a) it'll cause problems in production or (b) if there's another connection-pool library that handles preemptive concurrency.
<FromGitter>
<proyb6> @jgaskins Im curious what is the production app you wanted to develop?
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<proyb6> @bajro17 Regex on urls is possible but it’s safer to create a unique key value to avoid URL parameters duplication bomb
Groogy1 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter>
<bew> @dscottboggs_gitlab your first `to_json` is wrong, `abc` is not a valid json, `"abc"` is.. *just don't make the json yourself*
<FromGitter>
<bew> @woodruffw how is the string's length serialized? is it ascii numbers?
ashirase has quit [Ping timeout: 246 seconds]
<FromGitter>
<girng> omg i'm such a newb. i was doing sleep_time = 1/25 for my game loop
<FromGitter>
<girng> and was wondering why my damn cpu usage was 800% in top.. LOL
ashirase has joined #crystal-lang
<FromGitter>
<j8r> why having a sleep for a game loop?
<FromGitter>
<girng> iuno, makes creating a loop counter in intervals really easy
<FromGitter>
<girng> like, setInterval in js, can just do loop do sleep 0.04 for 25 ticks per second
<FromGitter>
<girng> i am going to need it because i needto calculate server-side collisions for example, when a player shoots a fireball. my physics loop will detect a collision and notify players
<FromGitter>
<girng> i was reading valve's article, i might use 60hz physics simulation
<FromGitter>
<chussenot> Is it possible to convert a string to a class in crystal lang ?
<Yxhuvud>
You may be able to do it compiletime or using a lookup table.
<Yxhuvud>
definitely not in a dynamic way like that
<FromGitter>
<chussenot> :)... Yet my old rubyist reflexes....
<FromGitter>
<chussenot> Oky
<jokke>
hey yall web devs! If you like to run a bare bone approach like using router.cr or something even more minimal, check out https://github.com/jreinert/paramnoia for type safe param parsing! Feedback and contributions very welcome!
<jokke>
i'd be even happier if this got embedded in one of the big players of crystal web frameworks i'm really missing type safe param parsing in most of them
<jokke>
s/frameworks/frameworks./
<FromGitter>
<bew> Nice name!
<jokke>
heh yeah i got my friend to thank for that :)
<FromGitter>
<proyb6> Nice, it does seem less to type? I haven’t seen if we could capture multi-language and add that in Readme is useful
_whitelogger has joined #crystal-lang
<FromGitter>
<proyb6> Jokke, I wonder if it handle rogue crafted a DDoS URL with hundreds of the same parameter foo=abc&foo=xyz will overload the server?
<FromGitter>
<straight-shoota> It's probably not just something for web devs, I figure it could be useful for other purposes as well...
<FromGitter>
<vladfaust> Yeah, the community has struggled for type-safe params parsing for a long time, and finally we've got this shard
<FromGitter>
<straight-shoota> And I really think we should start thinking about a more generalized serialization interface that can handle different data formats. Something like Rust's serde.
<jokke>
would be great if those could use the same interface
<jokke>
i'd also love to see optional `only` and `methods` params for to_json
<jokke>
and a `#to_named_tuple` method.
<jokke>
(also with `only` and `methods`)
<jokke>
proyb6 not sure why it would...
<jokke>
and i'd love the ability to define macro methods (methods you can call from macro context). It's super hard to write readable macros when things get a bit more complex.
<woodruffw>
i ended up parsing the length-prefix byte-by-byte (which is probably more correct than scanning anyways)
<jokke>
how so?
<jokke>
you could just use io.read_bytes(UInt64) or something
<woodruffw>
it's an ascii length prefix
<jokke>
ah
<jokke>
ic
<woodruffw>
yep, otherwise i agree ;)
<jokke>
what about gets(':') ?
<woodruffw>
yeah, that looks like it would work too
<jokke>
byte by byte parsing is usually pretty inefficient.
<jokke>
on the other hand the length prefix isn't going to be huge
<woodruffw>
well, in this case the "parser" is just checking whether each byte is in the '0' to '9' range
<woodruffw>
but yeah
<jokke>
still i think gets(':') is easier to read
<woodruffw>
mhm, i agree
<woodruffw>
i'll probably switch them (and do some performance tests, since i'm curious)
<woodruffw>
thanks!
<jokke>
then you can use UInt64.new(io.gets(':')) as this will raise if it can't parse a number. (not sure if to_ui64 would)
<woodruffw>
hmm, `UInt64` accepts numbers with leading zeros, so i still have to exclude those manually
<woodruffw>
e.g., `02:xx,` isn't a valid netstring
<jokke>
oh i see
<jokke>
well that should be easy to check though
<jokke>
after you have it in memory there's no problem going through byte by byte
<woodruffw>
mhm
<FromGitter>
<bew> indeed, if you have a buffered IO, byte per byte parsing is good, you can't do any other way! Btw, if you want blazingly fast parsing, don't create `String` objects, and only rely on `Bytes` and `Slice` methods
<jokke>
straight-shoota: i'm hitting a bit of a wall regarding PR #6912 :/ For me to detect that someone is reading from the body i'd have to modify the Content module to somehow allow injecting code before the read method. I have no idea how to elegantly do this...
<FromGitter>
<straight-shoota> You could either wrap the IO in a specific IO class that only provides that check on `read`. Or provide a method in `HTTP::Content` and use it in custom overrides of `read` in the implementing classes. I think I'd prefer the latter since these content IO's are tightly coupled to reading HTTP responses anyway.
<FromGitter>
<straight-shoota> So it's fine to put more HTTP-specific logic in them.
<jokke>
how i think i got it
<jokke>
-how
<jokke>
yeah
<jokke>
can i somehow make a kind of split memory io which will have a separate memory io for reading and writing?
<jokke>
(for specs)
<FromGitter>
<straight-shoota> `IO::Stapled`
<jokke>
nice
<jokke>
thanks
rohitpaulk has quit [Ping timeout: 272 seconds]
<jokke>
hmm if i have a class which inherits from another class and includes a module which provides another constructor, how can i differenciate which constructor should be used when using super?
return0e has quit [Read error: Connection reset by peer]
moei has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
moei has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> @bew then how do you recommend solving the problem I had?
<FromGitter>
<bararchy> Godda love OpenSSL errors: `SSL_accept: Success (Errno)`
<FromGitter>
<bew> @dscottboggs_gitlab the second was good (the one with `def to_json(builder : JSON::Builder) ....`)
<FromGitter>
<yxhuvud> Yes, they are in a special class of aweful.
<FromGitter>
<dscottboggs_gitlab> @bew oh ok thanks
akaiiro has joined #crystal-lang
DTZUZO has joined #crystal-lang
<raz>
gosh, i love crystal <3
<raz>
that feel when you condense >2k lines of messy Golang into 300 lines of super readable crystal... and it even runs faster than before
<FromGitter>
<bararchy> totally, just reviewd code from 3 devs at once, it is indeeed a pleasure to read as well as to write
DTZUZO has quit [Ping timeout: 260 seconds]
<FromGitter>
<bararchy> Yeha @drujensen I wish we can get higher accuracy with SHAInet but right now we got two things stopping us, 1. No GPU support 2. No multi-threading support, that means we are "caged" in small network and simple tests that runs for trivial times else it takes too much time to debug anything
<FromGitter>
<bararchy> Though I see the work on Fibers have been merged and this points nicely on multi-threading work coming our way, or so I hope haha
<jokke>
straight-shoota: uff.. super frustrating. my changes cause errors in the specs for chunked contend and i can't understand why... :( Here's how what i changed about http/content.cr: https://p.jokke.space/oHE8h/ and these are the errors/failures: https://p.jokke.space/sprFe/
<jokke>
i even commented out the part that calls `#expect_continue` just in case but the error keeps persistent
<FromGitter>
<straight-shoota> Oh, you changed a lot.
<FromGitter>
<straight-shoota> That looks way to complicated to me
<jokke>
as in: it should be easier?
<jokke>
*less-complicated
<jokke>
it's not that trivial
<jokke>
i could also just call send_continue from the read/read_byte/peek/skip method
<jokke>
s
<jokke>
but then i'd have to implement them everywhere
<FromGitter>
<straight-shoota> yeah, but that's much simpler than what you now have
<FromGitter>
<straight-shoota> All other relevant methods are already implemented, they just need to call the check method
<FromGitter>
<straight-shoota> *in the other types
<jokke>
hm yeah i'll give it a go
<FromGitter>
<straight-shoota> `internal_io` can just be a property
<FromGitter>
<straight-shoota> set by the processor whith `expect_continue`
Groogy1 has quit [Ping timeout: 246 seconds]
<FromGitter>
<straight-shoota> btw. `private getter` doesn't work
<FromGitter>
<straight-shoota> just use ivars
<FromGitter>
<straight-shoota> you don't need accessors for these internal state fields
<jokke>
oh
<jokke>
ok
DTZUZO has joined #crystal-lang
<FromGitter>
<jwoertink> So yesterday I was getting this `BUG: already had enclosing call` error using crystal 0.26.1. I figured out what was causing it, but it's sort of a strange error
<FromGitter>
<jwoertink> Is this an error I should submit an issue to crystal for?
<FromGitter>
<jwoertink> I'm not really sure what the error actually means, and to reproduce it for me requires a lot of moving parts
<FromGitter>
<ljuti> Can I split lib declarations to multiple files for a single C library?
<jokke>
ljuti: sure. The stdlib does this alot with libc
<FromGitter>
<ljuti> Thanks, jokke
DTZUZO has quit [Ping timeout: 244 seconds]
DTZUZO_ has joined #crystal-lang
<FromGitter>
<bew> @jwoertink yes, when it's written `BUG: ...` like this, it's definitely a bug
<FromGitter>
<jwoertink> ok. I'll try working out a smaller reproducible example. Thanks
<FromGitter>
<bew> there is #5299 with same error
<FromGitter>
<bew> see if it's same kind of code that triggeres it
<FromGitter>
<jwoertink> oh interesting. I think that might be the same thing
<FromGitter>
<jwoertink> basically I have this object that returns this Collection object. I was trying to create a Null version and just substituted the method with an empty array, and that causes the bug
<FromGitter>
<jwoertink> I figured since both respond to `#each` it would be ok, but nope
<jokke>
any idea why body is resolved to compile time type IO+ instead of Content here? https://p.jokke.space/q1H6L/
<jokke>
(Nil | IO+)
<jokke>
all of those include Content
Heaven31415 has joined #crystal-lang
<FromGitter>
<straight-shoota> jokke, see #6351
<jokke>
hm ok
non-aristotelian has joined #crystal-lang
<jokke>
straight-shoota: https://p.jokke.space/Q4k4F/ this will block forever. If i add a second empty line after the first one in the request it works. But shouldn't it work with a single empty line which would indicate that the headers are sent and what follows will be the body?
<FromGitter>
<straight-shoota> If you didn't change anything in the client response, I wouldn't expect the client response to understand the continue header
rohitpaulk has joined #crystal-lang
<FromGitter>
<straight-shoota> I'm not entirely sure what should follow that header, a single CRLF or two. I couldn't find anything in the specs...
<FromGitter>
<straight-shoota> I guess most implementations don't care
<FromGitter>
<kingsleyh> hey - what is the recommended approach for YAML in this situation?
<FromGitter>
<kingsleyh> ```undefined method 'map' for YAML::Any (compile-time type is (Array(YAML::Any) | YAML::Any))```
<FromGitter>
<HarrisonB> @fusillicode_twitter , is "trying this one" a note from you? If so, I don't see a `form` param required for that overload
<FromGitter>
<straight-shoota> @HarrisonB No, that's included in the compiler error message
<FromGitter>
<straight-shoota> that looks really weird @fusillicode_twitter
<FromGitter>
<straight-shoota> do you have a reproducible sample?
<FromGitter>
<straight-shoota> @kingsleyh Depends on what you want to do... Why is it even `Array(YAML::Any) | YAML::Any`. That doesn't make much sense to me.
<FromGitter>
<HarrisonB> @straight-shoota gotcha. ⏎ @fusillicode_twitter what version of Crystal are you on?
<FromGitter>
<kingsleyh> I guess it’s either a string or an array
Jenz has joined #crystal-lang
<FromGitter>
<straight-shoota> yeah, but where does it come from?
<Jenz>
@HarrisonB as an arch user I find it very foreign to not have the latest version of whatever :P
<FromGitter>
<straight-shoota> `Array(Any)` is usually wrapped by Any
<FromGitter>
<fusillicode_twitter> Here I am sorry for the delay gusy :( ⏎ @HarrisonB nope is the compiler that is telling me "trying this one" :)
<FromGitter>
<fusillicode_twitter> btw I'm on 0.26.1 :(
<FromGitter>
<kingsleyh> @fusillicode_twitter just as a side note - I have been using the Crest library for http and I find it very nice
<FromGitter>
<fusillicode_twitter> @kingsleyh yep I know the shard (by name) but I would really like to stick with the default if possible :(
<FromGitter>
<straight-shoota> @fusillicode_twitter I can't reproduce the error
<FromGitter>
<straight-shoota> Your code has an`},` too much in line 26
<FromGitter>
<straight-shoota> And then some calls to actually use this class are missing as well as a definition of `decision_request_body`
<FromGitter>
<mwean> Hey, how do you specify a certain compiler path? I'm on a mac, so I installed llvm with homebrew, but I'm not sure what env variables/flags to set
<FromGitter>
<mwean> It's also possible that I'm setting it correctly, but that's not fixing my error
<FromGitter>
<mwean> It only happens when I use the `--release` flag
<FromGitter>
<straight-shoota> and type of @reql should be JSON::Any not JSON::Any::Type.
<FromGitter>
<kingsleyh> hmm
<FromGitter>
<kingsleyh> the whole json aspect of the library looks like it needs re-writing
<FromGitter>
<kingsleyh> I guess it's not going to be a quick patch up job
<FromGitter>
<kingsleyh> I don't think I have time to do it - I might go to postgres or something instead
<FromGitter>
<dscottboggs_gitlab> @kingsleyh I'm not sure I get what's going on here? why isn't this code just using JSON::Serializable or JSON::Builder or JSON.mapping?
<FromGitter>
<kingsleyh> I have no idea - I have been using the library when my app was on crystal 24 - but just come back to it - and found it didn't work - so was just seeing if I could fix it up quickly - but I think the summary is - I can't - and it will need a lot more work for crystal 26
<FromGitter>
<kingsleyh> I only have a small grasp on how it works at the moment - but I don't really want to start supporting another project - I've got loads of stuff going on already
<FromGitter>
<kingsleyh> yeah it's pretty much dead at this point
<FromGitter>
<dscottboggs_gitlab> I'm sure someone will come along and pick up either that or another nosql driver at some point. I know some projects use postgres which is a bit of a different game but relational always seemed to make more sense in strictly typed code anyway.
<FromGitter>
<kingsleyh> I think postgres can also work like a nosql db
<FromGitter>
<dscottboggs_gitlab> oh wow that's really cool I didn't know that
<FromGitter>
<straight-shoota> yes, postgres is really awesome in almost any regard. I sometimes wonder why there are even *different* databases out there :D
<FromGitter>
<kingsleyh> I don't know if crystal driver supports the nosql features of postgres tho
<FromGitter>
<straight-shoota> it supports both json and jsonb data type
<Jenz>
Again, @straight-shoota I've just gotta thank you for being such a nice and helpfull fellow :D
<FromGitter>
<kingsleyh> hmm or maybe I should give Amber a try with Granite
<FromGitter>
<kingsleyh> or maybe just Granite
<FromGitter>
<straight-shoota> thanks, Jenz. I try to help when I can =)
baweaver is now known as lemur
lemur is now known as baweaver
lunarkitty has quit [Quit: WeeChat 1.9.1]
Jenz has quit [Ping timeout: 245 seconds]
<FromGitter>
<HarrisonB> @fusillicode_twitter no problem. It happens to me *all the time* lol. It's even more common in Elm if you've given that lang a shot
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter>
<Timbus> I believe custom signal handlers need to be yielded to, in order to work (so adding a sleep to the loop would fix it). And the reason it works without the trap is because the default handler doesn't work the same way
scott_tams has joined #crystal-lang
<FromGitter>
<straight-shoota> yup, `loop { }` is a tight loop and never yields control so that the signal loop can't process the handler.
<FromGitter>
<straight-shoota> When you don't trap the signal the OS will terminate it immediately.