ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.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
deavmi has joined #crystal-lang
<FromGitter> <galvertez> i can't figure out what `OpenSSL::Cipher.new(name : String)` wants - i tried `openssl ciphers | tr : \\n | while read cipher ; do crystal eval "require \"openssl\"; p OpenSSL::Cipher.new(\"$cipher\")" ; done` and they all failed
<FromGitter> <galvertez> i'm not sure if that means the compiler isn't able to locate them or if the constructor is expecting a different input for https://github.com/crystal-lang/crystal/blob/4401e90f001c975838b6708cc70868f18824d1e5/src/openssl/cipher.cr#L9
<FromGitter> <galvertez> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec5d3a39d1d2310cc399658]
<FromGitter> <Blacksmoke16> try like `aes-256-cbc`
<FromGitter> <galvertez> oh lower case
<FromGitter> <galvertez> rofl
<FromGitter> <galvertez> ya that worked
<FromGitter> <galvertez> thank you @Blacksmoke16
<FromGitter> <Blacksmoke16> Np
<FromGitter> <Blacksmoke16> Fwiw, I just looked in the specs :p
<FromGitter> <galvertez> idk why i didn't just do that
<FromGitter> <watzon> Idk if this will be useful to anyone or not, but https://github.com/watzon/identicon
chachasmooth has joined #crystal-lang
gangstacat has joined #crystal-lang
<raz> it will be!
* raz adds to his toolbelt, right next to https://github.com/Sija/blurhash.cr
<sorcus> watzon: Nice shard :-)
_ht has joined #crystal-lang
rocx has joined #crystal-lang
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#064b3b0 (master - Range: use `while true` when possible in `each` and `reverse_each` (#9325)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/689619369
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9325 (Range: use `while true` when possible in `each` and `reverse_each`)
Human_G33k has joined #crystal-lang
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#c13fd9c (master - Docs: correctly attach docs before annotations to following types (#9332)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/689642752
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9332 (Docs: correctly attach docs before annotations to following types)
zorp_ has joined #crystal-lang
yxhuvud has joined #crystal-lang
<FromGitter> <Blacksmoke16> how much of a hack is the mutable constant thing?
<FromGitter> <Blacksmoke16> i.e. using a macro to alter a constant, then. using the constant values in another macro...
<FromGitter> <Blacksmoke16> thats the only thing coming to mind for something i wanted to do
<FromGitter> <Blacksmoke16> option*
<FromGitter> <Blacksmoke16> could use an annotation, but wouldnt be a nice api
<FromGitter> <watzon> I would like to know as well
<FromGitter> <watzon> Sometimes it seems like a mutable constant would be the only way to accomplish something
<FromGitter> <Blacksmoke16> maybe just overusing it is a hack. Annotations are the better approach most of the time
<FromGitter> <Blacksmoke16> @watzon, yea esp since constants and annotations are the only things that are accessible at compile time
<FromGitter> <Blacksmoke16> could also run another crystal program, but yea...
<FromGitter> <Blacksmoke16> to give some context, the, my DI shard supports auto resolving dependencies based on types. This however only works for actual objects, not scalar values ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec6af543ffa6106f1c6a419]
<FromGitter> <Blacksmoke16> to give some context, the, my DI shard supports auto resolving dependencies based on types. This however only works for actual objects, not scalar values ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Or something like that. Also could add a third optional argument to scope it to specific types [https://gitter.im/crystal-lang/crystal?at=5ec6af7989941d051a143610]
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <jwoertink> I see that there's a `Union.nilable?` method, but with this `TypeDeclaration` I have, when I call `type_declaration.type.nilable?` I get `undefined macro method 'Union#nilable?'`
<FromGitter> <jwoertink> so it seems to be calling on an instance?
<FromGitter> <Blacksmoke16> `type_declaration.type.resolve.nilable?`
<FromGitter> <jwoertink> ahhhhh
<FromGitter> <jwoertink> nice
<FromGitter> <jwoertink> sweet. Thanks
<FromGitter> <jwoertink> oh interesting
<FromGitter> <ErikAGriffin> Hi, I've heard there's a crystal Slack channel but I can't find it. Is anyone able to point me in the right direction?
<FromGitter> <xmonader> anyone used ishi before? I want to generate png image for a chart? the API internal code seems to have IO object maybe I can dump that on the filesystem as png?
<FromGitter> <Blacksmoke16> @ErikAGriffin https://forum.crystal-lang.org/t/suggestion-for-growing-the-community-around-crystal/1918/3?u=blacksmoke16 Gitter is the official channel tho.
deavmi has quit [Quit: Eish! Load shedding.]
<FromGitter> <Blacksmoke16> @xmonader check out https://github.com/stumpycr/stumpy_png
<FromGitter> <ErikAGriffin> Okay thanks for the tip
<FromGitter> <xmonader> @Blacksmoke16 thank you
deavmi has joined #crystal-lang
<FromGitter> <xmonader> ```code paste, see link``` ⏎ ⏎ I can't access the IO and looks like the plot also returns an instance, my terminal gets polluted and can't reach hello world lines? [https://gitter.im/crystal-lang/crystal?at=5ec6cc1c225dc25f54998ad9]
<FromGitter> <Blacksmoke16> try, like `inst.class.io`?
<FromGitter> <Blacksmoke16> or even just `self.class.io`?
<FromGitter> <Blacksmoke16> or `itself.class.io`
<FromGitter> <xmonader> but self not avaialble in the scope no?
<FromGitter> <xmonader> what is itself :O
<FromGitter> <Blacksmoke16> `Ishi.new` is yielding an instance of https://github.com/toddsundsted/ishi/blob/177fa75de407cb8908c88a5ebb612c3012006754/src/ishi.cr#L13
<FromGitter> <Blacksmoke16> or really might be able to do like `class.io`?
<FromGitter> <Blacksmoke16> given the default receiver would be the instance
<FromGitter> <xmonader> first time to know that's a step further indeed
<FromGitter> <xmonader> now i get for ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec6cdacf0b8a2053aa5d4a1]
<FromGitter> <Blacksmoke16> pretty sure you're writing to a string?
<FromGitter> <Blacksmoke16> what does `StumpyPNG.read` return?
<FromGitter> <watzon> It returns a canvas I believe
<FromGitter> <xmonader> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec6ce15ff7a920a7202feb7]
<FromGitter> <watzon> The `IO` returned from `inst.class` must be closed
<FromGitter> <Blacksmoke16> ah right, yea its trying to read from a closed IO
<FromGitter> <xmonader> do i read it before doing plot call or what exactly? hmm
<FromGitter> <Blacksmoke16> at `inst.class.io` is STDOUT
<FromGitter> <xmonader> okaay maybe i try init it with Io memory
<FromGitter> <Blacksmoke16> could prob implement something like this but for PNG
<FromGitter> <Blacksmoke16> would be the way to go i think
<FromGitter> <xmonader> won't IO.copy cut it if i pass a specific IO ?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <xmonader> @Blacksmoke16 u were at an older commit i think
<FromGitter> <Blacksmoke16> ah yea, irp
<FromGitter> <Blacksmoke16> rip
renich has joined #crystal-lang
<FromGitter> <watzon> Any ideas? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec6d3dfa91f120a6cb50774]
<FromGitter> <watzon> Just a pretty standard HTTP get request
<FromGitter> <Blacksmoke16> can you manually do the request?
<FromGitter> <Blacksmoke16> not some expired cert or something on the dest?
<FromGitter> <xmonader> still struggling , I even added that ⏎ to the term base ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5ec6d5a7225dc25f5499a65f]
<FromGitter> <watzon> What is the IO though?
Human_G33k has quit [Quit: Leaving]
<FromGitter> <xmonader> @watzon i want to initialize it with IO::Memory instead of this one https://github.com/toddsundsted/ishi/blob/master/src/ishi/png.cr#L7
<FromGitter> <watzon> I think my SSL problem is something to do with trying to send the requests inside of a fiber
<FromGitter> <xmonader> but not sure how to pass it in its init
<FromGitter> <watzon> If you pretty print `inst.class.io` what do you get?
<FromGitter> <xmonader> @watzon I get nothing when i do puts .. ⏎ probably because it's stdout?
<FromGitter> <watzon> Use `pp`
<FromGitter> <watzon> For pretty printing
<FromGitter> <xmonader> still empty
<FromGitter> <watzon> Hmm that's weird. Even STDOUT should show up as a FileDescriptor object.
<FromGitter> <xmonader> well not sure how to continue any further :(
<FromGitter> <watzon> What if you pretty print `inst.class`?
<FromGitter> <watzon> I'm grasping at straws right now haha
<FromGitter> <watzon> Couldn't you do `StumpyPNG.read(Ishi::Term.io)`? Isn't that supposed to be the same IO?
<FromGitter> <xmonader> omg i was doing `shards build && ./bin/ishitest > abc.out` ⏎ ⏎ now that i removed it i get ⏎ ⏎ ```#<IO::FileDescriptor: fd=6> ⏎ Ishi::Png``` [https://gitter.im/crystal-lang/crystal?at=5ec6db714412600ccd5ce0e7]
<FromGitter> <Blacksmoke16> ha
<FromGitter> <xmonader> but still passing Term.io doesn't work because it is intiialized already to STDOUT :(
HumanG33k has joined #crystal-lang
<FromGitter> <xmonader> found out!!! ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ looks like i needed to reset the io stream to 0, but this again works when i hardcoded io stream in ishi class instead of STDOUT :) don't know how to change it yet.. [https://gitter.im/crystal-lang/crystal?at=5ec6e21327513a72fba50500]
<FromGitter> <watzon> Ahh yeah, just use `IO#rewind`
<FromGitter> <watzon> `StumpyPNG.read(inst.class.io.rewind)` should do it
<FromGitter> <xmonader> now only the problem of passing the io buffer :(
<FromGitter> <xmonader> finally ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I just needed not to use the github docs :( [https://gitter.im/crystal-lang/crystal?at=5ec6e4eaf0b8a2053aa60eb8]
<FromGitter> <Blacksmoke16> hm, i think ideally you would define your own png thing to write it to a file
<FromGitter> <Blacksmoke16> then it would just inherently work when you do `.show`
<FromGitter> <Blacksmoke16> versus adding this extra io/rewind logic
<FromGitter> <watzon> Yeah it would be nice if `Ishi::Png` contained a `StumpyPNG::Canvas`. It could export `save` and `buffer` methods to save to a file or return the raw PNG buffer.
<FromGitter> <Blacksmoke16> if only shards had optional dependencies :p
<FromGitter> <watzon> Right?
<FromGitter> <Blacksmoke16> related to that. how would you guys handle this case
<FromGitter> <Blacksmoke16> you have shard A and shard B
<FromGitter> <watzon> I wonder, with ysbaddadan stepping way from Crystal is he still going to be maintaining shards?
<FromGitter> <Blacksmoke16> shard B is an optional dependency to shard A
<FromGitter> <Blacksmoke16> within shard A you want to define some conditional logic to do something based on the type of a variable
<FromGitter> <Blacksmoke16> i.e. an included module or something
<FromGitter> <Blacksmoke16> do you ⏎ 1) just define the module in shard A, so it exists ⏎ 2) create hard C to essentially just hold interfaces that could be used in both A and B
<FromGitter> <Blacksmoke16> i.e.
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec6e6d9b101510b200c104c]
<FromGitter> <watzon> Hmm. I'd probably go with option 1, mainly to save myself a shard.
<FromGitter> <Blacksmoke16> or option 3, do something hacky like `{% if has_constant? "B::Module" %}`
<FromGitter> <watzon> Unless there are a bunch of interface modules like you're talking about
<FromGitter> <Blacksmoke16> to only define the logic if that module exists in the first place
<FromGitter> <Blacksmoke16> umm, maybe like 5
<FromGitter> <Blacksmoke16> i tend to agree tho, not really worth a shard for 5 `module SomeModule; end`
<FromGitter> <Blacksmoke16> no idea how'd you do it but `{% if Shards.installed? "shard_b" %}` would be cool as well
<FromGitter> <Blacksmoke16> php has some libs like https://github.com/php-fig/log
<FromGitter> <Blacksmoke16> option 1 sounds best i think yea. Easier to test than macro conditional logic
rocx has quit [Read error: Connection reset by peer]
<FromGitter> <sam0x17> can I put a type restriction on a splat?
<FromGitter> <sam0x17> @Blacksmoke16 one cheatsy approach might be to check if that shard's folder exists in `lib` in a macro lolol
<FromGitter> <Blacksmoke16> @sam0x17 yes, `def name(*args : String)` would assert you can do like `name "foo", 1, false` would have to all be strings
<FromGitter> <Blacksmoke16> yea thats similar to the if the constant exists
<FromGitter> <sam0x17> oh yup
<FromGitter> <sam0x17> thx
_ht has quit [Quit: _ht]
<FromGitter> <sam0x17> is there something like splatting with block arguments?
<FromGitter> <Blacksmoke16> with tuples yea
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec6f6453ffa6106f1c759b8]
renich has quit [Read error: Connection reset by peer]
duane has joined #crystal-lang
<FromGitter> <sam0x17> ah ok, that might be good for what I'm doing
<FromGitter> <jwoertink> Anyone have an example out there of using the Macro `block.args`?
<FromGitter> <Blacksmoke16> what are you trying to do
<FromGitter> <jwoertink> actually, I just got it
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <jwoertink> getting the afternoon sleeps over here lol
<FromGitter> <jwoertink> need to get up and run around or something
duane has quit [Ping timeout: 256 seconds]
<FromGitter> <sam0x17> is there a way to display the whole generated macro when getting a macro-related compiler error?
<FromGitter> <sam0x17> I'm just getting an "expecting END not EOF" and would like to try to figure out the context
<FromGitter> <Blacksmoke16> `{{debug}}`
<FromGitter> <Blacksmoke16> add that to the end
<FromGitter> <sam0x17> SWEET
<FromGitter> <sam0x17> thx
rocx has joined #crystal-lang
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec7034c7da67d06fac32fe2]
<FromGitter> <Blacksmoke16> got this idea working from earlier
<FromGitter> <watzon> Trying to think about how I could make use of this with Tourmaline
<FromGitter> <Blacksmoke16> probably would be possible? if it would be a good use case would depend on the API you want to have and how its architectured currently
<FromGitter> <Blacksmoke16> I find it neat, but that doesnt mean every project needs it
<FromGitter> <watzon> The main thing I could see it working for is context handling, but idk if it will work for that
<FromGitter> <Blacksmoke16> example?
<FromGitter> <watzon> Well right now I have an update context, which gets passed into every update. It's based off of the `Log::Context`, which means it's pretty limited. https://github.com/protoncr/tourmaline/blob/master/src/tourmaline/update_context.cr
<FromGitter> <watzon> I'm wondering if DI could help that situation
<FromGitter> <Blacksmoke16> hmm, im thinking not really
<FromGitter> <Blacksmoke16> DI is mainly for abstracting/managing dependencies of various types aka services. So like you say you have a `UrlUtils` type, that is instantiated with the current env's base URL, you can then inject this service into other things that need it
<FromGitter> <Blacksmoke16> given in this case it looks like you just have a struct to hold data, that gets passed around
<FromGitter> <watzon> Yeah I figured. Oh well.
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ Updated to support service, and arrays of services references [https://gitter.im/crystal-lang/crystal?at=5ec70908ff7a920a72039826]
<FromGitter> <Blacksmoke16> i just think its all super cool, esp being able to do all this at compile time and such
<FromGitter> <xmonader> does anyone have experience with that https://forum.crystal-lang.org/t/state-plans-of-gui-development-with-crystal/1615/27 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec70bbcf0b8a2053aa6666a]
<FromGitter> <Blacksmoke16> nope
<FromGitter> <Blacksmoke16> unless he comes up with a better way of handling it, prob better off with some c bound gui lib
<FromGitter> <Blacksmoke16> think hes just spawning a sub process and passing data to it
<FromGitter> <xmonader> yeah indeed, got too excited for adv GUI platform
<FromGitter> <stellarpower> Do we have any existing interface for getting and setting xattrs on files in crystal?
<FromGitter> <Blacksmoke16> not that i know of
sagax has joined #crystal-lang
<FromGitter> <stellarpower> The ruby gem links in via FFI so I guess it would be easy enough to wrap some day.
<FromGitter> <stellarpower> I just have too many projects on the go rn and am trying to finish then before I start more xD
<FromGitter> <stellarpower> Porting to Solaris probably before that.
<FromGitter> <Blacksmoke16> such is life ha
<FromGitter> <stellarpower> Yeah ikr
<FromGitter> <stellarpower> Did an all-nighter the other day to get a fish script finished off
<FromGitter> <stellarpower> It's a step up from bash but is not the right tool for the job
<FromGitter> <Blacksmoke16> 🐟