<FromGitter>
<proyb6> @elorest since database are faster because Crystal is single threaded but that’s not a problem for majority of the sites https://www.techempower.com/benchmarks/#section=test&runid=a2bc7ff7-4ede-456b-959d-1ba79303095f&hw=ph&test=db
<FromGitter>
<dscottboggs_gitlab> @talbergs you're running into the difference between paralellism and concurrency. The primary fiber in your link yields to the first-declared fiber (the "request animation frame loop" one), which then NEVER yields. If the `sleep 0.1.seconds` or a Fiber.yield was inside of that block, it would run as expected. Well... almost https://play.crystal-lang.org/#/r/61a8
<FromGitter>
<Blacksmoke16> but that would work as well
<FromGitter>
<Blacksmoke16> i have a branch of my granite fork working with annotations as well
<FromGitter>
<Blacksmoke16> so idea was this would/could be used with a like `@[Granite::OneToOne(class: Customer)]`
<FromGitter>
<Blacksmoke16> so that your relations are also just properties on the class
<FromGitter>
<Blacksmoke16> idk, might put this idea on hold
<FromGitter>
<dscottboggs_gitlab> yeah it really seems like the responsibilty of an ORM not a serializer
<FromGitter>
<Blacksmoke16> not sure, this doesn't have to be limited to orm
<FromGitter>
<dscottboggs_gitlab> good point
<FromGitter>
<Blacksmoke16> i could see it also used for custom stuff, like by default dont serialize a user's resume data, but make it able to do so by expansion: ["resume"]
<FromGitter>
<Blacksmoke16> which could execute a custom function
<FromGitter>
<dscottboggs_gitlab> yeah I was just thinking, how it could be used for arbitrary data or for nosql database connections and stuff
<FromGitter>
<Blacksmoke16> but i agree im not sold it should be an annotation tho
<FromGitter>
<Blacksmoke16> could be argued either way
<FromGitter>
<dscottboggs_gitlab> how would it handle *de*serialization?
<FromGitter>
<Blacksmoke16> hell if i know xD
<FromGitter>
<dscottboggs_gitlab> :D
<FromGitter>
<dscottboggs_gitlab> idk at that point I feel like maybe you should be defining subtypes that inherit from User?
<FromGitter>
<Blacksmoke16> i would think it would be read only
<FromGitter>
<dscottboggs_gitlab> No, I mean like, as a person writing code as opposed to the library author, it makes more sense to me to define `UserWithCustomer < User` and then use that instead of using special properties and macros with serialization instructions, you know? idk maybe that's just me
<FromGitter>
<Blacksmoke16> probably
<FromGitter>
<Blacksmoke16> we have the expansion thing at work and its quite handy
<FromGitter>
<Blacksmoke16> but yea, im not super sure how to best implement it atm :/
<FromGitter>
<dscottboggs_gitlab> I'm sure you'll figure it out if you put your mind to it. You're the macro wizard, remember? haha
<FromGitter>
<matthewmcgarvey> Is there a good library for performance testing?
<FromGitter>
<dscottboggs_gitlab> does the built-in `Benchmark` not suit your needs?
<FromGitter>
<Blacksmoke16> im sure ill think of something
<FromGitter>
<Blacksmoke16> i kinda want to refactor CrSerializer
<FromGitter>
<Blacksmoke16> to just be an overload to `to_json`/`from_json`
<FromGitter>
<Blacksmoke16> vs the such dog fooded thing it is
<FromGitter>
<dscottboggs_gitlab> how does it do it now? `#serialize`?
<FromGitter>
<Blacksmoke16> calling an overloaded `to_json` lol
<FromGitter>
<dscottboggs_gitlab> ..so what's the difference?
<FromGitter>
<dscottboggs_gitlab> haha
<FromGitter>
<Blacksmoke16> exactly
<FromGitter>
<Blacksmoke16> xD
<FromGitter>
<dscottboggs_gitlab> I'm confused
<FromGitter>
<Blacksmoke16> the idea for using a diff name was to still allow the default behavior to be used
<FromGitter>
<Blacksmoke16> i.e. the stdlib `.to_json`
<FromGitter>
<Blacksmoke16> ill prob do that tomorrow
<FromGitter>
<Blacksmoke16> in a perfect world the stdlib would support my extra features and then it would just work :3
<FromGitter>
<dscottboggs_gitlab> Hm, I think if you've `include`d CrSerializer, that's not gonna be an issue. I guess if there's like no internal way to do it in a class that could be a bit of a pain for someone...
<FromGitter>
<dscottboggs_gitlab> why not define a method that implements the default behavior of to_json in the CrSerializer module?
<FromGitter>
<Blacksmoke16> ill look into it
<FromGitter>
<Blacksmoke16> shouldn't be too hard i think
<FromGitter>
<dscottboggs_gitlab> you could just defer that problem til it becomes an issue ;)
<FromGitter>
<Blacksmoke16> had to override the standard `to_json` to take the groups
<FromGitter>
<dscottboggs_gitlab> I see
<FromGitter>
<Blacksmoke16> im basic just building on the standard lib's JSON::Serializable stuff, but with added functionality
<FromGitter>
<dscottboggs_gitlab> that won't cause other issues? I've always been a bit wary of reopening
<FromGitter>
<Blacksmoke16> like what?
<FromGitter>
<dscottboggs_gitlab> like if someone else adds a version of Object#to_json that also has an Array(String) as its second argument or doesn't specify a type
<FromGitter>
<Blacksmoke16> Hmm
<FromGitter>
<Blacksmoke16> I'll worry about that when/if it becomes an issue
<FromGitter>
<Blacksmoke16> Plus if you use a different param name I'm *pretty sure* it would be fine
<FromGitter>
<dscottboggs_gitlab> nope
<FromGitter>
<girng> finally syncing player's items from the db to the client's properties (on the gameserver) this is getting fun
<FromGitter>
<dscottboggs_gitlab> that only matters if you're using named arguments (which is why I use named arguments religiously), otherwise it just checks the type
<FromGitter>
<dscottboggs_gitlab> and if the argument has a version which doesn't specify a type, that overload interferes with *any* overload with the same number of arguments
<FromGitter>
<dscottboggs_gitlab> ayy there you go
<FromGitter>
<girng> i also don't really care about doing this dumb array matrix on the server. if a player wants to disassemble the game client, find the right send cmd, etc and put a couple more items in their inventory, go for it LOL
<FromGitter>
<dscottboggs_gitlab> @girng
<FromGitter>
<dscottboggs_gitlab> sorry, what?
<FromGitter>
<girng> sorry spazzing out with game stuff in crystal
<FromGitter>
<dscottboggs_gitlab> You're making a multiplayer game in crystal, yes, but what is the "dumb array matrix"?
<FromGitter>
<Blacksmoke16> well yea, they would *have* to use named args when calling `to_json`
<FromGitter>
<Blacksmoke16> prob is a decent solution
<FromGitter>
<dscottboggs_gitlab> I suppose if you document that you *must* use named arguments, it's ok, but not everyone reads the docs lol
<FromGitter>
<Blacksmoke16> :shrug: only do so much
<FromGitter>
<dscottboggs_gitlab> yep
<FromGitter>
<Blacksmoke16> yea this is a much better/simpler setup
<FromGitter>
<Blacksmoke16> serialization specs are passing
<FromGitter>
<Blacksmoke16> deserialization will just work since im using `after_initialize` anyway
<FromGitter>
<Blacksmoke16> 💯
<FromGitter>
<dscottboggs_gitlab> oh nice
<FromGitter>
<dscottboggs_gitlab> just found those hooks the other day, very useful
<FromGitter>
<Blacksmoke16> For sure, is also one that gets called after to json
<FromGitter>
<girng> think of the diablo 2, their grid. it's a ` Array(Array(Int32)).new ` and when a player moves an item in their inventory, they check to see if it fits. like a tetris piece. i have most of the code for that here (https://paste.ee/p/gsAY4), but i don't want to deal with it anymore because i forgot how it works. and on the client side, i already have the collision detection in place when looting an item, so it
<FromGitter>
... will go to the right spot. so, the hacker would have to disassemble the game client, find the right CMD (packet) to sent, then send the correct position so they could store more items in their inventory. that, of which i don't really mind. if a hacker wants do to that, go ahead lol.
<FromGitter>
<dscottboggs_gitlab> why couldn't they just watch the communication between the client and the server and find the command? TBH anything like that should probably be computed server-side. Like, the client says "hey I'd like to move my character to this square" and the server replies with "ok, if you do that, these events will occur.
<FromGitter>
<girng> omg
<FromGitter>
<girng> i don't CARE LOL i was just chatting
<FromGitter>
<dscottboggs_gitlab> I mean... I was too haha sorry
<FromGitter>
<dscottboggs_gitlab> sorry I was kinda being a dick ther
<FromGitter>
<girng> nah you are not wrong, that's it supposed to be done on the server lol
<FromGitter>
<dscottboggs_gitlab> but like it's your project and your priorites
<FromGitter>
<dscottboggs_gitlab> anyway, what kinda game is it?
<FromGitter>
<girng> i just found it funny that i have the power to make that decision. i'm free and not bound to do everything perfectly on the server
<FromGitter>
<dscottboggs_gitlab> true
<FromGitter>
<girng> but yeah i understand your concern 100% you are right that's how it should be done. i'm just different i guess, too lazy and i forgot how that code works hahaha
<FromGitter>
<girng> even though i wrote it 😆
<FromGitter>
<dscottboggs_gitlab> forgetting how your own code works is super common, that's what documentation is for, and why I always try to make my code as readable as possible.
<FromGitter>
<girng> if i were to write it again i'd do it differently now. i've learned so much with crystal in just the span of the past few months tbh
<FromGitter>
<dscottboggs_gitlab> same
<FromGitter>
<girng> especially with your help with macros hahaha
<FromGitter>
<dscottboggs_gitlab> yeah macros can be a tough concept
<FromGitter>
<dscottboggs_gitlab> you picked a good place to learn them IMO
<FromGitter>
<girng> ❤️
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter>
<girng> @dscottboggs_gitlab yeah, regards to documentation / readability.. my nodejs server code when i used to code in notepad++ was a mess. that's why i'm really grateful for the crystal formatter...
laaron has joined #crystal-lang
<FromGitter>
<Blacksmoke16> Always start on v2 of your game ;)
<FromGitter>
<girng> now that i think of it.. without crystal's formatter, i think my code would be extremely messy omg lol
<FromGitter>
<dscottboggs_gitlab> yeah I definitely had to be taught readability conventions
<FromGitter>
<dscottboggs_gitlab> @girng you're using crystal for the client but not the server?
<FromGitter>
<girng> no no just the server
<FromGitter>
<dscottboggs_gitlab> oh I see
<FromGitter>
<girng> crystal is amazing for the server my gosh
<FromGitter>
<dscottboggs_gitlab> what is the client?
<FromGitter>
<girng> godot engine
<FromGitter>
<dscottboggs_gitlab> seriously it is haha
<FromGitter>
<girng> i hope more godot developers use crystal for server purposes
<FromGitter>
<dscottboggs_gitlab> huh, I was under the impression that godot used python
<FromGitter>
<Blacksmoke16> Python like
<FromGitter>
<dscottboggs_gitlab> yeah I see that now. interesting
<FromGitter>
<girng> and the JSON.parse with crystal and godot work together flawlessly! for example, if your method grabs certain keys from the EXPECTED JSON::Any, like (this (https://i.gyazo.com/eae86839780a978c9beff15989d564f0.png)). if the user decides to enter any naughty input, OR, the user doesn't send the required keys or *TYPE!*. an exception will be raised. for that user's `handle_connection` fiber. so it's great for
<FromGitter>
... stability. i implemented a honey bucket flood protection system as well, which works great for chatting, certain commands, etc.
<FromGitter>
<girng> when i say great for stability, i mean instead of the entire server crashing, the exception just gets called for that fiber. then if it's something bad, you can decide to socket.close them if you want LOL
<FromGitter>
<girng> i only do socket.close if it's something really naughty though
<FromGitter>
<Blacksmoke16> neat
<FromGitter>
<Blacksmoke16> mm know you did something right when it just works doing a find replace for `serialize => to_json` and `deserialize => from_json`
<FromGitter>
<girng> 😆
<FromGitter>
<dscottboggs_gitlab> So, I found this (https://crystal-lang.org/api/0.27.0/toplevel.html#future%28%26exp%3A-%3E_%29-class-method) earlier, which, if you look at the source, implements a Future with error handling and states.
<FromGitter>
<Blacksmoke16> neat
<FromGitter>
<Blacksmoke16> try it out yet?
<FromGitter>
<dscottboggs_gitlab> no not yet
<FromGitter>
<Blacksmoke16> looks pretty legit
<FromGitter>
<dscottboggs_gitlab> indeed. gonna delete my future repo
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<Blacksmoke16> alright hashed this out a bit more
<FromGitter>
<Blacksmoke16> implementation is much simpler now
<FromGitter>
<Blacksmoke16> in theory since i scrapped the custom to/from methods, as long as each format implements an override and my logic in their own format, it should just work with whatever format
<FromGitter>
<Blacksmoke16> i.e. con, yaml, xml, etc
<FromGitter>
<Blacksmoke16> might do some testing with it since its similar to json
<FromGitter>
<girng> interesting
<FromGitter>
<Blacksmoke16> ill save that for tomorrow :p
<FromGitter>
<girng> no help at all! go meeeeeee!!
rohitpaulk has joined #crystal-lang
<FromGitter>
<j8r> @girng gj!
<FromGitter>
<j8r> GG, GirnG
<FromGitter>
<girng> LOL, gg
<FromGitter>
<girng> ty
<FromGitter>
<girng> funny cause my adminer.php csv exporter, some reason exports my csv data with 1 line at the end of the file. guess what baby??? `data.chomp` HAHAH it works greaatt!
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
mps has joined #crystal-lang
<FromGitter>
<Blacksmoke16> well now i gotta redo all my specs to test yaml too now
<FromGitter>
<Blacksmoke16> why do i make more work for myself :p
<FromGitter>
<vladfaust> I'm implementing a job processing system and want to have flexible concurrency system with arbitrary arity of values to check the limits on. I hope you get the idea
<FromGitter>
<vladfaust> Don't want to monkey-patch the whole program =(
<FromGitter>
<vladfaust> Thanks, guys
<FromGitter>
<vladfaust> I guess the best variant would be to stick with "inspect". Raw inspect gives 10M IPS, which is enough. But what are the fastest ways to hash an IO then? SHA1 leads to 10M -> 1M
laaron has quit [Remote host closed the connection]
<FromGitter>
<vladfaust> Again, I don't need crypto security
<FromGitter>
<elorest> Is there anyone here in the Crystal Community who would be interested in coming to work on existing crystal projects at Nikola Motor Company. Phoenix AZ. Not currently remote, which is unfortunate but I moved to Phoenix for it and it's pretty nice here.
<Yxhuvud>
Phoenix is a bit far away..
<FromGitter>
<vladfaust> If the company paid for relocation, I'd be interested
<FromGitter>
<Blacksmoke16> is crystal nightly still broken on travis?
<oprypin>
greenbigfrog, i'm sure the error is not in this piece of code...
<FromGitter>
<vladfaust> You're passing a nilable value to `DB.mapping`
<FromGitter>
<greenbigfrog> But how? I'm only calling a query_one?
<FromGitter>
<greenbigfrog> If I change it to `TransactionMemo?` I'll get `undefined constant TransactionMemo` ⏎ And If I then change it to `Data::TransactionMemo?` I'll get `PG::ResultSet#read returned a Slice(UInt8). A (Data::TransactionMemo | Nil) was expected. ⏎ `
<FromGitter>
<girng> i think i'm cracking the code of a programmer and how confidence can play a vital role in development
<FromGitter>
<girng> YOU MUST believe in yourself and feel confident in what you are coding. this makes you not re-compile your code every other 2 seconds just to make sure you wrote a correct variable. this let's you write more and saves a lot of time. i used to just write like 2 lines of code, and then re-compile just to check to make sure. but now, it's 4, 6, sometimes 8 lines instead. i am feeling more confident
<FromGitter>
<Blacksmoke16> indeed
<FromGitter>
<Blacksmoke16> 🚀 good to hear
<FromGitter>
<girng> 🚀 !
<FromGitter>
<Blacksmoke16> ayy, check it out
<FromGitter>
<Blacksmoke16> just gotta write tests