<FromGitter>
<watzon> I'm going to use it for userbots, and eventually to make a terminal client for Telegram. Just have to wait on a good terminal UI library.
<FromGitter>
<watzon> And it should be several times faster than the popular Python libraries being used
<postmodern>
watzon, is there any preference on crystal- vs .cr for the repo name?
<FromGitter>
<watzon> I prefer `.cr` personally
<FromGitter>
<Blacksmoke16> those are fine for the repo name, but the shard name should probably not be either
<FromGitter>
<watzon> Definitely
<FromGitter>
<watzon> Because that's the name that has to be `require`d
<postmodern>
if you have to map in C stuff from include/linux/, what lib name should it go under? LibC or Linux?
<postmodern>
or the main Lib?
<FromGitter>
<tenebrousedge> is it theoretically possible that that could be split off into a separate shard, either now or in the future?
<postmodern>
tenebrousedge, well this is for the v4l2 library, which is part library and part kernel API
<postmodern>
also is there a good way to do mass assign-by-value to a struct. ex: foo.bar = {1,2,3,{'a', 'b'}}? Or do I have to do foo.bar = Bar.new(a: 1, b: 2, c: 3, baz: Baz.new(a: 'a', b: 'b'))
<FromGitter>
<Blacksmoke16> prob the latter
<FromGitter>
<tenebrousedge> the latter
<FromGitter>
<Blacksmoke16> dont have to give the name for each arg if you provide them in right order tho
<FromGitter>
<tenebrousedge> and there's the `Foo{ }` syntax
<FromGitter>
<tenebrousedge> which is that even documented?
<FromGitter>
<watzon> Not as far as I know
<FromGitter>
<tenebrousedge> but IIRC if the class implements `[]` you can do e.g. `Array{1, 2, 3}` or `Hash{1 => 2, 3 => 4}`
<postmodern>
ooooh
<FromGitter>
<watzon> Well `[]=` anyway
<postmodern>
hmm getting undefined method << for my struct
<FromGitter>
<Blacksmoke16> does it define a `<<` method?
<FromGitter>
<watzon> Well in the case of C structs you can't really define methods on them. So you'll want to make a wrapper.
<FromGitter>
<watzon> I also don't know that there's a way to initialize a C struct unless the C lib provides a way to do so. You can probably use `Pointer(StructName).malloc`
<postmodern>
it's just populating fields in .bt, which judging by the number of fields has to be V4L2BTTimings
<postmodern>
can't find an example of where these timings would be used. I'm guessing you'd create the struct on the stack, populate fields with your appropriate defaults, and call some ioctl to inform the kernel side of v4l2
<postmodern>
suppose i could leave this bit unfinished. probably no one uses those macros...
sagax has quit [Quit: Konversation terminated!]
<postmodern>
ah ha, Bytes.new(io.size) and io.read_bytes(bytes) did the trick with reading binary data
<postmodern>
kind of wish that was a one-liner like File.read_bin or something
<postmodern>
which repo contains the `crystal init` tool? it irks me that LICENSE is generated without a .txt ext (something that i think Windows still requires)
<FromGitter>
<Blacksmoke16> crystal itself
<FromGitter>
<tenebrousedge> I have to confess to a total disregard, verging on contempt, for Windows filesystem conventions
<FromGitter>
<watzon> Same
<FromGitter>
<watzon> It's kind of a Github convention to have a license file just as LICENSE
<FromGitter>
<tenebrousedge> I think it's not just a Github convention, I think it's an old Unix/BSD thing
<FromGitter>
<tenebrousedge> like, decades old
<postmodern>
i don't care for windows much myself, but having file extensions on files to denote their format/contents is probably a good idea
<FromGitter>
<watzon> Hmm well whatever the case it's pretty common. Windows just kinda sucks.
<FromGitter>
<watzon> In some repos I do a markdown license
<postmodern>
appears looks like crystal 0.33's markdown parser isn't liking github style ``` blocks. it's translating the "```yaml" to "`yaml"
<postmodern>
https://github.com/postmodern/udis86.cr well here's my first crystal library. can't figure out why two specs keep failing. would appreciate it if you mercilessly critiqued it ;)
<FromGitter>
<watzon> Yeah it doesn't support GFM
<FromGitter>
<watzon> Which specs aren't passing?
<postmodern>
#input_skip and #operands. No clue about #input_skip. Thinking the generated assembled code is incorrect. udcli keeps outputting it as 16bit asm for some reason
_whitelogger has joined #crystal-lang
wakatara has left #crystal-lang ["Using Circe, the loveliest of all IRC clients"]
sagax has joined #crystal-lang
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 272 seconds]
return0e has quit [Ping timeout: 255 seconds]
return0e has joined #crystal-lang
sz0 has joined #crystal-lang
_whitelogger has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 272 seconds]
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
alexherbo22 has joined #crystal-lang
<Nilium>
It seems like sometimes when running tests via crystal spec, it'll eventually end up with something invalid and any subsequent runs will fail until I destroy most of ~/.cache/crystal -- is that a known problem? Haven't been able to consistently reproduce it, just seems to occasionally degrade.
<Nilium>
After a little more searching, looks like it might be related to #5890, though that seems to have only hit CI, so maybe something different (or I'm cursed, which wouldn't be unusual).
<wakatara>
While the cli examples in the codebase are handy, does anyone have any great examples of crystal cli apps designed for users (rather than just tech tasks) that they think are good examples of how to structure and build one? Have a few small projects I'd like to do in crystal and wanted to look at what good looks like (aspirationally... =] ).
<FromGitter>
<tenebrousedge> like shards ?
<FromGitter>
<tenebrousedge> or ameba ?
<FromGitter>
<tenebrousedge> or like a TUI ?
<wakatara>
No, more like heroku cli or similar. Or jrnl or passpie in python land (as app examples)
<wakatara>
or even gopass.
<wakatara>
A compiled tool to be designed to use on the cli for accomplishig a specific set of tasks.
<wakatara>
newsboat for newsreader. gopass for password management etc etc.
<FromGitter>
<tenebrousedge> that would include `shards`, `ameba`, and `crystal` itself, in my book
<wakatara>
But written in Crystal. =]
<FromGitter>
<tenebrousedge> but you might also check awesome-crystal
<FromGitter>
<watzon> Is there a PR for `check_type`?
<FromGitter>
<Blacksmoke16> no, but with that one PR you could define one
<FromGitter>
<Blacksmoke16> and just reuse that where you need this
<FromGitter>
<watzon> Ahhh
<FromGitter>
<Blacksmoke16> so heres a question, say you have a route controller action
<FromGitter>
<Blacksmoke16> and you have one argument that is not nilable with no default value
<FromGitter>
<Blacksmoke16> and a value for it fails to be resolved from a request
<FromGitter>
<Blacksmoke16> what would make more sense
<FromGitter>
<Blacksmoke16> 1) an exception that results in a 500 for the client, and a message saying the controller/action requires a value for x argument ⏎ 2) an exception that results in a 400 for the client saying required parameter x is missing
<FromGitter>
<Blacksmoke16> 500 for the client and internally a message that says*
<FromGitter>
<watzon> I'd go with a 400 error probably, because parameter x in this case is a missing required parameter right?
<FromGitter>
<Blacksmoke16> most likely yea, could also be some logic error in the user's code, but that's probably less likely
<FromGitter>
<watzon> Yeah I'd go the 400 route probably
<FromGitter>
<tenebrousedge> a 400 error seems to imply that something was malformed about the HTTP request itself
<FromGitter>
<tenebrousedge> that it's an issue with the transport rather than the application
<FromGitter>
<watzon> Well 400 can be for incorrect requests, which this is=
<FromGitter>
<Blacksmoke16> maybe 422 then? `The server understands the content type of the request entity (hence a 415 Unsupported Media Type status code is inappropriate), and the syntax of the request entity is correct (thus a 400 Bad Request status code is inappropriate) but was unable to process the contained instructions.`
<FromGitter>
<watzon> Lots of other frameworks do the same
<FromGitter>
<Blacksmoke16> also have one for stackoverflow
<FromGitter>
<watzon> I've just been using Dark Reader
<FromGitter>
<watzon> Works pretty nicely for most sites
<FromGitter>
<phykos> Is there a way to compile the Crystal compiler on ARM (aka Raspberry Pi & friends)? ⏎ I have seen a prebuilt version of Crystal but it's a bit outdated, so can I use that for bootstrapping the compiler?
_ht has joined #crystal-lang
ur5us_ has joined #crystal-lang
<FromGitter>
<j8r> @phykos I was statically linking my app with `crystal build --static` on qemu aarch64
<FromGitter>
<j8r> but now Crystal on Alpine arrch64 is broken with LLVM8 :/. Still, there is 0.30.1 available
<postmodern>
flag? worked but __USE_MISC isn't getting picked up by crystal (C recognizes it)
<FromGitter>
<watzon> Hmmm
<postmodern>
too bad i can't do something like flag("__USE_MISC",true) to default it on, and somehow allow users to do -D__USE_MISC=false to explicitly disable it?
<FromGitter>
<watzon> Yeah idk if anything like that is currently possible
<FromGitter>
<cuboide> hello, everyone!
<FromGitter>
<cuboide> ...that is all
<FromGitter>
<watzon> You might try with `flag?(:use_misc)`
<FromGitter>
<watzon> I'm looking for how PREVIEW_MT was defined in the compiler
<FromGitter>
<Blacksmoke16> its just a bunch of `{% if flag?(:preview_mt) %}`
<FromGitter>
<watzon> And I can't find any definition, just a lot of checks for `flag?(:preview_mt)`
<FromGitter>
<watzon> Yeah
<postmodern>
watzon, does it name mangle the C macros?
<FromGitter>
<watzon> It's possible
<postmodern>
still nothing
<FromGitter>
<watzon> Hmm
<FromGitter>
<watzon> I feel like it should be possible, but who knows
<FromGitter>
<watzon> I can't find anything on it
<postmodern>
if a C func defines __THROW, should I use @[Raises]
<FromGitter>
<watzon> I think so. I haven't actually dealt with that yet.
ur5us has quit [Ping timeout: 240 seconds]
<postmodern>
how do you do C function aliases? macros? alias? type?