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
postmodern has joined #crystal-lang
DTZUZU has joined #crystal-lang
trepanger_ has joined #crystal-lang
chachasmooth has quit [Ping timeout: 276 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 252 seconds]
chachasmooth has joined #crystal-lang
<FromGitter> <kevinsjoberg> straight-shoota: Are you looking into the problem I talked about yesterday? I fixed it in asdf-crystal, but the permanent solution would be to adjust the dylib path to be @executable_path/../embedded/lib/libyaml-0.2.dylib for macOS.
<FromGitter> <kevinsjoberg> I looked into the distribution-scripts yesterday and have found the place to do the change, but wasn't sure how to test it out.
<FromGitter> <kevinsjoberg> I can confirm that the binary you linked contains the hardcoded path for libyaml.
_ht has joined #crystal-lang
sorcus has quit [Ping timeout: 245 seconds]
daemonwrangler has joined #crystal-lang
hendursaga has joined #crystal-lang
hendursa1 has quit [Ping timeout: 240 seconds]
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<frojnd> Hi tehre
<frojnd> I get `Unhandled exception: no results (DB::NoResultsError)` when selecting column that does not exist in sqlite database. How can I rescue this?
<frojnd> I will not know at a runtime if column exists or not exists depending on search criteria
<FromGitter> <naqvis> doesn't normal exception process work?
<FromGitter> <naqvis> ```begin ⏎ # Do some work ⏎ rescue ex : DB::NoResultError ⏎ # handle exception ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=609bbe3bba27415f9b913256]
<frojnd> I think it should. I talked to someone in sqlite chan and said this zero row return is specific to scalar search queries. Not sure if this is is a bug or..
<frojnd> Ok this is just how it is. It's expected from me to write resuce for scalar
<FromGitter> <dinko-pehar> What kind of "heredoc" identifier can be used when heredoc strings ? I see example of XML, HTML and so on... can it be used for example to create CSS, JSON etc. ⏎ https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html#heredoc
<FromGitter> <naqvis> `identifier` can be anything. Be it `FOO` or `BAR`
<FromGitter> <naqvis> as long as start/closing identifiers match
postmodern has quit [Quit: Leaving]
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=609bc280012fc62dd5b3e05a]
<FromGitter> <dinko-pehar> But using it in response. for example server, should I only set `content_type` ?
<yxhuvud> surprisingly even `end` works as a delimeter. x_x
<FromGitter> <dinko-pehar> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=609bc317f94378630983d55c]
<FromGitter> <naqvis> its because you are sending "JSON"
<FromGitter> <dinko-pehar> I edited now, but what I'm asking will the Crystal set content type autimatically or should I set it for every type ?
<FromGitter> <naqvis> default content_type is `text`
<FromGitter> <naqvis> so for other content-types you would have to set that in your code
<FromGitter> <dinko-pehar> So this can be also as json response ? I don't see the reason for delimiter thing.. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=609bc3f76ad4c77d6e882a32]
<FromGitter> <dinko-pehar> Actually, based on delimiter it recognizes and applies highlight on content inside delimiters (in vscode)
<FromGitter> <naqvis> that should be vs code plugin doing some tricks, but to crystal compiler `heredoc` is just a string
<FromGitter> <naqvis> and heredoc are used when you have strings spanning multiple lines
<FromGitter> <dinko-pehar> OK, thank you again @naqvis
<FromGitter> <naqvis> 👍
<FromGitter> <naqvis> > *<frojnd>* I think it should. I talked to someone in sqlite chan and said this zero row return is specific to scalar search queries. Not sure if this is is a bug or.. ⏎ ⏎ that's the same behavior in Crystal-db. This `NoResultsError` is only raised when you call `QueryMethods#scalar` http://crystal-lang.github.io/crystal-db/api/0.10.1/DB/QueryMethods.html#scalar(query,*args_,args:Array?=nil)-instance-method
<FromGitter> <naqvis> for other query methods it shouldn't be raised
<frojnd> @naqvis 👍
<FromGitter> <naqvis> but question would be, if you are executing a query against a db with column you don't know if its present or not, shouldn't rdbms raising an error for columns which are not part of DDL?
<FromGitter> <Blacksmoke16> @dinko-pehar https://crystal-lang.org/reference/syntax_and_semantics/literals/string.html#heredoc, a bit more information on heredocs
<FromGitter> <kevinsjoberg> straight-shoota: I saw your post on GitHub. Out of curiousity, how did you go about not building libyaml dynamically? I'm fairly new to the C eco system in general.
<straight-shoota> simple configure flag
<FromGitter> <kevinsjoberg> Thanks, didn't know about that flag. :)
kevinsjoberg has joined #crystal-lang
<straight-shoota> Me neither
<straight-shoota> I'm by far not an expert on this
<straight-shoota> but when building libraries you usually have a choice of building static and/or dynamic
<kevinsjoberg> I appreciate it nevertheless. I think we should be all good now then. Future versions of the binary will work as expected and my patch to asdf-crystal will make sure prior binaries work properly as well. :)
<straight-shoota> ack
_ht has left #crystal-lang ["https://quassel-irc.org - Chat comfortably. Anywhere."]
<kevinsjoberg> and now I learned something else. Had to look up what "ack" was slang for, haha.
<straight-shoota> :D
<FromGitter> <ryanstout> quick question. Installing the compiler from source, how do I copy things into /usr? If I copy crystal_build_dir/bin/* or crystal_build_dir/.build/* to /usr/bin for example, I get errors about it not being able to find the prelude. (Would adding a make install be an option?)
duane has quit [Ping timeout: 260 seconds]
<straight-shoota> you need to place the wrapper in /usr/bin/crystal (https://github.com/crystal-lang/distribution-scripts/blob/master/linux/files/crystal-wrapper)
<straight-shoota> it's responsible to configure the build environment
<straight-shoota> .build/crystal goes into /usr/lib/crystal/bin/crystal
<straight-shoota> alternatively, you can just put a symlink to crystal_build_dir/bin/crystal in PATH
<FromGitter> <ryanstout> I still get the prelude issue when building shards, when putting crystal_build_dir/bin on PATH
<FromGitter> <ryanstout> thanks for the help, I'll try copying .build/crystal and the wrapper
<straight-shoota> hm, then CRYSTAL_PATH is misconfigured
<straight-shoota> what's `crystal_build_dir/bin/crystal env CRYSTAL_PATH` ?
<straight-shoota> or no, wait that's the issue
<FromGitter> <ryanstout> are there docs on this anywhere?
<straight-shoota> you can't put crystal_build_dir/bin/crystal in PATH
<straight-shoota> it needs to be a symlink with a different name, otherwise the wrapper script from the repo calls itself when trying to figure out the env config
<FromGitter> <ryanstout> ok, that explains why it hangs now
<FromGitter> <ryanstout> which file needs to be a symlink? (sorry, a bit confused)
<FromGitter> <ryanstout> thanks for the help
<straight-shoota> I mean something like `ln -s crystal_build_dir/bin/crystal crystal-local`
<straight-shoota> eh, less confusingly: `ln -s crystal_build_dir/bin/crystal /usr/bin/crystal-local`
<straight-shoota> that should work
<FromGitter> <ryanstout> ok, so now that gives me: ⏎ ⏎ ```CRYSTAL_PATH env variable does not contains /usr/src``` ⏎ ⏎ over and over [https://gitter.im/crystal-lang/crystal?at=609bf49a5358db5f8d17b22b]
<FromGitter> <ryanstout> where should CRYSTAL_PATH point?
<straight-shoota> to the location of the standard library
<straight-shoota> so that would probably be crystal_build_dir/src
<FromGitter> <ryanstout> ok, still gives me that error when pointing to crystal_build_dir/src
<FromGitter> <ryanstout> ```echo $CRYSTAL_PATH ⏎ /root/crystal/src``` [https://gitter.im/crystal-lang/crystal?at=609bf4f6da0d527d8247aa2d]
<FromGitter> <ryanstout> (using docker, hence the /root)
<straight-shoota> no idea where that error might come from
<straight-shoota> can you run with bash -x
<straight-shoota> ?
<FromGitter> <ryanstout> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=609bf56a012fc62dd5b46e2b]
<FromGitter> <ryanstout> with `set -x` right?
<straight-shoota> yes, debugging the commands
<FromGitter> <ryanstout> ok, I rebuild that part of the container, which seemed to fix it. Not sure what changed. Do I need to the CRYSTAL_PATH set to that build to prevent it from using the pacman one?
<straight-shoota> not really
<straight-shoota> CRYSTAL_PATH is usually not configured globally, the wrapper just sets it directly before executing the compiler
<FromGitter> <ryanstout> ok, thanks
<FromGitter> <ryanstout> thanks for the help
<straight-shoota> yw
<FromGitter> <ryanstout> I would offer to add a `make install` PR, but I don't really know `make`
<straight-shoota> I think make install would indeed be useful
<FromGitter> <ryanstout> ok, so next issue is trying to build shards using `crystal-local`. If I symlink to just `crystal` it hangs
<FromGitter> <ryanstout> and it looks like shards just tries `crystal`
<straight-shoota> you should be able to build shards with `make CRYSTAL=crystal-local`
<FromGitter> <ryanstout> cool, thanks
<straight-shoota> If you can't make the PR yourself, you could at least post a feature request for make install
<FromGitter> <ryanstout> will do
<FromGitter> <ryanstout> next issue, I just tried building shards on the latest shards release, and on master. Using both 1.0.0 of crystal and master I built. I get: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=609bf942f1397c69073edeaa]
<straight-shoota> is shards_build_dir/lib/molinillo installed?
<straight-shoota> the makefile should do that
<FromGitter> <ryanstout> I'm guessing its not, how would I check if its installed
<FromGitter> <ryanstout> I don't have a shards command currently
<FromGitter> <ryanstout> (trying to build it)
<straight-shoota> just ls the directory
<FromGitter> <Blacksmoke16> iirc it should fallback on curl or something
<straight-shoota> yes, the makefile should download it, even if no shards is available for bootstrap
<FromGitter> <ryanstout> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=609bfa2cbbac4857d4e15c4b]
<FromGitter> <ryanstout> it did, maybe didn't put it on the right path
<FromGitter> <ryanstout> ah, needs shards to install shards?
<straight-shoota> no that's fine, it falls back to curl if shards missing
<straight-shoota> is lib in your CRYSTAL_PATH
<straight-shoota> ?
<FromGitter> <ryanstout> just src
<straight-shoota> okay, make it `lib:src`
<straight-shoota> (full path for src ofc)
<FromGitter> <ryanstout> no luck
<FromGitter> <ryanstout> `echo $CRYSTAL_PATH ⏎ /root/crystal/lib:/root/crystal/src`
<FromGitter> <ryanstout> same error
<straight-shoota> not /root/crystal/lib
<straight-shoota> just "lib"
<straight-shoota> literal
<FromGitter> <ryanstout> but src is the full path?
<straight-shoota> lib directory relative to working directory
<straight-shoota> yes
<straight-shoota> src is for grabbing the global standard library, lib is the local shard dependencies
<FromGitter> <ryanstout> ok, thanks. Sorry for all of the noob questions
<FromGitter> <ryanstout> ok, looks like that worked
<FromGitter> <ryanstout> thanks
<FromGitter> <ryanstout> can I do a PR that adds to the docs somewhere? (though I'm only partially understanding the details of it)
<straight-shoota> hm I don't think there is any documentation about building the compiler you could expand on
<FromGitter> <ryanstout> ok, I'll try to add some docs and do a PR when I get a few. Any other details that should be in there?
duane has joined #crystal-lang
<frojnd> Hm. I'm trying to understand db scalar select statement. `select rowid, date from dailymeditation where DATE == DATE('2021-02-02');` gives me: https://termbin.com/8oqb in sqlite terminal but code in crystal: `db.scalar "select rowid, date from dailymeditation where DATE == DATE('2021-02-02');"` gives me: `33`
<frojnd> How can I get both rowids or dates?
<FromGitter> <Blacksmoke16> doesnt sql just use `=`
<frojnd> Where?
<FromGitter> <Blacksmoke16> `DATE = DATE('2021-02-02')`
<frojnd> Not sure which is correct :) same result
<FromGitter> <Blacksmoke16> looks like they're equivalent
<FromGitter> <Blacksmoke16> idt you want to use scalar in this case
<FromGitter> <Blacksmoke16> because the value you're selecting isn't scalar
<FromGitter> <Blacksmoke16> i.e. not a single value
<frojnd> Aha
<frojnd> So query
<FromGitter> <Blacksmoke16> yea prob
<FromGitter> <Blacksmoke16> http://crystal-lang.github.io/crystal-db/api/0.10.1/DB/QueryMethods.html#query_all(query,*args_,args:Array?=nil,astypes:NamedTuple)-instance-method is prob what you'd want?
<FromGitter> <Blacksmoke16> or even the tuple one 2 down
<FromGitter> <Blacksmoke16> no, deff the first one. Or more ideally http://crystal-lang.github.io/crystal-db/api/0.10.1/DB/QueryMethods.html#query_each(query,*args_,args:Array?=nil,&)-instance-method this one so you dont have to deal with (named)tuples
<FromGitter> <Blacksmoke16> depends on exactly what you want to do with the output
<frojnd> That query example is fine for me
<FromGitter> <Blacksmoke16> if you just want to iterate over something, just use `query_each` then
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo20 has joined #crystal-lang
alexherbo20 has quit [Ping timeout: 252 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo2 has joined #crystal-lang
<repo> Blacksmoke16: heya! quick question about athena serializer: is it possible to somehow annotate classes from other libs?
<repo> i'm writing c bindings for a library and ultimately would need to serialize the objects into json. it would feel kind of weird though to add the annotations (and pull athena serializer as a dep) in that c binding lib
<repo> the properties of those objects are in fact getters using the c lib
<repo> some of which might be expensive/unnecessary to always call
<FromGitter> <Blacksmoke16> could ofc reopen them and add the annotation. is like what i do in https://github.com/athena-framework/athena/blob/master/src/ext/negotiation.cr
<FromGitter> <Blacksmoke16> or alternatively have some wrapping type
<FromGitter> <oprypin:matrix.org> oh nice, https://github.com/sdogruyol/tren *is* the native interpolation solution. but could've been done without separate files too
<straight-shoota> +1
<FromGitter> <oprypin:matrix.org> & without macro run is also possible, i suppose
<FromGitter> <oprypin:matrix.org> (though it will look like https://github.com/oprypin/retour/blob/master/src/retour.cr :D )
<FromGitter> <rishavs> If I use `Random::Secure.urlsafe_base64(4, padding: false) `, the size of the resulting string is not 4, but is 6. Is this expected? ⏎ https://play.crystal-lang.org/#/r/b4mq
<FromGitter> <Blacksmoke16> thats prob what `padding: false` does
<FromGitter> <rishavs> i tried all variations, true/false/not specified. In all cases the size of the string is larger than the gievn value ⏎ https://play.crystal-lang.org/#/r/b4mv
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
<FromGitter> <Blacksmoke16> right
<straight-shoota> The argument determines the number of bytes, not the number of characters
<FromGitter> <Blacksmoke16> it'll then base64 encode those bytes which has some size overhead as well afaik
<straight-shoota> exactly. 4 bytes encoded in base64 takes 6 characters, plus 2 for padding
<FromGitter> <rishavs> ah. got it.
<FromGitter> <RespiteSage> @oprypin:matrix.org Have you used the `.from_stream` methods in `crSFML` at all? I'm not sure how or if they're supposed to work.
<FromGitter> <RespiteSage> I see they exist, but I don't see them in any of the examples.
<FromGitter> <oprypin:matrix.org> @RespiteSage: closest example might be SoundStream https://github.com/oprypin/crsfml/blob/cc4bc5cd0048dba1477b728263121ee64d5b6fda/examples/echo.cr#L21
<FromGitter> <RespiteSage> Thanks!
<FromGitter> <oprypin:matrix.org> hm that "closest" isn't close at all though :o
<FromGitter> <oprypin:matrix.org> @RespiteSage: just try implementing those abstract methods and see how that goes. https://oprypin.github.io/crsfml/tutorials/system/stream.html ⏎ i'm actually not confident that it works
<FromGitter> <RespiteSage> I'm trying to download an image and turn it into a texture. In my use case (just messing with the library to make a little domain-specific data visualization tool), it's fine to write a temp file, though, so instead of using a stream I just wrote to the temp file and then used `.from_file`.
<FromGitter> <RespiteSage> Well, I might make an attempt at that. It seems useful to be able to do with the shard.
<FromGitter> <oprypin:matrix.org> @RespiteSage: `MemoryInputStream` is very easy and saves you the temp file (though it's still not streaming)
<FromGitter> <RespiteSage> Yeah, that's a good point.
<FromGitter> <RespiteSage> I don't really need to stream, so I'm happy with that solution.
<FromGitter> <RespiteSage> Voila! ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=609c51c3c60a604255b6ac17]
<FromGitter> <RespiteSage> Thanks again!
<FromGitter> <oprypin:matrix.org> @RespiteSage: that's `stream = SF::MemoryInputStream.open(image_in_memory.to_slice)`
<FromGitter> <oprypin:matrix.org> probably an implementation of `InputStream` based on `IO` would be very useful :o
<FromGitter> <ryanstout> if I have a recursive type that looks like: ⏎ ⏎ ```@@data : Type = Type{"key" => "value"}``` ⏎ ⏎ but is there a simpler way to take a more complex data structure (think JSON) and convert it to a custom type (without specifying the type on all Hashes. (or am I thinking about this wrong) [https://gitter.im/crystal-lang/crystal?at=609c53702ee2b13d95a5bc93]
<FromGitter> <Blacksmoke16> recursive aliases are bad
<FromGitter> <ryanstout> @Blacksmoke16 I'm parsing something similar to JSON
<FromGitter> <Blacksmoke16> could you do something like `JSON::Any`?
<FromGitter> <ryanstout> isn't that a recursive alias?
<FromGitter> <Blacksmoke16> no
<FromGitter> <Blacksmoke16> similar concept but it uses an actual type that accepts a value of a scalar value, or a more complex type made up of also this type https://crystal-lang.org/api/master/JSON/Any.html#new(raw:Type)-class-method
<FromGitter> <ryanstout> reading the source.. I was using https://github.com/crystal-community/toml.cr/blob/master/src/toml.cr
<FromGitter> <Blacksmoke16> *thats* a recursive alias, which arent great
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/5155 related
<FromGitter> <ryanstout> thanks, reading #5155
<DeBot> https://github.com/crystal-lang/crystal/issues/5155 ([RFC] Remove recursive aliases)
<FromGitter> <RespiteSage> This would be fantastic.
alexherbo2 has quit [Ping timeout: 240 seconds]