<FromGitter>
<girng> its cool i will jut do DB.open for now thx
Renich has joined #crystal-lang
<FromGitter>
<HarrisonB> just curious: what are the current crystal options for background jobs? I see sidekiq.cr and mosquito, which both have Redis stores as dependencies
<FromGitter>
<HarrisonB> anything that works with a SQL db like Postgres?
Raimondi has joined #crystal-lang
<FromGitter>
<Blacksmoke16> none atm
<FromGitter>
<Blacksmoke16> could prob override it/add adatper for sql
<FromGitter>
<anamba> @HarrisonB i'm using faktory
<FromGitter>
<anamba> but only because i need it to work with crystal + other languages
<FromGitter>
<kevinelliott> @anamba How do you like it? I’ve had the faktory page up for over a week now.
<FromGitter>
<anamba> @kevinelliott A bit light on documentation, but working ok so far. factory.cr seems to be unmaintained, but it only needed a small tweak to work with 0.27.0.
<FromGitter>
<kevinelliott> @anamba Did you submit a PR for the tweak?
<FromGitter>
<anamba> not yet, still just trying to get everything working smoothly.
<FromGitter>
<kevinelliott> Ahh gotcha. Be sure to submit a PR when you do though, as I’m planning to use it too. Would love it if you tagged/mentioned me (github: kevinelliott) for visibility if you do :)
<FromGitter>
<anamba> @kevinelliott if it's not today there's no chance i'm gonna remember that :) subscribe to the repo maybe?
<FromGitter>
<kevinelliott> All good...
laaron- has joined #crystal-lang
laaron has quit [Ping timeout: 256 seconds]
ua_ has joined #crystal-lang
ua has quit [Ping timeout: 258 seconds]
_whitelogger has joined #crystal-lang
<FromGitter>
<HarrisonB> Thanks!
<FromGitter>
<Sija> @girng `rescue` branch makes it nilable
spacemanspam has quit [Read error: Connection reset by peer]
spacemanspam has joined #crystal-lang
<FromGitter>
<Blacksmoke16> heres an option parser question
<FromGitter>
<Blacksmoke16> can it be made that a command can takes multiple args?
<FromGitter>
<Blacksmoke16> like `./app --command test 123 abc
<FromGitter>
<Blacksmoke16> like map `test` to name, which i have working now
<FromGitter>
<Blacksmoke16> but rest to another var?
<FromGitter>
<Blacksmoke16> or would that have to be done manually
<FromGitter>
<girng> i removed rescue and just had DB.open, same thing
Renich has quit [Quit: Renich]
Raimondi has quit [Ping timeout: 240 seconds]
spacemanspam has quit [Read error: Connection reset by peer]
<FromGitter>
<domgetter> @bew I got everything working using Box.
<FromGitter>
<domgetter> For some things, I have to use `Box.box`, and for others I need to use `.as(Void*)` Is there any documentation on the difference between those two?
<FromGitter>
<domgetter> Oh, does Box "add" a pointer layer, whereas `.as(Void*)` expects a pointer to begin with?
bmcginty has joined #crystal-lang
spacemanspam has joined #crystal-lang
bmcginty has quit [Ping timeout: 245 seconds]
spacemanspam has quit [Read error: Connection reset by peer]
bmcginty has joined #crystal-lang
marmotini_ has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
spacemanspam has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
<FromGitter>
<bew> Box is used to go from some crystal type to void* and back, so you can pass any crystal object to a c method expecting void* (for exemple for c callback param like in the exemple code of Box)
<FromGitter>
<bew> Oops the markdown engine kicked in ^^ it's `Void*` when I say `void`
<FromGitter>
<bew> I don't understand what you say about some times you have to use x or y, can you show?
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
<FromGitter>
<girng> i guess i should use float32, then just round the value on the game client. just diablo 2 / poe don't have floats for HP values. so i figured `health` would have to be an int
marmotini_ has quit [Remote host closed the connection]
marmotini_ has joined #crystal-lang
ashirase has quit [Ping timeout: 272 seconds]
ashirase has joined #crystal-lang
<FromGitter>
<j8r> seems like crystal-lang core members loves its non modular monorepo :(
<FromGitter>
<j8r> it hurts because each time we want to work on a component we need to fork the *whole* language
spacemanspam has quit [Read error: Connection reset by peer]
<FromGitter>
<j8r> I tried to make a custom formatter and playground, but the actual state make this a pain. I got 2 forks of the whole monorepo, and I've to rebase regularly to be up-to-date with the stdlib :(
<FromGitter>
<j8r> and I end up with 3 crystal compilers that are the same but with different tools
<FromGitter>
<ideasasylum> Newbie crystal programmer here with a probably-not-so-newbie question: How would I start debugging a problem with a macro?
<FromGitter>
<bew> @ideasasylum your error is `can't declare class dynamically`, meaning that you're probably calling `Mocks.create_mock Caddy do ... end` inside a method or a block. The thing is that `Mocks.create_mock` will declare a class, and class declaration can only happen in top level (not in a method/block/expression)
<FromGitter>
<ideasasylum> ah! that is probably it
<FromGitter>
<bew> @girng you could do `to_u16` on the result to get back a UInt16: `p.health = (p.health * p.health_regen * delta).to_u16`
<FromGitter>
<ideasasylum> @bew that was it! Thank you so much. I was up til 2am trying to figure that out
badeball1 has quit [Quit: WeeChat 2.3]
badeball has joined #crystal-lang
badeball has quit [Quit: WeeChat 1.6]
badeball has joined #crystal-lang
<FromGitter>
<bew> you're welcome ;)
<FromGitter>
<straight-shoota> @j8r Whether it's developed in one repo or in separate ones, the formatter is deeply integrated with the compiler.
<FromGitter>
<straight-shoota> I don't think your pain would pass simply by putting it in a separate repository.
<FromGitter>
<j8r> I'm not talking technically, just on the principle
<FromGitter>
<j8r> Node.js, Python (with Black), Rust can have separated formatters - and that's nice for customization
<FromGitter>
<j8r> @straight-shoota that's the problem - it's tied to the compiler :/
<FromGitter>
<bararchy> @straight-shoota regarding the SNI
<FromGitter>
<bararchy> what I'm trying to achive is the full callback flow
<FromGitter>
<straight-shoota> I believe you just patched the wrong class
<RX14>
mps, unfortunately mbedtls isn't packaged well enough on older still-supported debian versions to drop openssl entirely :(
<RX14>
i.e. for debian 8, mbedtls was only packaged in backports and the backports version even has CVEs outstanding
<RX14>
and debian 8 is supported for another 1.5 years
<mps>
hmm, it is used just for some packages on debian, not much
<RX14>
yeah, debian 9 is an old mbedtls version but it's well-patched
<RX14>
so in 1.5 years i'm sure it'll be fine to drop openssl support from core
<RX14>
but until then it's eigher going to be openssl-only or mbed-preferred openssl-fallback
<mps>
understand, but like to have nice dream :)
<mps>
I know that there is no easy solutions to complicated stuff
<FromGitter>
<petoem> @greenbigfrog assuming that the symbols correspond to enums, it could only be `to : Array(Int64)` you are trying to pass in `Array(UInt64)`.
<FromGitter>
<greenbigfrog> wtf
<FromGitter>
<greenbigfrog> how tf did I keep missing this...
<FromGitter>
<yxhuvud> @rishavs We use the sdk
<FromGitter>
<j8r> but that's won't be the problem of the language anymore RX14, in the future?
<FromGitter>
<j8r> The goal will be to provide a stable API for external TLS libraries to implement them, no?
<FromGitter>
<greenbigfrog> thanks @petoem
<RX14>
@straight-shoota re: graceful shutdown of HTTP servers, I think the most reasonable solution for upgraded sockets is just to close the socket immediately.
<FromGitter>
<bararchy> RX14, @straight-shoota can you guys help me for a sec? ⏎ why can't the CI find `SSL_set_tlsext_host_name` in the specs? what version of openssl do we use?
<RX14>
you need to support 0.9.8 to 1.1.1
<FromGitter>
<bararchy> ho god no 😱
<RX14>
and honesylu we should drop support for 0.9
<rkeene>
RX14, For Tcl's TLS module I'm working on adding support for things other than OpenSSL. Over the years, I've liked NSS's implementation the best, but there's also small portable implementations.
<RX14>
nss?
<RX14>
not the libc nss?
<rkeene>
Netscape Security Services
<RX14>
ah
<rkeene>
It does stuff like store CRLs (and everything) in a database (now SQLite, BDB before that) because they can be HUGE -- OpenSSL is much slower
go|dfish has quit [Ping timeout: 250 seconds]
marmotini_ has quit [Quit: Leaving]
DTZUZO has joined #crystal-lang
<FromGitter>
<tonobo> Hey, we're currently testing memory consumption with kemal and router.cr. Crystal is consuming a massive amount of memory, after a few concurrent calls. You could easily reproduce by creating just a single route and fireing a few requests against it. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c361574bd592b2e6e78e04a]
powerbit has quit [Remote host closed the connection]
<FromGitter>
<girng> @bew thanks i wonder if that is less performant than just using a float32 in the game loop
<FromGitter>
<bew> basically: float are slow compared to integers, if you can avoid them the better (e.g in any time or accurate -sensitive context, like games)
<FromGitter>
<bew> @girng ^
<FromGitter>
<girng> yeah but in that code were are doing a conversion
<FromGitter>
<yxhuvud> @bew say what? Traditionally, floats was always used since they was a lot faster
<FromGitter>
<bew> @yxhuvud that doesn't make sense, maybe there are some path in modern processors that are optimized for floats, but overall, operations on integers are easier to do for the processor asaik
<rkeene>
It's more like the CPU has more opcodes that operate on integers and more integer registers -- but it depends on what you're doing
<FromGitter>
<bew> @tonobo what is "massive amount of memory" ?
Renich has quit [Ping timeout: 250 seconds]
Renich has joined #crystal-lang
<FromGitter>
<bew> @girng I'd say it's irrelevant and it doesn't matter really..
<FromGitter>
<girng> im just gonna do all float32's then
<FromGitter>
<girng> thanks
<rkeene>
You could always time it on your own system :-D
<FromGitter>
<j8r> @girng but it can be useful to be an Int32 instead of a float
<FromGitter>
<j8r> depends of the usecase
<FromGitter>
<girng> feels so wrong to use float32 though, for player health i guess it's fine. but on crit_multiplier or something.. that is gonna be 1.00 to 10.00 at most (anything above 10 is literally god mode)
<FromGitter>
<j8r> It will be simpler to have higher integer numbers
<FromGitter>
<girng> float32's max value is FAR MORE than 10.00
<FromGitter>
<j8r> like 1000/1000 HP instead of 10.00/10.00 HP
<FromGitter>
<j8r> it would be also more performant like @bew said
<FromGitter>
<girng> why 10.00 HP? wouldn't it be 1000.00 HP?
<FromGitter>
<j8r> You don't get it, I mean, for example, `1000_i32` instead of `10_f32` for max health
<FromGitter>
<j8r> no more decimals
<FromGitter>
<j8r> that's what most games do
<FromGitter>
<girng> what about modifying that though with percentages? we have to to the conversion method bew posted?
<FromGitter>
<girng> The 1000_i32
<FromGitter>
<girng> btw, is there something lower than a float32? for example, see my crit_multiplier example above. why would i set a variable's type float32, when the max value it will receive can't go above 10.00?
<FromGitter>
<girng> why does float32 force the developer to use more unneeded bytes? makes no sense
laaron has quit [Remote host closed the connection]
<FromGitter>
<j8r> it would be better not to have conversions at all. If you have a Float, `to_i` it
<FromGitter>
<bararchy> So, got my super PR to pass review, which means now I need to start working on callback
<FromGitter>
<j8r> Even by using float you'll need to round
<FromGitter>
<bararchy> I want to uses a block for the callback, let's hope I can manage it
<FromGitter>
<j8r> Use big integers like in Dot&2 or LoL @girng :)
laaron has joined #crystal-lang
<FromGitter>
<bararchy> @girng just keep it all as strings ;) then no need to think about types hahaha ⏎ ⏎ hp.to_s => "234432", then hp.to_i
<FromGitter>
<tonobo> @bew 100MB and up. The same service writtin in go consumes about 15MB
<FromGitter>
<tonobo> It should be pretty easy reproduce :D
<FromGitter>
<tonobo> I rekcon, this dependes on the number of open connections, there might be a bunch of resources allocated for each one.
<FromGitter>
<bararchy> @tonobo can you share the code of the app you're testing with? Maybe just an issue with resources not being freed
Raimondi has joined #crystal-lang
<FromGitter>
<straight-shoota> OMG. I'm hunting a compiler bug
<FromGitter>
<straight-shoota> It seems to be a ghost 😱
<FromGitter>
<straight-shoota> Or maybe not...
<FromGitter>
<straight-shoota> Nooooooooo 😢 It's an HCI failure.
<FromGitter>
<straight-shoota> We should make `=+` "operator" a syntax error
<FromGitter>
<jwoertink> anyone else here using the shard `clear`?
<FromGitter>
<jwoertink> going from version 0.4 to 0.5 throws `BUG: `` at has no type (Exception)` when you have a file that only has `require "clear"`.
<FromGitter>
<jwoertink> Not sure if that's a clear bug or crystal
<FromGitter>
<straight-shoota> @j8r Immutable strings are the only sane thing.
<FromGitter>
<rishavs> Is there a simpler way to write this? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ It works but I dont understand it. Specially, the io.pipe, spawn and channels. Can I not just use the FormData builder and then the http client? [https://gitter.im/crystal-lang/crystal?at=5c3648b31d1c2c3f9ce98ce1]
<FromGitter>
<bew> @rishavs there is some code missing after that i think, `channel` is not used outside the spawned fiber
<FromGitter>
<rishavs> upload an image file to cloudinary api
Raimondi has quit [Ping timeout: 240 seconds]
<FromGitter>
<bew> Ah ok i understand the example, it's the simplest way afaik
<FromGitter>
<rishavs> thanks. guess i have some reading to do then :)
<FromGitter>
<bew> I'm on my phone right now, but if you need help understand the code I may help later (or someone else can!)
<FromGitter>
<bew> @bajro17 what is it supposed to do?
<FromGitter>
<bajro17> Its just simple web router
<FromGitter>
<bajro17> @bew but it throw so much errors I'm so bad in debugging crystal
<FromGitter>
<bararchy> @bajro17 sending a gist with the errors might make it faster for you to get help, not everyone will be patient enough to clone the project and test it locally
<FromGitter>
<bararchy> @straight-shoota so, approved ?
<FromGitter>
<bajro17> @bararchy oh ok I'm so sorry I will do it now
<FromGitter>
<bararchy> so.. ⏎ ⏎ ```undefined method 'resource=' for HTTP::Request ⏎ ⏎ req.resource = req.resource.lstrip($1)``` ⏎ ⏎ Basiclly it means `req` which is an `HTTP::Request` does not have a method which sets a new `resource` [https://gitter.im/crystal-lang/crystal?at=5c365053cc73f46a16defb73]
<FromGitter>
<bararchy> you can `get` it (getter) but you can't `set` it (setter)
<FromGitter>
<bajro17> @bararchy Thank you so much now it all work except parameters
<FromGitter>
<bararchy> I would also use @Blacksmoke16 framework instead, or Kemal etc.. but, again, if you have an issue please try and provide more info, what do you mean by parameters?
<FromGitter>
<Blacksmoke16> auto param conversion ftw, what's not to love? ha
<FromGitter>
<bajro17> @bararchy Thank you so much I make it work with router.cr shard
<FromGitter>
<bajro17> <3
<FromGitter>
<Blacksmoke16> if you're just going to speed that is prob a good choice, id also checkout `amber-router` has some cool features i dont think the others have
<FromGitter>
<Blacksmoke16> with and without the \`\
<FromGitter>
<Sija> you don't need the loop inside `inherited`
<FromGitter>
<Blacksmoke16> how do you figure?
<FromGitter>
<Blacksmoke16> oh
<FromGitter>
<Sija> (it's a pain to write code on the mobile, so no example given)
<FromGitter>
<Blacksmoke16> because its `self`
<FromGitter>
<Blacksmoke16> er `{{@type}}`
<FromGitter>
<Sija> yep
<FromGitter>
<Sija> `Registry << self` should suffice
<FromGitter>
<Blacksmoke16> still would register them all again every time you run the binary, but i think thats the best way to do it
<FromGitter>
<Blacksmoke16> best way would be `class_getter commands : Array(Command.class) = {{Command.subclasses}}` as then you wouldnt *need* to register them, as it would already be set.
<FromGitter>
<Blacksmoke16> but i remember reading that that isnt a bug :/
<FromGitter>
<Sija> doesn't it work inside `finished`?
<FromGitter>
<Blacksmoke16> from within the registry class?