<FromGitter>
<talbergs> @Sija Yes chess is my cup of tea...
marmotini_ has joined #crystal-lang
<FromGitter>
<girng> hahaha
marmotini has joined #crystal-lang
marmotini_ has quit [Ping timeout: 250 seconds]
jemc has quit [Ping timeout: 240 seconds]
marmotini has quit [Remote host closed the connection]
marmotini has joined #crystal-lang
<FromGitter>
<sdogruyol> Have a nice week everyone π
<FromGitter>
<drum445> And you sir
<FromGitter>
<mavu> I think I will make it my mission to support crystal development by posting at least once per day how nice the standard library is. That is almost the most impressive part for me.
<FromGitter>
<HarrisonB> @mavu It is really wonderful! I especially love the `HTTP` namespaced modules & classes
<FromGitter>
<mavu> I used the JSON over the weekend. and the mapping module is just great.
<FromGitter>
<sdogruyol> @mavu that'd be really cool :)
<FromGitter>
<sdogruyol> I'd be happy to share you posts
<FromGitter>
<j8r> @mavu what about JSON::Serializable? :P
DTZUZO has joined #crystal-lang
<FromGitter>
<Prutheus> How to convert a Time object to a string with that format: "Feb 2, 2019 7:15 PMβ ?
ashirase_ has quit [Ping timeout: 250 seconds]
ashirase has joined #crystal-lang
ua has quit [Ping timeout: 244 seconds]
<FromGitter>
<drum445> JSON mapping and serializable are what got me into Crystal to begin with
<FromGitter>
<maximvl> Hello everyone :)
<FromGitter>
<maximvl> I'd like to check with you what is the status of Crystal? I come to check the language once in a while but never really learned or tried it
<FromGitter>
<luislavena> @bew hey! I moved to Paris back in June, so around pretty much all the time now π
<FromGitter>
<Prutheus> How to convert a Time object to a string with that format: "Feb 2, 2019 7:15 PMβ ?
sagax has quit [Ping timeout: 250 seconds]
<FromGitter>
<mavu> @maximvl Thats a hard to answer question. Its great? Everything is groovy?
<FromGitter>
<maximvl> @mavu I wonder how is it from your point of view :)
<FromGitter>
<mavu> @maximvl Pretty awesome. I'm about to deploy it a small crystal application in production on RaspberryPi in several Banks. (fingers crossed. so far internal testing seems β good :) )
<FromGitter>
<maximvl> for myself I'm coming from Erlang background looking for a language to write desktop GUI with
<FromGitter>
<maximvl> in crystal I like static typing, decent type system and memory management
<FromGitter>
<mavu> have not used desktop gui with crystal, can't say anything about it.
gangstacat has quit [Quit: Δis!]
<FromGitter>
<maximvl> I'm wondering mostly because crystal is not a wide spread language, even compared to erlang %)
<FromGitter>
<kingsleyh> @mavu you are deploying onto raspberryPI ? Are they being used in branches - I suppose they must be cheaper than full computers but I guess depends how much power is needed for whatever job they are doing
<FromGitter>
<mavu> @Blacksmoke16 that looks cool, but overkill for what I used the json mapping for. β I noticed that the web-radio I usually listen to has updated their website (and broke my old script that grabs the current playing artist/song and writes it to a file when I request it). β In this updated they added metadata (in json) to the currently playing song, and to my great delight it includes a url to the youtube
<FromGitter>
<mavu> @kingsleyh Raspberries are not that slow actually. I had Intel Atom boxes that feel much worse.
<FromGitter>
<alex-lairan> Hi, I want to build methods automatically from a template type, I've write this : β β ```code paste, see link``` β β This code give me `undefined constant T::FIELDS` (It's `T` who is undefined) ... [https://gitter.im/crystal-lang/crystal?at=5c617d15dc3f0523cc986f49]
<FromGitter>
<girng> hmmm was thinking about this dilemma today. for example, if a player loots some copper or silver (tons of it), i don't want to update their mysql column each time. it would destroy the database. however, i can increase client.gold += amount, then have a method running in the background that updates every xx seconds instead. and just check if any client's `gold` has changed and update them. would work quite well
<FromGitter>
... actually. β β however, one downside is f the gameserver disconnects, that player will lose that amount they just looted. it would be xx seconds worth (or how long the db update interval is set for). i was thinking of doing this with items, but i definitely don't want a player to loot something nice and it be gone. so tho ... [https://gitter.im/crystal-lang/crystal?at=5c617d22ecef85660b88fa5d]
<FromGitter>
<mavu> @girng have the world simulation run on the server not the client. if the client disconnects, it does not matter because the state of the world is on the server. This also avoids problems with cheating players.
<FromGitter>
<drum445> @girng you should never trust input from the client, all actions should be verified on the server ideally. This would also solve your issue with the server going down
<jokke>
is there a way to create an empty named tuple?
<FromGitter>
<j8r> why O.o?
<jokke>
just as a default value
<jokke>
i merge it to another named tuple
<FromGitter>
<j8r> `NamedTuple.new` ?
<jokke>
j8r: :)
<jokke>
thanks
<FromGitter>
<j8r> no sure it'll work in your case
tankf33der has left #crystal-lang [#crystal-lang]
<FromGitter>
<girng> possible dumb question incoming:
<FromGitter>
<girng> is it possible to communicate with crystal by using php?
<FromGitter>
<j8r> through a socket or file descriptor
<rkeene>
I'm going to say "Yes"
<rkeene>
Anything you can sufficiently define is possible
<rkeene>
Most things are a bad idea, though
<FromGitter>
<j8r> that's common to communicate through a socket
<FromGitter>
<j8r> for example PHP <=> MySQL
<FromGitter>
<j8r> it can be PHP <=> Crystal
<FromGitter>
<girng> hmm gonna look into sockets
<FromGitter>
<j8r> usually they are created in /run and end with `.sock` if you wonder
<FromGitter>
<girng> oh so php has sockets already. i can just use that when i need to send something to my crystal process
<FromGitter>
<girng> just connect and send message? do i have to do that every time? i wonder if it's possible to keep it open so i don't have to connect each time
<FromGitter>
<girng> but i guess this is more of a php question
<FromGitter>
<girng> end goal: when someone purchases an item from the auction house, i need php to send a message to my crystal process (master server) that the item was bought, which then notifies that player. i can code the auction house in my master server, but i really don't want to because i want it to be web based as well, and the entire site/forum is already written in php
<FromGitter>
<girng> or.. scratch the web based auction house and just have it in-game. prob better
marmotini has joined #crystal-lang
marmotini_ has quit [Ping timeout: 245 seconds]
<FromGitter>
<Blacksmoke16> π
<FromGitter>
<j8r> You can create the socket in Crystal, like /run/myapp.sock`
<FromGitter>
<j8r> Send your PHP app send data to it
<FromGitter>
<girng> i spoke too soon, sorry
<FromGitter>
<johanalkstal> If I understand things correctly, `require` is only used to tell the compiler about other files that are needed? Does that mean that you only need `require`calls in a single root file? It's not like `require()` and `import` from JavaScript for example?
<FromGitter>
<johanalkstal> Trying to learn Crystal by reading Programming Crystal and so far am liking it but some things are still not "crystal clear"... :P
cyberarm has quit [Ping timeout: 240 seconds]
<FromGitter>
<johanalkstal> Another one is when to use `private` or `protected`?
<FromGitter>
<j8r> Sure you can do everything in a single file or require the world
<FromGitter>
<johanalkstal> What does that mean? :D
<FromGitter>
<j8r> It's considered best practise to modularize, then require what you nees
<FromGitter>
<j8r> *need
<FromGitter>
<j8r> You can `require "./**"` :(
marmotini has quit [Ping timeout: 272 seconds]
<FromGitter>
<j8r> Why this exists :(
<FromGitter>
<johanalkstal> Perhaps my question and understanding is a bit off. `require` doesn't bring the required module into scope like it does in JavaScript? It's not "I need this module in this file so I will require it", or is it? β The way I read the book is that `require` is only for the compiler to compile all files into a single file in the end, is that right?
<FromGitter>
<jwoertink> @johanalkstal You are correct that the require is not like javascript. You require once, and then get access to that in all your files. The order of your require also matters.
<FromGitter>
<j8r> Use private if the method must not be used publicly
<FromGitter>
<johanalkstal> @jwoertink The order of require matters?
<FromGitter>
<jwoertink> if you had this, you couldn't access anything in file_b from within file_a because file_b hadn't been required at that time
<FromGitter>
<johanalkstal> Okay. So then it would make sense to use a `require` at the point a file actually "requires" another file
<FromGitter>
<jwoertink> however, you could access file_a stuff inside file_b because file_a had already been required
<FromGitter>
<johanalkstal> Hmm okay. So basically require anything that will be needed by anything further down the tree from that point.
<FromGitter>
<johanalkstal> A require is a new branch
<FromGitter>
<j8r> Yep. When writing tests, you usually only require the tested methods in a file, that eventually have requires inside
<FromGitter>
<johanalkstal> Okay, thanks for helping out
<FromGitter>
<j8r> IIRC there is a command to inspect the AST
fullforce has joined #crystal-lang
<fullforce>
is there a way to use OR with namedtuple?
<fullforce>
trying to make something where if the namedtuple key doesnt exist, it defaults to another value
<oprypin>
t[:key]? ||
<fullforce>
thank you.
<fullforce>
ill make sure to read the docs more harder next time lol
Kero has left #crystal-lang [#crystal-lang]
DTZUZO has joined #crystal-lang
<FromGitter>
<vivus-ignis> is there anything like python's `if *name* == '__main__':` in crystal? i would like my app to run in a "library mode" when i do `crystal spec`
<FromGitter>
<j8r> what do you mmea
<FromGitter>
<vivus-ignis> right now, when i do crystal spec
<FromGitter>
<vivus-ignis> it evaluates the main logic, which is to parse commandline parameters and then detect the current linux distro
<FromGitter>
<vivus-ignis> which is not what i want for testing
<FromGitter>
<vivus-ignis> so... is there a way to detect that my app is being run as a binary instead of being loaded in a spec file?
<FromGitter>
<Blacksmoke16> could maybe use a compile time flag that you pass to `crystal spec`
<FromGitter>
<bew> @vivus-ignis no there isn't
<FromGitter>
<Blacksmoke16> or within your main file...
<FromGitter>
<j8r> @vivus-ignis just create a `cli.cr`
<FromGitter>
<j8r> which require you `main_app.cr`, which you use in the specs
<FromGitter>
<Blacksmoke16> how would that be any diff to just requiring the main app?
<FromGitter>
<vivus-ignis> i think i can try with the compile flag
<FromGitter>
<vivus-ignis> i already had to do that to help with static build
<FromGitter>
<j8r> look at other projects
<FromGitter>
<j8r> they separate cli and the actual program
<FromGitter>
<Blacksmoke16> fair enough
<FromGitter>
<vivus-ignis> thank you @Blacksmoke16 @j8r
<FromGitter>
<Blacksmoke16> can you have a method with a type def of a specific enum member?