<FromGitter>
<Groogy> on Struct's it will return the proper size of that type, on classes it will return the size of the pointer
<FromGitter>
<Groogy> even though I am giving them the type
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
<FromGitter>
<mattrberry> So I have a ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ But I'm not sure how to grab the properties and getters from the block in order to define an initialize method with them. ... [https://gitter.im/crystal-lang/crystal?at=5e015755c5a23938b46f474b]
<FromGitter>
<Blacksmoke16> `{{yield}}`
<FromGitter>
<Blacksmoke16> instead of `{{block.body}}`
DTZUZU has joined #crystal-lang
<FromGitter>
<mattrberry> Okay, I can do that. Why is that preferred?
<FromGitter>
<Blacksmoke16> should work how you want it more
<FromGitter>
<Blacksmoke16> is essentially the same idea as blocks in normal methods
<FromGitter>
<mattrberry> Yield seems to be producing the same result as block.body, at least in my limited testing of it so far
<FromGitter>
<Blacksmoke16> oh i see what you wan
<FromGitter>
<mattrberry> Regardless, do you know how I might go about getting the property and getter definitions out of the body of the code block so that I can define an initialize method with them?
<FromGitter>
<Blacksmoke16> i think you would have to take a diff approach and do like
<FromGitter>
<Blacksmoke16> `macro dataclass(typename, *properties)` then you can iterate over the properties to do what you want
DTZUZU has quit [Read error: Connection reset by peer]
<FromGitter>
<Groogy> and here's the profiler running as it's supposed to again
<FromGitter>
<Blacksmoke16> fancy
<FromGitter>
<Blacksmoke16> whats with the backtrace?
<FromGitter>
<mattrberry> Yeah I totally could just do that haha. I was just curious about crystal macros, and thought that this would be a fun way to learn some more about macros while also cleaning up my syntax just a little bit :p ⏎ ⏎ Here's a little more detailed spec of what I'm trying to accomplish ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5e015b063e3f133894e803be]
<FromGitter>
<Blacksmoke16> you could do some hacks with like iterating over methods to find setters and use those minus the `=` to build the initialize method maybe/
<FromGitter>
<mattrberry> Really I'm just trying to achieve some of what I like about Python's dataclasses
<FromGitter>
<Blacksmoke16> although i wouldnt suggest it...
<FromGitter>
<mattrberry> Eh but that wouldn't work with just getters :/
<FromGitter>
<Groogy> @Blacksmoke16 the backtrace is where the allocation was done
<FromGitter>
<Blacksmoke16> symfony framework has one where you can do `!php/const CONST_NAME`
<FromGitter>
<Blacksmoke16> but idt you can do that w/o reflection, or having something that stores constant values
DTZUZU has joined #crystal-lang
DTZUZU has quit [Client Quit]
bougyman has quit [Ping timeout: 252 seconds]
bougyman has joined #crystal-lang
<FromGitter>
<randiaz95> guys, is it weird to do exercism while I am coding my app after work? or is that too much?
<FromGitter>
<randiaz95> Im thinking I should stop studying for fun, but its still fun to me :(
<FromGitter>
<Groogy> are you performing an exorcism? or am I missreading that?
<FromGitter>
<Blacksmoke16> :p
<FromGitter>
<Groogy> Anyway I am a bit stuck because Time now reads from a file meaning when I try to do that during allocation it makes everything go boom
<FromGitter>
<Groogy> somehow
<FromGitter>
<Groogy> (or well not somehow, it needs to lock a thread or something which results in the boom)
<FromGitter>
<Groogy> I just want something to measure "how many cpu cycles since allocation?"
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<randiaz95> lol
<FromGitter>
<randiaz95> Exercism
<FromGitter>
<randiaz95> my computer cannot detect if it is not malware...
<FromGitter>
<randiaz95> so I cant even do it..
<FromGitter>
<randiaz95> @Groogy does your computer explode?
<FromGitter>
<randiaz95> how many computers do you buy a week?
<FromGitter>
<Groogy> haha no but my compiler likes to explode :D
<FromGitter>
<Groogy> I sorta abuse it with all the macro stuff
<FromGitter>
<randiaz95> lol
<FromGitter>
<randiaz95> some times I like interpreted Langs
<FromGitter>
<randiaz95> cause fun
<FromGitter>
<firejox> morning /
f1reflyylmao has joined #crystal-lang
<FromGitter>
<randiaz95> What? where are you?
<FromGitter>
<randiaz95> its night here
f1refly has quit [Ping timeout: 268 seconds]
yukai has quit [Ping timeout: 265 seconds]
<FromGitter>
<randiaz95> Hey guys...
<FromGitter>
<randiaz95> Can you guys help me out with improving my implementation of this algorithm for finding sum of multiples?
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter>
<grkek> Hello
<FromGitter>
<grkek> @Blacksmoke16 So I disabled logging in and the rps went up to 21k
<FromGitter>
<grkek> now I am at 51150
<FromGitter>
<grkek> almost at your mark
<FromGitter>
<grkek> 2 instances bring it up to 70k/s
<FromGitter>
<grkek> so yeah that might be the top of it so far
return0__ has joined #crystal-lang
<FromGitter>
<Groogy> Hello o/
return0e has quit [Ping timeout: 268 seconds]
_whitelogger has joined #crystal-lang
<FromGitter>
<j8r> @grkek one strategy is not to flush everyline, perhaps each x second of x lines
return0__ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
alexherbo2 has joined #crystal-lang
Human_G33k has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
HumanGeek has quit [Ping timeout: 240 seconds]
<FromGitter>
<christopherzimmerman> @randiaz95 there's a mathematical solution to that problem that will be much faster than a brute force approach.
<FromGitter>
<christopherzimmerman> You shouldn't need any iteration.
alexherbo2 has quit [Ping timeout: 258 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter>
<randiaz95> @christopherzimmerman Do you think the formula will need iteration any ways since I will need to compute the various multiples?
<FromGitter>
<randiaz95> Or your saying there is a function that results in the sum of multiples of 3 and 5 as output? That sounds like rocket science lol.
<FromGitter>
<christopherzimmerman> You don't need to compute the various multiples, it's a gaussian sum.
<FromGitter>
<randiaz95> Interesting. I <3 gauss
<FromGitter>
<randiaz95> Thats the guy that invented the exponential normal distribution curve right?
<FromGitter>
<christopherzimmerman> I won't spoil the solution since this is (I'm assuming?) the project euler one. But to get the sum of the first `n` multiples of a number, the formula is: ⏎ ⏎ ```k(n*(n+1)/2)``` [https://gitter.im/crystal-lang/crystal?at=5e022a7fcf771f770821e5af]
<FromGitter>
<Daniel-Worrall> sum of n x (from x=1 to x=m) = 1/2 m (m + 1) n
<FromGitter>
<Daniel-Worrall> so not quite what chris put
<FromGitter>
<christopherzimmerman> Are you sure? What I posted above should work fine.
<FromGitter>
<Daniel-Worrall> oh wait, it's the same yeah, I was confused cause I used n to represent a different variable
<FromGitter>
<christopherzimmerman> @randiaz95 just remember that your `n` will need to change based on the value of `k`.
<FromGitter>
<Daniel-Worrall> we have the identity sum 1 to n = n(n+1)/2 and then the distributivity identity to pull out k
<FromGitter>
<randiaz95> That means we still have to iterate though..
<FromGitter>
<randiaz95> just less times.
<FromGitter>
<randiaz95> Guys... Lost in Space Season 2 came out today
<FromGitter>
<randiaz95> Get your popcorn ready!!
<FromGitter>
<Daniel-Worrall> No it doesn't
<FromGitter>
<Daniel-Worrall> You have a max value, you just need to find the highest multiple
<FromGitter>
<Daniel-Worrall> for example. from 1 to 10 is 3,6,9 ⏎ 3+6+9 = 3*(1+2+3)
<FromGitter>
<Daniel-Worrall> So your max value is 10, you need to get 9, then turn it into 3
<FromGitter>
<randiaz95> True, I meant the number of multiples, but we only have 2 in the case of project Euler.
<FromGitter>
<Daniel-Worrall> Trust me, no iteration
<FromGitter>
<randiaz95> I will have faith.
Human_G33k has quit [Quit: Leaving]
dwdv has joined #crystal-lang
<FromGitter>
<grkek> Anyone knows a great ORM ?
<FromGitter>
<grkek> for SQLite
<FromGitter>
<Blacksmoke16> i like granite, are others as well
<FromGitter>
<grkek> Can you give me docs for granite since I have my eyes on it as well
<FromGitter>
<Blacksmoke16> docs for what?
<FromGitter>
<grkek> Model creation
<FromGitter>
<grkek> and interaction with the framework
<FromGitter>
<grkek> orm*
<FromGitter>
<grkek> Oh found it
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<grkek> how did I even miss that
<FromGitter>
<grkek> still, thank you for it
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<Blacksmoke16> afaik is the only one that supports annotations on columns
<FromGitter>
<Blacksmoke16> so can work well with some of the shards i made 😉
<FromGitter>
<grkek> What is the most successful shard you have made so far ?
<FromGitter>
<Blacksmoke16> probably `oq`
<FromGitter>
<Blacksmoke16> ever hear of `jq`?
<FromGitter>
<jwoertink> Anyone know there's a crystal-pg or crystal-db method that would turn `5` in to `"5"` as well as `"yo"` in to `"'yo'"`? I found `PQ::Param.encode` which does the first part, but it doesn't seem to encase strings with single quotes
<FromGitter>
<jwoertink> Other than doing `String === val ? "'#{val}'" : PQ::Param.encode(val)`
Yxhuvud has quit [Quit: No Ping reply in 180 seconds.]
<FromGitter>
<jwoertink> you can do `puts :ok.class` or `puts typeof(:ok)`
<FromGitter>
<grkek> the .class property is so lovely
<FromGitter>
<jwoertink> the `.class` method as well as the `typeof()` will show you the type of something specific. This way you know where to start looking in the documentation
<FromGitter>
<Blacksmoke16> just use strings, only real use for symbols is a type for namedTuple keys and autocasting enums
<FromGitter>
<jwoertink> Ah, yeah, I guess it's just a fallback to not typed
<FromGitter>
<jwoertink> We actually have something in Lucky that sort of handles this already, but I'm running in to an issue with the compiler not knowing the type
<FromGitter>
<jwoertink> but I'm dealing with an array of who knows what, so I can't really cast it to something specific
<FromGitter>
<randiaz95> Hi guys has anyone installed libvoidcsfml-graphics?
<FromGitter>
<randiaz95> I think it stands for libvoid Computer science fuck my life I don't know how to install this graphics library
<FromGitter>
<jwoertink> but it doesn't know which overload to cast to
<FromGitter>
<jwoertink> Maybe I should just roll with my initial gut feeling and use a ternary to catch strings. `PQ::Param.encode` works for all other types it seems
<FromGitter>
<jwoertink> I thought about making the overload, but I'm not sure what else that might mess with
<FromGitter>
<jwoertink> oh.. actually.. Maybe I'm not using this right..
<FromGitter>
<jwoertink> I need all of the values to be a string representation of their actual values. `PQ::Param.encode(arg)` will give me access to a Slice. So I was passing that in to `String.new()`
<FromGitter>
<jwoertink> Is there a way to tell the compiler that a type is what it's class is? `value.as(value.class)` doesn't work, but maybe something similar to this?
return0e has quit [Ping timeout: 260 seconds]
<FromGitter>
<grkek> can I have private classes ?
<FromGitter>
<grkek> like
<FromGitter>
<grkek> private class Example
return0e has joined #crystal-lang
<FromGitter>
<jwoertink> yup
<FromGitter>
<grkek> niceee
<FromGitter>
<grkek> How can one turn this into a class oriented version
<FromGitter>
<jwoertink> I see why it doesn't work, but without getting in to crazy regex, I
<FromGitter>
<grkek> You probably need to split them up via " "
<FromGitter>
<grkek> spaces
<FromGitter>
<grkek> and then do the matching ?
<FromGitter>
<jwoertink> hmm... that may work
<FromGitter>
<grkek> since $ matches the end side
<FromGitter>
<grkek> or you're just using it as a character
<FromGitter>
<grkek> literal
<FromGitter>
<jwoertink> oh, nevermind. I got it!
<FromGitter>
<Blacksmoke16> im assuming in the real example there is other stuff in between the strings?
<FromGitter>
<jwoertink> I never knew what the `g` in `gsub` meant 😅
<FromGitter>
<jwoertink> `str.sub` is what I wanted
<FromGitter>
<jwoertink> but yeah, there's a lot more stuff in the real code
<FromGitter>
<Blacksmoke16> this for pg placeholder values/
<FromGitter>
<jwoertink> yeah
<FromGitter>
<Blacksmoke16> doesnt the driver handle argument substitution like this?
<FromGitter>
<jwoertink> it does when it makes the SQL call. I need a way to generate that SQL but without actually making the call to PG
<FromGitter>
<jwoertink> I didn't see how to do that with the SQL and args being separate objects
<FromGitter>
<Blacksmoke16> might not be a bad method to add to the base db shard?
<FromGitter>
<Blacksmoke16> like `get_sql`
<FromGitter>
<Blacksmoke16> pass it the string and the args and returns the final string
<FromGitter>
<jwoertink> Yeah, that would be awesome
<FromGitter>
<Blacksmoke16> would be helpful for caching queries as could generate sql, see if it exists in a hash, if so return that value, otherwise run, store, and return the result
<FromGitter>
<jwoertink> oooo yeah!
<FromGitter>
<Blacksmoke16> maybe make an issue about it ?
<FromGitter>
<grkek> @Blacksmoke16 what do you think so far ?
<FromGitter>
<Blacksmoke16> seems to be coming along
<FromGitter>
<grkek> the websocket part is an improvement over kemal
<FromGitter>
<grkek> since it only supports dsl websockets
<FromGitter>
<Blacksmoke16> i never really used websockets, dont know much about them
<FromGitter>
<grkek> Does your framework have them ?
<FromGitter>
<grkek> currently where I work we are rewriting the entire stack from python to elixir
<FromGitter>
<grkek> because of web sockets
<FromGitter>
<grkek> rip
<FromGitter>
<grkek> and I have to learn elixir in like 2-3 days
<FromGitter>
<grkek> and I am slacking off doing crystal stuff which is totally fine with me
<FromGitter>
<Blacksmoke16> it doesnt no
<FromGitter>
<grkek> That sure is interesting to hear my friend
<FromGitter>
<grkek> Wish I knew your project a lot more I would help you implement it
<FromGitter>
<grkek> its not really that hard
<FromGitter>
<Blacksmoke16> dont think websockets are common in REST APIs?
<FromGitter>
<grkek> most of them switch to ws for a keep-alive connection
<FromGitter>
<grkek> also I found something interesting about muffled white noise
<FromGitter>
<grkek> helping me with my concentration
<FromGitter>
<grkek> for chatting and whatever
alexherbo2 has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.6]
<FromGitter>
<mattrberry> Say I want ⏎ ⏎ ```class Parent ⏎ include SomeModule ⏎ end ⏎ class Child < Parent ⏎ end``` ⏎ ⏎ Is there a way for the module to know that it has been effectively included in the Child class? [https://gitter.im/crystal-lang/crystal?at=5e027ed1c62fdf33f74a1387]
<FromGitter>
<mattrberry> 1) plus an extra newline that isn't rendering in markdown
<FromGitter>
<Blacksmoke16> isnt that what you want?
<FromGitter>
<Blacksmoke16> module was included in parent and child inherits from that
<FromGitter>
<grkek> Made me think about it @Blacksmoke16 :D
<FromGitter>
<grkek> it seems like working ?
<FromGitter>
<mattrberry> Really, my goal is to do something with @Groogy's crystal-clear (https://github.com/Groogy/crystal-clear). I'd like the parent to `include CrystalClear`, then have the child define invariants. In its current state, though, only the class including crystal-clear directly is able to actually use the invariant macro
<FromGitter>
<Blacksmoke16> where you the one on reddit?
<FromGitter>
<Blacksmoke16> asking about obj validation?
<FromGitter>
<mattrberry> Haha yeah I was
<FromGitter>
<Blacksmoke16> i figured :p
<FromGitter>
<Blacksmoke16> so why isnt your example working?
<FromGitter>
<Blacksmoke16> dont all you have to do is replace the `p "nested inherited" with `include CrystalClear`?