RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
jemc has quit [Ping timeout: 250 seconds]
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> @j8r i figured out a way https://play.crystal-lang.org/#/r/5o1a
<FromGitter> <Blacksmoke16> so im thinking i can have a parent object that implements the `serialize` method
<FromGitter> <dscottboggs_gitlab> so you have to inherit from rather than `include`ing?
<FromGitter> <dscottboggs_gitlab> (not that I'm partial to either way)
<FromGitter> <Blacksmoke16> let me finish :p sec
<FromGitter> <dscottboggs_gitlab> haha ok
<FromGitter> <Blacksmoke16> it'll return an array of `SerializeableObject` or something that contains key/value properties
<FromGitter> <Blacksmoke16> then each sub module will implement a method that will be responsible for converting that array of objs into whatever type you want
<FromGitter> <dscottboggs_gitlab> ohhh no I see
Renich has quit [Quit: Renich]
<FromGitter> <dscottboggs_gitlab> that's acutally great
<FromGitter> <Blacksmoke16> so like if you want `serialize` to do `JSON` you `include CrSerializer::JSON`
Renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> yaml would be like `::YAML`
<FromGitter> <Blacksmoke16> etc
<FromGitter> <dscottboggs_gitlab> yes that's great
<FromGitter> <dscottboggs_gitlab> having a standard interface to build serializers off of makes a lot of sense
Renich has quit [Client Quit]
<FromGitter> <Blacksmoke16> if you want your own thing should just be able to override the `SerializableObject` to include your `Serializeable` module if you have one
Renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> and/or implement your sub module you can include
<FromGitter> <Blacksmoke16> deserialization would work in a similar way i think
<FromGitter> <dscottboggs_gitlab> yeah you just use PullParser for one and Builder for the other to make your Serializeable module
<FromGitter> <Blacksmoke16> and should be generic enough where other style wouldnt have to implement my custom logic for my annotations, as the `serialize` method would return an array or single obj of `SerializeableObject`
<FromGitter> <Blacksmoke16> then its the submodule's job to turn that into X
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <Blacksmoke16> wish you could declare abstract defs on module :p
<FromGitter> <Blacksmoke16> but i guess it doesnt really make sense
<FromGitter> <dscottboggs_gitlab> why not?
<FromGitter> <Blacksmoke16> because there isnt really a concept on inheritance with a module
<FromGitter> <Blacksmoke16> it could be included in a class, another module, extended etc
<FromGitter> <dscottboggs_gitlab> oh,yeah
<FromGitter> <dscottboggs_gitlab> also if `include` two modules that define the same function overload it works like ruby functions
<FromGitter> <dscottboggs_gitlab> :/
<FromGitter> <Blacksmoke16> thats the one downside of this, if you want to support say both YAML *AND* JSON you wouldnt be able to do that...but i dont think that is a common need?
<FromGitter> <Blacksmoke16> since one include would override the other
<FromGitter> <Blacksmoke16> since method names are the same
<FromGitter> <dscottboggs_gitlab> wouldn't they be different overloads since they'd each have their type ::Serializable as the argument?
<FromGitter> <dscottboggs_gitlab> oh, not the actual conversion method, I see. :/
<FromGitter> <Blacksmoke16> unless i renamed the methods to like `serialize_x`
<FromGitter> <Blacksmoke16> ?
<FromGitter> <Blacksmoke16> but is it really that common to want to output json in one context and yaml in another, or con or xml for example?
<FromGitter> <dscottboggs_gitlab> well
<FromGitter> <dscottboggs_gitlab> in the stdlib it's `to_json`and `from_yaml`
<FromGitter> <dscottboggs_gitlab> so why not?
<FromGitter> <Blacksmoke16> or could just take over those names...
<FromGitter> <Blacksmoke16> nvm no i cant
<FromGitter> <Blacksmoke16> yea i cant do that
<FromGitter> <dscottboggs_gitlab> I wouldn't say it's common but I think it should be easy to do. What if you want to store a class in YAML or CON and send it through an IPC in a gob or JSON encoding
<FromGitter> <Blacksmoke16> even renaming them, as it would break the generic parent method
<FromGitter> <dscottboggs_gitlab> what if the generic parent method iterates over the values in @type in a macro like JSON::Serializable does?
<FromGitter> <Blacksmoke16> but i guess i could just have a macro plop down the code so i dont have to duplicate it
<FromGitter> <Blacksmoke16> it does
<FromGitter> <dscottboggs_gitlab> ah shit I tried to figure out how to make that work with methods and I could only get it for instance vars. I don't think that feature exists yet?
<FromGitter> <Blacksmoke16> it would do that to build out an array of the `SerialzableObject` then its the submodule's job to turn that into X type
<FromGitter> <Blacksmoke16> it does but only in context of a method atm
<FromGitter> <Blacksmoke16> is the current json implementation on my shard
<FromGitter> <dscottboggs_gitlab> sorry, I don't get it, where are you getting the instance methods of @type there?
<FromGitter> <Blacksmoke16> they're just available in a method in macro land
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5o1g this could prob work? assuming i can share all the code via a macro....
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5o1h
<FromGitter> <dscottboggs_gitlab> oh
<FromGitter> <Blacksmoke16> which returns an array of `TypeNode`
<FromGitter> <dscottboggs_gitlab> no I mean a macro method that would get `[name, age, get]` for that claass
<FromGitter> <Blacksmoke16> like the values of all the properties?
<FromGitter> <dscottboggs_gitlab> because in the module you don't need ivars, there aren't any, you need the actual method names
<FromGitter> <dscottboggs_gitlab> no properties are an ivar with a getter and a setter.
<FromGitter> <dscottboggs_gitlab> actually, the macro concept I'm talking about would get `[name, name=, age, age=, get]` for that class
<FromGitter> <Blacksmoke16> its included in the class, so in the module `@type` refers to the type it gets included in which have the properties
<FromGitter> <dscottboggs_gitlab> oh so you can just to `@type.name = ...`
<FromGitter> <dscottboggs_gitlab> ?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5o1m
<FromGitter> <Blacksmoke16> like that?
<FromGitter> <Blacksmoke16> :magic:
<FromGitter> <dscottboggs_gitlab> wtf
<FromGitter> <ilanusse> Hey guys
<FromGitter> <ilanusse> Anyone here?
<FromGitter> <dscottboggs_gitlab> apparently there's a wizard here
<FromGitter> <ilanusse> I'm making Pundit for Crystal
<FromGitter> <Blacksmoke16> o/
<FromGitter> <Blacksmoke16> that sounds familiar
<FromGitter> <ilanusse> And I was wondering how to do sth like Ruby's constantize
<FromGitter> <ilanusse> For convention over configuration
<FromGitter> <Blacksmoke16> would be best if you provided an example in the playground or something
<FromGitter> <ilanusse> Good point
<FromGitter> <Blacksmoke16> as its prob not going to be map-able 1:1 to ruby
<FromGitter> <ilanusse> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c01eb2c464b6c0fd67108f5]
<FromGitter> <ilanusse> I'm making a PolicyFinder
<FromGitter> <ilanusse> Which basically looks for a class's policy
<FromGitter> <ilanusse> A class can either have a method called `policy_class` which states this explicitly
<FromGitter> <ilanusse> Or what I had in mind was to use an implict `#{class_name}Policy`
<FromGitter> <ilanusse> Say if my class is Post
<FromGitter> <dscottboggs_gitlab> does it matter what a policy is in this context?
<FromGitter> <ilanusse> No
<FromGitter> <dscottboggs_gitlab> ok
<FromGitter> <ilanusse> Call it foo or bar or whatevs
<FromGitter> <ilanusse> So I just wanted to get something dynamically but obviously this is a compiled language
<FromGitter> <ilanusse> I don't really have much experience with macros and I'm guessing I want something like that?
<FromGitter> <Blacksmoke16> prob
<FromGitter> <ilanusse> Basically, I want a way that given a constant Foo
<FromGitter> <ilanusse> My function should return the constant FooPolicy
<FromGitter> <dscottboggs_gitlab> yeah but this just doesn't make sense in the context of a strictly typed language.
<FromGitter> <ilanusse> Figured as much
<FromGitter> <dscottboggs_gitlab> why not have it be a generic like `PolicyFinder(PolicyType)`?
<FromGitter> <ilanusse> I'm still thinking this way too Rubyish
<FromGitter> <dscottboggs_gitlab> I mean, you can usually shoehorn dynamic types into crystal but there's usually a better way to implement it, you know?
<FromGitter> <ilanusse> Yeah
<FromGitter> <dscottboggs_gitlab> idk maybe the wizard has an idea 😉
<FromGitter> <dscottboggs_gitlab> also, object.class is a constant that you could then modify in a macro
<FromGitter> <ilanusse> ```module Praetorian ⏎ module HasPolicy ⏎ abstract def policy_class ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5c01eca048d021555ad15b68]
<FromGitter> <ilanusse> I guess I can use this module
<FromGitter> <dscottboggs_gitlab> like `{{object.class}}Policy` but then, lets say object is of type `Foo`, `FooPolicy` must exist at compile time
<FromGitter> <ilanusse> Yeah that's what I was thinking of doing pretty much
<FromGitter> <ilanusse> I meant my idea but I wasn't sure how to go about coding it
<FromGitter> <ilanusse> So thanks for that :)
<FromGitter> <dscottboggs_gitlab> haha
<FromGitter> <dscottboggs_gitlab> read this whole section really https://crystal-lang.org/docs/syntax_and_semantics/macros.html
<FromGitter> <dscottboggs_gitlab> macros are great in crystal and really clean up your code in some cases
<FromGitter> <ilanusse> Thanks!
<FromGitter> <ilanusse> Will do right awAY
<FromGitter> <dscottboggs_gitlab> np!
<FromGitter> <Blacksmoke16> i actually do something just like that in my shard
<FromGitter> <dscottboggs_gitlab> wow.
<FromGitter> <dscottboggs_gitlab> dude.
<FromGitter> <Blacksmoke16> when you have an `@[Assert::Email]` annotation, for example, on a property that will pick it up and at compile time will look like `assertions << EmailAssertion(String).new("name",nil,name)`
<FromGitter> <Blacksmoke16> where the property name is name of type `String`
<FromGitter> <dscottboggs_gitlab> oh nice
<FromGitter> <dscottboggs_gitlab> but then how does EmailAssertion get defined?
<FromGitter> <Blacksmoke16> ^^
<FromGitter> <dscottboggs_gitlab> oh you have to define it manually?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <dscottboggs_gitlab> ok
<FromGitter> <Blacksmoke16> but can define your own
<FromGitter> <dscottboggs_gitlab> yes that's very nice.
<FromGitter> <Blacksmoke16> i.e. `@[Assert:Custom]`
<FromGitter> <Blacksmoke16> Think I'll go with only one include possible, let it become an issue, I don't think multiple serialization would be real common ..
<FromGitter> <Blacksmoke16> Less complex code on my end
<FromGitter> <Blacksmoke16> btw, @dscottboggs_gitlab https://crystal-lang.org/api/0.27.0/Crystal/Macros/TypeNode.html
<FromGitter> <girng> need to do server-side skill tree web
<FromGitter> <girng> i don't know how to tackle this issue programatically
<FromGitter> <anamba> trying to use the new language-agnostic Passenger 6 with the hello world example in HTTP::Server but both the passenger agent process and the crystal process just go to max cpu until i kill them. it feels like both sides are silently erroring on something and immediately retrying. any ideas on how to troubleshoot?
<FromGitter> <girng> create a array of classes with a `property required_ids`, and then when user tries to activate a new skill, loop through the player's current skills to make sure they have the required skill_ids? If so, then append that new skill id to their `skills` array? i'm not sure but that's what i'm thinking
<FromGitter> <Blacksmoke16> could prob use `Enumerable#all?`
<FromGitter> <girng> oh that' snice, yeah
<FromGitter> <Blacksmoke16> not sure @anamba
<FromGitter> <Blacksmoke16> anyone know how to declare any empty array of a struct that has a generic
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/5o1z
<FromGitter> <Blacksmoke16> but that could be of any type
<FromGitter> <Blacksmoke16> and cant use `Value` as generic type yet...
<FromGitter> <Blacksmoke16> guess just use a union of all types?
<FromGitter> <anamba> time to start a Crystal community on spectrum? https://spectrum.chat/spectrum/general/spectrum-is-joining-github~1d3eb8ee-4c99-46c0-8daf-ca35a96be6ce
<FromGitter> <girng> what is spectrum ??
<FromGitter> <Blacksmoke16> looks like gitter type app
<FromGitter> <Blacksmoke16> crap, found an issue :((
<FromGitter> <Blacksmoke16> ill have to sleep on it
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
<FromGitter> <girng> :(
<FromGitter> <proyb6> Nice!
<FromGitter> <proyb6> I think it's a great time to move gitter to spectrum
<FromGitter> <proyb6> Yeah, Spectrum is like a Gitter from what a HN commenter said
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
<FromGitter> <dscottboggs_gitlab> @Blacksmoke16 oh wow I don't know how I've never seen that before
<FromGitter> <ezrast> @Blacksmoke16 You can do this workaround https://play.crystal-lang.org/#/r/5o2k
<FromGitter> <dscottboggs_gitlab> @ezrast what in the hell
<FromGitter> <ezrast> ?
<FromGitter> <dscottboggs_gitlab> that just... it's not very obvious how that all works
<FromGitter> <dscottboggs_gitlab> I guess it makes sense if you can have arrays of Modules but that doesn't really make a ton of sense to think about, having an array of a Module type.
<FromGitter> <ezrast> Including a module is in practice almost the same as inheriting from a class
<FromGitter> <ezrast> Which works the same way here: https://play.crystal-lang.org/#/r/5o2m
<FromGitter> <dscottboggs_gitlab> that makes a lot more sense IMO but I guess the other one is useful too.
Renich has quit [Quit: Renich]
<FromGitter> <dscottboggs_gitlab> oh actually I totally get it now
Renich has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> because types are verified on the basis of the presense or lack of a given method, and including a module adds its methods to your class
Renich has quit [Client Quit]
Renich has joined #crystal-lang
<FromGitter> <ezrast> Not quite; simply defining a type's methods isn't enough to make an object be of that type in Crystal (you may be thinking of Go)
<FromGitter> <dscottboggs_gitlab> oh I see, I must be
<FromGitter> <ezrast> It's just that including a module adds that module to your type's list of ancestors, just like inheriting from a class does
<FromGitter> <dscottboggs_gitlab> yes I'm thinking of go interfaces, you're right
<FromGitter> <dscottboggs_gitlab> interesting
<FromGitter> <dscottboggs_gitlab> well it sort of works that way in crystal too if you don't specify a type but I see what you mean about this not being an example of that
<FromGitter> <ezrast> yeah
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Vexatos has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
return0e_ has quit []
DTZUZO has quit [Ping timeout: 272 seconds]
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
ashirase has quit [Ping timeout: 250 seconds]
<oprypin> i really enjoyed reading this last conversation. you figured it out completely :)
ashirase has joined #crystal-lang
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
<FromGitter> <vladfaust> There is a spectrum chat already - https://spectrum.chat/crystal
<FromGitter> <vladfaust> Taken by someone called James James, who is that
<FromGitter> <vladfaust> Hate squatters so much, those who take a name and do nothing with it
<FromGitter> <vladfaust> "Neither me nor anyone else"
<FromGitter> <vladfaust> I dislike that right-sided spectrum chat on community pages, it's so bad
Raimondi has quit [Read error: Connection reset by peer]
Raimondi has joined #crystal-lang
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
<FromGitter> <drum445> Cheers DRVTiny if you're here for: https://github.com/drum445/dotenv
<FromGitter> <drum445> PR
return0e has joined #crystal-lang
<FromGitter> <j8r> @drum445 ouch you managed to use regexes to parse such simple data format 😮
<FromGitter> <j8r> you can take example of the stdlib's INI. It used regexes before, now not anymore
<FromGitter> <j8r> @drum445 https://carc.in/#/r/5o4t - isn't fine?
<FromGitter> <jamesfuture> @vladfaust That's was me
<FromGitter> <jamesfuture> I haven't explore Spectrum yet and might take time to get used to it but I like to hear the team and everyone's feedbacks ⏎ https://github.com/crystal-lang/crystal/issues/7132
<FromGitter> <j8r> or https://carc.in/#/r/5o4z
<FromGitter> <j8r> @jamesfuture what's the pros of se
<FromGitter> <jamesfuture> I have a random research on various chats a while ago until I heard Spectrum became free
<FromGitter> <j8r> does it have an API, is it open source?
<FromGitter> <jamesfuture> One of which I like thread styles as alternative to Discourse forum
<FromGitter> <jamesfuture> I'm yet to check on API, will research now
<FromGitter> <jamesfuture> @j8r ⏎ ⏎ Spectrum’s Repo ⏎ https://github.com/withspectrum ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5c028615a6c29a1037c80f77]
<FromGitter> <KevinSjoberg> Does Crystal have the `DATA` and `__END__` capabilities from Ruby?
<FromGitter> <KevinSjoberg> At first try, it doesn't seem like it.
ua_ has joined #crystal-lang
<FromGitter> <j8r> @jamesfuture really nice! This could be considered if it has pros vs Gitter. https://github.com/withspectrum/spectrum/issues/2621 remains to do :/. This is a blocking point because it prevent ot have an IRC bridge like here
ua has quit [Ping timeout: 246 seconds]
Raimondi has quit [Ping timeout: 240 seconds]
Raimondi has joined #crystal-lang
Raimondi has quit [Ping timeout: 245 seconds]
<FromGitter> <jamesfuture> Yeah, it could take a while to get there
<FromGitter> <Sija> @KevinSjoberg nope IIRC
<FromGitter> <jtianling> http://crystalshards.xyz/ is down?
<FromGitter> <jtianling> I open it and display "Kemal has encountered an error. (500)"
<FromGitter> <vladfaust> Looks like something wrong with GitHub responses there
<oprypin> jtianling, https://crystalshards.org/
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
<FromGitter> <jtianling> thanks @FromIRC
<oprypin> jtianling, how did u find out about the other link? maybe we can update the reference
<FromGitter> <jtianling> https://crystal-lang.org/community/
<FromGitter> <jtianling> CRYSTAL SHARDS, TOOLS AND TUTORIALS
<FromGitter> <jtianling> and some old youtube videos
<oprypin> thanks
jtianling has joined #crystal-lang
jtianling has quit [Client Quit]
jtianling has joined #crystal-lang
<FromGitter> <ilanusse> Heyy
<FromGitter> <ilanusse> New to crystal here
<FromGitter> <ilanusse> Suppose I have a selection of methods such as follows: ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5c02a5e19f38cc0fd58b3c37]
<FromGitter> <ilanusse> And I have another method that receives a symbol
<FromGitter> <Blacksmoke16> better to use an enum
<FromGitter> <Blacksmoke16> than symbols
<FromGitter> <ilanusse> ```def foo(symbol) ⏎ // I want to call the method where method name == symbol ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5c02a67e8fa4333e39221344]
<FromGitter> <ilanusse> Why an enum?
<FromGitter> <ilanusse> I'm trying to make a shard recreating Pundit
<FromGitter> <Blacksmoke16> you could do it with a macro, but it wouldnt be real clean as it would have to be a case statement mapping symbol to method name
<FromGitter> <Blacksmoke16> is the symbol going to be the same as the method name?
<FromGitter> <ilanusse> Yep
<FromGitter> <ilanusse> I guess I could just go for the case statement
<FromGitter> <ilanusse> I was wondering if there was any way it could be extensible
<FromGitter> <ilanusse> But this'll do for now
<FromGitter> <ilanusse> Thanks!
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> those methods are not global, would be specific to something?
<FromGitter> <Blacksmoke16> @ilanusse
<oprypin> ilanusse: definitely do the case statement, but you can generate it using macros, which can list all methods in the current object. or it may be wise to maintain the list manually but at least you don't write out the actual cases
jtianling has quit []
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> @ezrast 💯 perfect!
<FromGitter> <ilanusse> Sorry, was coding!
<FromGitter> <ilanusse> So the whole idea is
<FromGitter> <ilanusse> You have Policies for your different model objects
<FromGitter> <ilanusse> https://github.com/varvet/pundit/
<FromGitter> <ilanusse> @Blacksmoke16 I'm basing myself on that
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <ilanusse> Here's the source I just pushed, feel free to snoop around
<FromGitter> <ilanusse> I'm writing a README rn
<FromGitter> <noahlh> hey everyone - quick question about some code that’s working, but I don't understand why (which scares me ;)
<FromGitter> <drum445> @j8r don't think that would work exactly how the guy changed it, commented lines wouldn't be taken into account
<FromGitter> <drum445> see his spec
<FromGitter> <noahlh> If I launch a node server and pipe the output to a logger: ⏎ ⏎ ‘’’’ ⏎ node_process = Process.new("node server.js", shell: true, output: Process::Redirect::Pipe) ⏎ node_process.output.each_line do |line| ... [https://gitter.im/crystal-lang/crystal?at=5c02b692500e8e372843b789]
<FromGitter> <noahlh> (oops sorry for bad formatting - on mobile)
<FromGitter> <noahlh> My Crystal prog stays alive and patiently pipes the output until I Ctl-C, at which point the program (and the external process) both exit. ⏎ ⏎ If I simply create the Process without the pipe or logger, the node server launches, my Crystal program immediately exits, and I have an orphan process. ⏎ ⏎ What’s going on here? I assume ‘IO.each_line’ is spawning Fibers behind the scene? Why and how
<FromGitter> ... does the node process get killed when I exit in that first scenario? [https://gitter.im/crystal-lang/crystal?at=5c02b6bb99ad1556dbee11b7]
<FromGitter> <ilanusse> Now added a README!
<FromGitter> <drum445> @j8r "Dotenv values containing spaces must be surrounded by quotes."
<FromGitter> <Blacksmoke16> ahh i dont have a good way to handle array of objects...
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> `["{\"name\":\"Bob\",\"age\":234}", "{\"name\":\"Bob\",\"age\":234}"]` i get that since its just making an array of each obj as a string...
<FromGitter> <Blacksmoke16> i cant just do `.to_json` on the array since i need to preprocess that data, for custom keys for example
<FromGitter> <Blacksmoke16> was able get around it by doing like ``` ⏎ class Array(T) ⏎ def serialize ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5c02bae49f38cc0fd58bc0cc]
<FromGitter> <Blacksmoke16> but that would require user to do like `require "CrSerializer/json_array`
<FromGitter> <Blacksmoke16> otherwise it would do that same logic for both yaml and json
<FromGitter> <drum445> can't you include json serializable in your class
<FromGitter> <drum445> so it mimics this: https://play.crystal-lang.org/#/r/5o6s
<FromGitter> <Blacksmoke16> no, because i have to do some custom logic before,
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c02bb7b464b6c0fd675d250]
<FromGitter> <Blacksmoke16> would be like `{"NAMe":"Bob", "age":123}`
<FromGitter> <drum445> I don't quite follow what you're trying to do I'm afraid
<FromGitter> <drum445> do you have a playground link that includes it?
<FromGitter> <Blacksmoke16> not that would be simple, sec ill link you some source code
<FromGitter> <drum445> ah right, so you've got the serializing in the array handler
<FromGitter> <drum445> Guess there's no way it could be in the class themselves
<FromGitter> <Blacksmoke16> nor that would be generic enough to support all serialization types
<FromGitter> <drum445> damn
<FromGitter> <Blacksmoke16> would be nice if you could edit/remove key/value pairs using json builder
<FromGitter> <Blacksmoke16> i have an idea
<FromGitter> <Blacksmoke16> naw wont wory
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Client Quit]
Renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> anyone have an example of how to use `YAML::Nodes::Builder`?
Jenz has joined #crystal-lang
<Jenz> Is there a macro method to read a file during compile time?
<Jenz> Specifically I want to read a file into a constant during compile-time
<Jenz> Im aware of the method using `cat file`, but Im a bit sceptical to doing it like that
<FromGitter> <r00ster91> Jenz, this macro has actually been added some time ago: https://github.com/crystal-lang/crystal/pull/6967. But it won't be available until 0.27.1 is released. So you probably have to use `cat` for now.
<Jenz> Ah, well ok, thanks rooster91, I knew I had seen it _somewhere_
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <Blacksmoke16> how do you get the resulting yaml from a `YAML::Nodes::Builder`
junland has quit [Quit: Disconnected.]
junland has joined #crystal-lang
<FromGitter> <drum445> How do I force the type of a union hash value into a method
<FromGitter> <drum445> I can use .as(String) is that best?
akaiiro has quit [Remote host closed the connection]
<jokke> anyone here doing AoC in crystal? :)
<jokke> i'm doing both rust and crystal this year and i love how the crystal solution to part one is literally one line long
<jokke> and still super readable
<Jenz> jokke: Im doing crystal
<jokke> cool :)
<Jenz> input.each_line.map(&.to_i).sum
* Jenz :D
<jokke> yup :)
<jokke> spoiler though :P
<Jenz> oh, eh well
<Jenz> too late D:
<Jenz> Maybe if I just post a lot of messages it'll go away with the scroll
* Jenz hmmm
<FromGitter> <drujensen> Lol
<jokke> :D
<FromGitter> <r00ster91> eh I just wanted to begin solving the puzzle and read this message lol
<Jenz> Thanks for the help
<jokke> well it's part 1 isn't rocket science
<jokke> -it's
<Jenz> Sorry, @r00ster91
<Jenz> Is there a crystal leaderboard?
<jokke> Jenz: you can make one!
<jokke> i already made one for work
<Jenz> Here's one for crystal: 289786-69f3013e
<Jenz> Where do we share it?
<jokke> dunno?
<Jenz> Ok, I'll see what I can do to share it
<jokke> i joined :)
<Jenz> Nice :D
<FromGitter> <Blacksmoke16> @j8r its not going to work out. Cant come up with a good enough way that will cover *all*serialization types in a generic way
<FromGitter> <Blacksmoke16> what would work for one obj doesnt work for an array
<FromGitter> <Blacksmoke16> it is possible but i would have to override and maintain my own `to_x` method that implements my logic, which isnt terrible, could easily do that if i have code to copy :p and there is a need
<FromGitter> <Blacksmoke16> but not plug and play method :(
<jokke> Jenz: in case you're interested: https://p.jokke.space/eFuXs/
<FromGitter> <j8r> @Blacksmoke16 too bad :/
<FromGitter> <Blacksmoke16> it would be better if the std `to_x` methods supported what i was trying to do
<FromGitter> <Blacksmoke16> but then my shard would be obsolete in the serialization side of things, is what it is
<jokke> Jenz: get the session token from any request on AoC from the network tab of your browser's dev tools
<Jenz> Oh nice, I like, thanks jokke
<jokke> np
<jokke> assuming you're also from germany. By chance from hessen?
<Jenz> No haha, from Norway
<Jenz> Why did you assume Germany?
<jokke> oh really?
<jokke> Jens is a pretty common name here
<jokke> but of course it has nordic origins
<jokke> i'm originally from finland :)
<jokke> so hi there neighbor o/
* Jenz :)
<jokke> https://teespring.com/adventofcode#pid=655&cid=102829&sid=front
<jokke> ^^
<FromGitter> <Blacksmoke16> i did find an issue with current master branch of my shard, it didnt handle array of objects correctly 😱
<FromGitter> <Blacksmoke16> i also dont think i can convert the classes to structs
<FromGitter> <Blacksmoke16> at least without some refactoring
thews has quit [Ping timeout: 245 seconds]
thews has joined #crystal-lang
Jenz has quit [Quit: leaving]
<FromGitter> <greenbigfrog> Is there a method on Enumerable, that basically does Enumerable#select.size ? Basically my usage would be to get the amount of X in an Enumerable
<FromGitter> <Blacksmoke16> Sum?
<FromGitter> <greenbigfrog> Not rly. I'll explain better in a sec
<oprypin> greenbigfrog, https://crystal-lang.org/api/0.27.0/Enumerable.html#count%28%26block%29-instance-method ???
<FromGitter> <greenbigfrog> thanks
<FromGitter> <greenbigfrog> smh I kept missing that
moei has joined #crystal-lang
sevensidedmarble has joined #crystal-lang
<FromGitter> <asterite> jokke: I'm doing advent of code
<FromGitter> <asterite> Every year it's the same, I want to try other languages but get bored because I have to write so much
<FromGitter> <asterite> And I tried Nim but the Set implementation seems to be really slow or dumb and the second part took like 4 seconds, I thought it was never going to end
<FromGitter> <asterite> So I guess I'll just do them in Crystal again
<FromGitter> <greenbigfrog> ```input = File.read_lines("input.txt") ⏎ pp input.size ⏎ pp input.to_set.size``` ⏎ ⏎ Shouldn't this output the same size!? [https://gitter.im/crystal-lang/crystal?at=5c0312186c3c565096bc00aa]
<FromGitter> <jgaskins> @greenbigfrog Not if there are duplicate input values
<FromGitter> <jgaskins> `pp input.group_by(&.itself).transform_values(&.size)` will show you how many of each value there are. there are a lot of duplicates.
<FromGitter> <greenbigfrog> oh. right
* FromGitter * greenbigfrog was simply being stupid as always
<FromGitter> <greenbigfrog> thanks...
<FromGitter> <girng> array.includes? is nice, loving it
<FromGitter> <redcodefinal> Anyone know whats going on with https://crystalshards.xyz/ ?
ashirase has quit [Quit: ZNC - http://znc.in]
<FromGitter> <girng> just use http://crystalshards.org i think that site is a goner
<FromGitter> <dscottboggs_gitlab> it might just be broken temporarily lol
<FromGitter> <dscottboggs_gitlab> .org is a lot slower than .xyz in my experince so I hope it's not gone
<FromGitter> <redcodefinal> @girng ty
<FromGitter> <khalilgharbaoui> @redcodefinal slow indeed!
<FromGitter> <girng> here is my example code: https://play.crystal-lang.org/#/r/5o9k ⏎ I was reading this and it said i should use a tuple instead of allocating a new array. https://crystal-lang.org/docs/guides/performance.html ⏎ ⏎ but i've also read about "stack overflow". how does a stack overflow error work within crystal and is it possible to get a stack overflow by using stack allocated code instead of heap allocated
<FromGitter> <dscottboggs_gitlab> I've definitely overflowed the stack in crystal by creating too many fibers/channels
<FromGitter> <dscottboggs_gitlab> I tried to do a naive merge-sort algorithm using fibers to demonstrate concurrency and it did not go well
<FromGitter> <girng> this is why i worry about structs because the stack is only so much, and the heap we have a lot more memory available (less chance of stack overflowing)? or can the stack take more memory from the heap when it needs it?
<FromGitter> <dscottboggs_gitlab> tbh I still need to learn how all that works :/
<FromGitter> <dscottboggs_gitlab> would love to see some resources using Crystal or Go or something at least legible to demonstrate these concepts. Kinda like I tried to do here (https://madscientists.co/pointers/)