ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | 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
alexherbo2 has quit [Ping timeout: 240 seconds]
<FromGitter> <djberg96> no SizeT on Mac? `Error: undefined constant SizeT`
<FromGitter> <djberg96> Also tried `LibC::SizeT`
<FromGitter> <Blacksmoke16> try `::LibC::SizeT`
<FromGitter> <djberg96> ah, yes, thanks
<FromGitter> <Blacksmoke16> you prob have your `LibC` type in some custom namespace
<FromGitter> <djberg96> is `GC.malloc_atomic(256).as(UInt8*)` really the way to allocate an in/out char buffer?
<FromGitter> <djberg96> seems...i dunno, scary
<FromGitter> <Blacksmoke16> :shrug:
<straight-shoota> how did you end up with that?
<FromGitter> <djberg96> was that question for me? i found it in the crystal source code while looking for sysctl examples, e.g. executable_path.cr
<straight-shoota> yes. okay
<straight-shoota> didn't understand how your question was meant
<straight-shoota> why scary?
<FromGitter> <djberg96> well, in ruby you just create a regular string buffer, e.g. `buf = 0.chr * 256`
<FromGitter> <djberg96> i guess i'm not sure why i'm touching GC (which I assume is the garbage collector), using `malloc` directly, and then casting it
<straight-shoota> you shouldn't need to interface with the garbage collector directly unless you're doing very specific stuff
<straight-shoota> that's very low level
<straight-shoota> in user code you would usually use `Bytes` (or even `StaticArray`)
<FromGitter> <djberg96> ah, thanks!
chachasmooth has quit [Ping timeout: 272 seconds]
chachasmooth has joined #crystal-lang
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 258 seconds]
chachasmooth has quit [Ping timeout: 258 seconds]
chachasmooth has joined #crystal-lang
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
deimos_ has quit [Quit: leaving]
deimos_ has joined #crystal-lang
<FromGitter> <djberg96> @asterite run in terror from mkmf
<FromGitter> <djberg96> I wrote this btw: https://github.com/djberg96/mkmf-lite
<FromGitter> <djberg96> it just does checking, not building, but it's designed as a library and it's easy unlike the monstrosity that is mkmf.rb
bazaar has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
aquijoule_ has quit [Remote host closed the connection]
aquijoule_ has joined #crystal-lang
HumanG33k has quit [Read error: Connection reset by peer]
HumanG33k has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <bararchy> hmmm why does stumpy on `0.36.1` get this error? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60210db0ae4b9b27c1a8f614]
<FromGitter> <bararchy> there is a require `digest/crc32`
<FromGitter> <bararchy> hmmm seems to compile with : `::Digest::CRC32.update(slice, @crc)`
postmodern has quit [Quit: Leaving]
<FromGitter> <jrei:matrix.org> I'll stop adding a cron build to my projects using GitHub Actions – I'm spammed by deacrivated CIs after 60days of inactivity
<FromGitter> <jrei:matrix.org> Also I'm not alerted if the build fails, it is quite useless
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org) don't know why you're not alerted, must have messed up some notification config
<FromGitter> <oprypin:matrix.org> regarding deactivated CIs - *that's* where *I* didn't get notified. did you?
<FromGitter> <jrei:matrix.org> I chose to receive no mails
<FromGitter> <oprypin:matrix.org> well don't choose that :D
<FromGitter> <jrei:matrix.org> it is possible to get alerted in GH notifications?
<FromGitter> <oprypin:matrix.org> seems not
<FromGitter> <oprypin:matrix.org> regarding deactivating crons... you wouldn't believe what the solution is. make a cron that activates them.
<FromGitter> <jrei:matrix.org> haha lol, which means have a "keep alive commit"
<FromGitter> <oprypin:matrix.org> no no there's an explicit "activate" api
<FromGitter> <oprypin:matrix.org> i'll tell you more later, don't have my code at hand now
<FromGitter> <jrei:matrix.org> ok, why not then... I'll consider this for bigger projects
<FromGitter> <oprypin:matrix.org> tempFileForShare_20210208-133004.jpg (https://gitter.ems.host/_matrix/media/v1/download/matrix.org/deXaxpHbZgOVQJikSVOhQjZb)
<FromGitter> <jrei:matrix.org> noice
<FromGitter> <jrei:matrix.org> I now checked "Web" and the "Send..."
<FromGitter> <oprypin:matrix.org> i actually prefer mail only, then i set up an email filter in a way that the email app doesn't notify me
<FromGitter> <oprypin:matrix.org> in my workflow in a way the Web notifications are the high priority ones
<FromGitter> <jrei:matrix.org> I don't like mail, I use it at minimum. Very easy to get spammed.
<FromGitter> <jrei:matrix.org> Yeah on my side I always have a pinned tab with GH notifications
<FromGitter> <oprypin:matrix.org> i like. i tell GitHub to also send me my own comments. then i get full threads of my participation (and can actually search it, can u imagine??)
<FromGitter> <jrei:matrix.org> you can do that with GitHub notifications
<FromGitter> <HertzDevil> > should `record` be documented here? https://crystal-lang.org/reference/syntax_and_semantics/structs.html ⏎ ⏎ crystal-lang/crystal-book#379
<straight-shoota> The crystal-book is intended to be a language reference, but record is not a language feature.
<straight-shoota> Ideally we should have a separate language reference and a guide which combines language and stdlib
<straight-shoota> For practical reasons, it would probably be best to add a note that stdlib offers a macro for easy struct definition
<raz> yup macro docs in general are a bit tricky to find (but they're also tricky to document, so that makes sense)
<straight-shoota> Macros themselves are easy to document, just as methods
<straight-shoota> The key is to know what's a macro and what's a language feature :D
willamin has quit [Read error: Connection reset by peer]
issyl0 has quit [Read error: Connection reset by peer]
sz0 has quit [Read error: Connection reset by peer]
Liothen has quit [Read error: Connection reset by peer]
entel has quit [Read error: Connection reset by peer]
r0bby has quit [Read error: Connection reset by peer]
<raz> well yea, but figuring out which parts of the api-docs refer to macros took me a few passes to figure out ;)
<raz> once you get the hang of `TypeNode` etc. it becomes easier, but early on i never knew where to look
willamin has joined #crystal-lang
sz0 has joined #crystal-lang
<straight-shoota> ah, thought you mean macro defs
Liothen has joined #crystal-lang
<raz> ah yep, conflated the two. for "use-only" macros it's indeed a bit easier.
entel has joined #crystal-lang
<straight-shoota> macro reflection is a bit more hidden, yes. but IMO that's good because it's more advanced topic
r0bby has joined #crystal-lang
issyl0 has joined #crystal-lang
<FromGitter> <alexherbo2> what is the recommended way to generate a temporary filename?
<FromGitter> <Blacksmoke16> File.tempfile
<FromGitter> <alexherbo2> it creates a temporary file no?
<FromGitter> <alexherbo2> I'm messing around with `mkfifo` in `Process.run`
<FromGitter> <alexherbo2> I need to attribute a path for the `mkfifo` command and clean it when the program exit
<raz> you could close/unlink it and then re-use the filename, or perhaps make up your own in Dir.tempdir
<FromGitter> <alexherbo2> having a temporary dir could be nice for that usage, so I can create files in it
<FromGitter> <alexherbo2> yeah, I was thinking about the ruby tempdir
<raz> ah, wait!
<raz> https://crystal-lang.org/api/0.36.1/File.html#tempname(prefix:String?,suffix:String?,*,dir:String=Dir.tempdir)-class-method
<raz> there's actually a way to get only a temp filename without creating it :)
<FromGitter> <alexherbo2> omg
<FromGitter> <Blacksmoke16> right
<FromGitter> <Blacksmoke16> `File.tempfile` creates the file in your system's tmp dir as well
<FromGitter> <alexherbo2> yeah but `mkfifo` expect its argument to be a file that does not exist
<FromGitter> <Blacksmoke16> ah yea, then just use the other method if all you need is the name
<FromGitter> <alexherbo2> when using the tempname, does crystal remove it when the program exit, or it's our responsability to do it?
<FromGitter> <Blacksmoke16> remove what?
<raz> yours
<FromGitter> <Blacksmoke16> > Returns a fully-qualified path to a temporary file. The file is not actually created on the file system.
<raz> old neckbeard trick: create file, open it, then delete it.
<FromGitter> <Blacksmoke16> why?
<FromGitter> <Blacksmoke16> when there is a method that does exactly what he wants without creating file at all
<raz> ensures it disappears even when the processes crashes without cleaning up
<FromGitter> <Blacksmoke16> but theres nothing to cleanup
<FromGitter> <Blacksmoke16> unless you mean after `mkfifo` creates it?
<raz> he said he wants to creates fifo's?
<raz> yea sorry, i meant after actually creating it of course ;)
<FromGitter> <Blacksmoke16> that makes more sense. The docs say it's suggested to delete it
<FromGitter> <Blacksmoke16> prob could do something like
<raz> yup, most people just reach for at_exit(), but that's no reliable
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=6021410d24cd6b60d827ce4e]
<raz> well, the delete needs to happen after he opens it ;)
<FromGitter> <Blacksmoke16> right
<raz> oh yea, your code does that
* raz needs more coffee
<FromGitter> <Blacksmoke16> you upgrade to latest version of Athena yet? :p
<raz> hrhr, soon! sadly not much crystal time lately
<FromGitter> <Blacksmoke16> boo :p
<raz> i bet you broke all my fun hacks and i have to rewrite half the thing :p
<FromGitter> <Blacksmoke16> oh boy, what have you done
<raz> well, not too much actually. will prob just be a matter of following all your renames ;)
<raz> i remember something about StreamedResponse or such
<FromGitter> <Blacksmoke16> was really only 3 breaking changes, new annotation alias, rename the logger const, and config stuff
<raz> ah yea, doesn't sound too bad
<raz> will look into it soon'ish
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <djberg96> is there an example of how to filter specs based on tag?
<FromGitter> <djberg96> i have a spec I only want run on darwin, for example
<FromGitter> <Blacksmoke16> can do like `describe "foo", tags: "darwin" do`
<FromGitter> <Blacksmoke16> then can do like `crystal spec --tag 'darwin'`
<FromGitter> <Blacksmoke16> OR, are you wanting to only run a entire spec file only on darwin?
<FromGitter> <alexherbo2> I have methods that are very similar, but I'm not sure how I can refactor them
<FromGitter> <alexherbo2> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60214ca99238c531ad314838]
<FromGitter> <alexherbo2> the only thing changing is the overload of the `send` method
<FromGitter> <Blacksmoke16> is `client` nilable within the `send` method? or is that two overloads as well
<FromGitter> <alexherbo2> I have two methods for `send` using the params for sending to the good method (not sure if it was a good idea)
<FromGitter> <djberg96> @Blacksmoke16 basically something like this: https://github.com/djberg96/sys-cpu/blob/ffi/spec/spec_helper.rb
<FromGitter> <alexherbo2> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60214d299d5c644f665b2c2b]
<FromGitter> <Blacksmoke16> or using the tag stuff, but then you would need a way to determine what tags to use when running the specs
<FromGitter> <HertzDevil> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60214dcb5500a97f82f47e04]
<FromGitter> <djberg96> @Blacksmoke16 hmm, that skips the whole file doesn't it? i was hoping to skip individual specs
<FromGitter> <HertzDevil> if the spec straight up doesn't compile you could wrap it inside `{% unless flag?(:darwin) %}`
<FromGitter> <Blacksmoke16> then you'd need to use the tag thing, or could maybe make a method that wraps describe and doesnt yield if not darwin
<FromGitter> <Blacksmoke16> or i guess is there a reason the spec just cant be fixed to run everywhere?
<FromGitter> <alexherbo2> @HertzDevil I was going to do that thanks
<FromGitter> <alexherbo2> I'm a bit disapointed I cannot manage to leverage the overloading
<FromGitter> <djberg96> seems this is illegal: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=6021568b428d9727dd62e69c]
<FromGitter> <djberg96> syntax error somewhere it looks like, but my eyeballs aren't seeing it
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> whats the error?
<FromGitter> <djberg96> wait...now it's working? maybe i forgot to save, not sure
<FromGitter> <djberg96> wow, some members just straight up empty on Linux, not sure what I did wrong
<FromGitter> <djberg96> oops, forgot the struct size is different and linux has an extra member
<FromGitter> <RespiteSage> Is it expected and intended to be able to call `Class` class methods (like `Class.name`) from within the body of a class definition?
<FromGitter> <RespiteSage> https://carc.in/#/r/adpr
DTZUZU_ has quit [Read error: Connection reset by peer]
<FromGitter> <asterite> @RespiteSage the snippet doesn't match your question
<FromGitter> <asterite> `thing` is an instance method
<FromGitter> <RespiteSage> My point is that I'm able to set `@thing` to the output of `Class.nilable?`.
<FromGitter> <RespiteSage> This question stems from this behavior: https://carc.in/#/r/adps
<FromGitter> <RespiteSage> Which is complicated by adding `YAML::Serializable`: https://carc.in/#/r/adpj
<FromGitter> <asterite> I think the initializer of an instance variable runs at the class level
<FromGitter> <asterite> because at that point there's no instance yet
<FromGitter> <asterite> or maybe not, not sure
<FromGitter> <RespiteSage> That makes sense. I was just surprised to have access to class methods from `Class`.
<FromGitter> <Daniel-Worrall> I think it's getting evaluated in the macro?
<FromGitter> <HertzDevil> you could do the same without `getter`
<FromGitter> <HertzDevil> ```class Foo ⏎ @x : Bool = nilable? ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=6021675132e01b4f71824e7c]
<FromGitter> <RespiteSage> ^
<FromGitter> <RespiteSage> Proving so: https://carc.in/#/r/adpv
<FromGitter> <HertzDevil> imo supporting this implies that there is indeed a `self` in this scope of type `Foo.class`
<FromGitter> <RespiteSage> I guess that makes sense.
<FromGitter> <HertzDevil> but `@x : Bool = self.nilable?` is an error
<FromGitter> <RespiteSage> Huh.
<FromGitter> <RespiteSage> So there's an implicit `self` of `Foo.class` but an explicit `self` of `Foo`?
<FromGitter> <HertzDevil> i prefer that we don't have any `self` here at all
<FromGitter> <RespiteSage> The error from `@x : Bool = self.nilable?` implies that your preference is intended: `Error: there's no self in this scope`.
<FromGitter> <HertzDevil> ruby does have `self` even though the same code means a different thing (ruby classes can have class variables *and* instance variables)
<FromGitter> <HertzDevil> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=602168d29238c531ad319d83]
<FromGitter> <HertzDevil> and yes, `@x = self.ancestors` works on ruby too
<FromGitter> <asterite> Probably a bug in Crystal
<FromGitter> <RespiteSage> Yeah, this should be consistent either way (either allowing both implicit and explicit `self.<method>` in `Klass.class` scope or disallowing both).
<FromGitter> <RespiteSage> I guess unless there's a good reason not to be.
<FromGitter> <RespiteSage> @HertzDevil Do you want to make an issue or shall I?
DTZUZU has joined #crystal-lang
Xorg has joined #crystal-lang
<Xorg> is there a cheat sheet for this lang ?
<FromGitter> <Blacksmoke16> in what regard?
<FromGitter> <Blacksmoke16> either way, not that im aware of
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
Xorg has quit [Quit: WeeChat 3.0]
<FromGitter> <HertzDevil> what's with the playground showing `playpen: application terminated with error code 1` for 0.35.1
_ht has quit [Remote host closed the connection]
<FromGitter> <oprypin:matrix.org> can someone explain to me how HTTP::Request does not have a #uri method?? ⏎ and who wants to log the host and port and path separately?? ⏎ https://github.com/crystal-lang/crystal/blob/master/src/http/log.cr
<FromGitter> <asterite> Isn't resource that? There's a private uri. I think the reason it's not exposed is because uri is mutable, not sure
<FromGitter> <asterite> It feels so good to code in Haskell
<straight-shoota> a request only has a resource, not a URI (typically)
<straight-shoota> see #10246 for effective request URL feature
<DeBot> https://github.com/crystal-lang/crystal/issues/10246 ([RFC] Effective request URL for `HTTP::Server`)
<FromGitter> <oprypin:matrix.org> (this is about http client) my pain point is that i *had* specified a literal URL but it is not possible to log it consistently, without wrapping every possible method of http::client
alexherbo2 has quit [Ping timeout: 264 seconds]
<straight-shoota> you had it specified as `resource` string?
<FromGitter> <oprypin:matrix.org> `HTTP::Client.get("http://example.com/foo?bar")`
<FromGitter> <oprypin:matrix.org> how do i log exactly that string?
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://glassy-framework.github.io/ TIL there's another framework out there :p
<FromGitter> <Blacksmoke16> looks pretty neat
<straight-shoota> oprypin, yeah that's a bit difficult with the current layout
<FromGitter> <oprypin:matrix.org> but i get it now, it's because a client request is being fit into the mold of a server request
<straight-shoota> that may be part of the problem
<FromGitter> <oprypin:matrix.org> wasn't there some issue about this?
<straight-shoota> Client.get deconstructs the URI: initializes an instance with the authority and then sends a request with the path as resource
<straight-shoota> the request object itself doesn't care about authority and scheme
<straight-shoota> it just represents a plain HTTP request which belongs in the context of an HTTP connection
<straight-shoota> but the logger should be able to extract that information from the client instance
<FromGitter> <oprypin:matrix.org> straight-shoota, there is no protocol
<straight-shoota> ?
<FromGitter> <oprypin:matrix.org> oh in the client there is protocol
<FromGitter> <oprypin:matrix.org> well then that's indeed possible, so can just add a `uri` method
<oprypin> it's not good though
<FromGitter> <oprypin:matrix.org> aa i switched client again
<FromGitter> <oprypin:matrix.org> need to get protocol and host from the client, then request_target from the request (or painstakingly construct it from separate parts)
<straight-shoota> yes
<straight-shoota> and there's also Host header... :P
<straight-shoota> maybe logging should rather happen in the class method because there we have a clear URI
<FromGitter> <oprypin:matrix.org> i was trying to make that possible with a small change but that didn't pan out
<FromGitter> <oprypin:matrix.org> https://github.com/crystal-lang/crystal/pull/10375 is the least that can be done here
<FromGitter> <oprypin:matrix.org> (but it's for a different issue I had)
issyl0 has quit [Ping timeout: 240 seconds]
issyl0 has joined #crystal-lang
<FromGitter> <oprypin:matrix.org> mhmmmm `malloc(): unsorted double linked list corrupted` - on that note i think i'll sign out for the day
<straight-shoota> ending the day on something nice would be better... :D