ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.29.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
alex`` has quit [Ping timeout: 272 seconds]
alex`` has joined #crystal-lang
<FromGitter> <watzon> I guess that would work, huh?
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <watzon> Would I just link libssl with `-lssl`?
<rkeene> You'd check via pkg-config --libs openssl probably
<rkeene> And --static if you wanted to link statically
<rkeene> If you want to link statically to JUST OpenSSL you'd do: -Wl,-Bstatic $(pkg-config --libs --static openssl) -Wl,-Bdynamic
<rkeene> Then you'll be statically linked to openssl, but dynamically linked to your other dependencies
<FromGitter> <watzon> What if I wanted to statically link multiple? Just repeat the`pkg-config` part?
<rkeene> For a lot of things, some things don't use pkg-config though
<FromGitter> <tenebrousedge> that sounds annoying
<FromGitter> <watzon> Quite haha. I wish the `--static` flag was supported on more than just alpinelinux
<FromGitter> <watzon> Anyone know why that is?
<rkeene> It's supported on pretty much anything
<rkeene> pkg-config has supported static for a while
<FromGitter> <watzon> I was referring to this https://github.com/crystal-lang/crystal/wiki/Static-Linking
<FromGitter> <watzon> Support in the Crystal compiler itself
<rkeene> I don't know, probably just poor support for it within Crystal... but generally totally static executables aren't a great idea (and most OSes don't support them anyway)
<FromGitter> <watzon> I did just run `crystal build` with the `--static` and `--cross-compile` flags together though and didn't get any errors
<FromGitter> <watzon> Yeah that's true
<FromGitter> <watzon> Sucks
<FromGitter> <watzon> Ahh I got an error when trying to link the `.o` file though
<rkeene> You probably just want to link statically to a few things which you would otherwise redistribute
<rkeene> You'll need to specify all the libraries when linking
<rkeene> ELF shared objects indicate what other libraries they require, but relocatable objects (.o files) don't do this so you have to know
<rkeene> (this is also why you have to include all transitive dependencies when linking statically -- .a (Archive) files are just a group of ELF relocable object files, basically like a zip file without the compression)
<rkeene> As far as I can tell --static within Crystal doesn't care about what platform it is on
<FromGitter> <watzon> What else could be useful to have in the cli? https://github.com/watzon/arachnid/tree/v0.2.0#the-cli
<FromGitter> <girng> --static works on debian
<FromGitter> <girng> nvm, you mean running --static
<FromGitter> <girng> i thought you mean executing the executable on the OS
<FromGitter> <girng> have not tested on debian, sorry
<FromGitter> <girng> so --static only works on WSL and Alpine? wtf
<FromGitter> <girng> I doubt that's true, I'm sure it works on more operating systems
rohitpaulk has joined #crystal-lang
snsei__ has joined #crystal-lang
<FromGitter> <j8r> it doesn't use the latest shards 0.9.0 because it can't solve more than 8+ dependencies (with no limitation)
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
<FromGitter> <j8r> @watzon I don't understand the purpose of https://github.com/watzon/arachnid/blob/master/src/arachnid.cr? Good lib BTW!
alex`` has quit [Ping timeout: 248 seconds]
laaron has quit [Remote host closed the connection]
alex`` has joined #crystal-lang
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
alex`` has quit [Ping timeout: 272 seconds]
alex`` has joined #crystal-lang
lucasb has joined #crystal-lang
<FromGitter> <Blacksmoke16> prob so you can just do `require "arachnid"`
duane has joined #crystal-lang
<FromGitter> <cfsamson> Does anyone know if how (or if) it's possible to access `GC.stack_bottom`. I see this code in `src\crystal\shceduler` and I'm trying to extract out the part of Fibers that does the context switch but it seems the GC is giving me trouble when resuming from a stack, and there is this in the source code: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ But I get `undefined method 'stack_bottom=' for GC:Module` if I
<FromGitter> ... try to access this outside of the compiler.... [https://gitter.im/crystal-lang/crystal?at=5d1a12da490abf627a56dde6]
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> what about `set_stackbottom`
<FromGitter> <j8r> @Blacksmoke16 this was more a question about why having `src/arachnid/`
<FromGitter> <Blacksmoke16> ah
<FromGitter> <Blacksmoke16> dunno
<FromGitter> <watzon> Yeah I don't know either lol
<FromGitter> <watzon> It's waiting on a refactor
alex`` has quit [Quit: WeeChat 2.5]
<FromGitter> <cfsamson> @Blacksmoke16 `set_stackbottom`seems to build at least :)
<FromGitter> <Blacksmoke16> #progress
<FromGitter> <Blacksmoke16> oops
<FromGitter> <cfsamson> Yeah, but not much. Valgrind still reports this for my ~150 lines of code: ⏎ ⏎ ```RROR SUMMARY: 1403 errors from 57 contexts (suppressed: 0 from 0)``` [https://gitter.im/crystal-lang/crystal?at=5d1a191d676ff14d2762f1d1]
<FromGitter> <Blacksmoke16> :shrug: i know like nothing about this :/
<FromGitter> <cfsamson> It's not good.
<FromGitter> <girng> hi
<FromGitter> <Blacksmoke16> o/
<FromGitter> <cfsamson> @Blacksmoke16 Where did you find the documentation on `set_stackbottom`? I also need to do this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1a1b0c676ff14d276303ac]
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/GC.html#set_stackbottom%28stack_bottom%3APointer%28Void%29%29-class-method
<FromGitter> <cfsamson> Thanks
<FromGitter> <wontruefree> @watzon the subnet repo is awesome I am definitely using that. Thanks !!
<FromGitter> <watzon> No problem :) IPv6 support isn't finished yet, but IPv4 should work great
<FromGitter> <wontruefree> I have to read move of the source but it is going to be a lot more solid then what I have now
<FromGitter> <watzon> Luckily for you the documentation is pretty robust
<FromGitter> <Blacksmoke16> and this one has tests 😉
<FromGitter> <watzon> Lots of them
<FromGitter> <watzon> Lol
<FromGitter> <watzon> Has anyone implemented any kind of async queue? Like a fiber pool.
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/toplevel.html#parallel%28%2Ajobs%29-macro ?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/toplevel.html#future%28%26exp%3A-%3EUNDERSCORE%29-class-method
<FromGitter> <watzon> Hmm interesting
<FromGitter> <kinxer> Regarding the `<project_directory>/src/<shard_name>` pattern, I think it's a useful convention for separating library code from driver/setup code. Even when you don't have a driver or setup to do, I think it's useful to use the convention so people know where things are. It also makes it so that you can have another directory under `src/` if you need another, separate `module`.
<FromGitter> <girng> @Blacksmoke16 look what you have done to me https://github.com/crystal-lang/crystal/issues/7942#issuecomment-507304652
<FromGitter> <Blacksmoke16> i dont get it
<FromGitter> <Blacksmoke16> the issue is that json doesnt allow non string keys
<FromGitter> <Blacksmoke16> so when trying to deserialize the json string into an object, it doesnt work since the hash needs Int32 keys, while the json is using String keys
<FromGitter> <girng> he's sending an int32 to the constructor tho
<FromGitter> <girng> it works
<FromGitter> <watzon> Also, "```crystal"
<FromGitter> <watzon> Just sayin
<FromGitter> <Blacksmoke16> right, but he wants the keys of his hash to be `Int32` not strings
snsei__ has joined #crystal-lang
<FromGitter> <girng> if he needs the keys to be int32 he can just do `pp y.locations.keys.map &.to_i`
<FromGitter> <Blacksmoke16> but again thats not the issue
<FromGitter> <Blacksmoke16> doing from_json on his obj should convert the keys from the JSON string to Int32 keys
<FromGitter> <Blacksmoke16> also `y.locations.transform_keys &.to_i` would be better
<FromGitter> <girng> yeah was just reading bcardiff's post, i don't think json spec allows keys to be ints, so it might not even be an issue
<FromGitter> <Blacksmoke16> it doesnt
<FromGitter> <Blacksmoke16> thats the whole point of the issue :P
<FromGitter> <girng> isn't crystal conforming to json spec's standards?
<FromGitter> <Blacksmoke16> when generating the json yes, but it should handle the conversion from valid json, into the types you want
<FromGitter> <Blacksmoke16> in this case at least
<FromGitter> <girng> but the types he wants, doesn't follow json's spec
<FromGitter> <Blacksmoke16> it doesnt matter at that point because hes not using json
<FromGitter> <Blacksmoke16> he wants `{"0": "foo"}` in JSON to be deserialized to a crystal hash like `{0 => "foo"}`
<FromGitter> <Blacksmoke16> because he typed his hash to be `Hash(Int32, String)`
<FromGitter> <Blacksmoke16> i.e. just convert `"0"` to a number on deserialization, based on the type of `K` in the hash. like `asterite ` mentioned
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <girng> @Blacksmoke16 reduced issue: https://play.crystal-lang.org/#/r/760h
<FromGitter> <girng> you are saying he wants that to work?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <girng> it's not valid json
<FromGitter> <Blacksmoke16> right, which is why the deserialization code needs to be updated to do that conversion
<FromGitter> <girng> hmmmm
<FromGitter> <Blacksmoke16> @girng no because thats not valid json
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/760r
<FromGitter> <watzon> Ok, using the `future` approach I just created a sitemap of forum.crystal-lang.org in like 3 seconds. I better be careful or I'm going to end up with an accidental DOS attack 😂
<FromGitter> <Blacksmoke16> oh boy
<FromGitter> <girng> @Blacksmoke16 this is not valid json either tho https://play.crystal-lang.org/#/r/760h
<FromGitter> <girng> what am i missing
<FromGitter> <Blacksmoke16> that in his example the keys are strings
<FromGitter> <watzon> This is the sitemap that was generated in 3 seconds
<FromGitter> <Blacksmoke16> hes trying to deserialize `{"locations":{"2":"Alfa"}}` which is valid
<FromGitter> <watzon> With great power comes great responsibility
<FromGitter> <Blacksmoke16> to_json is basically doing like `hash["2"] = "Alfa"` but since his hash is typed to `Hash(Int32, String)` it doesnt compile
<FromGitter> <girng> `property locations = {} of Int32 => String`
<FromGitter> <girng> doesn't map to valid json
<FromGitter> <Blacksmoke16> it generates valid json, but cant consume said json
<FromGitter> <Blacksmoke16> which is the issue
<FromGitter> <Blacksmoke16> because crystal is always assuming the key is going to be a string
<FromGitter> <Blacksmoke16> when deserializing the json
<FromGitter> <watzon> Here's what I came up with for my queue
<FromGitter> <girng> why does to_json work there
<FromGitter> <girng> it's not valid json
<FromGitter> <girng> it's an int key based hash
<FromGitter> <Blacksmoke16> it *generates* valid json
<FromGitter> <girng> why
<FromGitter> <girng> it should error?
<FromGitter> <Blacksmoke16> no
<FromGitter> <girng> that literally makes zero sense
<FromGitter> <Blacksmoke16> because its not a `1:1` mapping
<FromGitter> <girng> so we can have int : value hashes that generate valid json by converting the int32's to a string. but when loading invalid json, it doesn't convert to a string, but errors out
<FromGitter> <Blacksmoke16> there is some code that takes crystal objects (in this case a hash), and encodes the data into a valid JSON string
<FromGitter> <Blacksmoke16> its loading valid JSON
<FromGitter> <girng> if a hash is an int : value, it should not be allowed to export to valid json, because json spec says keys are strings
<FromGitter> <girng> like wtf
<FromGitter> <Blacksmoke16> but the deserialization step isnt taking into consideration there can be other types of keys besides String
<FromGitter> <watzon> You can generate JSON from anything that implements to_json
<FromGitter> <watzon> But `from_json` requires valid json to parse
<FromGitter> <Blacksmoke16> it's `to_json`'s responsibility to generate valid json
<FromGitter> <girng> well that just will confuse the developer
<FromGitter> <girng> because now they can't load it again
<FromGitter> <girng> because it's not valid json
<FromGitter> <Blacksmoke16> which knows, `hey this key is an Int32, JSON only allows String. I'll convert it to String`
<FromGitter> <Blacksmoke16> *its valid json*
<FromGitter> <Blacksmoke16> how many times to have to say that :P
<rkeene> Blacksmoke16, 5
<FromGitter> <Blacksmoke16> go to https://jsonlint.com/ and paste in the output of https://play.crystal-lang.org/#/r/760z
<FromGitter> <girng> using `property locations = {} of Int32 => String`
<FromGitter> <girng> and `"{\"locations\":{\"2\":\"Alfa\"}}"`
<FromGitter> <girng> is NOT valid
<FromGitter> <Blacksmoke16> but it is
<FromGitter> <girng> that doesn't even make sense
<FromGitter> <girng> no it is not
<FromGitter> <Blacksmoke16> why not?
<FromGitter> <Blacksmoke16> the key in the generated json is a string
<FromGitter> <girng> string based keys
<FromGitter> <Blacksmoke16> which it has
<FromGitter> <girng> that property locations is an Int32 : String
<FromGitter> <girng> Doesn't match, so why does it work
<rkeene> Output: {"locations":{"2":"Alfa"}}
<FromGitter> <Blacksmoke16> ☝️ July 1, 2019 11:50 AM (https://gitter.im/crystal-lang/crystal?at=5d1a2bd3a8b20942babda3fb)
<rkeene> Every key in that is a string
<FromGitter> <girng> `property locations = {} of Int32 => String`
<FromGitter> <girng> how many times
<FromGitter> <girng> do i need to paste that
<rkeene> I don't even know why you guys think your disagreeing with each other
<rkeene> your -> you're
<FromGitter> <girng> `property locations = {} of Int32 => String` is assuming the INCOMING JSON DATA will be: `%({"locations":{2:"Alfa"}})`
<FromGitter> <girng> ..which is *not valid json*
<FromGitter> <Blacksmoke16> but thats not the problem
<rkeene> Right, so the core disagreement is that since the JSON deserializer knows it can't actually look like that it should look for the only possible interpretation of that, "2" must start out as a string and be converted into an Int32, or fail
<FromGitter> <Blacksmoke16> `the deserialization step isnt taking into consideration there can be other types of keys besides String`
<FromGitter> <Blacksmoke16> right
<FromGitter> <Blacksmoke16> then based on the type of `K` in your hash, convert it to the expected type
<rkeene> Well, it knows that the JSON side will always be a string but the desired internal representation could be something different, and apply the correct schema or fail to decode
<FromGitter> <girng> but the deserailization should conform to json's spec, where keys are *strings* only
<FromGitter> <Blacksmoke16> deserialization isnt part of the JSON spec, its the act of converting one format into another
<rkeene> girng, That's the JSON representation, when deserializing it can apply a schema
<FromGitter> <Blacksmoke16> JSON just happens to be the input
<FromGitter> <Blacksmoke16> in this case we're converting JSON into an object, which can have logic that can do this
<rkeene> Bloacksmoke16, JSON is just one representation, and a lossy interchange format -- since we know it's lossy and the ways in which it is lossy it's possible to unambigiously do the right thing (or fail)
<FromGitter> <girng> @Blacksmoke16 yeah, but were also applying logic to that object, to make it conform to spec
<FromGitter> <girng> if a hash is not string key based, how can it conform to the spec??
<FromGitter> <girng> by cheating?
<rkeene> The basic cause of this is that the schema doesn't exist within JSON, it's external so it has to be managed externally
<FromGitter> <girng> then, now, we get issues like that one where it confuses the developer
<FromGitter> <girng> because they think the int32 will work
<rkeene> girng, The representation within the JSON output is a string, when converting it to a different representation you can unambigiously convert it to a known schema (or fail) *IF* a schema is given
<FromGitter> <Blacksmoke16> its not cheating tho. its taking a known format with a known structure, and applying logic to it to get the desired output
<FromGitter> <girng> this is why it's important to conform to the spec on serializing and deserializing
<rkeene> This is just applying a schema to decoding JSON, it's well understood, well documented, and not confusing.
<FromGitter> <Blacksmoke16> which in this case is an object
<rkeene> There's even a standard for doing this
<rkeene> https://json-schema.org/ but, it's not a great fit for Crystal
<FromGitter> <Blacksmoke16> its not a hard problem to understand. the code is just like ⏎ ⏎ ```hash[{% if K <= Number %}K.new key{% else %}key{% end %}] = V.new(pull)``` [https://gitter.im/crystal-lang/crystal?at=5d1a2e01ffd4b84a8fe9bcf8]
<rkeene> Blacksmoke16, That example sucks
<FromGitter> <Blacksmoke16> probably
<FromGitter> <Blacksmoke16> i couldnt think of anything better
sorcus has joined #crystal-lang
<FromGitter> <girng> okay it kinda makes sense basically json has to go in an out of crystal a bit
<FromGitter> <girng> to work for input / output
<FromGitter> <girng> so crystal's object does have the right to output valid json even if they need to convert a hash's key from int32 to string
<FromGitter> <Blacksmoke16> yes, so the reverse should also be true, be able to convert that string back into an Int32
<FromGitter> <Blacksmoke16> since you have the schema to define what they should be
<FromGitter> <Blacksmoke16> i.e. `Hash(Int32, String)`
<FromGitter> <girng> makes sense, i'll delete my posts. thanks
<FromGitter> <watzon> If deserialization conformed to JSON spec that would severely limit us as developers
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
<sorcus> Hi all.
<sorcus> How i can call C macros from crystal?
<sorcus> > #define lxb_dom_interface_document(obj) ((lxb_dom_document_t *) obj)
<FromGitter> <watzon> I don't believe so
<FromGitter> <watzon> You'd have to make a wrapper that calls the macro in a function I believe
<sorcus> Hmm... Ok... Thanks.
<jokke> can you call inline functions in crystal?
<jokke> *inline c functions
<jokke> then it wouldn't be any performance loss
<sorcus> Where i can read about inline functions?
<jokke> hm but this is done by the compiler
<jokke> so i guess not
<jokke> sorcus: i think you're out of luck then
<jokke> you'll have to write a wrapper that's an actual function
<sorcus> Sad :-(
<jokke> yeah but i mean c macros are handled by the c preprocessor
<jokke> has nothing to do with crystal
<jokke> you can reimplement the macros as crystal macros of course
<FromGitter> <watzon> This is true
<jokke> in your case something like https://p.jokke.space/gHZ7J/cr
<sorcus> Ok, i will try.
<jokke> but even better something like this: https://p.jokke.space/kb7lv/cr
<jokke> then you can restrict it to be usable for only the types it makes sense for
<FromGitter> <wontruefree> I just starting messing with https://github.com/crystal-lang/crystal_lib and it is magic I cannot believe its output
<FromGitter> <wontruefree> that is such a time saver
<sorcus> @jokke Looks cool, thanks.
<jokke> np
<jokke> wontruefree: oooh sweet!
<jokke> hm but seems a bit abandoned
<FromGitter> <watzon> Have you tried https://github.com/olbat/libgen?
<FromGitter> <watzon> It's based on crystal_lib
<FromGitter> <watzon> I'm using it for https://github.com/watzon/nacl
snsei__ has quit [Remote host closed the connection]
<jokke> ooh that is awesome!
<sorcus> crystal_lib doesn't want generate binding for macro function `lxb_dom_interface_document`. This is what i got - `Unhandled exception: can't find function lxb_dom_interface_document (Exception)`
<jokke> how does it handle callbacks?
<jokke> sorcus: of course not
<jokke> it's not a function
<jokke> it's a macro
<sorcus> Yeah, i understand it.
<jokke> it won't create bindings for constants defined with #define either
<jokke> or does it?
<jokke> i don't think it does. but it would be amazing if it did
<sorcus> I think no. :-(
<jokke> yeah
<sorcus> Asterite said here - https://forum.crystal-lang.org/t/define-iconv-open-libiconv-open-in-libiconv-1-15/706/2 - "There’s no way to run a C macro from Crystal. Can’t you install it using homebrew?"
<FromGitter> <watzon> No it doesn't
<FromGitter> <watzon> You have to define those constants yourself
<jokke> yeah, makes sense
laaron has quit [Remote host closed the connection]
<jokke> although it should be quite easy to parse
<jokke> hm
<jokke> no
<jokke> it wouldn't
<FromGitter> <watzon> I had to do a lot of that in nacl
<FromGitter> <watzon> Rewriting constants
<jokke> yeah i've done that a lot too
<FromGitter> <wontruefree> @watzon I have not I am checking it out now
<jokke> it's annoying and leaves you with a feeling that it might break as soon as someone changes one of the constants upstream
<jokke> but i guess it's no different in any other language
<jokke> so i don't think the constants are changed lightly
<FromGitter> <wontruefree> @watzon what do you use nacl for?
<FromGitter> <watzon> I was working on a paseto client
<FromGitter> <watzon> Still am, but I got hung up on something so I'm taking a break
<FromGitter> <mwlang> hmm....I'm guessing markdown tables not supported in ```crystal docs``` ? https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#tables
<FromGitter> <watzon> Yeah they don't support GFM
<FromGitter> <watzon> One of the many issues I have with the current doc generation
<FromGitter> <mwlang> meh. I'm struggling with it as well.
<FromGitter> <mwlang> is documentation on the table generally speaking to be improved or is it more or less what we have is what we get for foreseeable future?
<FromGitter> <wontruefree> is that a problem with the markdown parser in the stdlib?
<FromGitter> <mwlang> (heh, no pun was intended with that use of "on the table"...)
<jokke> :D
<jokke> wontruefree: it's just very basic, that's all;
<FromGitter> <watzon> Hopefully doc generation will get better
<FromGitter> <watzon> Or we will have a choice of multiple generators in the future
<FromGitter> <watzon> Like with ruby's YARD and rdoc
<FromGitter> <wontruefree> I would prefer crystal choose a format and if other people want to make other tools that is awesome
<FromGitter> <wontruefree> I have a love hate relationship with markdown
<FromGitter> <watzon> Same. What I want is templates
<FromGitter> <watzon> And metadata tags in comments
<FromGitter> <watzon> Like `@see` and `@note`
<FromGitter> <mwlang> yeah, I've been wanting that as well.
<FromGitter> <wontruefree> I am curious if you would make a document format out of code and macros
<FromGitter> <mwlang> I know backticks kind of sort of work...as long as you're in the same namespace
<FromGitter> <mwlang> gets cumbersome to type it all out all the time.
<FromGitter> <wontruefree> yeah and it seems like there are bigger fish to fry
<FromGitter> <watzon> @wontruefree what do you mean?
snsei__ has joined #crystal-lang
<jokke> probably parallelilsm and windows support :P
<jokke> -l
<FromGitter> <mwlang> another would-be-nice-to-have is to write annotated specs that builds browseable documentation.
<FromGitter> <mwlang> like cucumber relish project: https://relishapp.com/
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
<FromGitter> <mwlang> but really, I would settle for improving the markdown tagging/formatting support.
<FromGitter> <watzon> That would be pretty cool. I'd like to be able to run documentation examples as specs
<FromGitter> <mwlang> run 'em as spec, tag 'em as examples to show in README. :-)
<FromGitter> <mwlang> another idea for documentation...when a method has a lot of possible parameters... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1a4622ddd2c007c742deff]
<FromGitter> <mwlang> be able to get the intended table I wanted above with a reduced format like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1a46788dff05627ba90298]
<FromGitter> <watzon> This is a shitty tradeoff, but I think you can include html in the markdown. So you could do a HTML table.
<FromGitter> <mwlang> As it is, it just looks terrible:
<FromGitter> <watzon> Yeah
sz0 has joined #crystal-lang
<FromGitter> <wontruefree> @watzon there are other features like windows support or something that probably take priority
sorcus has quit [Quit: WeeChat 2.5]
<FromGitter> <jwoertink> I have a macro where I call `run`, but I keep getting a "can't find file" error. Is there a way to see what file context I'm in at the point it runs?
<FromGitter> <watzon> Yup there are. Really the standard library needs to be divided up first, and ideally the documentation generator needs to be separated from the compiler into it's own shard.
sorcus has joined #crystal-lang
<FromGitter> <jwoertink> ```{% raise `ls -la` %}```
<FromGitter> <jwoertink> ok, doing that seems to help some
<FromGitter> <jwoertink> The weird thing though is that if I put in the path according to what that returns, I still get file not found
<FromGitter> <jwoertink> Maybe the path passed to `run` and what system returns as `pwd` are not the same context?
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
<FromGitter> <mwlang> so, uhm...try ```{% raise `pwd` %}``` ? That's what I'd be trying to test that hypothesis.
alex`` has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
<FromGitter> <mwlang> I tend to use File.expand_path explicitly to avoid these sort of issues.
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
<FromGitter> <jwoertink> I did that, and used that path in `run`, but I still get that error
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
snsei__ has joined #crystal-lang
snsei__ has quit [Remote host closed the connection]
<FromGitter> <watzon> Can anyone tell me why this doesn't work as expected? https://carc.in/#/r/761d
<rkeene> I'm going with "The Universe Hates You"
<FromGitter> <Blacksmoke16> what are you expecting it to be?
<FromGitter> <Blacksmoke16> to pull the `%F` out via regex?
<FromGitter> <watzon> Exactly
<FromGitter> <watzon> It's pulling it out, but Time isn't parsing it
rohitpaulk has joined #crystal-lang
<FromGitter> <tenebrousedge> because you're not passing it?
<FromGitter> <watzon> What do you mean? It's being passed.
<FromGitter> <watzon> The output shows that
<FromGitter> <watzon> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1a594affd4b84a8feb6149]
<FromGitter> <tenebrousedge> `Time.now.to_s("\\1") #=> "\\1"`
<FromGitter> <tenebrousedge> so your expression is just pulling off the parens
<FromGitter> <watzon> Of course `Time.now.to_s("\\1") #=> "\\1"` is going to output `"\\1"` if you don't have a regex match group to pull from
<FromGitter> <tenebrousedge> no, that's going to execute before `gsub` does
<FromGitter> <watzon> Ok that makes sense
<FromGitter> <watzon> But then why do I still get `"hello-%F"` as the output?
<FromGitter> <tenebrousedge> because it's subbing out the entire match
<FromGitter> <tenebrousedge> maybe use `\K`
<FromGitter> <tenebrousedge> I think you need an explicit block too
<FromGitter> <tenebrousedge> something like `string.gsub(/time\(\K[^)]+/) { |m| Time.now(m) }`
<FromGitter> <tenebrousedge> with whatever `to_s` or matchdata manipulation you need in the block
<FromGitter> <cfsamson> May I ask why you want to do this with a regex and not just `sub("%F")`?
<FromGitter> <tenebrousedge> that is a good question o__o
<FromGitter> <watzon> Good point. More than anything I was just wondering why it wasn't working
<FromGitter> <cfsamson> Ok :)
<FromGitter> <watzon> I also don't just want `%F`
<FromGitter> <watzon> I want to be able to include any of the valid `Time::Format` options
<FromGitter> <watzon> I'm trying to make a command line formatter for an image downloader
<FromGitter> <tenebrousedge> I think my next project is `scanf`
<FromGitter> <cfsamson> Ah, ok, I see.
<FromGitter> <watzon> `scanf` would be awesome to have in the stdlib
<FromGitter> <tenebrousedge> I'm probably going to follow Ruby in returning the resulting array rather than following C and returning an integer
<FromGitter> <watzon> That's what I'd do
<FromGitter> <watzon> Writing results to a buffer is a very outdated way of doing things
<FromGitter> <tenebrousedge> outdated to the point where it's preferable to rewrite the method in Crystal even though it's technically possible to just use the C version
snsei__ has joined #crystal-lang
<FromGitter> <mwlang> Does Crystal have it's own version of Timecop or Delorean for freezing/advancing Time.now in specs?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <mwlang> awesome!
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1a624b189e7b4ff04c71d0]
<FromGitter> <Blacksmoke16> such a contrived example but, progress is being made ha
<FromGitter> <Blacksmoke16> i guess the has should be `{"root" => {"name" => "Jim"}}` tho
<FromGitter> <Blacksmoke16> would make more sense
<FromGitter> <Blacksmoke16> actually in this case, it should prob raise, since the input is not a hash of string, string
<FromGitter> <mwlang> *sigh* trying to Timecop.freeze and yield: can't use `yield` inside a proc literal or captured block
<FromGitter> <mwlang> ok, there's non-block versions of timecop methods. Those work.
snsei__ has quit [Ping timeout: 250 seconds]
<robacarp> @mwlang may I ask which timecop you're using?
<FromGitter> <mwlang> @robacarp: https://github.com/crystal-community/timecop.cr
<FromGitter> <watzon> The way I get passed that is by just calling the block instead
<FromGitter> <watzon> So instead of `yield thing` I do `block.call(thing)`
DeBot has quit [Ping timeout: 258 seconds]
snsei__ has joined #crystal-lang
<FromGitter> <mwlang> hmmm...block.call was giving me same error.
jhass has quit [Ping timeout: 258 seconds]
asterite has quit [Ping timeout: 252 seconds]
<FromGitter> <watzon> Weird, it shouldn't
<FromGitter> <mwlang> for what it's worth, this is the code invoking timecop: https://github.com/mwlang/binance/blob/master/spec/support/vcr.cr
<FromGitter> <mwlang> basically, API signed calls are time sensitive, so I have to capture/freeze the time when recording a new playback and then set the time to that same time when playing it back.
<FromGitter> <mwlang> I just realized, I hadn't committed the latest.
<FromGitter> <mwlang> using begin/ensure in latest to guarantee unfreezing.
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <watzon> Change `def with_vcr_cassette(name : String)` to `def with_vcr_cassette(name : String, &block)` and then replace `yield` with `block.call`
<FromGitter> <watzon> That should work
<FromGitter> <watzon> You might have to do `def with_vcr_cassette(name : String, &block : Nil ->)`
jhass has joined #crystal-lang
<FromGitter> <watzon> My CLI so far
<FromGitter> <watzon> Image downloading with `imgd` works like a charm
asterite has joined #crystal-lang
<FromGitter> <bararchy> @watzon looks awsome
<FromGitter> <watzon> Thanks :) I need to implement an option that's the opposite of ignore though
<FromGitter> <bararchy> whitelist v.s blacklist ?
<FromGitter> <mwlang> @watzon thanks for that tip. I'll give it a shot. I figured it had to do with not explicitly naming a block argument, but I didn't know how to define it's return type since I really didn't want it to matter.
<FromGitter> <Blacksmoke16> can always use `_`
<FromGitter> <watzon> That's true
<FromGitter> <watzon> `_` works
<FromGitter> <Blacksmoke16> basically means, "any type"
<FromGitter> <mwlang> hmmm...new to me.
<FromGitter> <mwlang> so suggested signature becomes: ```def with_vcr_cassette(name : String, &block : _ ->)``` ?
<FromGitter> <watzon> Yup
<FromGitter> <mwlang> neither variation works.
<FromGitter> <mwlang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1a73c503d62b4d28c6cf72]
<FromGitter> <mwlang> with Void, ```no overload matches 'Proc(Void, Nil)#call' ⏎ Overloads are: ⏎ ⏎ 1) Proc(T, R)#call(*args : *T) ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5d1a73f2ffd4b84a8fec55a8]
<FromGitter> <mwlang> ha! first version @watzon started with does work.... ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d1a74488dff05627baab291]
<FromGitter> <watzon> Hmm weird that the underscore doesn't work. It's possible it only works as a generic return type
<FromGitter> <mwlang> possible. It's definitely a topic I hope to dig further into at some point. For now, really focusing on pushing through getting all the API endpoints coded and passing
<FromGitter> <mwlang> then I'll circle back around and try to understand some of crystal's finer implementation points like this one.
snsei__ has quit [Ping timeout: 276 seconds]
bougyman has quit [Ping timeout: 246 seconds]
bougyman has joined #crystal-lang
<FromGitter> <mwlang> seeing this a lot today: mwlang/.cache/crystal/crystal-run-spec.tmp): No such file or directory: No such file or directory (Errno)
<FromGitter> <mwlang> running specs
<FromGitter> <mwlang> rerunning specs immediately usually resolves it.
<FromGitter> <mwlang> oh, and running specs automatically with guardian.
<FromGitter> <mwlang> so I should clarify, "saving again with no changes" causes guardian to retry w/no errors.
<FromGitter> <mwlang> more detailed output this time: https://gist.github.com/mwlang/d6e324edb29afd902561e679d5fdfa3c
<FromGitter> <mwlang> any clue what's causing this?
alex`` has quit [Ping timeout: 245 seconds]
alex`` has joined #crystal-lang
snsei__ has joined #crystal-lang
<FromGitter> <tenebrousedge> 👽
sorcus has quit [Ping timeout: 252 seconds]
snsei__ has quit [Ping timeout: 250 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
snsei__ has joined #crystal-lang
ashirase has quit [Ping timeout: 248 seconds]
ashirase has joined #crystal-lang