ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
alex`` has quit [Ping timeout: 248 seconds]
<FromGitter> <Blacksmoke16> anyone know how to delete a cookie?
<FromGitter> <Blacksmoke16> @tenebrousedge i tried setting it to time in the past and didnt do anything
<FromGitter> <Blacksmoke16> or at least i just cant override the cookie...
<FromGitter> <watzon> oprypin could you explain what's happening there?
<oprypin> then im trying to automatically find issues of this type
<FromGitter> <watzon> Ahh very interesting
<FromGitter> <watzon> Oh I posted this yesterday but I don't think any core devs saw it. Is this a bug? ⏎ ⏎ ```20.times.do |i|``` [https://gitter.im/crystal-lang/crystal?at=5d004ec123ebdc57c3dae8c8]
<FromGitter> <watzon> Oh I posted this yesterday but I don't think any core devs saw it. Is this a bug? ⏎ https://carc.in/#/r/725n
<FromGitter> <Blacksmoke16> i managed by setting the value to an empty string
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <watzon> For some reason `Random.rand` with a range of `Float64::MIN` to `Float64::MAX` always returns Infinity
<oprypin> well the thing is MAX = infinity
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Blacksmoke16> that would do it
<FromGitter> <watzon> And MIN is -Infinity isn't it?
<oprypin> and technically the answer is correct then lol
<oprypin> pick a random number up to infinity
<oprypin> yep that's infinity
<FromGitter> <watzon> But it works with Int64::MAX and MIN
<oprypin> they're not equal to infinity
<oprypin> like literally `p Float64::MAX`
<FromGitter> <watzon> I guess it makes sense when put that way
<FromGitter> <watzon> I guess if you wanted a Float you'd have to do `Random.new.rand(Int64::MIN..Int64::MAX).to_f`
<oprypin> uhhhhh
<oprypin> that's a very arbitrary range
<oprypin> why would you ever specifically want a float between -2**31 and 2**31
<oprypin> actually is **63
<oprypin> how about -1e100..1e100
<FromGitter> <watzon> That would work
<FromGitter> <watzon> Really I was just mainly wondering if that was a bug
<FromGitter> <watzon> But it makes sense now
<oprypin> there's probably at least one bug there, yeah
<oprypin> but for that specific case it's hard to expect a different behavior
<oprypin> cuz maybe it should return minus infinity in half of the cases?
<oprypin> who knows lol
<oprypin> ah dang, in latest version of Crystal it's no longer equal to infinity!
<oprypin> then there's some overflow happening
<oprypin> and it's just a really difficult bug then :>
<oprypin> https://crystal-lang.org/api/0.24.1/Float64.html is different from latest
<FromGitter> <watzon> So it is a bug
<FromGitter> <watzon> Should I go ahead and create an issue?
faitswulff has quit [Remote host closed the connection]
<FromGitter> <bcardiff> Hi! I'm looking for some apps repositories using crystal (apps, not shards libraries) to check some build stuff. I would like to check it with some repos I don't know :-) . As long as it's a linux app (cli, webserver, image processing) it should be fine. Send PM of @ with the repo if you can. Thanks!
laaron- has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <bcardiff> @rkeene does it has a manual / configuration I would need to know?
<rkeene> No, it has no configuration at all
<FromGitter> <bcardiff> ok, thanks! I guess I will need to read the source. to know if it works further than building :-)
<rkeene> Anything specifically you are looking for ? I have a few things I haven't published
<FromGitter> <watzon> Pretty printing of matrices working :)
<rkeene> I was working an SSH Agent daemon that used Duktape to run my JavaScript-based SSH Agent ported from ChromeOS but I've since abandoned Crystal for it
<FromGitter> <bcardiff> I would say that apps that a end-user could want to use. Or something that will require small context/environment. My best sample is https://github.com/manastech/benchy a CLI tool that given a config (in yaml ) does something and exit
<FromGitter> <bcardiff> So, an app that could appear in a store for someone to download and use it.
<rkeene> bcardiff, Why ?
<FromGitter> <bcardiff> Because I am at https://snapcraft.io/blog/snapcraft-summit-montreal
<rkeene> I'm not a fan of users
<FromGitter> <watzon> Lol
<FromGitter> <bcardiff> 😂
<FromGitter> <watzon> Jealous @bcardiff
<FromGitter> <watzon> Damn Canadians having all the fun
<rkeene> I'm pretty sure I'm the only user of most of my software, it's handy
<FromGitter> <watzon> I'm definitely the opposite, I love creating things for other people to use
<rkeene> I just want to solve problems I'm having
<rkeene> I just have unique problems, apparently
<FromGitter> <bcardiff> @rkeene usually the problems are shared, the challenge is finding the audience (or finding another approach that is shared among others). But doing software for yourself is definitely good.
blassin2 has joined #crystal-lang
blassin has quit [Ping timeout: 246 seconds]
faitswulff has joined #crystal-lang
<rkeene> bcardiff, Tangentially related to your conference is AppFS: http://appfs.rkeene.org
<FromGitter> <bcardiff> but that is not written in crystal, or am I missing somthing?
<rkeene> But it is related to the conference topic
<rkeene> (It makes the number of steps before running software lower -- specifically to 0, where snaps still require you to install the snap. With AppFS, you just run it and any dependencies are pulled in -- but it doesn't handle sandboxing, but sandboxing can be built on top of it)
<FromGitter> <watzon> I think @bcardiff is looking for projects specifically written in Crystal rkeene
<FromGitter> <watzon> I'd say to use my Tourmaline library, but you'd have to set up a telegram bot to run the examples
<FromGitter> <bcardiff> Oh! I see rkeene. But it might be beyond my limits and knowledge :-)
<FromGitter> <bcardiff> @watzon is an end up or I need to code to use it?
<FromGitter> <watzon> You could for the repo and run the examples with little to no code. All you need is an API key which you can get from @BotFather on Telegram
faitswulff has quit []
Seich has quit [Ping timeout: 250 seconds]
Seich has joined #crystal-lang
<FromGitter> <bararchy> oprypin That's really cool!
rohitpaulk has joined #crystal-lang
yield has joined #crystal-lang
<oprypin> thx :>
rohitpaulk has quit [Remote host closed the connection]
flaviodesousa has joined #crystal-lang
<FromGitter> <j8r> @bcardiff don't know if it fits your needs, on my side I have: ⏎ ⏎ 1) a text editor: https://github.com/j8r/cride ⏎ 2) a server app installer/manager: https://github.com/DFabric/dppm (and currently woking on a REST API) [https://gitter.im/crystal-lang/crystal?at=5d00a8098655842639e59c9d]
DTZUZU has quit [Ping timeout: 252 seconds]
yield has quit [Remote host closed the connection]
DTZUZU has joined #crystal-lang
<FromGitter> <mamantoha> @bcardiff https://github.com/crystal-community/icr
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
ashirase has quit [Ping timeout: 246 seconds]
ashirase has joined #crystal-lang
<oprypin> im looking for some really basic storage solution
<oprypin> sqlite would be perfect if it wasn't, u know, sql
<oprypin> right now i'm considering dumping a bunch of json files
<oprypin> glad to see the healthy situation in here tho :> https://github.com/crystal-lang/crystal-sqlite3/commits/master
<FromGitter> <j8r> RocksDB?
<oprypin> thanks for suggestion. i realize that i might be impossible to satisfy, though. i suppose it would need to be tightly integrated with Crystal
<FromGitter> <dscottboggs_gitlab> @oprypin holy crap those fuzz results
<FromGitter> <r00ster91> Is there a difference between ⏎ ⏎ ```HTTP::Client.post("url/path", headers, json)``` ⏎ ⏎ ? ... [https://gitter.im/crystal-lang/crystal?at=5d00e68a17fefb263b08ae72]
<FromGitter> <bararchy> yes
<FromGitter> <bararchy> there is a tricky difference
<FromGitter> <bararchy> the non oo style will need the full URL, the oo one will only want the path (uri.full_paht)
<FromGitter> <Blacksmoke16> make sure you dont include the protocol on the first one @r00ster91
<FromGitter> <Blacksmoke16> "google.com" not "https://google.com"
blassin2 has quit [Quit: The Lounge - https://thelounge.chat]
blassin has joined #crystal-lang
<FromGitter> <Blacksmoke16> also if you want to use https do like `HTTP::Client.new("google.com", 443, true)`
duane has joined #crystal-lang
<jokke> or more verbosely `tls: true`
<FromGitter> <r00ster91> aaaah
<FromGitter> <r00ster91> thanks
<z64> @r00ster91 the difference is whether or not you want to re-use a single connection for multiple request. if you make an instance of a client, a single tcp connection will be used; using the class methods will use a new connection each time
<FromGitter> <r00ster91> ooh.. I have 4 other `HTTP::Client.get(...)`s in my code. maybe I should all turn them into object versions so not a new connection is made every time (probably faster)
<z64> if you're doing them sequentially, it's probably a good idea. if they can happen "randomly" with any amount of time in between, its fine to connect when needed
<FromGitter> <Blacksmoke16> i always made an obj version tied to a constant and used the const everywhere...
<FromGitter> <r00ster91> oh well then I will leave it all as needed because the requests all happen on request
<FromGitter> <r00ster91> s/as needed/as-is
<z64> @Blacksmoke16 that can be fine, but you can block concurrent operations that way, if thats important to you
<FromGitter> <Blacksmoke16> prob fine for now
alex`` has joined #crystal-lang
<FromGitter> <mwlang> How do I check a specific class is assigned to a variable? ⏎ ```response.is_a?(Cossack::Response) ? response.body == "{}" : false``` gives me this error: "undefined method 'body' for Nil (compile-time type is (Cossack::Response | Nil))"
<FromGitter> <Blacksmoke16> well that doesnt make sure `response `isnt nil
<FromGitter> <Blacksmoke16> hence your error
<FromGitter> <mwlang> because of the union possibilities?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d010340209ae3263ab717b8]
<FromGitter> <Blacksmoke16> try that
<FromGitter> <mwlang> same error.
<FromGitter> <mwlang> ```code paste, see link``` ⏎ ⏎ also produces same error. [https://gitter.im/crystal-lang/crystal?at=5d0103a3c2e5ba268ce528f6]
<FromGitter> <Blacksmoke16> (r = response) && r.is_a?(Cossack::Response) ? r.body : false
<FromGitter> <Blacksmoke16> one liner
<FromGitter> <mwlang> ok, that variation worked.
<FromGitter> <mwlang> so what am I missing here?
<FromGitter> <Blacksmoke16> response can either be Nil or a Cossack::Response
<FromGitter> <z64> what is `response`? is it a method or a variable
<FromGitter> <Blacksmoke16> id imagine its the var from a like `HTTP::Client.get`
<FromGitter> <mwlang> response is a property on the class, ```property response : Cossack::Response?```
<FromGitter> <Blacksmoke16> oh, well that would do it
<FromGitter> <z64> okay, so its a method - when you call a method, it will be fully typed because crystal can't know that it will return the same thing every time. assigning it to a local variable first will only call the method once, allowing the type `Nil` to be removed from the union with the ternary expression
<FromGitter> <Blacksmoke16> same reason why you have to do like `if val = @value`
<FromGitter> <Blacksmoke16> id imagine?
<FromGitter> <Blacksmoke16> since its just a getter of the underlying ivar
<FromGitter> <mwlang> Ah, I haven't encountered that problem yet, @Blacksmoke16
<FromGitter> <mwlang> thanks, @z64 -- that explains it well.
<FromGitter> <mwlang> unlearning some Ruby here.
<jokke> :)
<FromGitter> <z64> @Blacksmoke16 yeah it's a similar reason, but the implementation of the getter doesn't matter here; this would happen with any method call that returns a union. in the case of `@var`, they are always fully typed because its value could be any one of its types each time you observe it, so to speak
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <cserb> Hey, can someone explain this to me: https://play.crystal-lang.org/#/r/727e ⏎ ⏎ Why isn't the Fiber continued
<FromGitter> <z64> the `sleep 1` keeps the main fiber alive for a second. the `Fiber.yield` allows a context switch to occur, but once that happens execution returns back to the main fiber - the only thing it has left to do is to `puts "MORE STUFF"`, and then the main fiber is done so the program exits
<FromGitter> <z64> if you want to block and wait for another fiber to complete, you can use a Channel to communicate with the main fiber
<FromGitter> <cserb> Yes, I have a heavy CPU task (similar to the one in the example) and I want it to take a break to switch context and than resume
<FromGitter> <cserb> Not sure I understand how this would work with Channels
<FromGitter> <mwlang> very happy this morning...I got a basic VCR record/playback working for specs using webmock tom accomplish goal: https://github.com/mwlang/binance/blob/master/spec/support/vcr.cr
<FromGitter> <mwlang> One thing I could not figure out was how to pass a block given in one method call to another. So I ended up doing the yield from the first method call ```with_vcr_cassette``` -- it took a little rethinking of how I would normally have done this in Ruby, but fortunately, webmock's wrap and callback approach made it doable.
<FromGitter> <mwlang> So I am wondering...is it possible to pass a block along? I sort of kind of got close, I think, but my attempts led me to believe implementing such required knowing the return type of the methods for the &block variable.
<FromGitter> <Blacksmoke16> you dont actually `_need_` the `&block` arg
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/727j
<FromGitter> <Blacksmoke16> but is helpful to document that it has one, and to do typing
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/syntax_and_semantics/block_forwarding.html is prob what you want tho?
<FromGitter> <mwlang> ah, ha! ```block.call``` instead of ```yield``` in later methods
<FromGitter> <mwlang> that was the mistake I was making.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <mwlang> for what it's worth regarding vcr playback capability, I'm offering to submit PR for it on webmock shard: https://github.com/manastech/webmock.cr/issues/33
moei has joined #crystal-lang
<FromGitter> <mwlang> oh, now I find it despite probably half an hour hunting for a vcr re-implementation: https://github.com/vonKingsley/hi8.cr
<oprypin> what CI systems do people use these days? circleci is being advertised by core team but i don't get why it's considered better necessarily
<FromGitter> <Blacksmoke16> i just use travis
<z64> i've preferred circle because its ridiculously faster and the configs feel more intuitive/composable
moei has quit [Ping timeout: 245 seconds]
<FromGitter> <Blacksmoke16> prob also depends on the complexity of your projet
<z64> your CI setup is just built on top of docker so you can do whatever you like with it. and you don't run into issues like this - https://github.com/travis-ci/travis-ci/issues/8537
<oprypin> so have they actually removed "language" support? you always directly reference docker?
<FromGitter> <Blacksmoke16> no, can still do `language: crystal`
<jokke> oprypin: i use gitlab ci and i love it
duane has quit [Ping timeout: 248 seconds]
<jokke> oprypin: i havent tried circle but i _hated_ travis.
<jokke> i think gitlab ci is very flexible. You can install runners on pretty much anything (the runner is written in golang) and compile natively on mac for example or windows or arm or whatever
<jokke> or - and this is what i mostly do - just use docker containers for the scripts to run in
<z64> sorry if my last message was confusing - i was referring to circle configs being based on docker, not travis. and yeah - i maintain a ruby library where we use travis and we run CI against all supported ruby versions. it takes like 10min, minimum, to complete
<z64> build times can vary +/-5min
<z64> sometimes provisioning just takes forever
<oprypin> @Blacksmoke16: why isnt that the recommended way then?
<FromGitter> <Blacksmoke16> hm?
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<alex``> How about adding a 'master' version of the API documentation?
<FromGitter> <kinxer> Like https://crystal-lang.org/api/master/ ?
<alex``> yep
<FromGitter> <kinxer> You were referring to the Crystal API docs, right?
<alex``> Sometimes I want to link a module not linked to its version, and remove the version part, like: https://crystal-lang.org/api/0.29.0/YAML.htmlhttps://crystal-lang.org/api/YAML.html, the site resolves to puts the version missing part in it
<FromGitter> <kinxer> Well, you can use https://crystal-lang.org/api/master/ in that case, if that's what you really want.
duane has joined #crystal-lang
<alex``> another use case, is I saved a bunch of pages in my bookmarks and they are not accurate now
<alex``> they are 0.17 or something
<alex``> wow
<alex``> didn’t know /master/ was a thing
<z64> which is probably what you want; master is unstable docs
<alex``> latest versus master?
<alex``> z64
<z64> latest will redirect to the latest release. master is the latest code on github
<alex``> latest resolve to 0.29.0 to me
<alex``> I want to save my bookmarks for example
<alex``> but if it resolves to a fixed version..
<z64> yes. you'd have to edit the bookmark to point to /latest/
<z64> so the next time you click on it, it will resolve again to the current version
<alex``> what if "officially" supported?
<alex``> is "2." wrong?
<alex``> (it works though)
<z64> #2 looks like it is the same as /latest/
<alex``> this resolve is a feature or a borderline behavior?
<z64> feature, i guess
<alex``> if I link this type of link, I would like to be sure it will not break later
<z64> it should be fine to use those links; the only time they will break is if the API changes - like if YAML was removed
<FromGitter> <kinxer> Yeah, I'd generally say that z64's suggestion (https://crystal-lang.org/api/latest/) would be better, since it's a stable release.
<FromGitter> <kinxer> I'd forgotten it exists.
<FromGitter> <kinxer> And I prefer that over your option 2 because it's explicit in the URL that it's the latest release.
<FromGitter> <watzon> How is it that C# gets away with this shit? https://github.com/eabdullin/Word2Vec.Net/blob/master/Word2Vec.Net/Word2Vec.cs#L161
_whitelogger has joined #crystal-lang
<FromGitter> <r00ster91> what's wrong? I don't really see it
<FromGitter> <r00ster91> oh wait
<FromGitter> <r00ster91> is that thing like a weak hash function? https://github.com/eabdullin/Word2Vec.Net/blob/master/Word2Vec.Net/Word2Vec.cs#L174
<FromGitter> <watzon> Translating that into Crystal it becomes an infinite loop
<FromGitter> <r00ster91> oh
<FromGitter> <watzon> I think so. For some reason they're building a hash of words using multiple arrays instead of a hash table. I think it's because they want it to be sortable, but it makes things so complicated.
<FromGitter> <r00ster91> you can do it better in Crystal
<FromGitter> <watzon> I feel like I can haha
<FromGitter> <watzon> But deciphering that C# is a pain in the ass
<FromGitter> <watzon> Thank you :) I thought it would improve the API a bit
<FromGitter> <mwlang> makes me happy I'm not doing C# coding. :-D I ditched .Net in, oh...2002, I think...it was still in "beta" at the time and so full of bugs, it was not even funny.
<FromGitter> <watzon> Now it just looks like Microsofty Java
<FromGitter> <mwlang> nice find @kinxer -- I agree and I'm totally stealing that idea.
<FromGitter> <watzon> Glad you guys like it 😸
<FromGitter> <j8r> Any idea how to handle multiple errors in Kemal, or other web frameworks? We would like to implement https://jsonapi.org/examples/#error-objects-multiple-errors
<FromGitter> <Blacksmoke16> id imagine you'd have to have some code to validate the request with some manual logic?
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
<FromGitter> <watzon> @j8r I believe you want something like the `ExceptionHandler`. Then attach it with this http://kemalcr.com/docs/Kemal/Config.html#add_error_handler%28status_code%3AInt32%2C%26handler%3AHTTP%3A%3AServer%3A%3AContext%2CException-%3E_%29-instance-method
<FromGitter> <Blacksmoke16> in Athena you could prob define a custom exception that accepts an array of `Exception`, then define a custom `handle_exception` that would render it
<FromGitter> <j8r> `ExceptionHandler` doesn't have a notion of error stack
<FromGitter> <Blacksmoke16> could maybe have a class var that is an array of errors
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> with a handler for each error case
<FromGitter> <Blacksmoke16> then one final that renders all the errors on the stack, then resets it
<FromGitter> <watzon> ExceptionHandler itself doesn't, but you can write a handler that catches multiple errors
<FromGitter> <j8r> We had a solution like this, that was monkey patching Context
laaron has quit [Client Quit]
<FromGitter> <j8r> Thanks, yes it may do the job
<FromGitter> <j8r> I think we could also use the `@cause` inside the `Exception` to build the JSON errors list
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Client Quit]
<FromGitter> <watzon> How to you get a `Char` from it's ord?
laaron has joined #crystal-lang
<FromGitter> <watzon> Never mind, finally found `Int#chr`
laaron has quit [Client Quit]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<rkeene> In BASIC it's CHR$(), if that helps
<FromGitter> <Blacksmoke16> he already found it
<FromGitter> <Blacksmoke16> you just call `.chr` on the `Int32` val
<FromGitter> <watzon> Hahaha BASIC does definitely not help, but thanks rkeene
<rkeene> Blacksmoke16, Sounds just like BASIC to me
<FromGitter> <Blacksmoke16> in that the method
<FromGitter> <Blacksmoke16> in that the method's name is the same i guess
<rkeene> thatsthejoke.jpg
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
DTZUZO has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
rkeene has left #crystal-lang [#crystal-lang]
<oprypin> the identifier "parse_or" has 2 occurences in the entire codebase but both of them are *usages*, not definitions
<FromGitter> <watzon> Very good question
<oprypin> neevermind, right below it's `def parse_{{name.id}}`
alex`` has quit [Ping timeout: 244 seconds]
alex`` has joined #crystal-lang
greengriminal has joined #crystal-lang