RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.1 | 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
<FromGitter> <drewbharris> hello! would anyone be able to point me in the right direction here: https://play.crystal-lang.org/#/r/3k11
<FromGitter> <drewbharris> (expecting that to be true, i must be missing something)
duane has quit [Ping timeout: 240 seconds]
maattdd has joined #crystal-lang
<FromGitter> <bew> No, you can't retrive the original password from the hashed password
<FromGitter> <drewbharris> i'm not trying to - i'm trying to compare the hashed original password with the previously hashed value
<FromGitter> <drewbharris> think i figured it out though
maattdd has quit [Ping timeout: 260 seconds]
<FromGitter> <bew> To check if the supplied password is correct, you need to encrypt it, and check that the 2 hashed version are the same (the one you just did, and the one you woukd have stored in a database)
<FromGitter> <drewbharris> right - i think it was just my syntax. thanks!
<FromGitter> <bew> I don't understand what you were trying to do though
<FromGitter> <drewbharris> ok, added some more comments: https://play.crystal-lang.org/#/r/3k17
<FromGitter> <drewbharris> trying to hash the user's signup password, store the hash in the db, then later hash what the user provides at login and compare that with what's in the db, but i must be missing something
<FromGitter> <bew> Maybe you're missing a to_s on hashed_login_password ?
<FromGitter> <bew> What are you doing line 17?
<FromGitter> <drewbharris> https://play.crystal-lang.org/#/r/3k1a
<FromGitter> <drewbharris> line 17 is parsing the stringified original hash (imagine that's coming from the database)
<FromGitter> <bew> note: don't need to use `"#{a_string}"` you can simply pass the string to the function
<FromGitter> <drewbharris> ah k
<FromGitter> <drewbharris> (same result, of course)
<FromGitter> <drewbharris> i'm just not clear on why, when i hash the same password a second time, i'm getting a different hash
<FromGitter> <drewbharris> if that's the case, then i can't really compare them
cremes has joined #crystal-lang
<FromGitter> <bew> did you look at the first example in https://crystal-lang.org/api/0.24.1/Crypto/Bcrypt/Password.html
<FromGitter> <bew> hm nevermind
<FromGitter> <drewbharris> yeah, but that doesn't really include the case of storing that hash in the database and retrieving later for comparison
<FromGitter> <bew> you have to store/retrive from the DB, I understand now
<FromGitter> <drewbharris> i must be missing something obvious in how people do this :)
<FromGitter> <bew> I got it!
<FromGitter> <drewbharris> !
<FromGitter> <drewbharris> huh!
<FromGitter> <bew> you didn't need to re-hash the user password, the Password object handle this for you
<FromGitter> <drewbharris> ahh, gotcha
<FromGitter> <drewbharris> thanks a bunch!
maattdd has joined #crystal-lang
<FromGitter> <bew> you're welcome ;)
maattdd has quit [Ping timeout: 260 seconds]
maattdd has joined #crystal-lang
<FromGitter> <xfbs> Is it possible to do something like this in crystal: ⏎ ⏎ ```def show_new(type) ⏎ pp type.new ⏎ end ⏎ ⏎ show_new(Int32)``` [https://gitter.im/crystal-lang/crystal?at=5a7f91fa86ef1bb141943116]
<FromGitter> <bew> yes
maattdd has quit [Ping timeout: 256 seconds]
cremes has quit [Quit: cremes]
qard has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <thegreyfellow> Hi everyone, how can I send an optional block to a method: ⏎ ⏎ ```def foo(bar, &block) ⏎ puts yield ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5a7f9e71d74ee9f50dabddac]
qard has quit [Quit: qard]
<FromGitter> <aisrael> If I’m not mistaken that’s not directly possible. Instead, the current idiom is to overload `foo(bar, &block)` with just `foo(bar)` (and in some cases, call the original method with an empty block).
<FromGitter> <thegreyfellow> Hmm I see, thanks for the suggestion
<FromGitter> <bew> I can't find the commit/PR where the local variable restriction syntax `local_var : Bool = true` has been added, anyone knows where to search?
<FromGitter> <faustinoaq> @bew I think it was introduced after 18.7 😅
<FromGitter> <bew> TIL I can use `@def` in macro code to access the current def, still not sure when this can be useful though.. (this was there since 0.20.0!!)
alex`` has quit [Ping timeout: 265 seconds]
<FromGitter> <bew> @faustinoaq thanks, tried to look at the changelogs around this release until current, but I couldn't find it >< I give up for now
cremes has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
cremes has quit [Quit: cremes]
<FromGitter> <bew> demo of `@def`: https://carc.in/#/r/3k2k
<FromGitter> <bew> I remember telling some people here that this was not possible, I apologize...
faustinoaq has quit [Quit: IRC client terminated!]
hightower4 has joined #crystal-lang
DTZUZO has joined #crystal-lang
danielpclark has quit [Quit: Leaving]
maattdd has joined #crystal-lang
maattdd has quit [Ping timeout: 248 seconds]
alex`` has joined #crystal-lang
maattdd has joined #crystal-lang
maattdd has quit [Ping timeout: 255 seconds]
hightower3 has joined #crystal-lang
hightower4 has quit [Ping timeout: 260 seconds]
<FromGitter> <bararchy> If someone will ask me what I really want in regard to shards, it's Javascript supported `HTTP::Client`, it would be great to have a client that can fetch javascript and eval it
hightower3 has quit [Ping timeout: 255 seconds]
alex`` has quit [Ping timeout: 276 seconds]
sandelius has joined #crystal-lang
alex`` has joined #crystal-lang
alex`` has quit [Client Quit]
alex`` has joined #crystal-lang
alex`` has quit [Client Quit]
alex`` has joined #crystal-lang
sandelius has quit [Client Quit]
jnyw has joined #crystal-lang
jnyw has quit [Quit: WeeChat 2.0.1]
Ven`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
Ven`` has quit [Client Quit]
Ven`` has joined #crystal-lang
jeromegn has quit [Quit: Connection closed for inactivity]
rohitpaulk has quit [Ping timeout: 240 seconds]
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 256 seconds]
<FromGitter> <bararchy> How can I get the index of foo ? ⏎ ⏎ ```["bar", "baz", "foo"]``` [https://gitter.im/crystal-lang/crystal?at=5a802fb086ef1bb141966890]
<FromGitter> <mamantoha> ```["bar", "baz", "foo"].index("foo")```
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> thanks :)
<FromGitter> <xfbs> How do I check if two objects have the same class?
<FromGitter> <mamantoha> you can use methon `class` on each object and compare it
<FromGitter> <xfbs> works like a charm, merci! :)
<FromGitter> <thegreyfellow> weird enough @mamantoha check this out: https://carc.in/#/r/3k4t
<FromGitter> <thegreyfellow> any idea why `===` gives false :/
<FromGitter> <mamantoha> implementation of `===` differs depending on type
<FromGitter> <straight-shoota> @bararchy for running JavaScript in a web context, you'll need to implement an entire browser engine including DOM, layout, JS runtime
<FromGitter> <mamantoha> ```/text/ === "text" ⏎ => true``` [https://gitter.im/crystal-lang/crystal?at=5a8031ded74ee9f50dadf099]
return0e has quit [Read error: Connection reset by peer]
<FromGitter> <bararchy> Yeha I know @straight-shoota , can't a dev dream ? :)
return0e has joined #crystal-lang
<FromGitter> <xfbs> If you want a client that can eval JS and fetch it, you should look at headless-chrome
<FromGitter> <straight-shoota> well you could just use bindings to webkit
<FromGitter> <xfbs> True, always an option, depending on what you want to do.
moei has joined #crystal-lang
<FromGitter> <thegreyfellow> Thanks @mamantoha !
cremes has joined #crystal-lang
<greenbigfrog> Is there a nicer syntax/way of doing following? https://hastebin.com/mobuyiniwe.rb
<FromGitter> <straight-shoota> you could use decomposition if query_one returned a tuple instead of a named tuple. But I don't think this would really an improvement
<greenbigfrog> decomposition?
* greenbigfrog just gound DB.mapping
<FromGitter> <xfbs> How do I use class methods in an instance? `ClassName.method`? Or is there a better way?
alex`` has quit [Quit: WeeChat 2.0.1]
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <thegreyfellow> so apparently we can not have class methods inside classes which negates your case. but if you need to call a calss method from a module, you can include the module and call it from inside the instance method. https://carc.in/#/r/3k66
yaewa has joined #crystal-lang
moei has quit [Ping timeout: 255 seconds]
<FromGitter> <thegreyfellow> btw all these writing are working ⏎ ⏎ ```self.class_method ⏎ # or ⏎ B.class_method ⏎ # or even ⏎ class_method``` [https://gitter.im/crystal-lang/crystal?at=5a804b6818f388e6268c8e36]
<greenbigfrog> can I somehow have a getter for class vars?
<FromGitter> <xfbs> You mean like `getter :var` but for `@@var` instead of `@var`?
<FromGitter> <xfbs> Seems like `class_getter :var` might do what you want
<FromGitter> <xfbs> https://carc.in/#/r/3k6u
Ven`` has joined #crystal-lang
<greenbigfrog> ah. nice. thanks!
<greenbigfrog> mind telling me where you found that info?
thunker[m] has joined #crystal-lang
alex`` has joined #crystal-lang
return0e has quit []
return0e has joined #crystal-lang
<FromGitter> <xfbs> I just read the source of the `getter` macro
<FromGitter> <xfbs> https://carc.in/#/r/3k6u
<FromGitter> <bew> Just use `class_getter var` without the colon
<FromGitter> <xfbs> I think it's equivalent, itsn't it?
<FromGitter> <bew> Yes sure
<FromGitter> <bew> But why use a colon when you can not use it
snsei has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven`` has joined #crystal-lang
snsei has quit []
snsei has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
rohitpaulk has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
faustinoaq has joined #crystal-lang
Ven`` has joined #crystal-lang
alex`` has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 265 seconds]
snsei has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
snsei has joined #crystal-lang
Ven`` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alex`` has quit [Ping timeout: 256 seconds]
snsei has quit [Remote host closed the connection]
duane has joined #crystal-lang
rohitpaulk has joined #crystal-lang
alex`` has joined #crystal-lang
TakeYourFreedom has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
Ven`` has joined #crystal-lang
TakeYourFreedom has quit [Quit: Leaving]
TakeYourFreedom has joined #crystal-lang
Ven`` has quit [Ping timeout: 240 seconds]
cremes has quit [Quit: cremes]
TakeYourFreedom has quit [Read error: Connection reset by peer]
TakeYourFreedom has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
TakeYourFreedom has quit [Remote host closed the connection]
cremes has joined #crystal-lang
TakeYourFreedom has joined #crystal-lang
snsei has joined #crystal-lang
cremes has quit [Quit: cremes]
snsei has quit [Ping timeout: 255 seconds]
codenoid has joined #crystal-lang
<codenoid> morning
<TakeYourFreedom> Evening
<codenoid> yeah
<codenoid> it's evening sky
<codenoid> 04am
codenoid has quit [Ping timeout: 248 seconds]
<FromGitter> <thegreyfellow> it's 22h here
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
yaewa has quit [Quit: Leaving...]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
qard has joined #crystal-lang
qard has quit [Quit: qard]