jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<oprypin> well dang https://carc.in/#/r/a3xj
<oprypin> now just need to really figure out which one is correct
<oprypin> omg i made a mistake
<oprypin> whew the result is the same πŸ˜… https://carc.in/#/r/a3xk
<straight-shoota> the first two are going backwards, the second two forward
<straight-shoota> =)
<straight-shoota> much easier to follow when you leave out those comparisons
<straight-shoota> https://carc.in/#/r/a3xk
<oprypin> im an idiot lol
<oprypin> https://carc.in/#/r/a3xs still holds
<straight-shoota> seems everything's as expected
<straight-shoota> shift by hour should have the same effect as hours.ago
<straight-shoota> except when you haven offset shift of less then 1 hour
<straight-shoota> but that's thankfully very, very rare
<straight-shoota> (not necessary less than 1 hour but rather not a full hour)
<FromGitter> <j8r> ...why there is both Circle and GH Actions?
<FromGitter> <j8r> which have the same CIs
<straight-shoota> we're gradually moving to GHA
<straight-shoota> what do you mean by "have the same CIs"?
<FromGitter> <j8r> that's why there are 36 CIs...
<FromGitter> <j8r> same checks, like test_linux, format etc
<straight-shoota> I suppose we just use the same job names for both
<straight-shoota> that should make sense
<FromGitter> <j8r> they do the same thing?
<straight-shoota> yeah
<straight-shoota> we could probably drop circle by now, but I'm not sure
<oprypin> oh my, is circleci pending for 2 days on master?
<FromGitter> <j8r> I was no sure to make a PR, I prefer let the core members discuss about Travis (still there), Circle and Actions
<FromGitter> <j8r> seems so oprypin
<oprypin> wait, travis? that's a big lol
<straight-shoota> oprypin 2 days?
<straight-shoota> last nightly build was successful
<straight-shoota> that was ~20 hours ago
<FromGitter> <j8r> BTW same story for shards (but less checks)
<straight-shoota> those checks refer to the currently running nightly build
<oprypin> oo sorry. that makes sense then
<FromGitter> <j8r> anyway 36 checks is quite a lot
<FromGitter> <j8r> oprypin you use Firefox (!)
<FromGitter> <j8r> I won't tell your corporation, I'm not evil :P
<straight-shoota> yeah it's a lot
<straight-shoota> and we're even only running CI on the main supported platforms
<FromGitter> <j8r> straight-shoota nightly build... why running the tool format?
<FromGitter> <j8r> *check_format
<FromGitter> <j8r> ...why not, :shrug:
<straight-shoota> exactly
<oprypin> one thing i will never understand is, why doesnt github or something start complaining that this is using up too much resources
<straight-shoota> yeah our jobs are quite demanind, especially memory :D
<straight-shoota> s/demanind/demanding/
<straight-shoota> but with GHA coming relatively late to the party, they definitely knew what demand to expect for a freebie service
<straight-shoota> and right now they're probably mostly focused on drawing projects in from other CI providers
<FromGitter> <j8r> I can make a PR tomorrow. If something is not to remove, I'll certainly receive comments
<FromGitter> <j8r> I'm used to infrastructure cleanup
<straight-shoota> sure
<straight-shoota> as far as I know, circleci should continue to be used to build nightlies and releases
<straight-shoota> but it doesn't need to run on pulls
<FromGitter> <j8r> I think we can remove the format from Circle, master is always formatted
<FromGitter> <j8r> at least, Travis should go now
<straight-shoota> yeah, travis definitely
<straight-shoota> unless for some reason we need to ensure compatibility with a six year old distribution
<straight-shoota> that still runs on trusty
avane has quit [Ping timeout: 256 seconds]
avane has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
f1refly has joined #crystal-lang
hightower3 has quit [Ping timeout: 258 seconds]
chachasmooth has quit [Ping timeout: 256 seconds]
f1reflyylmao has quit [Ping timeout: 240 seconds]
chachasmooth has joined #crystal-lang
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
_ht has joined #crystal-lang
avane has quit [*.net *.split]
deavmi has quit [*.net *.split]
early has quit [*.net *.split]
avane has joined #crystal-lang
deavmi has joined #crystal-lang
early has joined #crystal-lang
<Andriamanitra> is adding methods to built-in types a good thing to do in crystal?
<FromGitter> <naqvis> for project use, shouldn't matter, but if you are developing a shard, then that might confuse users or that might get conflicted with higher versions of language
<FromGitter> <naqvis> in essence, monkey patching isnt' that bad as people ought to think about it :P
<yxhuvud> well, changing existing methods is pretty bad.
<FromGitter> <naqvis> true , but that falls back to line between use and abuse
<FromGitter> <naqvis> same can be said for operator overloading
<Andriamanitra> hmm i see, so if you were developing a shard would you rather make your own type and add methods to that or use functions instead?
<Andriamanitra> like, let's say you wanted to add #is_prime method to integers
<FromGitter> <naqvis> opening stdlib classes and adding methods is risky in a fact that it might conflict with higher versions (as there might be similar methods get added, but with different implementation and/or usage)
<FromGitter> <naqvis> for such cases, I would recommend against polluting the stdlib and provide separate helpers/utils module to provide the functionality
<Andriamanitra> yeah but how would you go about doing that? would you prefer inheriting/compositing from stdlib classes or just having functions at the cost of not-so-nice api
<FromGitter> <naqvis> definitely customized code (either via inheritance and/or composition) is preferred as that would have different namespace than stdlib and won't conflict
<Andriamanitra> presumably the functions would also be within a module
<FromGitter> <naqvis> i think we were talking about monkey patching
<Andriamanitra> yeah, we were, but since i got the impression that it's not such a great idea for shards i was asking what's the "proper" way to things in crystal
<FromGitter> <naqvis> for project own use, adding methods/functionality to stdlib shouldn't be a big deal, but for libraries, adding functionality to stdlib should be treated with care, as that might confuse users, prone to conflict and prone to frowning eyes from other users of your library :P
<FromGitter> <naqvis> but if you really have good thoughts/ideas and believe that should be part of stdlib, then it won't hurt to proceed with raising a RFC on crystal repo and bring that up to table for discussion with community and core team. Might get a chance to get that added to future version
<FromGitter> <naqvis> just my thoughts and suggestions
<Andriamanitra> i appreciate it, i guess i won't go modifying stdlib (or maybe i will, but i won't publish it and no one will ever know of my sins)
<FromGitter> <naqvis> :P
<repo> Blacksmoke16: hey o/ i'm giving athena-validator a try and i'm a bit stuck with the callback validator. I used it like described in the docs: https://p.jokke.space/UWua/ but it gives me a compile time error: https://p.jokke.space/SESDq4/
<raz> woopsie, google is down
<FromGitter> <maxbertinetti> Badly down….
<raz> well, i told them to get a backup server but they wouldn't listen πŸ™„
<oprypin> oopsie woopsie
hightower4 has joined #crystal-lang
<FromGitter> <erdnaxeli:cervoi.se> sadly a yielding method cannot be recursive, it bit me today for the AoC puzzle :p
<FromGitter> <erdnaxeli:cervoi.se> I could have use a proc
<frojnd> I have Parser class (src/parser.cr) inside Main class (src/main.cr) I would like to call Parser class, but I'm getting Error: undefined constant Parser on line `class Main < Parser`
<frojnd> Is there someting I'm missing with classes being in each own files?
<frojnd> Do I have to "load" Parser class in main.cr? Just like I have to require "shards"?
<yxhuvud> yes
<frojnd> I did add requre "parser"
<FromGitter> <erdnaxeli:cervoi.se> you need to require the specific file with a relative path
<frojnd> But then I got message `Error: can't find file 'parser'`
<FromGitter> <erdnaxeli:cervoi.se> require "./parser"
<frojnd> Ouh
<FromGitter> <jrei:matrix.org> Hi from Matrix
<FromGitter> <erdnaxeli:cervoi.se> hi :)
<FromGitter> <jrei:matrix.org> i tried to post a message in IRC from Matrix, not sure it works
<repo> works
<FromGitter> <jrei:matrix.org> You received "Test2"?
<FromGitter> <jrei:matrix.org> I don't see it there in Matrix and Gitter
<FromGitter> <Blacksmoke16> repo: pretty sure thats not the right setup
<FromGitter> <erdnaxeli:cervoi.se> > <@jrei:matrix.org> i tried to post a message in IRC from Matrix, not sure it works ⏎ ⏎ what did you tried?
<FromGitter> <erdnaxeli:cervoi.se> the freenode channel in bridged in #freenode_#crystal-lang:matrix.org
<FromGitter> <jrei:matrix.org> This one yes erdnaxeli (https://matrix.to/#/@erdnaxeli:cervoi.se)
<FromGitter> <jrei:matrix.org> On Matrix
<FromGitter> <jrei:matrix.org> (Element)
<FromGitter> <jrei:matrix.org> Screenshot_2020-12-14-14-55-07-358_im.vector.app.png (https://gitter.ems.host/_matrix/media/v1/download/matrix.org/vdkjOBHETXmmxpqKjPYLlrnQ)
<FromGitter> <erdnaxeli:cervoi.se> it should have worked, that's weird
<FromGitter> <jrei:matrix.org> Anyway, going to use the Gitter channel instead of IRC in Matrix
<repo> Blacksmoke16: oh ok that should work!
<FromGitter> <erdnaxeli:cervoi.se> > <@jrei:matrix.org> Anyway, going to use the Gitter channel instead of IRC in Matrix ⏎ ⏎ that's probably a better idea :p
<FromGitter> <Blacksmoke16> πŸ‘
<raz> sigh... those times when the code in front of you is so terrible, you try different different syntax themes to see if that makes it any better
* raz mumbles something about go-lang
<frojnd> haha
<raz> blacksmoke16: can athena have a little cookbook about auth? (i assume it's easy, but not sure where to start looking. would like an annotation `@[Auth]` that grabs the token from auth-header, looks up user, makes it available in the endpoint-handler)
<FromGitter> <Blacksmoke16> can check those out
<raz> ahhh!
<raz> how did i miss that
<raz> thanks πŸ™‡β€β™‚οΈ
<FromGitter> <Blacksmoke16> πŸ‘
<frojnd> I have a file wuth bunch of lines like this: `{"2021-01-01" => "bla"}` I would like to add stuff to it and make it json so it would look like this: https://carc.in/#/r/a405 so reading file line by line and then how to make this enormous json?
<FromGitter> <Blacksmoke16> gl
<FromGitter> <Blacksmoke16> why does the file contain ruby/crystal hashes in the first place?
<frojnd> First it was array: `array = Array(Array(String)).new` then I added inside some data like this: `array << ["#{date}", verse_id]` and after that I made it hash: `hash = array.to_h`
<FromGitter> <Blacksmoke16> can you regenerate the data in the file?
<FromGitter> <Blacksmoke16> that would be easier
<frojnd> And make it json dynamically?
<FromGitter> <Blacksmoke16> i mean like do `array.to_json` instead, then write that to the file?
<frojnd> Well **** let me activate my server... It's my ISP's issue I can't reach bunch of US sites wiych HTTP:Client.get "url"
<frojnd> This weekend I went to other location and it worked like charm... just to let you know if you remember my last HTTP::Client.get "url" not working
<FromGitter> <Blacksmoke16> might be able to write a regex that matches like `/" => "/` and replaces it with `": "`
<FromGitter> <Blacksmoke16> then just parse it as json
<frojnd> Wait so in the end it looks like this: `{"2020-12-14" => "MT 21:23-27 "}` ?
<frojnd> Wait so in the end it looks like this: `{"2020-12-14" : "MT 21:23-27 "}` ?
<FromGitter> <Blacksmoke16> neither of those are valid json
<FromGitter> <Blacksmoke16> it should be like `{"2020-12-14": "MT 21:23-27"}`
<frojnd> Ok
<frojnd> Ok done
<frojnd> I have structure in that file that is `{"foo": "bar"}` now how can I make it more complex? like I showed here: https://carc.in/#/r/a40f
<FromGitter> <Blacksmoke16> parse it, modify it, resave it
<frojnd> Is it valid now if it looks like this: https://carc.in/#/r/a40j
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> assuming you parse each line on its own
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<Andriamanitra> erdnaxeli: i also tried to write a recursive yielding method for today :D
<FromGitter> <erdnaxeli:cervoi.se> ahah ^^
<repo> hmm i noticed that micrate now needs sqlite libs for linking
<repo> even when i'm not using sqlite
<repo> cannot find -lsqlite3
<repo> probably need sqlite-static
<FromGitter> <erdnaxeli:cervoi.se> on which system are you compiling?
<repo> docker alpine image
<FromGitter> <erdnaxeli:cervoi.se> on alpine you need sqlite-static + sqlite-dev
<repo> ah also sqlite-dev
<repo> hm no seems sqlite-static was enough
<FromGitter> <erdnaxeli:cervoi.se> oh, good to know
<repo> still i can't recall, that micrate needed the lib beforfe
<repo> -f
<repo> i've been using it for years
johnny101 has quit [Ping timeout: 256 seconds]
<repo> Blacksmoke16: hey! quick question about athena validator with granite: how would i go and validate the presence of a foreign key?
<FromGitter> <Blacksmoke16> I.e. your doing like `POST {"user_id": 10, ...}` and you want to ensure a user with ID 10 exists?
<repo> yes
<repo> and that it exists
<repo> i tried annotating the belongs_to macro but then weird things started to happen :D
<FromGitter> <Blacksmoke16> annotating it with what?
<repo> @[Assert::NotBlank]
<FromGitter> <Blacksmoke16> i see
<repo> but it might be an underlying problem: i'm using strings as primary keys
<FromGitter> <Blacksmoke16> boo :p
<repo> `column id : String, primary: true, auto: false`
<repo> yeah i guess it's boo
<FromGitter> <Blacksmoke16> id create a custom constraint for it
<repo> they're existing ids
<repo> hmm?
<FromGitter> <Blacksmoke16> something like
<repo> `column id : String, primary: true, auto: false`
<repo> `belongs_to user : User, foreign_key: id : String`
<repo> `Error: A primary key must be defined for BackendApi::Models::MediaAsset`
<repo> before i just had `belongs_to :user` but then it interpreted the "{"user_id":"foo"} as an int
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fd7994855c9c37b30662b42]
<FromGitter> <Blacksmoke16> something ilke that
<FromGitter> <Blacksmoke16> ```@[Assert::Exists(User)] ⏎ column ...``` [https://gitter.im/crystal-lang/crystal?at=5fd7995f67034a3e900a4c8c]
<FromGitter> <Blacksmoke16> untested, but thats the general idea
<FromGitter> <repomaa> why column?
<FromGitter> <repomaa> shouldn't it be on top of `belongs_to ...`?
<FromGitter> <Blacksmoke16> that should work too, want to apply it to whatever ivar holds the fk value
<FromGitter> <repomaa> yeah
<FromGitter> <repomaa> then i seem to have a problem with granite
<FromGitter> <repomaa> because it doesn't let me use strings as foreign keys
<repo> sorry, i'm writing on different channels :D
<FromGitter> <Blacksmoke16> can you share your models?
<repo> sure
<repo> don't mind the assert groups, they're still a bit off
<FromGitter> <Blacksmoke16> `A primary key must be defined for BackendApi::Models::MediaAsset` and this is the error you get?
<FromGitter> <Blacksmoke16> πŸ€”
<repo> yes
<FromGitter> <Blacksmoke16> you sure?
<FromGitter> <Blacksmoke16> i setup those files and did `pp BackendApi::Models::MediaAsset.new` and it worked fine
<repo> wtf
<FromGitter> <Blacksmoke16> like those are the only two files you have?
<repo> no i have controllers etc
<FromGitter> <Blacksmoke16> what granite version?
duane has joined #crystal-lang
<repo> 0.21.1
<FromGitter> <Blacksmoke16> yea no, created a new app, added athena, granite, and sqlite deps
<FromGitter> <Blacksmoke16> then created a file with your code and was fine
<FromGitter> <repomaa> weird..
<FromGitter> <Blacksmoke16> oh wait, needed to actually interact with it more
<repo> ah ok
<FromGitter> <Blacksmoke16> what i dont get is like: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fd79f0628a57c581b122fc7]
<FromGitter> <Blacksmoke16> annotation is being added with `primary: true`
<FromGitter> <repomaa> yeah should be
<FromGitter> <Blacksmoke16> ah i see whats happening
<FromGitter> <Blacksmoke16> :phew: not an athena issue πŸ˜‰
<FromGitter> <repomaa> hehe
<FromGitter> <Blacksmoke16> `belongs_to user : User, foreign_key: id : String`
<FromGitter> <Blacksmoke16> thats adding another `@id : String?` ivar
<FromGitter> <repomaa> ahhh
<FromGitter> <Blacksmoke16> sure that shouldnt be like `foreign_key: user_id : String`?
<FromGitter> <repomaa> ahh
<FromGitter> <repomaa> yes
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <repomaa> i thought foreign_key would name the column of the key in the other table
<FromGitter> <Blacksmoke16> i never remember how all that works ha
<FromGitter> <repomaa> but this probably happens through some other magic
<FromGitter> <repomaa> should be user_id on both sides, right?
<FromGitter> <Blacksmoke16> im not sure
<FromGitter> <Blacksmoke16> off the top of my head
<FromGitter> <repomaa> seemed to work
<FromGitter> <repomaa> thanks a lot! :)
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <kingsleyh> is there a way to get the last 10 elements from a range? I can see first but not last on Enumerable
<FromGitter> <Blacksmoke16> did you try `.last 10`
<FromGitter> <kingsleyh> like (0..100_000_000).each.select(&.even?)
<FromGitter> <kingsleyh> there is no .last
<FromGitter> <Blacksmoke16> :0
<FromGitter> <kingsleyh> for Iterator::Select
<straight-shoota> iterator and enumerable only work in one direction
<FromGitter> <kingsleyh> any plans to have last ?
<straight-shoota> that doesn't work generically
<straight-shoota> for range, maybe we could add it
<FromGitter> <kingsleyh> Ruby has `take` for that scenario
<straight-shoota> you can use range.reverse_each.first(10)
<straight-shoota> but take works like first
<FromGitter> <kingsleyh> ah yeah oops
<straight-shoota> in fact, maybe Range could actually implement Indexable
<FromGitter> <Blacksmoke16> how would that work
<straight-shoota> yeah it could only work for integer ranges
<FromGitter> <kingsleyh> reverse_each does what I want - thanks :)
<FromGitter> <Blacksmoke16> character range too prob
<FromGitter> <Blacksmoke16> anything finite that is
<straight-shoota> so maybe not Indexable directly, but it could have a number of indexable methods, like last
erdnaxeli has joined #crystal-lang
erdnaxeli has left #crystal-lang ["User left"]
<yxhuvud> wouldn't that just be an alias of #end ?
<FromGitter> <anthonyshull> anyone have a good pattern for mimicing inheriting from a string?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <anthonyshull> basically we have a type ISOString that is just a string in ISO format that could have time and/or time and a timezone
<FromGitter> <anthonyshull> so i want to be able to have methods for `time?` and `timezone?`
DTZUZU has quit [Remote host closed the connection]
DTZUZU has joined #crystal-lang
<FromGitter> <anthonyshull> i'm assuming there is some kind of stringer interface
<FromGitter> <anthonyshull> `to_s`
<FromGitter> <Blacksmoke16> any reason to not just use a `Time`?
<FromGitter> <anthonyshull> would that be flexible enough to deal with just having a date, having a date time, and having a date time with timezone?
<FromGitter> <anthonyshull> i need to be able to support all three
<FromGitter> <anthonyshull> when i looked at time it tried to pin an instance, i believe
<FromGitter> <anthonyshull> which, we obviously won't have if we have no timezone. we can't assume UTC
<FromGitter> <anthonyshull> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5fd7b9211f36292125ef5d9e]
<FromGitter> <anthonyshull> but i think i would lose all string methods
<FromGitter> <Blacksmoke16> hm
<FromGitter> <Blacksmoke16> i mean doesnt every time have a timezone?
<FromGitter> <anthonyshull> not if they don't report it
<FromGitter> <anthonyshull> it's five o'clock somewhere
<FromGitter> <anthonyshull> java has separate classes for date, datetime, and datetime with timezone
<FromGitter> <Blacksmoke16> mk
<FromGitter> <Blacksmoke16> fwiw in your example you want to do `def to_s(io : IO) : Nil`
<FromGitter> <anthonyshull> what i want to be able to do is have some methods on top of string methods. so they could still do something like split on 'Z'
<FromGitter> <anthonyshull> ah, thanks
<FromGitter> <anthonyshull> i'm thinking maybe the best thing would just be helper functions that map `string -> bool` for things like `timezone?`
<FromGitter> <Blacksmoke16> got an example of what that would look like?
<FromGitter> <anthonyshull> haven't thought about implementation yet. probably just some regex looking for 'Z' or '+' or '-'
<FromGitter> <anthonyshull> helper functions should just go in a module, right?
<FromGitter> <Blacksmoke16> not unless you intend to use them elsewhere?
<FromGitter> <Blacksmoke16> couldnt they just be methods in that type
<FromGitter> <anthonyshull> well, if i have a type ISOString then i would lose all methods like `split`
<FromGitter> <Blacksmoke16> is that something you want to call on your instance directly?
<FromGitter> <Blacksmoke16> `forward_missing_to @value`
<FromGitter> <anthonyshull> yeah
<FromGitter> <anthonyshull> omg, that's perfect
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <anthonyshull> you have been super helpful as always
<FromGitter> <anthonyshull> googling `crystal lang inherit from string alternative` netted me nothing
<FromGitter> <jrei:matrix.org> Can you give an example of the String format?
<FromGitter> <HertzDevil> why do you want to keep them as strings
<FromGitter> <anthonyshull> they are https://en.wikipedia.org/wiki/ISO_8601
<FromGitter> <anthonyshull> this is for an SDK and the underlying API returns different granularity depending on the underlying service provider
<FromGitter> <anthonyshull> so keeping the values as strings allows the user to use string methods...like split on 'Z'
<FromGitter> <anthonyshull> if we tried to cast to `Time` we would be making assumptions that the end user might not want to make since Time is an instant (meaning you have to know the timezone)
<FromGitter> <HertzDevil> but why would you let the clients do the splitting
<FromGitter> <anthonyshull> we are going to provide some convenience methods
<FromGitter> <jrei:matrix.org> @anthonyshull: not really, because methods exists on it to set/change timezone
<FromGitter> <jrei:matrix.org> `#location`, `#zone` for instance
<FromGitter> <anthonyshull> i don't think that's a very good user experience...we cast the TZ to something and then the user can override it
<FromGitter> <anthonyshull> better to say ... here is a string and some convenience methods but we're not going to make assumptions
<FromGitter> <jrei:matrix.org> `Time` has all the convenience methods needed
<FromGitter> <jrei:matrix.org> What assumptions? It justs parse the date
<FromGitter> <anthonyshull> yes, but we *have* to make an assumption about the TZ
<FromGitter> <anthonyshull> which we don't know
<FromGitter> <jrei:matrix.org> ha ok
<FromGitter> <jrei:matrix.org> There are dates with no timezones?
<FromGitter> <jrei:matrix.org> or there are in UTC?
<FromGitter> <jrei:matrix.org> > Z is the zone designator for the zero UTC offset
<FromGitter> <anthonyshull> no, it's very common in industry for time to be reported local time but without the timezone information
<FromGitter> <Daniel-Worrall> Pretty sure `Time` can parse all those scenarios
<FromGitter> <anthonyshull> so, i worked in oil and gas and one company would report everything in CST because that is where their headquarters was
<FromGitter> <jrei:matrix.org> for example, there is just 16:01:05.... nice
<FromGitter> <anthonyshull> `Time represents a date-time instant in incremental time observed in a specific time zone.`
<FromGitter> <jrei:matrix.org> @Daniel-Worrall: Time needs a timezone :/
<FromGitter> <anapsix> > did you try `.last 10` ⏎ ⏎ oh nice.. beats `[-10..-1]`
<FromGitter> <anthonyshull> in this application something happened at 4pm...but 4pm where? where your headquarters is? where the event happened? etc.
<FromGitter> <jrei:matrix.org> maybe use UTC, and document it ?
<FromGitter> <anthonyshull> so, because we really don't know it's safer not to assume and cast it to 4pm UTC
<FromGitter> <anthonyshull> yeah, that could lead to events happening seemingly on different days depending on the time difference
<FromGitter> <jrei:matrix.org> If you use UTC, you can use `Time.parse_utc`
<FromGitter> <anthonyshull> haha, it's not about not having methods to parse time
<repo> jrei: are you on matrix.org or are you running your own home server?
<FromGitter> <anthonyshull> it's that you have to have an instant in time in a timezone which we do not know
<repo> i'm still waiting for anything that isn't python to self host
<FromGitter> <anthonyshull> it's like saying we want a float but we don't know the mantissa so we're just going to say it's .5 and document it
<repo> well.. not _anything_
<FromGitter> <anthonyshull> that's really weird
<FromGitter> <jrei:matrix.org> repo: matrix.org. I ran in the past mine, but not bothering with it now
<repo> but something a bit less resource hogging
<repo> jrei: alright
<FromGitter> <jrei:matrix.org> @anthonyshull: or you can use a custom type to make it clear
<FromGitter> <anthonyshull> making a type `ISOString`
<FromGitter> <jrei:matrix.org> which then holds the string, and `Time`, for example
<FromGitter> <jrei:matrix.org> yeah
<FromGitter> <jrei:matrix.org> note that you probably want to be a struct, being immutable
<straight-shoota> Why not go just use dedicated types for date and floating time?
<FromGitter> <jrei:matrix.org> repo: resources is not really the problem for home use with Python
<FromGitter> <jrei:matrix.org> it's usually the environment and admin, like venvs, dependencies, upgrade
<straight-shoota> stdlib doesn't provide that, but you could easily add your own. Should be sufficient to make them simple structs wrapping `Time` and only exposing what's relevant
<FromGitter> <HertzDevil> just looked at ruby and it actually has a dedicated date class
<FromGitter> <jrei:matrix.org> sometimes python-dev gcc is needed, then make. If we upgrade the OS, it can break the app because of dynamic linking, etc
<FromGitter> <HertzDevil> it uses the julian epoch
r0bby has quit [Read error: Connection reset by peer]
<FromGitter> <anthonyshull> yeah, like i was saying, java has date, datetime, and datetime with timezone
<repo> jrei: ouch
<FromGitter> <anthonyshull> so i could use a union of those three and they could pattern match
<repo> jrei: i might be giving dendrite a try
r0bby has joined #crystal-lang
<FromGitter> <HertzDevil> and it's more than just the date portion of `Time` because it needs to support multiple calendar reforms
<FromGitter> <jrei:matrix.org> repo: not sure it is a good idea, will be less stable with less feature
<repo> not a fan of go but it's way further on the way to a fully featured synapse replacement than conduit
<repo> jrei: mmh i gues
<repo> s
<FromGitter> <jrei:matrix.org> ha, looks better now
<FromGitter> <jrei:matrix.org> last time I looked to Dendrite, it was far from production ready
<FromGitter> <jrei:matrix.org> (maybe I'm mixing with an other), it was using ElasticSearch - which is a huge no for me
<repo> oh boy
<FromGitter> <HertzDevil> ruby actually has `Time` (date + time) and `DateTime` (date + time + calendar)
<straight-shoota> Java's date and time API actually has about 9 different date/time types or so
<straight-shoota> so you can always do "more" :D
zorp has joined #crystal-lang
<straight-shoota> but I think the scope of Crystal's stdlib is fine. `Time` represents a timeline instant and is fully based on the ISO calendar.
<straight-shoota> That's sufficient for basic needs
<FromGitter> <jrei:matrix.org> repo: ha no, that was Kafka
<repo> yeah that's almost as bad
<repo> but it can run without kafka for smaller deployments
<repo> with "naffka"
<FromGitter> <jrei:matrix.org> hopefully yes! For a homeserver, SQLite for the win!
<repo> mmh postgres is fine i think
<FromGitter> <jrei:matrix.org> why bother?
<repo> it's no bother?
<FromGitter> <jrei:matrix.org> sqlite is fast for few users, easy to backup, light
<FromGitter> <jrei:matrix.org> Postgres you need to upgrade, do SQL thing to create an user, passwords, etc
<repo> naah
<repo> not in docker
<FromGitter> <jrei:matrix.org> it will use more resources like a synapse + sqlite then
<repo> no it won't :D
<FromGitter> <jrei:matrix.org> more than sqlite then
<repo> don't mistake postgres for sqlite
<repo> *mariadb
<repo> yes sure, more than sqlite
<Andriamanitra> sqlite is nice for quickly putting something up but the lack of features does get annoying quickly
<FromGitter> <jrei:matrix.org> Andriamanitra but here we won't touch posgtres, dendrite will
<FromGitter> <jrei:matrix.org> as said in the INSTALL.md doc, depends on your deployment size. If you're alone, there will be no difference.
<FromGitter> <jrei:matrix.org> as you prefer then. Docker + postgres sounds overkill, I'd just put the binary somewhere + systemd unit file personally
<repo> ?
<repo> how is that overkill
<repo> if i already have a docker swarm running multiple services
<Andriamanitra> docker + postgres sounds simpler than messing with systemd and binaries tbh
<repo> ^
<FromGitter> <jrei:matrix.org> fair enough then
<FromGitter> <jrei:matrix.org> Andriamanitra not for me, systemd is really simple (like 5 lines)
<Andriamanitra> so is docker, like 2 commands :p
<FromGitter> <jrei:matrix.org> yeah, as you wish
<FromGitter> <jrei:matrix.org> Really, by experience, I prefer having things simple, because sh** happens.
<Andriamanitra> and as a bonus it makes it trivial to migrate between machines if ever necessary
<FromGitter> <jrei:matrix.org> K8S is a mess :(
<repo> jrei: your simple clearly isn't my simple though :)
<FromGitter> <jrei:matrix.org> scp -r the directory, on my case
<FromGitter> <jrei:matrix.org> Simple for devs != simple for admins
<Andriamanitra> it's probably just a matter of which tools we're familiar with :p
<FromGitter> <jrei:matrix.org> K8S make it simple to continuously deploy, but there are multiple layers which makes debugging harder
<FromGitter> <jrei:matrix.org> no, really, I know what I'm talking about Andriamanitra. I mean, just see the codebase of K8S
<FromGitter> <jrei:matrix.org> At work we have Hardware -> EC2 VM -> K8S pod -> the app, vs in my home: Raspberry PI -> the app
<FromGitter> <jrei:matrix.org> it is a bad decision to go to K8S if we have not enough resources...
<repo> and don't get me wrong, i know my way around systemd. I've written probably around 100 service with all the bells and whistles systemd has to offer. Including socket activation, protected system, change root, etc. I like docker for it's simplicity to define all services needed for an application in a single file. It's trivial to update and to migrate across servers.
<FromGitter> <jrei:matrix.org> So I don't see what's wrong with synapse
<repo> it's a resource hog
<FromGitter> <jrei:matrix.org> If you use Docker + Swarm + Postgres, resources optimization is not the most important
<repo> they have their own chapter in the readme for it
<straight-shoota> overhead with orchestration can certainly make sense when you're managing hundreds or of nodes
<FromGitter> <jrei:matrix.org> repo: did you have issues?
<repo> a friend did
<straight-shoota> but for a single app deploy: not so much
<FromGitter> <jrei:matrix.org> really, as said before, depends of the users
<FromGitter> <jrei:matrix.org> how many?
<repo> like.. 5?
<FromGitter> <jrei:matrix.org> this will do, really.
<FromGitter> <jrei:matrix.org> synapse it largely capable of 5 concurrent users. Matrix.org runs it with a lot more
<repo> no, he had 5 users, and complained about massive ram usage
<repo> with what hw specs? :D
<repo> because that, too, matters
<FromGitter> <jrei:matrix.org> ... not sure it was because of synapse/Python.
<repo> otoh this was maybe 2 years ago. things might've changed since then
<FromGitter> <jrei:matrix.org> that's not because a program is in Go vs Python that it won't have memory leaks
<FromGitter> <jrei:matrix.org> and/or consume lots of RAM
<repo> of course not
<FromGitter> <jrei:matrix.org> Personally, I'd go for synapse: production-ready, less likely to have bug/leaks in consequence.
<repo> yeah i'll give it a og
<repo> go
<repo> sorry, this has been crazily off topic :D
<FromGitter> <jrei:matrix.org> Would be great is synapse is compatible with dendrite
<FromGitter> <jrei:matrix.org> then you could switch easily
<FromGitter> <jrei:matrix.org> ... yeah ^.^'
<FromGitter> <jrei:matrix.org> Anyway, my main point is to have something that fits your need ;) ⏎ Enterprises and people like having HA, perf and so on but sometimes it not a good deal
<FromGitter> <jrei:matrix.org> and also, scalability
<FromGitter> <jrei:matrix.org> swarm is good, to bad it was "replaced" by K8S :(
<repo> mmh
<FromGitter> <jrei:matrix.org> no?
<repo> i've avoided having to deal with that
<repo> still use swarm in production
<repo> k8s seems so overkill for most of my use cases
<FromGitter> <jrei:matrix.org> in your job? Yes it is a good idea
<FromGitter> <jrei:matrix.org> Nomad is another option
<repo> yeah in my job
<FromGitter> <jrei:matrix.org> repo: you're "DevOps"?
<repo> naah
<repo> but i have to deal with that a lot
<FromGitter> <jrei:matrix.org> ...a dev in a startup, I guess?
<repo> we're a small company
<repo> heh yeah it feels like a startup
<repo> but it's been around since 1996 :D
<repo> i like it though. i have great freedom and am lucky to write crystal in my daily job
<FromGitter> <jrei:matrix.org> πŸ‘οΈ for using Matomo
<repo> :)
<FromGitter> <jrei:matrix.org> like the site. A bit heavy, but good look
_ht has quit [Remote host closed the connection]
<repo> i'll let the frontend team know :)
<FromGitter> <anthonyshull> is there a way to alias namespaces so you don't have to type them out fully every time?
<FromGitter> <anthonyshull> i can't find anything in the requires or modules sections of the docs
<repo> sure
<FromGitter> <anthonyshull> awesome, thanks
<FromGitter> <anthonyshull> is that in the docs somewhere?
<repo> hm i don't know
<repo> i guess it's not explicitly mentioned, that you can abbreviate namespaces like this
<FromGitter> <anthonyshull> yeah, it's like 1 sentence at the bottom of a page in Programming Crystal
<FromGitter> <jrei:matrix.org> repo: I post there because I don't where otherwise: I got `CORS header β€˜Access-Control-Allow-Origin’ missing` when accepting your invite
<repo> ah nice
<repo> hm
<repo> oh boy
<repo> nothing works :D
<repo> i can't join any rooms either
<FromGitter> <jrei:matrix.org> likely a configuration is missing
<FromGitter> <jrei:matrix.org> AFAIK, by default, the server is "isolated"
<repo> likely
<FromGitter> <jrei:matrix.org> that's legit if the goal is to have a corporate chat
<repo> hm no resources is [client, federation]
<repo> log is full of errors :/
<repo> meh, another time