<FromGitter>
<DanilaFe> I'm happy with 200 millis though
<FromGitter>
<Blacksmoke16> had to cast the `action.action.as(Proc(XX))`
<FromGitter>
<Blacksmoke16> @jwoertink but yea, im not sure yet. Mostly started as a project to see if i could figure out a good way to do param conversion from url path to action method
<FromGitter>
<Blacksmoke16> im envisioning you could add some annotation or something to an action method to, for example, `/users/1/`
<FromGitter>
<Blacksmoke16> where that would do a query like `User.find 1` or return json error that `A user with that id could not be found`
<FromGitter>
<proyb6> @vladfaust I thought the Agoo have a C version that is written just recently
jokke has quit [Ping timeout: 272 seconds]
asterite has quit [Ping timeout: 252 seconds]
jhass has quit [Ping timeout: 250 seconds]
DeBot has quit [Ping timeout: 252 seconds]
jhass has joined #crystal-lang
jokke has joined #crystal-lang
asterite has joined #crystal-lang
<Yxhuvud>
danilafe: 80ms.
<Yxhuvud>
though that is for both parts
Raimondi has quit [Ping timeout: 240 seconds]
<Yxhuvud>
but I basically based mine on the same algorithm.
<FromGitter>
<DanilaFe> the one from wiki?
<Yxhuvud>
Yes. Best using some other algorithm was some 20s.
<FromGitter>
<DanilaFe> I used my own for the 200ms
<FromGitter>
<DanilaFe> that's also both parts
<FromGitter>
<DanilaFe> I only saw the wiki page the next day
<FromGitter>
<DanilaFe> admittedly it's smarter than what I came up with
<Yxhuvud>
Nice. What was the basic idea behind yours?
<FromGitter>
<DanilaFe> tell you after this AoC :)
<FromGitter>
<DanilaFe> it's in 10 sec
shmibs has quit [Quit: leaving =o]
shmibs has joined #crystal-lang
junland has quit [Quit: Disconnected.]
fifr has quit [Ping timeout: 250 seconds]
junland has joined #crystal-lang
<FromGitter>
<DanilaFe> it's another "run your problem on a larger input"
fifr has joined #crystal-lang
lunarkitty7 has quit [Ping timeout: 260 seconds]
<Yxhuvud>
yes, but with a twist.
moei has quit [Quit: Leaving...]
<FromGitter>
<DanilaFe> it stabilizes at the end, yeah
<FromGitter>
<DanilaFe> even then, I can't fight the right number
<FromGitter>
<DanilaFe> off by one. finally done
<FromGitter>
<DanilaFe> I didn't like this one
<Yxhuvud>
I did :P
<FromGitter>
<anamba> > off by one. finally done ⏎ i get the feeling i also have an off by one error somewhere but i can't find it.
<FromGitter>
<anamba> a regex in my program also crashes `crystal tool format` which is interesting
<FromGitter>
<DanilaFe> I think there's a massive difference in increasing computation difficulty with "MORE ITERATIONS" vs what yesterday's problem did, which is increasing the domain
<FromGitter>
<DanilaFe> but that's just personal preference, I suppose
<FromGitter>
<DanilaFe> @anamba, what's the regex?
<FromGitter>
<anamba> @DanilaFe `/^(\.+)(.*?)\.*$/` but oddly i have two copies of this (i often make a copy of part1 before moving on) and the part 1 file does not crash the formatter
<FromGitter>
<DanilaFe> that is strange.
<FromGitter>
<DanilaFe> it doesn't seem all that weird
<FromGitter>
<anamba> aha... it wasn't that at all. i did something weird :)
<FromGitter>
<anamba> for some reason i put a suffix if on an if / end block 😆
<FromGitter>
<anamba> unfortunately fixing that does not change the result of my program...
<Yxhuvud>
well, the MORE ITERATIONS was big enough to not be comptable at all, as opposed to yesterday which was just ugly slow when expanded.
<Yxhuvud>
Not as bad as day9 though, were I was like, ok, I added more iterations. It still doesn't take a second..
<FromGitter>
<DanilaFe> yeah, day 9 threw me off
<FromGitter>
<DanilaFe> I expected there to be a more sophisticated algorithm, and spent quite a while on that
<FromGitter>
<DanilaFe> isntead of just stupidly optimizing my code for insertions / deletions
<FromGitter>
<DanilaFe> I think MORE ITERATIONS is only good if the new iteration limit is impossible, and you have to redefine the algorithm
<FromGitter>
<DanilaFe> The only issue was that it wasn't a new algorithm we had to derive, but we had to physically look at the output
<Yxhuvud>
I didn't look at the output, I looked at how the count changed over time.
<FromGitter>
<DanilaFe> yeah, that's how I found it too. I still think that's part of "output". Yesterday was a strange one, too. It was a lot slower in part 2, but not slow enough to warrant a new solution
<Yxhuvud>
(and looking at the output is totally something aoc can force us to do, just see day10)
<FromGitter>
<DanilaFe> I didn't like day 10 for the same reason :)
<FromGitter>
<DanilaFe> my favorite AoC problem so far was 2017-23
<FromGitter>
<DanilaFe> part 2 specifically
<Yxhuvud>
well, day10 doesn't really force you to do anything but read the printed characters off the screen, if done properly. My solution is precise enough to show a single timeslot.
<FromGitter>
<DanilaFe> did you do the adjacency check for all points?
<FromGitter>
<DanilaFe> the brute force?
<FromGitter>
<DanilaFe> or was that Aaron?
<Yxhuvud>
No, I just checked if all was within the required range y-wise.
<FromGitter>
<DanilaFe> ah, the line height
<FromGitter>
<DanilaFe> did you use something to skip the iterations?
<FromGitter>
<DanilaFe> or did you iterate one by one?
<Yxhuvud>
There was no need to skip any iterations. I did shortcut the line height calc by checking only the first two points first.
<FromGitter>
<DanilaFe> I don't think there was a need. I try to find somewhat elegant solutions, and mine figured out about how many simulations to do and just did it in one step
<FromGitter>
<DanilaFe> the precision suffered from that approach quite a bit
<Yxhuvud>
still takes 10ms. :shrug:
<FromGitter>
<DanilaFe> just curious, how do you measure these numbers? just using time?
<Yxhuvud>
yeah
<Yxhuvud>
it is not super exact, but it doesn't need to be
<FromGitter>
<DanilaFe> I know crystal has the {} of array-like initialization
<FromGitter>
<dscottboggs_gitlab> hooray
<FromGitter>
<DanilaFe> So maybe something like UserHash { error => true }
<FromGitter>
<dscottboggs_gitlab> lemme try that
<FromGitter>
<dscottboggs_gitlab> oh shit I can' tbelieve that worked
<FromGitter>
<DanilaFe> :)
<FromGitter>
<DanilaFe> This does seem a little strange to me, though. Perhaps using a hash here isn't a good idea? Kind of feels like primitive obsession
<FromGitter>
<dscottboggs_gitlab> Actually it's appropriate in this case, as I'm formulating a JSON response
<FromGitter>
<dscottboggs_gitlab> Trying to add JWT auth to a Kemal API
<FromGitter>
<DanilaFe> I've been using JSON.mapping with custom classes for all my JSON APIs
<FromGitter>
<DanilaFe> though I admit it's fairly tedious
<FromGitter>
<anamba> could not get AoC system to accept my solution. i even tried guessing with +1/-1 generations. oh well
<FromGitter>
<DanilaFe> ooh, darn
<FromGitter>
<DanilaFe> mind if I see your solution?
<FromGitter>
<dscottboggs_gitlab> Same, but that would require rewriting the shard to make use of generics somehow
<FromGitter>
<DanilaFe> @dscottboggs_gitlab alright, I agree that's not worth it :)
<FromGitter>
<DanilaFe> Unrelated: what do you people use for your front-ends? Assuming crystal is the backend. I've been using Elm recently, and I know it's a very unorthodox combination
<FromGitter>
<dscottboggs_gitlab> Experimenting with it a bit. Probably my favorite that I've come across is Vue.js. I have a project in React too, it's not bad but kinda bloated. ⏎ Also have another project that just uses ECR templates and that's kinda nice.
<FromGitter>
<dscottboggs_gitlab> elm looks nice on it's face
<FromGitter>
<DanilaFe> I use ECR for pretty much all projects. Even non-web, my parser generator uses ECR :D
<FromGitter>
<DanilaFe> @anamba, that looks....totally fine.
<FromGitter>
<anamba> @DanilaFe right??
<FromGitter>
<DanilaFe> wait!!
<FromGitter>
<DanilaFe> I know what it is.
<FromGitter>
<anamba> i haven't changed it in the past hour... just been... staring at it
<FromGitter>
<DanilaFe> or what it could be
<FromGitter>
<DanilaFe> do you use bigint?
<FromGitter>
<DanilaFe> because if you don't...50 billion * other numbers will overflow
<FromGitter>
<anamba> do i have to specify that manually
<FromGitter>
<DanilaFe> why are you defining by gen - last_gen
<FromGitter>
<DanilaFe> won't that always be 1?
<FromGitter>
<anamba> no, since i only check every 100 (`gen % 100 == 0`)
<FromGitter>
<DanilaFe> ah, then it will always be 100
<FromGitter>
<anamba> well yes. i experimented with different values, and even removed that entirely for a while. but the result is always the same.
<FromGitter>
<DanilaFe> I assume you've tried adding and removing 1 from gen?
<FromGitter>
<DanilaFe> this seems completely right to me at first glance
<FromGitter>
<anamba> yeah i tried guessing +1/-1 since i didn't have any other ideas :-\
<FromGitter>
<DanilaFe> well
<FromGitter>
<DanilaFe> after 1 iteration your gen is 0
<FromGitter>
<DanilaFe> so I am tempted to say gen needs to be + 1
<FromGitter>
<anamba> if you mean the output `gen: 0 -> 100` that's just what i initialized last_gen to. (originally that was accurate but then i changed to `(1..2000).each` instead of `2000.times`)
<FromGitter>
<DanilaFe> no, I mean in your loop
<FromGitter>
<DanilaFe> you run one iteration, but the i variable inside the loop is 0-indexed, so it stays at 0
<FromGitter>
<DanilaFe> oh wait
<FromGitter>
<DanilaFe> nevermind, I read that as (0..2000)
pbodev1 has quit [Read error: Connection reset by peer]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
<FromGitter>
<girng> hi @dscottboggs_gitlab
<FromGitter>
<dscottboggs_gitlab> what's up? o/
<FromGitter>
<girng> not much just saying hi, saw you were when i scrolled up \o
pbodev1 has joined #crystal-lang
pbodev1 has quit [Excess Flood]
<FromGitter>
<mach_potpurri_twitter> hey all, back again with another late night question. How would you parse through an HTML and seperate the <h2> tag from the rest of the tags in Crystal?
Renich has quit [Quit: Renich]
Renich has joined #crystal-lang
Renich has quit [Remote host closed the connection]
Renich has joined #crystal-lang
Renich has quit [Quit: Renich]
<FromGitter>
<bew> @mach_potpurri_twitter could use the XML parser, then use xpath to find all `h2` tags
<FromGitter>
<bew> @dscottboggs_gitlab why use a macro here btw?
<FromGitter>
<dscottboggs_gitlab> that's exactly what I did was just dropped the macro and put the literal text in. it wasn't there for any reason except neatness
<FromGitter>
<bew> weird, changing `macro` to `def` works..
<FromGitter>
<dscottboggs_gitlab> yeah, but the macro references local variables that wouldn't be present in a def, and it really didn't serve any purpose that a comment couldn't do just as well. but yeah that seems like valid syntax to me
<FromGitter>
<bew> hmm dunno
<FromGitter>
<girng> i think it should just be re-written in haskell or rust
<FromGitter>
<dscottboggs_gitlab> what should be?
<FromGitter>
<girng> nvm hahah
<FromGitter>
<mach_potpurri_twitter> @bew would that also allow me to exclude the tag?
<FromGitter>
<mach_potpurri_twitter> I have markdown pages converted to HTML, and i want everything but the h2 tags rendered to the page, do i use the XML parser to exclude the tag?
<FromGitter>
<dscottboggs_gitlab> sounds like a good way to me
powerbit has joined #crystal-lang
ashirase has quit [Ping timeout: 272 seconds]
ashirase has joined #crystal-lang
moei has joined #crystal-lang
DTZUZO has joined #crystal-lang
ua has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
<FromGitter>
<proyb6> Shall we all move our chats on Crystal newest forum?
<FromGitter>
<j8r> ? A forum isn't real-time like chats
<FromGitter>
<bararchy> exactly
<FromGitter>
<bararchy> it's so that you won't need to ask in the google group or search support in Reddit
<FromGitter>
<proyb6> Chat in real-time like Gitter is nice but I think it won't be helpful for long-term solutions where we often search someone's past conversations that could be useful for startups or other coders. Just as I like to see what was happening in the past.
<FromGitter>
<girng> i just like to "hang out" on gitter. and use forum/github or whatever for more "formal" communication. that's how i view it anyway i'm sure everyone is different
<FromGitter>
<girng> but since we have a nice forum, if ig et stuck on a hard problem i'll prob post it there
<FromGitter>
<proyb6> Or advent of code could be in forum because it's useful for future learners and how you guys tackle on the problems
Raimondi has joined #crystal-lang
nathanj has quit [Ping timeout: 252 seconds]
nathanj has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<z64>
yep. the forum is best for persistant, longer form content and discussion. An AOC discussion thread would be neat - there is even a "blur spoiler" under the post composer you can use to hide solutions if you were so inclined :)
<z64>
a collapsable "hide details" markdown as well
powerbit has quit [Remote host closed the connection]
<FromGitter>
<Blacksmoke16> thats prob an issue tho
JuanMiguel has joined #crystal-lang
<FromGitter>
<greenbigfrog> I got it to work now, still not sure if the code above shouldn't work as well though
<FromGitter>
<Blacksmoke16> the other `HTTP:Client` allows tls as a bool, but this one doesnt...
JuanMiguel has quit [Client Quit]
rohitpaulk has quit [Ping timeout: 240 seconds]
<z64>
@Blacksmoke16 the `new(uri, tls)` constructor parses whether tls should or should not be used from the URI itself (it reads whether "http" or "https" is present for example). the tls parameter is there to pass an existing TLS context
<z64>
other methods may not accept a URI, and may be something else where TLS settings are ambiguous
<FromGitter>
<Blacksmoke16> fair enough
Raimondi has quit [Ping timeout: 240 seconds]
sevensidedmarble has joined #crystal-lang
sevensidedmarble has quit [Client Quit]
sevensidedmarble has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
Raimondi has joined #crystal-lang
Jenz has joined #crystal-lang
Jenz has quit [Ping timeout: 246 seconds]
Jenz has joined #crystal-lang
<FromGitter>
<DanilaFe> Wow, no new messages overnight
* Jenz
O_o
<FromGitter>
<bew> @DanilaFe you broke the spell!!!
non-aristotelian has joined #crystal-lang
Jenz has quit [Quit: leaving]
<FromGitter>
<DanilaFe> Wow, that's strange
<FromGitter>
<DanilaFe> Was my Gitter client malfunctioning?
<FromGitter>
<DanilaFe> Or was it not just me
<FromGitter>
<bew> Na, nobody is talking afaik
<FromGitter>
<DanilaFe> I just received a lot of messages that weren't there before. Mysterious
<FromGitter>
<DanilaFe> I'd be happy for advent of code to be in the forums. However, I do also like hanging out in the gitter chat :)
<FromGitter>
<Blacksmoke16> ill have a question here soon ;)
<FromGitter>
<bew> You may get an answer here soon ;)
<FromGitter>
<Blacksmoke16> i need a way to have the return type of `convert` to be of type `Params`
<FromGitter>
<Blacksmoke16> because it wont let you splat the union tuples
<FromGitter>
<Blacksmoke16> and i cant cast the return value using `as`
<FromGitter>
<Blacksmoke16> (this is just a demo) im actually using radix tree shard for the storage/lookup
<FromGitter>
<drosehn> I use the Opera browser (on macOS) to follow this gitter channel, and if I have it running for days then sometimes it does get confused or hung up in some way. So every once-in-awhile I'll close the tab for gitter, and open a new tab. That seems to help a lot.
<FromGitter>
<Blacksmoke16> and im out of ideas on how i can restrict the return type, as to me it should already be restricted since its called on a specific object with return type set with a generic
Renich has joined #crystal-lang
<FromGitter>
<bew> why do you want to result as a tuple?
<FromGitter>
<Blacksmoke16> So I can splat the values for a method
<FromGitter>
<bew> note that you will be blocked with `@routes`, because when you do `@routes[N]` what is the type of the action?
<FromGitter>
<Blacksmoke16> Whatever the generic on that given route is
<FromGitter>
<bew> wrong
<FromGitter>
<bew> it'll be a union of all the possible generic, because the compiler can't know at compile time if `@routes[1]` will be a `RouteAction(X)` or `RouteAction(Y)`, so the type of `@routes[1].convert([...])` will be `X | Y`
<FromGitter>
<bew> and you still can't splat that
<FromGitter>
<Blacksmoke16> fair enough :/
<FromGitter>
<Blacksmoke16> i guess the question is now is there a diff method of doing this to get the singular return type
<FromGitter>
<bew> btw your `convert` can be simplified (and speedup) using macros: https://carc.in/#/r/5rzk
powerbit has joined #crystal-lang
<FromGitter>
<Blacksmoke16> Huh, neat
<FromGitter>
<bew> I remember I did a carcin about sth like that a while ago, the solution I did was that your `routes` array would be a list of Proc, taking always the same params and returning the same thing, and inside this proc, the implementation change based on the action (so it'll take the args, convert them to a tuple, splat it in the real method we want to call, then gather the result and return it from the Proc
<FromGitter>
<Blacksmoke16> Hmm
<FromGitter>
<Blacksmoke16> I'll have to play around with it I guess
Yxhuvud has quit [Disconnected by services]
Yxhuvud has joined #crystal-lang
FromGitter has quit [Ping timeout: 250 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]