return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
<FromGitter>
<neutrinog> @kinxer ⏎ ⏎ > @neutrinog `Prism::Common::Objects::Plain` is cheeky but should probably be renamed to have the correct spelling. :P ⏎ ⏎ Haha probably. I'm currently learning another spoken language so I might be mixing up some of my english ;) [https://gitter.im/crystal-lang/crystal?at=5e95195d1aaf8e4b8e7f0af4]
<FromGitter>
<straight-shoota> But yeah, there are awesome possibilities :D
postmodern has quit [Quit: Leaving]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
<FromGitter>
<naqvis> Will performing `Time.measure` in Fiber going to yield correct results? provided there is some kind of IO activity involved?
<FromGitter>
<naqvis> i'm seeing some interesting results where time measured in Fiber is showing different value then the total execution time, captured in main running thread.
<FromGitter>
<straight-shoota> @naqvis Time.measure just takes a measurement from monotonic clock before and after executing the block. So the result should always correctly represent the time spent in the block.
<FromGitter>
<straight-shoota> If you're using fibers, maybe some fibers continue outside the block?
<FromGitter>
<straight-shoota> Can you show some example what you mean?
<FromGitter>
<naqvis> so what i should be using is `total_milliseconds` instead, as I misunderstood the `milliseconds` lol
alexherbo2 has quit [Ping timeout: 250 seconds]
alexherbo24 is now known as alexherbo2
<FromGitter>
<naqvis> yeah @stronny docs are some what confusing, at least to me
<repo>
jhass: i also soooo wish there was some kind of pretty output for timespan which would determine the unit that's most suitable (e.g. the first unit that's > 1)
<FromGitter>
<stronny> they are clear to me, they just disagree wuth @repo =)
<repo>
i have implemented this for logging so many times
<FromGitter>
<naqvis> lol
<jhass>
can always issue and PR to suggest it :)
<repo>
yeah
<repo>
do you guys know the docs for devdocs are updated?
<FromGitter>
<stronny> I fail to see how int rounding would be a problem here
<repo>
stronny: because of what i posted up there
<repo>
"Time elapsed: %ds %dms %dns"
<repo>
or to make it clearer: "Time elapsed: %d:%d:%d.%d"
<repo>
if the values were rounded it would be plain wrong
<FromGitter>
<stronny> you will have "Time elapsed: 1s 234ms 234567890ns", does that make sense?
<repo>
hm yeah you're right. it doesn't... i too was confused about the output of the methods it seems
<repo>
its clearly not 0..999
<repo>
so none of it makes sense :D
<FromGitter>
<stronny> so rounding seems appropriate
<repo>
no
<repo>
returning 0..999 seems appropriate
<repo>
you can use total_* for rounding
<FromGitter>
<stronny> I have a solution: drop the helper methods!
<repo>
i'd like to hear one of the core devs to explain the behavior of those methods
<repo>
maybe i'm missing something
<repo>
so it seems to me that the methods always return the fraction relative to a second. Not relative to the next bigger unit
<repo>
which does seem kind of pointless
<repo>
straight-shoota: any thoughts?
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo21 is now known as alexherbo2
kevinsjoberg has quit [Ping timeout: 240 seconds]
kevinsjoberg has joined #crystal-lang
deavmi has quit [Quit: No Ping reply in 180 seconds.]
teardown has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter>
<straight-shoota> > it seems to me that the methods always return the fraction relative to a second. ⏎ ⏎ Yes, that's how it works.
<FromGitter>
<straight-shoota> I suppose the idea behind that is that you often combine it with the seconds+ parts and only need subsecond precision to some extend.
<FromGitter>
<straight-shoota> But I see how this might be confusing.
<FromGitter>
<straight-shoota> A trivial solution would be to simply remove `microseconds` and `milliseconds`. I'm not sure whether there are actually relevant use cases for them.
<FromGitter>
<stronny> well if you don't remove them how about rounding the values?
<FromGitter>
<straight-shoota> Yes, if we keep them they should be rounded
darkstardevx has quit [Read error: Connection reset by peer]
<wmoxam>
~
<FromGitter>
<kinxer> I was going to object to removing `#microseconds` and `#milliseconds`, but I realized that I thought they did what `#total_microseconds` and `#total_milliseconds` do... I also can't think of a good use case for the former two methods.
<oprypin>
right
skrzyp has joined #crystal-lang
<skrzyp>
Hello. I would like to ask about Kemal - I know this is not a 100% correct place to do so, but closest one I can find as I really don't want to get into these bloated and weird Gitter rooms.
<FromGitter>
<Blacksmoke16> what about it?
<skrzyp>
Does anyone know how to catch a route with parameter being a part of the path, including "/", like `get "/foo/:bar"` but with 'env.params.url["bar"]' containing the rest of the path with all its elements
<skrzyp>
Currently Kemal throws 404 in such case
<FromGitter>
<Blacksmoke16> i think that would have to be a feature request
<FromGitter>
<Blacksmoke16> whats the use case/
<FromGitter>
<Blacksmoke16> actually
<FromGitter>
<Blacksmoke16> try like `get "/foo/*bar"`
<skrzyp>
I'm doing something like a middleware for my private file hosting exposed publicly with various stuff. Not confidental at all, but I've got quite tired with giving all people the same basicauth creds and having access to all the data stored, mostly because they start to hard stuff. So I've got an idea to implement completely anonymous "tokens" with filepaths assigned to it (that's the only
<skrzyp>
data I store, 100% gdpr compliance lol) and share them for specified people
<skrzyp>
then someone can do "wget myserver.com/token/0000BEEF/photos/2020/staying-at-home.zip" and it'll reply with correct file
<FromGitter>
<Blacksmoke16> wouldnt a header/query pram make more sense here?
<skrzyp>
of course I would use X-Accel-Redirect to let HTTP server serve that instead of letting crystal HTTP server to lift the havy files
<skrzyp>
Header/query might work, but I wanted to make these URLs nice and accessible for users who don't know much about HTTP
<FromGitter>
<Blacksmoke16> `?token=FOO` and call it a day
<skrzyp>
yeah, then someone's gotta encode paths with %2D on its own, good
<FromGitter>
<Blacksmoke16> and ofc if no token is provided either only allow it to access public stuff, or 401 if trying to access non public
<FromGitter>
<Blacksmoke16> why would they need to do that?
<skrzyp>
Just because if file is "photos-2020.zip" and I share the link, I might add token access for "photos-2019.zip" and tell the person just to change the year in path. With query encoded pathss it might get a bit problematic
<skrzyp>
Also, REST-style paths are actually looking better to everyone
<FromGitter>
<Blacksmoke16> sorry, to be clear i mean just pass. the token as a query param, but keep everything as a path
<FromGitter>
<Blacksmoke16> as yea, normally a token isnt part of the path
<skrzyp>
ohhh
<skrzyp>
okay then
<FromGitter>
<Blacksmoke16> header is most common, query param if a header cannot be used
<skrzyp>
but passing just "myserver.com/token/0000BEEF/" is intended to throw a filelist of all available files for that user
<skrzyp>
As I should compare if requested file "/foo/bar/baz.zip" is within the path of "/foo/bar/". String matching might work unles someone gets smart with ".." and other path traversal tricks
<skrzyp>
so if that Path object is comparable it might actually help
<FromGitter>
<lbarasti> Hello 👋 I'm trying to port some code to 0.34.0. The following raises a warning ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ How would you change this to not have the warning and to also not have a meaningless `else`? Can I avoid `if a == true`? ... [https://gitter.im/crystal-lang/crystal?at=5e96052cc52b6a38abe7a0d7]
<FromGitter>
<Blacksmoke16> make `a` not nilable, or add an empty `else`
<FromGitter>
<Blacksmoke16> its warning because the case isn't handling `nil`
<FromGitter>
<Blacksmoke16> er, nvm you wanted to avoid that...
<FromGitter>
<lbarasti> It's OK :)
<FromGitter>
<Blacksmoke16> id go with if/else otherwise
<FromGitter>
<lbarasti> all right, I'll just bite the bullet
<FromGitter>
<tenebrousedge> making `a` not nilable is good too
<FromGitter>
<Blacksmoke16> ^
<FromGitter>
<lbarasti> well, there are legitimate use cases for making `a` nillable
<FromGitter>
<Blacksmoke16> if `a` is not nilable you can just do `puts a ? "A" : "B"` and call it a day
<FromGitter>
<Blacksmoke16> fair enough
<FromGitter>
<lbarasti> especially if it represent a boolean flag
<FromGitter>
<tenebrousedge> `a.try {|t| t ? "A" : "B" }`
<FromGitter>
<lbarasti> :light-bulb:
<FromGitter>
<Blacksmoke16> 👏
<FromGitter>
<lbarasti> that takes the `nil` out of the picture! Thanks, let's see if the shard owner thinks :)
zorp has quit [Ping timeout: 256 seconds]
<FromGitter>
<bararchy> @asterite hm... I don't think I own any slack other then our company one, but i'll make sure
<FromGitter>
<bararchy> Oh ...yes no clue how but i'm the workspace owner? I guess I was the last one left? hahaha
<FromGitter>
<sam0x17> how do I manually pass a proc to a method that takes a block?
<FromGitter>
<tenebrousedge> `&` ?
<jhass>
the_method(&the_proc)
<FromGitter>
<tenebrousedge> `method(&my_proc)`
<FromGitter>
<watzon> Hmm so I decided to profile a program using valgrind's massif and it seems like openssl is the biggest memory user
<FromGitter>
<sam0x17> thx
<FromGitter>
<watzon> If I could get my stuff to stop using openssl I think my memory usage for my program would be in the hundreds of kilobytes instead of almost 10MB
<FromGitter>
<watzon> Unfortunately it doesn't seem as though you can get away with using HTTP::Client and not having the openssl dependency
<FromGitter>
<watzon> Even though tls is off
<FromGitter>
<Blacksmoke16> isnt there a flag for that
<FromGitter>
<Blacksmoke16> `-D without_openssl`
<FromGitter>
<watzon> Well yeah, but the HTTP client doesn't work without it haha
<FromGitter>
<watzon> Looks like the problem may actually be in zlib though
<skrzyp>
Hmm, if I want to create a type which acts as a string (and is represented as string in arrays, can be compared and so on) but has its own properies and methods, how to do that properly?
<FromGitter>
<Blacksmoke16> for your `can be compared` requirement
<skrzyp>
that's better than I imagined
<skrzyp>
neat
<FromGitter>
<Blacksmoke16> 👍
<jhass>
sharing a patch as a screenshot of gitk, that's a first for me
_ht has quit [Quit: _ht]
<FromGitter>
<asterite> same :-)
<FromGitter>
<bararchy> We just released `Wafalyzer` an opensource CLI tool to detect if a website sits behind a WAF and which WAF it is -> https://github.com/NeuraLegion/wafalyzer
<FromGitter>
<bararchy> All in Crystal ofc :)
<skrzyp>
logo.cr :D
<skrzyp>
btw. seems like `sdl` examples are broken in Crystal's master, throwing OverflowError from sdl/surface.cr:27:57 in '[]=' and dl/surface.cr:31:5 in '[]='
ur5us has joined #crystal-lang
<FromGitter>
<j8r> @bararchy yay, nice :) Interested about your use case a NeuraLegion?
postmodern has joined #crystal-lang
<FromGitter>
<watzon> Good stuff @bararchy!
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
<FromGitter>
<bararchy> @j8r it's to detect if a target being scanned has a WAF online that might affect the scan results :)
<FromGitter>
<bararchy> thanks @watzon !
ur5us has quit [Ping timeout: 256 seconds]
<hightower2>
Hey is there an even more shorthand notation for somevar.try &.method, or that exists only in Ruby?
<hightower2>
(like somevar&.method or similar)
<FromGitter>
<tenebrousedge> only in Ruby
<hightower2>
danke
alexherbo25 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo25 is now known as alexherbo2
alexherbo2 has quit [Remote host closed the connection]
<hightower2>
Do we have any preferred shard for curl bindings?
<hightower2>
I am looking at https://github.com/kostya/curl-downloader . There is a note that using libcurl will block the main thread. Is it really that run_with_fork (which literally calls 'fork') is necessary and it can't be done with fibers?
<FromGitter>
<asterite> why not use http client?
<hightower2>
well I assumed that HTTP::Client does not have support for sessions (which take advantage of keep-alive)
<hightower2>
or rather, I see it has something similar, but requires me to manually implement reusing a client for pages in the same domain. OK.
zorp has joined #crystal-lang
<FromGitter>
<straight-shoota> oprypin, I hope you had a least a lot of fun with your super-fancy refactor ;)
<hightower2>
If I have an int variable and do 'var += ' from fibers, is this thread-safe or I need to Mutex.synchronize it ?