ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | 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
<hightower2> Hey help me with the syntax a little bit here. So, let's say I have "action" which is an instance of Proc(Event,Nil). And I have Wrapper(T). How would I instantiate this Wrapper(Proc(Event,Nil)) ?
<FromGitter> <Blacksmoke16> assuming the initialize is like `@action : T`?
<hightower2> yes, good enough. And there are 2 other params
<FromGitter> <Blacksmoke16> `Wrapper(Proc(Event, Nil)).new action, param2, param3`?
<FromGitter> <Blacksmoke16> `def initailize(@action : T, @param2 : Int32, @param3 : String)`?
<hightower2> Hm I did that, it keeps telling me that it expects to be called with a block
<FromGitter> <Blacksmoke16> oh?
<hightower2> Even though I did provide both the proc and block initializer
<FromGitter> <Blacksmoke16> are you sure? :p
<hightower2> I can delete the block one and retest :)
<hightower2> mm yeah the type didn't match so it was trying the block one
<hightower2> ok, now trying to adjust type
<FromGitter> <watzon> @christopherzimmerman was able to get license plate detection somewhat working with this
<FromGitter> <watzon> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddb1e431bf5192e669b877d]
alexherbo2 has quit [Ping timeout: 240 seconds]
<FromGitter> <watzon> .23
DTZUZO has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
<hightower2> Blacksmoke16 Absolutely fantastic, the double proc trick worked, I finally figured it out. Now just checking why isolated examples work, while something as part of existing tests causes an error...
snsei has joined #crystal-lang
<FromGitter> <watzon> Starting to write bindings to freetype2. Fuck this has a lot in it.
<FromGitter> <watzon> Can't even use libgen on it because of the way they structure imports
<hightower2> vi s:w
dwdv has quit [Ping timeout: 265 seconds]
<FromGitter> <christopherzimmerman> @watzon SOD doesm
<FromGitter> <christopherzimmerman> I have a few training atm, unfortunately it doesn't support GPU training, but they still should be done in the next day or so.
<FromGitter> <watzon> I agree there. We'd just need to find some good datasets and put in the time to do some training
<FromGitter> <watzon> My computer wouldn't be any good for GPU training anyway
<FromGitter> <watzon> What kinds of sets are you working on?
<FromGitter> <christopherzimmerman> Just facial recognition for now
<FromGitter> <christopherzimmerman> That's one of the most popular for research.
<FromGitter> <christopherzimmerman> I think the ideal goal is: host a few popular ones ourselves, and maintain a curated list of user sourced models as well.
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <watzon> Yeah I was gonna suggest it
<FromGitter> <watzon> I'm working on bindings to libfreetype as well so we can get font rendering
<FromGitter> <christopherzimmerman> Is it possible to specify a generic in a proc type? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddb33041bf5192e669c0f56]
<FromGitter> <Blacksmoke16> dont see why not
<FromGitter> <christopherzimmerman> Thats what I thought. It throws `no overload matches 'Bottle::Tensor(T).from_proc' with types Array(Int32), Proc(Int32, Float64)`
<FromGitter> <Blacksmoke16> what are you giving it?
<FromGitter> <christopherzimmerman> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddb33cfc52bc74c968706dd]
<FromGitter> <christopherzimmerman> Nothing fancy, it works fine if I explicitly pass the type.
<FromGitter> <christopherzimmerman> It just seemed odd that it's clearly inferring the type of the generic, but still raising.
<FromGitter> <Blacksmoke16> whats the ful error?
<FromGitter> <christopherzimmerman> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddb3430b010e6227664bf24]
<FromGitter> <Blacksmoke16> could try making it a forall vs generic
<FromGitter> <christopherzimmerman> Yea that works. I have to imagine the desired behavior would be for the two to behave identically here though.
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddb3f59ac81632e65fb0fac]
<FromGitter> <Blacksmoke16> any idea what this means
<FromGitter> <Blacksmoke16> apparently it happens when i try to reopen a struct/class to extend it
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/82fh
<FromGitter> <Blacksmoke16> is that expected?
<FromGitter> <Blacksmoke16> \cc @asterite ^
hightower2 has quit [Ping timeout: 240 seconds]
hightower3 has quit [Ping timeout: 276 seconds]
<FromGitter> <watzon> Fuck that's a lot of bindings to write by hand
<FromGitter> <watzon> And I'm not even all the way through
duane has quit [Remote host closed the connection]
snsei has joined #crystal-lang
f1refly has quit [Ping timeout: 250 seconds]
f1reflyylmao has joined #crystal-lang
ur5us has quit [Ping timeout: 250 seconds]
snsei has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
snsei has quit []
<FromGitter> <phangs> @Blacksmoke16 thank you got the code working with just probably minor issue. I left another reply in the blog's comment. thank you very much
ht_ has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
gangstacat has quit [Ping timeout: 250 seconds]
dwdv has joined #crystal-lang
gangstacat has joined #crystal-lang
_whitelogger has joined #crystal-lang
ur5us has quit [Ping timeout: 250 seconds]
alexherbo2 has joined #crystal-lang
HumanGeek has joined #crystal-lang
return0__ has joined #crystal-lang
justinmcp_ has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
return0e_ has quit [Read error: Connection reset by peer]
justinmcp has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter> <asterite> @Blacksmoke16 yes, it's expected. The first time `Value` is the implicit supertype. Similar to how when you don't specify it with `class` it's `Reference`
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> πŸ‘
DTZUZO has joined #crystal-lang
<FromGitter> <Blacksmoke16> @phangs thanks, I pushed a fix for the log file issue, forgot a line
<FromGitter> <Blacksmoke16> the other issue is saying that the database doesn't have a table called `users`
<FromGitter> <tenebrousedge> does crystal optimize away instance variables? I'm getting the impression from llvm-ir that these things produce the same instructions: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddbd70d1bf5192e66a0a2ca]
<FromGitter> <yxhuvud> Eh, those are not instance variables.
<FromGitter> <tenebrousedge> well, yes, but this is my pre-coffee brain
<FromGitter> <tenebrousedge> local variables, then
hightower4 has joined #crystal-lang
<hightower4> It's funny that active_record.cr does not come up in search on either crystalshards.org or crystalshards.xyz, yet it certainly exists - https://github.com/waterlink/active_record.cr
<FromGitter> <Blacksmoke16> id be surprised if it still works
<hightower4> yeah I saw last commit ages ago
<hightower4> Just btw, how would one specify the minimum crystal version required to run a shard?
<hightower4> (i.e. is this somehow available in shard.yml - I don't see it in https://github.com/crystal-lang/shards/blob/master/SPEC.md)
<FromGitter> <didactic-drunk> @hightower4 Without a `crystal` project tag active_record.cr won't show on crystalshards.
duane has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 252 seconds]
<FromGitter> <Fryguy> @didactic-drunk Is that a recent change? I know a while ago I had a number of personal projects show up there even without the tag (though i don't see them now)
<FromGitter> <Fryguy> actually now that I check, even my projects that have the crystal tag are not there
<FromGitter> <didactic-drunk> crystalshards has `where updated > 1.year.ago` in it's github search query which hides lots of old projects.
<FromGitter> <manveru> is there a way to do: `def a(*args : String); b(*(["bar"] + args.to_a)); end; def b(*args) ...; end; a "one", "two"`?
<FromGitter> <tenebrousedge> formatted: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddbf9d94517d002b2ef0293]
<FromGitter> <manveru> thanks :)
<FromGitter> <tenebrousedge> did you try ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddbfaa599dfe74c95a6dfbb]
<FromGitter> <manveru> ah, that's neat
<FromGitter> <manveru> thanks a ton :D
<FromGitter> <tenebrousedge> np
<FromGitter> <christopherzimmerman> Why not just: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ddbfd76c4fca14de3ea0a1f]
<FromGitter> <tenebrousedge> hmm, that's a thing too
<hightower4> didactic-drunk oooh, I thought it selected projects based on them being recognized as written in crystal language
<hightower4> Blacksmoke16 re. /SPEC.md#crystal , yes, yes, but you see it says it is the "The last known Crystal version that is capable to compile the Shard (String).". It doesn't define a way to set minimum required version
<FromGitter> <Daniel-Worrall> It's "latest known", so not minimum, but I find Crystal in its prerelease form is always in a state of updating. Closer to release, it'll be a much more useful parameter
hpyc9 has joined #crystal-lang
<FromGitter> <Blacksmoke16> Wouldn't that be essentially the same thing
<FromGitter> <Blacksmoke16> Minimum version required would also be the last one required to compile the shard
<FromGitter> <Daniel-Worrall> Say my app compiles on 29,30,31. Latest supported is 31. Minimum is 29
<FromGitter> <Daniel-Worrall> Like how ruby can specify a minimum version with bundler
<FromGitter> <wontruefree> @hightower4 did you run Chicago Ruby back in the day?
<FromGitter> <straight-shoota> @Daniel-Worrall Minimum Crystal version is not much relevant, because it is usually expected to use a rather current Crystal compiler.
HumanGeek has quit [Ping timeout: 252 seconds]
Raimondi has quit [Quit: WeeChat 2.5: Β‘Chau!]
<FromGitter> <straight-shoota> That's different in Ruby, where the interpreter is a runtime dependency, which leads to far wider version distribution. Crystal apps need the compiler only to build the software, not to execute them. This makes it much easier to always use the latest release.
Raimondi has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter> <Daniel-Worrall> hightower4 ^
<hightower4> wontruefree wish that I did :) I'm in Europe
<hightower4> mm, yes, but I think this "last known to work" which the current field 'crystal' signifies is kind of not the same thing. Because I think the version there affects the version with which Travis will compile the shard, right?
<hightower4> so people keep bumping this to latest version, and the info about minimum version required is lost
<FromGitter> <straight-shoota> > Because I think the version there affects the version with which Travis will compile the shard, right?
<FromGitter> <straight-shoota> It should not.
<FromGitter> <straight-shoota> > so people keep bumping this to latest version, and the info about minimum version required is lost ⏎ ⏎ That's how it's intended.
<FromGitter> <Daniel-Worrall> The only thing I know which uses the crystal version like that is crenv, not travis.
<FromGitter> <straight-shoota> travis should always use latest crystal
<hightower4> ok, great, thanks for clarifications
<hightower4> Well, OK. I think knowing a minimum version would be useful without trying to compile the project to find out (and possibly not finding out even then, in the case that the difference doesn't cause a compile error)
<hightower4> maybe it's not important now when everyone just wants/needs to use latest anyway
<FromGitter> <straight-shoota> What would be the use case for compiling with a non-recent compiler release?
<hightower4> Well say you have a program which you want to use, and it works, but the only requirement is that you compile with compler <= some version.
<hightower4> compiler*
<hightower4> so you don't see this requirement anyway, can't guess why the compile is failing, and don't know which version to use instead, other than assuming it's due to compiler changes and trying one by one backwards
<FromGitter> <straight-shoota> The only reason for that would be that an other dependency doesn't compile with a current release.
<hightower4> ok
<hightower4> well, maybe if a shard or program stop being updated at some point, then also their crystal: field in shard.yml won't be updated either
<hightower4> so someone who wants to use it after a couple years will be able to refer to the version that's there
<hightower4> ok, makes sense, thanks
<FromGitter> <straight-shoota> Exactly. That's why we keep track of the latest supported version.
alexherbo2 has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
ht_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> anyone know the default HTTP::Client timeout amount?
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<hightower4> Seems like 5 minutes?
<hightower4> or no default?
<FromGitter> <Blacksmoke16> yea seems to be a few min
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/2963 is kinda a bummer
<hightower4> it appears timeout is allowed to be nil and falls back to any default in libevent, or maybe even no default/no timeout?
<FromGitter> <Blacksmoke16> proxy thing is a blocker for a little test project i had going at work :sad:
<FromGitter> <Blacksmoke16> might see if i can get that example working, seems quite old
<hightower4> That double-proc trick keeps causing me issues. First was, my idea with events was that, if you register an event with "on SomeEvent, myhandler", you can also remove it with "off SomeEvent, myhandler".
<hightower4> Now this doesn't work because when double-proc implicitly gets created, the code which goes over the list of handlers searching for handler==myhandler no longer matches anything (because the handler in the list is double-proc, not the original handler)
<hightower4> So I solved this issue by not doing comparison of handler==myhandler, but comparing stored handler.hash (the original one) with the supplied myhandler.hash
<hightower4> But I have a different error now, now wherever I
<hightower4> n/m, too complex to describe... need to stare more
<FromGitter> <manveru> does anyone by chance have a GeoJSON type around? :)
sagax has quit [Ping timeout: 240 seconds]
<FromGitter> <kinxer> @manveru I have a non-public library for parsing and handling GeoJSON that I intend to put on GitHub soon (TM). If someone would actually use it, I'll make it more of a priority.
<FromGitter> <manveru> that'd be awesome, yeah
<FromGitter> <manveru> atm i have a half-assed class for it, but i'd like to properly handle it
<FromGitter> <kinxer> I have a pretty complete implementation, so hopefully it'll be able to provide what you need.
<hightower4> Is #hash a quick operation? Does it compute something or just assigns unique ID?
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <tenebrousedge> it's overridden by some classes, I believe
<FromGitter> <tenebrousedge> it's mostly used internally by Crystal
<FromGitter> <tenebrousedge> it's useful for referencing a specific object in Crystal
<hightower4> Does it really work on a per-object level? If I do "2.times do p [1].hash end" it prints the same value both times
<hightower4> But e.g. ->(){1}.hash prints a different value each time
<FromGitter> <tenebrousedge> I think your examples are strange
<FromGitter> <Daniel-Worrall> wouldn't `->(){1}.hash` be for the proc`
<hightower4> yes
<FromGitter> <Daniel-Worrall> so they'd be 2 different procs
<hightower4> The same like [1] would be two different array
<hightower4> arrays*
<hightower4> but there's more, check this strange behavior:
<FromGitter> <tenebrousedge> `[1]` hashes to the same value as `[1]`
<FromGitter> <tenebrousedge> `nil` hashes to `0` always
<FromGitter> <tenebrousedge> some objects override `hash` for comparison purposes
<hightower4> ok, as long as it's not being actually computed in runtime it works for me regardless of how it works. But how do we explain the behavior from this last example on play?
<FromGitter> <tenebrousedge> well, it is computed at runtime
<hightower4> right, yes, but at object creation, not when calling #hash, right?
<FromGitter> <tenebrousedge> yes
<hightower4> actually, oh boy, it seems it changes, check this:
<FromGitter> <tenebrousedge> https://play.crystal-lang.org/#/r/82h7
<hightower4> ok it's clear that if some classes override it for comparison purposes, then as elements are added to array looks reasonable the hash will change
<FromGitter> <tenebrousedge> yes
<FromGitter> <Daniel-Worrall> Did some testing. Arrays hash are the same when the values are the same regardless of instancing
<hightower4> ok speed-wise it appears calling array.hash is equally fast as array.size, so I would conclude no particular time is wasted when calling #hash
HumanG33k has joined #crystal-lang
<hightower4> tenebrousedge> https://play.crystal-lang.org/#/r/82h7 <-- you posted this as another interesting/unusual result?
<FromGitter> <tenebrousedge> yes
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<hightower4> Will need to figure this out because whether each Proc has a unique hash influences whether I can help myself with obj.hash or not
<FromGitter> <Daniel-Worrall> Each proc has a unique hash
<hightower4> Daniel but how do we explain the result of e.g. https://play.crystal-lang.org/#/r/82hc ?
<hightower4> you see that the 2 middle results have same hashes
<FromGitter> <Daniel-Worrall> I presume it's from LLVM optimisations
<FromGitter> <Daniel-Worrall> in 3.times, they're all the same, but for some reason the other didn't see them all as the same
<hightower4> yes but they must be different objects
<FromGitter> <Daniel-Worrall> They don't have the chance to be different objects from the code you gave
<FromGitter> <Daniel-Worrall> so it can make the assumptions that they are
<hightower4> look at this: https://play.crystal-lang.org/#/r/82hh
<hightower4> funky
<FromGitter> <Daniel-Worrall> yeah, those 3 cannot be different
<FromGitter> <Daniel-Worrall> Maybe someone more informed can help, but that's my best guess for what's happening here
<hightower4> But check this:
<hightower4> actually n/m
<hightower4> interesting, ok
<hightower4> github seems to have issues, works slowly, and when I open https://github.com/crystal-lang/crystal it gives me a HTTP 500 error
<FromGitter> <tenebrousedge> I got a 500, reloaded, got the page
<FromGitter> <igor-alexandrov> They had an incident today: https://www.githubstatus.com. But for me it is still does not work properly too..
<hightower4> Here's the question about Proc#hash: https://github.com/crystal-lang/crystal/issues/8517
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<hightower4> Found this article randomly today:
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <Daniel-Worrall> It was posted on the reddit recently
<FromGitter> <watzon> Nice!
commavir has quit [Ping timeout: 245 seconds]
commavir has joined #crystal-lang
ht_ has quit [Quit: ht_]
ur5us has joined #crystal-lang
ur5us has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us has quit [Remote host closed the connection]
<FromGitter> <jwoertink> I have a shard that has a bunch of stuff in it's spec directory that I'd like to use in other projects. Is there a way to require stuff from a shard's spec directory?
<FromGitter> <jwoertink> Or is it just better to move that in to the library?
<FromGitter> <tenebrousedge> that second one seems like a better idea
<FromGitter> <jwoertink> Yeah. I was trying to avoid putting all the spec related stuff in the main lib, but it seems like that's my best option
ur5us has joined #crystal-lang
<FromGitter> <wontruefree> just a little reminder but @asterite is speaking at Chicago Crystal next week chicagocrystal.org/events/bbhsjryzqbhb/
<FromGitter> <kinxer> @jwoertink Do you only want to use it in the projects that already require that lib?
<FromGitter> <jwoertink> Yeah
<FromGitter> <Daniel-Worrall> @jwoertink You could require relatively to the spec file like `require "../lib/my_lib/spec/spec_file"`
<FromGitter> <watzon> Was just about to say that haha
<FromGitter> <Daniel-Worrall> or uh, use *DIR*?
<FromGitter> <jwoertink> haha let me try that
<FromGitter> <Daniel-Worrall> I'd only recommend it for your own personal stuff, and not something you expect a user to do
<FromGitter> <Daniel-Worrall> it's pretty janky
<FromGitter> <kinxer> I think it's probably still cleaner to move that stuff to the main shard, create a new shard for it, or not use those things and instead stick with the shard API you already have set up.
<FromGitter> <Daniel-Worrall> Oh, definitely
<FromGitter> <Daniel-Worrall> sometimes you just wanna say fuck it and use bad code
<FromGitter> <tenebrousedge> D:
<FromGitter> <kinxer> Or you just can't spare the up-front time to make it good code.
<FromGitter> <tenebrousedge> I've never, ever used or written bad code. I tell no lies <___<
<FromGitter> <kinxer> XD
<FromGitter> <Daniel-Worrall> that's the usual cause of bad code
<FromGitter> <jwoertink> Well, it's all shared code. In Lucky there's these objects called Boxes which is like a factory object for specs
<hightower4> Is there a way to reopen a class without knowing what it inherited from? Like, once it's defined with "class X < Something", is there a way to reopen "class X" without knowing "Something" ?
<FromGitter> <jwoertink> Boxes live in the spec directory. But I want to use the Boxes in the shard in the projects that require that shard
<FromGitter> <jwoertink> Ok, so it looks like just doing the literal path works
<FromGitter> <kinxer> @hightower4 Are you having issues with that? It seems to work for me: https://play.crystal-lang.org/#/r/82kd
<hightower4> @kinxer awesome, thanks, maybe I remembered from Ruby that that didn't work, not sure
alexherbo2 has joined #crystal-lang
duane has quit [Ping timeout: 250 seconds]
<FromGitter> <lbarasti> @Core-team, may I get a second approval on this Fiber documentation PR, please, I just resolved some merge conflicts πŸ’… ⏎ https://github.com/crystal-lang/crystal/pull/8356/
HumanG33k has quit [Remote host closed the connection]
<FromGitter> <straight-shoota> @jwoertink I'd just put the reusable spec supports in `src/spec` and require them using `shard_name/spec` from other shard's spec suite
<FromGitter> <straight-shoota> @lbarasti done, waiting for CI to give green light
<FromGitter> <manveru> so i'm just digging into JSON parsing... is there a way to parse a `[{"type": "A", "x": 1},{"type":"B","y":2}]` to correct types based on the `type`s value?
<FromGitter> <Blacksmoke16> @manveru in `0.32.0` there will be yes
<FromGitter> <manveru> thanks
<FromGitter> <manveru> will give it a try :)