<FromGitter>
<faustinoaq> @eliasjpr @paulcsmith I think would be nice to create a new shard using latest updated protocol
<FromGitter>
<fgimian> I believe the only way forward is to drop support for everything except 0.25.0+, at least that's how I'm approaching it. I noticed the major breaking changes when I started developing my libriary so I had been running my own build from the master branch up until now.
<FromGitter>
<fgimian> YAML, JSON and File.stat in particular affected me
<FromGitter>
<fgimian> I actually couldn't get what I wanted out of `File.info` personally, need to look at it again.
<FromGitter>
<fgimian> So I re-implemented `File.stat` in my library using the previous code in Crystal stdlib
<FromGitter>
<fgimian> not sure how Python manages to do it, but they have an `os.stat` and stay compatible with Windows and Unix
<FromGitter>
<paulcsmith> I think until 1.0 itโs ok to make breaking changes without backward compatibility. Iโd much rather the core team spend time getting to 1.0 than maintaining old versions of code. It kinda sucks to update all the shards, but thatโs ok if it saves the Crystal team time
<FromGitter>
<paulcsmith> With that said, if adding a comparability layer for just the previously released version is fairly easy then thatโd be great to have!
<FromGitter>
<fgimian> Absolutely agreed!
<FromGitter>
<fgimian> I'm not sure how trivial that would be in this case though
<FromGitter>
<fgimian> (re staying compatible with both versions in libraries that is)
<FromGitter>
<fgimian> one of the things I love most about Crystal is how refined and well-thought-out the stdlib is
<FromGitter>
<fgimian> so any improvements (breaking or not) there to continue in that tradition are highly welcome from my end
<FromGitter>
<paulcsmith> Yeah me too :)
<FromGitter>
<fgimian> ๐
sz0 has quit [Quit: Connection closed for inactivity]
That_Guy_Anon1 has joined #crystal-lang
That_Guy_Anon has quit [Ping timeout: 265 seconds]
<FromGitter>
<fgimian> Forgive me guys, but is there a way to catch a Ctrl+C in a Crystal program?
<FromGitter>
<fgimian> a simple rescue won't do, and there are no Interrupt or SystemExit exceptions available that I can see
<FromGitter>
<fgimian> maybe i need to use signal trap
<FromGitter>
<fgimian> works perfectly in case anyone has the same question ๐
<FromGitter>
<fgimian> i'm not sure if `&block` is even needed, testing
<FromGitter>
<fgimian> nah it's not
<FromGitter>
<robacarp> it's not, but it helps readability
<FromGitter>
<fgimian> true
<FromGitter>
<fgimian> thanks a lot
<FromGitter>
<robacarp> no problem
That_Guy_Anon1 has quit [Quit: Leaving]
That_Guy_Anon has joined #crystal-lang
<FromGitter>
<bararchy> How's everyone handling the 0.25.0 upgrade?
<FromGitter>
<bararchy> The JSON change took us sometime to work around with
<FromGitter>
<codenoid> i still use 0.24
<FromGitter>
<bararchy> @codenoid because of selenium? :)
<FromGitter>
<codenoid> i fear to upgrade crystal
<FromGitter>
<fgimian> @bararchy The JSON / YAML changes were an adjustment, but I think that overall they are for the better. I'm really happy with 0.25.0 so far. (though as mentioned earlier, I switched to the master branch of Crystal a few weeks after starting to use 0.24 and finding breaking changes, so it's been less of a transition)
<FromGitter>
<fgimian> I think checking code against the master branch every couple of weeks is probably not a bad idea actually.
<FromGitter>
<fgimian> @codenoid Feel free to ask any questions when you upgrade, hopefully it won't be so painful.
<FromGitter>
<bararchy> True, I guess as Crystal becomes more mature the impact of new versions will subdue
<FromGitter>
<fgimian> yah
<FromGitter>
<fgimian> this is why I would still be weary of using Crystal in production atm personally
<FromGitter>
<fgimian> but for personal projects, I don't think it's a problem
<FromGitter>
<fgimian> the language is great enough (and unique enough compared to other choices) that it justifies living with some breaking changes (in my eyes)
<FromGitter>
<codenoid> yeah, i don't want to use my time to following breaking change
<FromGitter>
<fgimian> yah, but you never know, maybe in the next year or so we see 1.0, I hope (and pray) hehe
<FromGitter>
<fgimian> the latest hangout was very positive and gave me hope ๐
<FromGitter>
<bararchy> And RX14 Windows support is coming nicely
<FromGitter>
<fgimian> That's awesome!! ๐
<FromGitter>
<valamorgon> after upgrading to crystal 0.25, I got this: undefined method 'each' for JSON::Any
<FromGitter>
<valamorgon> so how we will loop after parse json
<FromGitter>
<fgimian> check out the docs
<FromGitter>
<fgimian> the behaviour has changed in JSON
<FromGitter>
<valamorgon> I checked but we dont have each method
<FromGitter>
<valamorgon> I couldnt find info related to it
<FromGitter>
<fgimian> ah yes, I just need to pop out for a bit but will try to help as soon as I'm back online
<FromGitter>
<fgimian> otherwise maybe someone else can assist here
That_Guy_Anon has quit [Remote host closed the connection]
<FromGitter>
<fgimian> @valamorgon try to cast it to a hash, using .as(Hash)
<FromGitter>
<fgimian> can you share a code snippet showing the problem?
<FromGitter>
<fgimian> donโt hesitate to look at the Crystal source, itโs easy to read
<FromGitter>
<valamorgon> hey @fgimian for nested jsons, should I as_h each time for loop? I actually started to do it, but I think it was way a lot easier to loop json::any
<crystal-gh>
[crystal] r00ster91 opened pull request #6208: Fix examples in Formatting and Parsing Time (master...patch-5) https://git.io/vhMZp
<Groogy>
eh not sure, but right there it looks more like you want an Alias anyway?
<Groogy>
also right you should be using JSON::Any I believe not JSON::Any::Type
<Groogy>
why it fails is probably something because constants for types seems to be pretty strict, if you check this out https://play.crystal-lang.org/#/r/4b89
<Groogy>
so even if they look to be the same, the compiler will err
<FromGitter>
<fgimian> Hey guys, there's an argument in Python's `subprocess` module which is as follows: โ โ ```code paste, see link``` โ โ Would you happen to know a way to do this in Crystal? It allows for performing a setuid or setgid in the child process just before it runs for example. [https://gitter.im/crystal-lang/crystal?at=5b263478f3e3007371b8eec1]
<FromGitter>
<fgimian> the Python code is all in C ... just about to look at it but I'm scared ๐
<FromGitter>
<stronny> python doesn't have lambdas like other langs do, so it invents all kinds of defer mechanics instead
<FromGitter>
<stronny> you should probably just do what you need directly
<FromGitter>
<stronny> note that in order to call another program from your process you have to 1) fork and then 2) exec
<FromGitter>
<stronny> you are free to do anything you need between those two
<FromGitter>
<fgimian> thanks so much @stronny, will give it a try ๐
<FromGitter>
<stronny> Groogy: your example at least makes it clear that two types are not `==` as well as do not have the same signature
<FromGitter>
<stronny> I am still unclear why crystal tells me that it expects "A, not A"
<Groogy>
ยฏ\(ยฐ_o)/ยฏ
<FromGitter>
<codenoid> yeah
<FromGitter>
<codenoid> i mean can i add custom argument at crystal compile time
<Groogy>
though not sure if they can have values or just be set
<FromGitter>
<fgimian> @stronny Your info was super helpful, I can see exactly what you're saying in `process.cr`. Looks like maybe I can subclass it and override `self.exec_internal` to add some logic in before the call to `LibC.execvp` ๐
<FromGitter>
<stronny> you're welcome!
Jenz has joined #crystal-lang
<Jenz>
Morning
<Jenz>
Or evening, or whatever it is for you guys :D
<Groogy>
o/
<Jenz>
What does 'o/' mean? I've seen it a couple if times, but never understood what it is
<FromGitter>
<fgimian> never seen that
<Jenz>
ยฏ\_(ใ)_/ยฏ
<FromGitter>
<fgimian> may I ask where you saw it?
<Jenz>
Hmm, might have been here; but I think also in some Discord server
<FromGitter>
<stronny> it's a picture of a head and a raised hand, so a greeting
<Jenz>
Ah, I see it now. Thanks!
<Groogy>
Jenz: it's a guy waving
<Jenz>
Yeah, thanks
* FromGitter
* codenoid a
<FromGitter>
<hmans> I know I'm a bit late, but congrats to everyone on the release of 0.25! \o/
* Jenz
\o/
<FromGitter>
<codenoid> \o\
<FromGitter>
<codenoid> *o*
* Jenz
/o/
* Jenz
\o\
* Jenz
\o/
<FromGitter>
<rishavs> -- o --
<FromGitter>
<rishavs> Is there a way to install the latest checkin using shards?
<RX14>
@stronny i'm still confused about your usecase - JSON has no concept of sparse arrays. How does your JSON relate to sparse arrays?
<RX14>
perhaps some example code would help
<Jenz>
@rishavs 'checkin'?
<RX14>
commit I assume
<Jenz>
Ah
<FromGitter>
<stronny> I get the initial tree from JSON, later I want to modify it
<FromGitter>
<rishavs> old svn lingo :/
<Jenz>
Why, why do I only get Terraria hits when i search for 'crystal shards'
<FromGitter>
<rishavs> I want to run kemal with its last commit
<Groogy>
you've probably been googling bunch of other terraria stuff before and crystal shards is a thing in that game? :P
<RX14>
@stronny so the initial array isn't sparse at all, then you want to use it as a sparse array later?
<Jenz>
@rishavs: you can specify 'branch: master'
<RX14>
I really wish I had an idea of the code and json to see whats going on
<FromGitter>
<stronny> I'm not picky about the mechanics, I just want to be able to assign a value out of the existing range
<FromGitter>
<stronny> ideally anywhere in typeof(index)
<Groogy>
how yeah while I got you here RX14, I've cleared the cache in ~/.cache/crystal, is there any more I need to clear to fix debug info making compiler crash when I compile with --debug in 0.25?
<RX14>
no
<RX14>
its a bug
<Groogy>
aah it's known? I tried to find a issue on it
<RX14>
Groogy, --debug is only useful with gdb/lldb anyway
<RX14>
so it's not the biggest of deals
<RX14>
the default without --debug is to include line numbers in the debug info
<RX14>
--debug adds variable names
<RX14>
and --no-debug removes all debug info
<FromGitter>
<rishavs> even Sentry is broken ๐ฟ
<RX14>
@stronny I'm still struggling to imagine the datastructure you're using
<FromGitter>
<rishavs> 1) 25 is murdering me
<FromGitter>
<stronny> RX14: I'm not insisiting on sparse arrays by the way, what really bugs me right now is that I'm unable to resize the array manually
<FromGitter>
<codenoid> yeah, that's why i fear upgrade crystal to latest verfsion
<RX14>
@stronny well since arrays always have to return *a* value for 0...arry.size, then the array has to be filled with something
<RX14>
so you can just keep inserting nil until you get the size you want
<FromGitter>
<stronny> that's what I am doing right now and it's suboptimal
<RX14>
yeah
<RX14>
how much of your array is nil and how much is data
<RX14>
i.e. how sparse is it
<RX14>
is the JSON sparse at all?
<FromGitter>
<stronny> I will only know at runtime
<RX14>
yeah but estimate
Jenz has quit [Ping timeout: 264 seconds]
<FromGitter>
<stronny> let's take an example from doc: `array[1_000_000] = "that's a waste"` โ so, a million nils and one string
<RX14>
so what are you trying to build, big picture?
<FromGitter>
<stronny> I need to support a dynamic structure that users fill in at runtime
<Groogy>
why do you need to keep the nil values though?
<FromGitter>
<stronny> I don't, that's the point
<FromGitter>
<stronny> I want a type that only allocates for non-nils
<RX14>
@stronny whats that data structure actually holding, like can you tell me what the whole application you're building is
<RX14>
the whole project or whatever
<FromGitter>
<stronny> A generic data processor with plugins and JSON apis
<FromGitter>
<stronny> So I have no idea what it will hold, I have to account for any possibility
<RX14>
hmm
<FromGitter>
<stronny> I mean manual extenstion with a << JSON::Any.new(nil) does work now, it's just not optimal
<RX14>
yeah I get that
<FromGitter>
<stronny> while you are here can you also take a look?
<RX14>
I'd say use a hash
<RX14>
but then you loose the ordering of the indexes
<RX14>
if you're making a generic JSON processor, how would you then serialize the sparse array back out?
<RX14>
you'd end up generating a JSON array with 999999 nils then 1 value
<FromGitter>
<stronny> that's a good point!
<RX14>
it just seems to me that you might not actually need sparse arrays
<RX14>
because JSON doesn't support sparse arrays
<RX14>
so why should a JSON processing tool?
<FromGitter>
<stronny> all right, let's drop sparse arrays
<FromGitter>
<stronny> it there a reason then to not allowing a manual array resize?
<RX14>
because what do you fill the space with?
<RX14>
if you have an Array(String)
<FromGitter>
<stronny> a second argument?
<RX14>
you can't fill the space with nil
<RX14>
ok, thats fair enough
<FromGitter>
<stronny> `a.resize(1_000_000, "")`
<RX14>
then the answer is because nobody's needed it
<RX14>
and it's pretty easy to create your own utility method to do it
<RX14>
because it's just << until you get to the correct size
<FromGitter>
<stronny> Yes, but I will have to subclass Array
<RX14>
why?
<FromGitter>
<stronny> and JSON.parse will not use my subclass
<FromGitter>
<stronny> how else? it's private
<RX14>
<< and size aren't private
<RX14>
also we have array[array.size...new_size] = nil
<RX14>
which is a single line
<RX14>
and does what you want
<FromGitter>
<stronny> it doesn't
<FromGitter>
<stronny> oh
<FromGitter>
<stronny> I didn't test the Range
<FromGitter>
<stronny> I will, thanks!
<RX14>
no
<RX14>
its the same
<RX14>
i just checked
<RX14>
it doesnt resize the array
<FromGitter>
<stronny> yeah
<FromGitter>
<stronny> so would't a call to resize be much faster than a million .pushes?
<RX14>
yeah, it would
<RX14>
but
<RX14>
pushing would still be fairly fast
<FromGitter>
<stronny> so it we start from zero size how many reallocs will happen along the way?
<RX14>
something close to log2(n) i guess
<RX14>
so ~20
<FromGitter>
<stronny> we might also be left with twice the needed size allocated
<FromGitter>
<stronny> If we allocate a new Array with the size given in .new and copy old values, will it be resizable later?
<FromGitter>
<stronny> oh, oh, I know!
<FromGitter>
<stronny> how about adding a `.new(initial_size : Int32, a : Array(T))` that will allocate a new array and copy values from the given array?
<RX14>
but if we've decided that sparse arrays aren't needed, why are we still trying to insert at 1 million?
<RX14>
you'll still end up with serializing out 999999 nils
<RX14>
whether you call the array sparse or no
<RX14>
I just don't see why you wouldn't treat an array like an array and support only append ops
<FromGitter>
<stronny> I guess I'm going on inertia, sorry =)
<FromGitter>
<stronny> Even if sparse arrays aren't needed, I will still have to allow users to insert at an arbitraty index
<FromGitter>
<stronny> and then yes, serializing all the nils
<RX14>
i don't get why you have to support that
<FromGitter>
<stronny> Because It's better than a runtime exception?
<RX14>
is it?
<FromGitter>
<stronny> well there are reasons to support either side depending on factors
<RX14>
ruby supports one way
<RX14>
crystal supports the other
<RX14>
and most languages are like crystal
<RX14>
ruby is really the odd one out
<FromGitter>
<stronny> well, I use ruby and crystal not because they are like most languages, quite the opposite in fact =)
<FromGitter>
<stronny> anyway, I see your points and will have to think it over again
<FromGitter>
<stronny> probably you are correct and I should just forbid that
<RX14>
because is it better to crash now or crash later when you generate 100MiB of nils? :P
<RX14>
in your serialized json
<FromGitter>
<stronny> or have a third way and check the diff size against some reasonable limit
<crystal-gh>
[crystal] kostya opened pull request #6209: Serializable, remove version conditions (master...serializable_cleanup) https://git.io/vhMB4
<FromGitter>
<stronny> all right, thanks for the explanation, sorry for using your time
<RX14>
no, its no problem
<FromGitter>
<vlazar> When I have nillable object `bar` inside object `foo` what would be a Crystal way to check for `bar.value` in spec? Here is what I'm trying to do https://play.crystal-lang.org/#/r/4b97 โ โ In Ruby I would just check for `foo.bar` to not be nil before checking for `foo.bar.value`. In Crystal that wouldn't compile. So what's an idiomatic way in Crystal to do this?
<RX14>
I was playing minecraft while chatting anyway so it's not like i'd be using the time productively anyway :P
<FromGitter>
<hmans> Is there any issue with the new HTTP::Server interface? My compiler is claiming the only overload for #bind is with socket : Socket::Server
<FromGitter>
<vlazar> @stronny the program does non compile, something like `bar.should_not be_nil` or `bar.nil?.should_not be_false` doesn't change it
<FromGitter>
<hmans> I'm pretty sure the documentation's example of `server.bind 8080` should say `server.bind_tcp 8080` (and some other occurences)
<RX14>
yes
<RX14>
thats a known issue
<RX14>
we medded up the docs
<RX14>
messed*
<FromGitter>
<hmans> Ah, I see it's already fixed on master.
<FromGitter>
<hmans> Other than that, my project is compiling fine... cool!
<FromGitter>
<stronny> @vlazar you have to check `bar`, not `bar.value` first, then use `is_a?` to separate execution paths
<FromGitter>
<vlazar> right, `bar.nil?` is stricter
<FromGitter>
<vlazar> ok then, if's it is.. thanks @stronny
<FromGitter>
<hmans> The new time zone support is clashing with sqlite3
<FromGitter>
<fgimian> @vlazar you could actually depend on regular truthies with `String | Nil` since an empty string will always evaluate to false
<FromGitter>
<fgimian> e.g. you should be able to write
<FromGitter>
<fgimian> ```bar.value.should eq("bar") if bar```
<FromGitter>
<fgimian> nil will evaluate to `false` and ANY string will evaluate to `true` using truthies
<FromGitter>
<fgimian> the only time I'm really careful is when using `Bool | Nil` ๐
<FromGitter>
<vlazar> yeah, sure
<FromGitter>
<fgimian> just a thought, using `nil?` is perfectly fine too
<FromGitter>
<vlazar> I see not_nil! is used a lot actually in Crystal specs
<FromGitter>
<fgimian> oh interesting, kewl
<FromGitter>
<vlazar> so I guess both if's and not_nil! are fine in specs
<FromGitter>
<fgimian> yeah
<FromGitter>
<fgimian> they are all technically correct I think ๐
<FromGitter>
<fgimian> but I (like you) often reference the Crystal source and try to follow the style used there
<FromGitter>
<fridgerator> @hmans we will get a fixed sqlite3 version on Monday
Jenz has joined #crystal-lang
<FromGitter>
<hmans> @fridgerator Cool! Thanks for the heads-up.
<FromGitter>
<vlazar> @fgimian yeah, I've been wasting time not reading Crystal's source, I definitely should do it more
<FromGitter>
<fgimian> Honestly, the source code (primarily the stdlib) is one of the biggest selling points of Crystal.
<FromGitter>
<fgimian> It's not really talked about much, but try reading the stdlib for Ruby or some of Python .... Crystal's stdlib is worlds apart in terms of readability and
<FromGitter>
<fgimian> Highly recommend just having the repo cloned alonside your project and open in your editor's sidebar for quick reference
Jenz has quit [Ping timeout: 240 seconds]
<FromGitter>
<vlazar> totally agree, almost everything is written in Crystal, easy to check how something works even with no docs
<FromGitter>
<fgimian> absolutely! I'm also learning a lot more about LibC ๐
<FromGitter>
<fgimian> and how things ACTUALLY work
<FromGitter>
<vlazar> interesting, do you mean that Crystal bindings push you to learn more about libc?
<FromGitter>
<fgimian> moreso I am understanding how LibC plays a role in various activities, I've written various bindings myself too (because Crystal just makes it so damn easy to do)
<FromGitter>
<fgimian> but also looking the `process.cr` code for example (which I'm doing as we speak), I'm seeing what's actually going on with cals to fork and execvp
<FromGitter>
<fgimian> which is all C bindings to LibC and exposing certain functionality that the stdlib doesn't
<FromGitter>
<fgimian> no unit tests yet though (naughty!!!) but coming soon I hope
<FromGitter>
<j8r> The state of the LibC bindings in Crystal is meh - not well documented. Also adding more bindings not used in Crystal itself are refused :(
<FromGitter>
<fgimian> Would love to see more yeah, hence why I started my lib
<FromGitter>
<vlazar> sweet
<FromGitter>
<j8r> I advocate to move the LibC out of the compiler like rust did, to have complete bindings to the LibC and not only ones used in the compiler
<FromGitter>
<fgimian> @vlazar for sure mate, you should give it a shot!
<FromGitter>
<fgimian> @j8r complete bindings would be lovely
<FromGitter>
<fgimian> Python does have very thorough bindings which are very true to the original, whether or not that's a good or bad thing is up to the each individual
<FromGitter>
<vlazar> I mean I'm playing with Crystal in my spare time, but also hope to use it at work in production, that's not my decision to make, but I will try
<FromGitter>
<j8r> why it would be bad @fgimian ?
<FromGitter>
<fgimian> @j8r Perhaps just because it may be considered a little too low-level. For example, the `os` module in Python feels a bit out of place in areas, because it's much more like C than it is Python.
<FromGitter>
<fgimian> Personally I do prefer bindings that mimic the original behaviour because they are well known and make porting code from Python easier ๐
<FromGitter>
<j8r> btw this is better than nothing :)
<FromGitter>
<j8r> This is fine if you write tests, as usual
<FromGitter>
<fgimian> @j8r It's a huge project to support all the bindings, but why not just create a new shard?
<FromGitter>
<fgimian> if you have the time of course
<FromGitter>
<j8r> Not support all tomorrow, more bindings if people are willing to propose them
<FromGitter>
<fgimian> notice in my library, I try to "crystalize" the bindings
<FromGitter>
<fgimian> I expose pretty names, use overloading where I can .etc
<FromGitter>
<fgimian> it's not just an original interface
<FromGitter>
<fgimian> I'm going to add some more to my library, but it will be mostly limited to what I need personally
<FromGitter>
<fgimian> and I don't reallly want to maintain all bindings, because ... I don't have the time ๐
<FromGitter>
<fgimian> but I don't doubt that having a library that does would be great!
<FromGitter>
<fgimian> Yah, but you could always use `lib_c` in your shard
<FromGitter>
<fgimian> I do in mine, I rely on `Errno` for example
<FromGitter>
<fgimian> weird name for an exception
<FromGitter>
<fgimian> Python calls it `OSError`
<FromGitter>
<fgimian> Ruby does `Errno` too
<FromGitter>
<fgimian> wow those Rust bindings are very thorough
<FromGitter>
<j8r> @fgimian as you said, there are bindings missing. And it's better to write reusable bindings for other projects. That's why creating a documented shard thaht have the goal to support OS most native functions makes sense
<FromGitter>
<fgimian> just a mere 48,309 lines of code
<FromGitter>
<crash2burn_twitter> basically if I have a nillable instance var, I need to use the .try boilerplate everywhere in my code that I use it?
<FromGitter>
<faustinoaq> Hi @crash2burn_twitter ๐
<FromGitter>
<crash2burn_twitter> ugh why did it make my name crash2burn_twitter, thanks glitter
<FromGitter>
<faustinoaq> > if I have a nillable instance var, I need to use the .try boilerplate everywhere in my code that I use it? โ โ I prefer `if var = @var`
<FromGitter>
<faustinoaq> or avoid `nil` in your code
<FromGitter>
<crash2burn_twitter> ah thats pretty good, still a bummer though! Yea maybe I'm thinking about the whole thing wrong, as I do see people mentioning to just not use nil
<FromGitter>
<crash2burn_twitter> but I cant seem to wrap my head around not supporting nil in a lot of cases
snsei has quit [Remote host closed the connection]
<FromGitter>
<crash2burn_twitter> and its weird to me as even golang seems to support nil for structs in a less "think about it" kind of wa
<FromGitter>
<crash2burn_twitter> still enjoying the lang though :)
<FromGitter>
<faultyserver> So I'm looking at the UUID docs and the class overview seems to have come from the JSON extension to the class, rather than the original class itself... https://crystal-lang.org/api/0.25.0/UUID.html
<FromGitter>
<faultyserver> granted, the UUID class itself doesn't really have docs, that still seems like it shouldn't be what ends up on the API reference
snsei has quit [Remote host closed the connection]
<FromGitter>
<j8r> @S-YOU Yes totally its extracted from the main repo. โ If you need new libc bindings that aren't in Crystal's `LibC`, feel free to send PRs - that's the main purpose of this shard ๐
<FromGitter>
<bendietze_twitter> Great guys ๐ ๐
alex`` has joined #crystal-lang
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 245 seconds]
<FromGitter>
<vectorselector> Hi folks, I'm dumb. โ breaking change #5183 has me running around trying to understand how to specifically set a Hash(String,JSON::Any) to string value in the end. โ myTxtSpan["textValue"] = "text" โ does not work anymore, since crystal 0.25 โ ... [https://gitter.im/crystal-lang/crystal?at=5b26a72863cb0b1a2d1f47b3]
<FromGitter>
<rishavs> I am using Bcrypt. โ ` if user && Crypto::Bcrypt::Password.new(user.password_hash.not_nil!) == pass` this works. โ but โ `if pass == user.password_hash.as(String)` doesn't. I dindt think I had to hash it up again using `new` [https://gitter.im/crystal-lang/crystal?at=5b26b0e6d0546c33e701cba3]
<FromGitter>
<fridgerator> no you dont have to rehash it
<FromGitter>
<vectorselector> > *<oprypin>* vectorselector, `myTxtSpan["textValue"] = JSON::Any.new("text")` should work โ Thank you very much @oprypin โ re:" relying on mutating JSON::Any can be a bad idea" โ What are the alternatives? โ the db is couchdb and I'm doing updates to small parts of documents requiring only casting at the last minute as couchdb updates require an entirely new document constructed out of a
<FromGitter>
<rishavs> what is the difference between `.as(String)` and `.to_s`?
akaiiro has quit [Ping timeout: 256 seconds]
akaiiro has joined #crystal-lang
<FromGitter>
<drum445> Why is Time.now returning "2018-06-17 20:42:32 +01:00" after upgrading to 0.25, has the behaviour changed?
<FromGitter>
<drum445> $ date โ Returns: Sun 17 Jun 20:42:32 BST 2018
<FromGitter>
<drum445> Seems like it's an hour out :(
<Yxhuvud>
are those times not the same? Only formatted differently
<FromGitter>
<drum445> @yxhuvud Nah it's an hour out, although I just looked at patch notes and found โ Time.utc_now
<Yxhuvud>
BST = british summer time = +1, no?
<FromGitter>
<drum445> yep, however when i do Time.now + some seconds it's an hour ahead of what it should be
<FromGitter>
<drum445> due to that +01:00
<FromGitter>
<j8r> @rishavs tyically `as_s` comes from `JSON::Any` or `YAML::Any`, and for them is more efficient for casting than `to_s`
akaiiro has quit [Ping timeout: 256 seconds]
akaiiro has joined #crystal-lang
hightower3 has quit [Ping timeout: 256 seconds]
<FromGitter>
<drum445> Ok I found my issue, I had a datetime stored in MySQL as NOW(), then I was finding out the elapsed time between Time.now in Crystal and NOW() in MySQL. โ MySQL was UTC โ Crystal was +01:00 โ So it meant I couldn't perform this [https://gitter.im/crystal-lang/crystal?at=5b26c07294a11e0adea803f9]
<FromGitter>
<drum445> Had to change my sql script to use a time from Crystal using โ Time.utc_now โ Instad of SQL's NOW()
<FromGitter>
<drum445> Sorry for spam, but this is my issue or a bug not sure. So I have two times โ a = 2018-06-17 21:16:54 UTC (Generated from Mysql NOW()) โ b = 2018-06-17 21:25:32 +01:00 (Generated from Time.now()) โ โ When I do a - b I would expect around 10 minutes, but it is actually 51 minutes. ... [https://gitter.im/crystal-lang/crystal?at=5b26c40fd0546c33e701f0f1]
<FromGitter>
<Blacksmoke16> if mysql NOW is in UTC, why not just use Time.utc_now to match
<FromGitter>
<drum445> Because Time.utc_now is an hour behind
<FromGitter>
<drum445> mysql NOW is being read in sql as utc but it's bst
<FromGitter>
<drum445> I need my rs.read(Time) to know it's bst not utc
<FromGitter>
<Blacksmoke16> it looks like Time.parse has an optional param to tell it what timezone to use, could maybe use that to let it know that it should be bst not utc