<gcds_>
now I am trying to port that 1.5gb folder to Crystal
<FromGitter>
<watzon> From what I gather, and I'm new to the concept myself, `self.included` is a hook that allows you to perform some action when a module is included in a class
<FromGitter>
<bew> Cool, I only have a arduino uno and RPi2.. very basic kit
<gcds_>
get some STM32 nucleo boards
<gcds_>
they are under 20$
<FromGitter>
<bew> I was about to say "if you need I'd love to help" but I have no idea how ^^
<gcds_>
me too... :D
<gcds_>
I am learning about Crystal and whole stm32 thing
<gcds_>
i am freaking idiot... I am writing small parser for constants and trying to make padding but it does not work... after 10 mins I see my replace \s{2,}...
<FromGitter>
<watzon> Groogy: For mass assignment and I think that Rails uses it with schemas to add properties to a model
<Papierkorb_>
watzon, I'd think about a macro implementing a mapping pattern for this
<FromGitter>
<watzon> So basically how Crecto does it?
<Papierkorb_>
Would also allow you to say what code is to be used for validation etc.
<Papierkorb_>
no idea about crecto beyond it existing
Ven has joined #crystal-lang
<FromGitter>
<watzon> Ahh lol. Pretty sure it uses some kind of `schema` method or macro that allows you to define a schema in the model
Ven is now known as Guest33365
<Papierkorb_>
You really really really don't want to mirror rubys model API
<Papierkorb_>
It simply doesn't translate
<Papierkorb_>
That AR is simply inferior to other solutions doesn't help
<FromGitter>
<watzon> Personally I just kind of like the idea of having migrations that generate a schema that models look to for properties. I can see the obvious downsides to such an approach, but it really does make defining models super simple
<FromGitter>
<watzon> Although maybe a reverse approach would be possible in Crystal?
<Papierkorb_>
It's just not possible without ugly method_missing stuff
<Papierkorb_>
What's not there can't be inspected
<Papierkorb_>
That's already an insane issue with Ruby
<Papierkorb_>
With some trickery, I mean, you could do that. But not type-safe at all, so that alone already breaks any nice usage
<FromGitter>
<watzon> What about defining everything in the model and then having a tool, like Rails' migration tool, that reads the models and generates a schema based on them rather than the other way around. Then it could check against the previous schema and past migrations and generate migrations for any changes.
<FromGitter>
<watzon> I'm just trying to think of a better way to handle models and migrations than currently exists in Crystal
rohitpaulk has quit [Ping timeout: 240 seconds]
<Papierkorb_>
Full automatism isn't possible. That way doesn't allow you to define conversions
<FromGitter>
<watzon> Conversions?
<Papierkorb_>
how would you detect this? `ALTER TABLE RENAME COLUMN foo;`
<Papierkorb_>
or a `ALTER TABLE x SET TYPE y TO z USING (...)`
<FromGitter>
<watzon> Hmm that's a good point
<FromGitter>
<watzon> Didn't think about that
<Papierkorb_>
I'm not entirely sure that you want to wrap every single SQL function in existence either, finding the right one sometimes really sucked when using Rails
<Papierkorb_>
A small frame around upgrade/downgrade functions should already be everything you need
<Papierkorb_>
and those funcs could have helpers for the *most common* operations only (like, add_column). And beyond that, some #execute(sql). If having those helpers at all
gcds has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gcds has joined #crystal-lang
rohitpaulk has joined #crystal-lang
gcds has quit [Client Quit]
<FromGitter>
<yxhuvud> upgrade/downgrade and versions table to know which migrations to run.
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
gcds has joined #crystal-lang
mbarbar has joined #crystal-lang
Guest33365 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest30134
Guest30134 has quit [Client Quit]
qard has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 246 seconds]
Hates_ has joined #crystal-lang
<FromGitter>
<sdogruyol> just learnt that Kotlin team has 40 full time employees
<FromGitter>
<sdogruyol> can't imagine what we'd achieve with that much humanpower :O
<FromGitter>
<bew> Oh man that would be awesome :D
<FromGitter>
<sdogruyol> indeed!
alex`` has quit [Ping timeout: 246 seconds]
alex`` has joined #crystal-lang
Ven has joined #crystal-lang
Ven is now known as Guest43736
Guest43736 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Papierkorb_>
full of banter, trivia and "awzum!". can't get much better than that
<Groogy>
What's Kotlin?
<Papierkorb_>
a JVM language by the IntelliJ guys
<Hates_>
Is the Crystal Weekly newsletter dead?
<FromGitter>
<sdogruyol> @Hates_ no, it's just irregular
<Hates_>
Ahh ok :) thanks!
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #5238: Fix to keep double quote of symbol in syntax higlight for `crystal docs` (master...fix/crystal-doc/syntax-highlight-symbol-keep-quote) https://git.io/vFnVr
<FromGitter>
<drujensen> @watzon Amethyst Model -> Kemalyst Model -> Amber Model attempted that but had little success at it. I was querying the meta-data and doing diffs to perform the migrations. It was additive so non-destructive. However, it was difficult to know what data to copy if someone wanted to rename a column. There were manual steps to make it work and I realized it wasn’t possible to predict the users intent when
<FromGitter>
... they updated the model.
<FromGitter>
<drujensen> we ripped all that logic out and went to using `micrate` which is a rails like migration tool
rohitpaulk has quit [Ping timeout: 240 seconds]
d1rewolf has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter>
<faustinoaq> `micrate` is good 👍
d1rewolf has joined #crystal-lang
<ducklobster>
Is there a way to determine the name of the method from the {{ @type }} macro?
<Groogy>
I kind of did in a rundabout way using method_added but might not work in your circumstance
<FromGitter>
<bew> No ducklobster
<FromGitter>
<bew> @type is used to get information about the type you're in
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
Ven is now known as Guest66351
<crystal-gh>
[crystal] RX14 closed pull request #5209: Give error if using instance_sizeof on a generic type without type vars (master...instance_sizeof) https://git.io/vFLqd
claudiuinberlin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has quit [Ping timeout: 240 seconds]
claudiuinberlin has joined #crystal-lang
ducklobster has quit [Ping timeout: 260 seconds]
<FromGitter>
<unreadable> > just learnt that Kotlin team has 40 full time employees
<FromGitter>
<unreadable> Well
<FromGitter>
<unreadable> They have a bunch of IDE licenses for sale starting from 300 euros
<FromGitter>
<unreadable> hence the possibility to pay the entire team
<vivus>
anything to not write Java
Guest66351 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter>
<fridgerator> haha
<FromGitter>
<bew> Let's write a Java IDE in Crystal and sell it to pay a team to work on crystal x)
<FromGitter>
<unreadable> there was a guy proposing to the crystal team to write a project that could generate some budget to improve the them
<FromGitter>
<unreadable> or something like this
<FromGitter>
<unreadable> reddit stuffs
<d1rewolf>
does crystal have any corporate sponsorship? you'd think the sizeable amount of frustrated rubyists out there would lure sponsors...
<Papierkorb_>
The thing with OSS is that most think that someone else can pay
<d1rewolf>
Papierkorb_: true. although we try to sponsor projects when we can. I've donated a number of large servers to debian over the years
<FromGitter>
<unreadable> I always wondered how Crystal would look after being touched by google
<FromGitter>
<unreadable> they did a pretty good job on Go
<FromGitter>
<faustinoaq> Well, Crystal was born and raised at https://manas.tech/
<Papierkorb_>
d1rewolf: I mean, friggin OpenSSL had *severe* issues not a long time ago to keep afloat
<Papierkorb_>
d1rewolf: If OpenSSL, whose technology the internet literally runs on, can't get funded, who will?
sz0 has joined #crystal-lang
Papierkorb_ has quit [Quit: Konversation terminated!]
<vivus>
OpenSSL is hidden software. its like libc or other obscure software. projects like that client-side JS framework (can't recall name) have a decent patreon running (something like 8K a month)
rohitpaulk has joined #crystal-lang
faustinoaq_ has joined #crystal-lang
<FromGitter>
<unreadable> The syscall is handled in crystal via libc, right?
<faustinoaq_>
Hi community, I'm on IRC too :)
qard has joined #crystal-lang
<d1rewolf>
is there a roadmap to 1.0 somewhere?
Ven has joined #crystal-lang
Ven is now known as Guest27335
<vivus>
welcome faustinoaq_
mark_66 has quit [Remote host closed the connection]
<faustinoaq_>
Any recommended desktop client for IRC?
d1rewolf has quit [Ping timeout: 248 seconds]
<vivus>
hexchat
<robacarp>
what platform? I know several people use textual on mac. I'm a weechat man myself
d1rewolf has joined #crystal-lang
<vivus>
or weechat
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 264 seconds]
greengriminal has joined #crystal-lang
<d1rewolf>
if I launch a subprocess in `` in a spawn'd fiber, is there a simple way to kill it?
<FromGitter>
<Shalmezad> If you had the pid, probably.
<d1rewolf>
Shalemezad: so echo the PID back to the spawning process? that might be doable. let me try that
<d1rewolf>
what is `` an alias for?
<FromGitter>
<Shalmezad> Give me a sec, had it up when I was digging through to see what was causing the issue.
<FromGitter>
<maxpert> But how would I get Pointer of socket object here?
<FromGitter>
<maxpert> free requires a Pointer(void)
<FromGitter>
<maxpert> how to get Pointer out of managed object
<FromGitter>
<asterite> I think there's nothing you can do about it
<FromGitter>
<maxpert> I guess the follow up would be is it just the memory that's not GCed or is it the whole socket object with the file descriptors and everything
<RX14>
the GC obviously garbage collects memory but any memory it frees just gets returned to the GC pool
<RX14>
it doesn't get returned to the OS
<RX14>
it's also nothing to do with conservative GC
<RX14>
you can compile boehm GC with an option to do this
<RX14>
but aparrently its buggy and untested
hightower4 has joined #crystal-lang
<RX14>
the GC is designed for a fairly constant memory load
<FromGitter>
<unreadable> Fautinoq, why does it has to deal with the GC?
<FromGitter>
<asterite> A conservative GC just scans the stack and heap and anything that looks like a pointer is not freed. A precise GC is one that frees memory that is known to be related to an allocated object. So a conservative GC is kind of worse. Crystal could have a precise GC but it's too much work
<FromGitter>
<unreadable> How does Go handle it?
<FromGitter>
<unreadable> I know it's GC collected too, but does it follow the same pattern?
<FromGitter>
<asterite> Go is probably precise
hightower3 has quit [Ping timeout: 240 seconds]
<FromGitter>
<maxpert> @unreadable Go's GC is more agressive from my experience I was able to handle 10K+ connections on 512MB instance
<FromGitter>
<maxpert> no problem
<FromGitter>
<maxpert> that's something I will deal with later
<FromGitter>
<maxpert> but is there a way to explicitly mark something free?
<FromGitter>
<maxpert> I guess not
<FromGitter>
<asterite> nope
<RX14>
i'd peg go's memory efficiency at it useing split stacks and a custom stack allocation
<RX14>
instead of just mmapping and making the OS do the right thing
<RX14>
10000 fibers is 83GiB of virtual memory
<RX14>
@maxpert it'd be very unsafe to do so
<FromGitter>
<unreadable> well, if you managed to handle it better with go, why did you switch to crystal?
<FromGitter>
<unreadable> oO
<FromGitter>
<maxpert> @unreadable trying it out and I love ruby syntax
<FromGitter>
<unreadable> Was thinking about this
<FromGitter>
<unreadable> and I fully agree
<FromGitter>
<maxpert> @RX14 what's cost per Fiber?
<FromGitter>
<unreadable> 4 or 8kb, depending by the os
<FromGitter>
<maxpert> Has anyone tried this in NodeJS?
<RX14>
about 2 pages
gcds has quit [Ping timeout: 240 seconds]
<RX14>
we allocate 8MiB of virtual stack space and 1 page gets allocated immediately
<FromGitter>
<unreadable> Well, I've been working with socket.io and sockjs in Node, but never been so curious
<RX14>
and I typically see 4kIb of kernel memory usage per fiber too
<RX14>
just for bookkeeping thost mmaps
<FromGitter>
<unreadable> @maxpert I like your programming background
<RX14>
when i benchmarked loop { spawn { sleep } }
<FromGitter>
<unreadable> in terms of languages
<RX14>
i saw about 50/50 OS/userspace memory
<FromGitter>
<maxpert> @unreadable ya I have explored a lot of landscape due to research nature of my job :)
<FromGitter>
<maxpert> @RX14 ok so I still have to read on Bohem GC but there must be a way in GC to say return memory why don't we expose that as part of API
<FromGitter>
<unreadable> What are you working at your current job if I may ask u
<FromGitter>
<unreadable> 😄
stephenwithav has quit [Ping timeout: 240 seconds]
<RX14>
@maxpert there's no such way to do it
<RX14>
there's simply no way to return the memory back to the OS
<RX14>
there's a ./configure flag but it's experiemental, beta, etc
<FromGitter>
<maxpert> @unreadable well this is something I am exploring due to a hobby project; otherwise I am working at Microsoft Research
<FromGitter>
<maxpert> @RX14 got it just looking at it
<RX14>
in practice its a small problem
<FromGitter>
<sdogruyol> @maxpert I've had some time benchmarking websockets against node and Crystal was doing better however this was like 1-2 years ago
<RX14>
for server applications its best to keep your peak memory usage in mind
<RX14>
we're not using *mkore* memory because of this
<RX14>
we're just using it forever
<FromGitter>
<maxpert> @RX14 agreed; what took me by surprise was if there is a leak :P
<RX14>
well if there's a leak then it'll never get freed to the GC
<RX14>
let alone to the OS
<FromGitter>
<maxpert> And GC.collect is blocking right?
<RX14>
yeah
<RX14>
just as much as GC.malloc when we need to run the GC
<FromGitter>
<maxpert> Ok so I did a crazy experiment of running `GC.collect` like 1000 times from an API
<FromGitter>
<maxpert> just to make sure I force collect everything
<FromGitter>
<maxpert> guess what is difference
stephenwithav has joined #crystal-lang
stephenwithav has joined #crystal-lang
stephenwithav has quit [Changing host]
<FromGitter>
<sdogruyol> lol
<RX14>
none?
<FromGitter>
<maxpert> :P
<RX14>
GC.stat will show you the GC has a big heap
<FromGitter>
<maxpert> @RX14 you understand GC really well
<FromGitter>
<maxpert> :D
<RX14>
but nothing will change as far as the OS can see
<RX14>
yeah I try to understand crystal well lol
<RX14>
i've seen a lot of things in this channel
<FromGitter>
<maxpert> @RX14 I am wrapping my head around it yet :P
greengriminal has joined #crystal-lang
<FromGitter>
<maxpert> but I think the amortized memory for 5K connections should remain same
<FromGitter>
<maxpert> i.e. it should never go beyond ~300MB figure
claudiuinberlin has joined #crystal-lang
<RX14>
if you hold 5k connections it should be a constant memory
<RX14>
when you stop holding those 5k a bunch of fibers will exit
<RX14>
and the memory associated with the fiber stacks will slowly reach 0
Kug3lis_off is now known as gcds_
<RX14>
but the memory associated by memory those fibers allocated on the heap will stay
<RX14>
if you hold another 5k
<RX14>
the memory usage should be the same
<RX14>
the peak memory should be the same it just wont return to nearly the startup memory before any connections came
<FromGitter>
<maxpert> @RX14 the top peak remains same
<FromGitter>
<crisward> @asterite it can if you compile it with a flag - that's how we've been using it since January. Works well.
<FromGitter>
<maxpert> @crisward what are you using it for?
<FromGitter>
<crisward> return memory to the os, that is.
<RX14>
cool
<vivus>
is anybody from Amber channel around?
<FromGitter>
<maxpert> I mean what kind of use case?
<FromGitter>
<aarongodin> The issue there is that I can’t cast to a union type, which is what JSON::Type is
<FromGitter>
<maxpert> did same benchmark on Node.js :P < 100MB of memory
<FromGitter>
<aarongodin> Maybe there is another way to get the same result, since I think what I’m doing also doesn’t make sense
<FromGitter>
<luislavena> @unreadable the problem is that `{"test" => "test"}` is a `Hash(String, String)`
<FromGitter>
<luislavena> If you want that be a `JSON::Type`, first top-level method works because Hash(String, String) conforms the signature for JSON::Type
<FromGitter>
<luislavena> however, passing that to an instance variable, doesn't which is why the compiler fails.
<faustinoaq>
> did same benchmark on Node.js :P < 100MB of memory
<faustinoaq>
@maxpert What benchmark?
ducklobster has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<FromGitter>
<unreadable> Well done Node
<FromGitter>
<unreadable> Did you use any framework or the http standard module?
d1rewolf has quit [Ping timeout: 248 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
alex`` has quit [Ping timeout: 252 seconds]
greengriminal has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
d1rewolf has joined #crystal-lang
greengriminal has joined #crystal-lang
faustinoaq has quit [Quit: Konversation terminated!]
faustinoaq has joined #crystal-lang
greengriminal has quit [Quit: Leaving]
eliasjpr has quit [Ping timeout: 258 seconds]
<crystal-gh>
[crystal] asterite opened pull request #5241: Syntax: fix incorrect handling of "%w(" (master...bug/5239-untermined-string-array-literal) https://git.io/vFcgF
Guest72603 is now known as waveprop
waveprop has quit [Changing host]
waveprop has joined #crystal-lang
eliasjpr has joined #crystal-lang
sz0 has joined #crystal-lang
eliasjpr has quit [Ping timeout: 252 seconds]
eliasjpr has joined #crystal-lang
eliasjpr has quit [Ping timeout: 255 seconds]
eliasjpr has joined #crystal-lang
eliasjpr has quit [Ping timeout: 255 seconds]
eliasjpr has joined #crystal-lang
eliasjpr has quit [Ping timeout: 264 seconds]
Kug3lis_off has quit [Read error: Connection reset by peer]
<vivus>
anybody lurking?
<FromGitter>
<crisward> I'm ere... Need to add errors to my mailer lib. Not sure if to have a callbacks or raise exceptions. Raising feels a bit severe, but has the benefit of being 'rescued' further up the call stack. Thoughts anyone?
<FromGitter>
<straight-shoota> me to
<FromGitter>
<straight-shoota> o
<FromGitter>
<straight-shoota> what kind of errors?
<FromGitter>
<crisward> the mailer lib talks to mailgun, sendgrid and eventually smtp. If the email can't be sent, because it's malformed, or the upstream service is unavailable, I want to let the sender know.
<FromGitter>
<crisward> Crystal db has `query`, which raises and `query?` which returns null if it doesn't find anything. Thinking something like that may be nice. So send, and send?.
<robacarp>
add send! which just raises no matter what
<vivus>
this is my question from yesterday concerning amber. I am trying to get my before_action to run, but I cannot figure out which keyword to use for doing this before authentication
<vivus>
is there a place I can look for the code relating to authentication?
<FromGitter>
<elorest> Yeah. `amber g auth User`
<FromGitter>
<elorest> Then just look at the code it generates.
<FromGitter>
<straight-shoota> @crisward sounds good
<vivus>
@elorest in the controllers/ or handlers/?
<FromGitter>
<crisward> @straight-shoota thanks, good to have a second opinion - https://github.com/arcage/crystal-email uses a callback, which feels more js than crystal. Trying to wrap all this stuff in a common api so provider swapping is straight forward.
<FromGitter>
<elorest> I believe that it uses a handler.
<FromGitter>
<straight-shoota> yes, such a callback does not feel like crystal
<FromGitter>
<marksiemers> @straight-shoota - Following up to your stack overflow answer (the one with `@@config` and toml) - I didn't think to take your approach (which is a good approach) because older versions of the crystal compiler wouldn't allow the `if something.nil?` check (like here: https://play.crystal-lang.org/#/r/3100) ⏎ Do you know when that change was introduced?
<vivus>
I know that @marksiemers likely knows the answer, as I am transpiling rails to amber XD
<RX14>
and i duped an email to the mailinglist again...
<RX14>
i do it too often
<FromGitter>
<marksiemers> Ah, looks like 0.15.0 crystal introduced the `.nil?` change
<FromGitter>
<marksiemers> vivus - answer to what? How to deal with before filters with authentication in amber? ⏎ Not off the top of my head, is it possible to see your repo?
<vivus>
@marksiemers all my code is the generated code from a few days ago. I am now hacking at it by working backwards. I can provide the steps to reproduce the setup @marksiemers ?
<FromGitter>
<marksiemers> Drop it in the amber channel
<FromGitter>
<elorest> @crisward The docs are coming along nice but the CLI is probably the easiest way to become knowledgable. IMO. But that’s how I learned rails too.
<vivus>
I think I found it. the keyword is `context` ? but it still doesn't show the items
<FromGitter>
<marksiemers> vivus - what is happening now vs what you want to happen? ⏎ Is it that a post show page - you have to be logged in, and you want that public?
<FromGitter>
<marksiemers> vivus - this is one place that amber will diverge a bit from rails. It uses pipelines. ⏎ For your fix look in `src/handlers/authenticate.cr`
<vivus>
@marksiemers that's where I found context :P
<FromGitter>
<marksiemers> In the `else` if you put `return call_next(context)` without the `if` statement then it will open up your whole site to the public
<FromGitter>
<marksiemers> Being able to skip that pipe for certain controller actions, I'm not sure if there is a way to do that yet. If not, it should be a feature request.
<vivus>
@marksiemers I think you are right. I need to hack through the authenticate.cr
<FromGitter>
<marksiemers> Right now, you just need to come up with a list of public paths and allow those in the pipe, or a list of restricted paths and don't allow those in the pipe
eliasjpr has joined #crystal-lang
<vivus>
is it correct to assume that all the paths are restricted?
<FromGitter>
<marksiemers> Except the ones in that array: `["/signin","/session","/signup","/registration"]`
eliasjpr has quit [Ping timeout: 240 seconds]
<FromGitter>
<marksiemers> Basically, if `return call_next(context)` is executed, it will render the controller action and page as normal
<FromGitter>
<marksiemers> If not, then the redirect happens due to the lines of code that follow