ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
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.
<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 -]
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:
<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``` []
<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> <> I'll stop adding a cron build to my projects using GitHub Actions – I'm spammed by deacrivated CIs after 60days of inactivity
<FromGitter> <> Also I'm not alerted if the build fails, it is quite useless
<FromGitter> <> j8r ( don't know why you're not alerted, must have messed up some notification config
<FromGitter> <> regarding deactivated CIs - *that's* where *I* didn't get notified. did you?
<FromGitter> <> I chose to receive no mails
<FromGitter> <> well don't choose that :D
<FromGitter> <> it is possible to get alerted in GH notifications?
<FromGitter> <> seems not
<FromGitter> <> regarding deactivating crons... you wouldn't believe what the solution is. make a cron that activates them.
<FromGitter> <> haha lol, which means have a "keep alive commit"
<FromGitter> <> no no there's an explicit "activate" api
<FromGitter> <> i'll tell you more later, don't have my code at hand now
<FromGitter> <> ok, why not then... I'll consider this for bigger projects
<FromGitter> <> tempFileForShare_20210208-133004.jpg (
<FromGitter> <> noice
<FromGitter> <> I now checked "Web" and the "Send..."
<FromGitter> <> i actually prefer mail only, then i set up an email filter in a way that the email app doesn't notify me
<FromGitter> <> in my workflow in a way the Web notifications are the high priority ones
<FromGitter> <> I don't like mail, I use it at minimum. Very easy to get spammed.
<FromGitter> <> Yeah on my side I always have a pinned tab with GH notifications
<FromGitter> <> 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> <> you can do that with GitHub notifications
<FromGitter> <HertzDevil> > should `record` be documented here? ⏎ ⏎ 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 ``
<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> 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``` []
<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``` []
<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:
<FromGitter> <alexherbo2> ```code paste, see link``` []
<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``` []
<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``` []
<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> 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 ``) from within the body of a class definition?
<FromGitter> <RespiteSage>
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:
<FromGitter> <RespiteSage> Which is complicated by adding `YAML::Serializable`:
<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``` []
<FromGitter> <RespiteSage> ^
<FromGitter> <RespiteSage> Proving so:
<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``` []
<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> <> 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?? ⏎
<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> ([RFC] Effective request URL for `HTTP::Server`)
<FromGitter> <> (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> <> `HTTP::Client.get("")`
<FromGitter> <> how do i log exactly that string?
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
<FromGitter> <Blacksmoke16> 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> <> 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> <> 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> <> straight-shoota, there is no protocol
<straight-shoota> ?
<FromGitter> <> oh in the client there is protocol
<FromGitter> <> well then that's indeed possible, so can just add a `uri` method
<oprypin> it's not good though
<FromGitter> <> aa i switched client again
<FromGitter> <> 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> <> i was trying to make that possible with a small change but that didn't pan out
<FromGitter> <> is the least that can be done here
<FromGitter> <> (but it's for a different issue I had)
issyl0 has quit [Ping timeout: 240 seconds]
issyl0 has joined #crystal-lang
<FromGitter> <> 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