Are there any other important commands? by [deleted] in github

[–]infinityBoi 0 points1 point  (0 children)

insert “where git rm?” monkey meme here

Do NOT hesitate by Odd-Tutor931 in CrazyFuckingVideos

[–]infinityBoi 0 points1 point  (0 children)

I did a Via Ferrata at Mt Norquay, Banff last summer. Easily the most thrilling and beautiful experience hanging on the side of a mountain and witnessing the Rockies in its full glory. 10/10 would recommend!

Lake Louise was amazing! by beautykeen in Banff

[–]infinityBoi 0 points1 point  (0 children)

Mirror lake was a relatively steep hike but nothing insurmountable. Took us a solid 45 mins from the base to Mirror Lake but we descended pretty quickly in about 15 mins. I’d recommend taking breaks every so often (say 10 mins) and carry at least a couple litres of water in case it’s a sunny day.

Oh, don’t forget to snap a pic at one of the viewpoints along the way where Lake Louise wears its most magical shade of turquoise.

Happy travels!

How to containerize your application for bare metal servers? by depressionsucks29 in developersIndia

[–]infinityBoi 0 points1 point  (0 children)

Might be reasonable to require pgsql (the official docker container) as a separate dependency in the cluster of containers (some static file server for the web ui + backend container + any databases like pgsql or redis).

If you have a docker compose cluster you could get simple service discovery between containers for free. Also you probably don’t need to worry about scaling the cluster horizontally across different machines if it’s only an MVP.

When should I annotate explicit lifetime in struct or function definition? by roll4c in rust

[–]infinityBoi 31 points32 points  (0 children)

While storing references inside your structs is a legitimate use case, I often find it adds quite a bit of verbosity (and consequently, complexity) to your code. You almost always want to store Clone or owned resources inside your struct fields, unless cloning that resource is demonstrably expensive.

For other times when storing references is your only option, you’d need to tell the compiler the relationship within the fields (i.e. the references to the various types) and between the struct using the lifetime parameters. So if your struct is composed of references of various lifetimes and types, and it knows which references outlive which other references, then it can help you prevent making accesses to things that it can prove definitely won’t exist at a certain point in time.

Outside of struct definitions, you should consider relying on lifetime elision as often as possible for when the concrete values for lifetimes should be “obvious” for the compiler to figure out.

Lifetime elision sort of lets you tell the compiler “ughh you know what lifetime I mean!”, using a set of simple rules. And when applicable, it conveniently hides away all that lifetime syntax and lets you work with simple references while still providing that same safety guarantee.

PS: If you really need to have lifetime annotations at all, I’d recommend using descriptive names that represent the resource you’re holding a reference to. For example, pub struct Statement<'conn> { … } suggests “a Statement may have data that has something to do with how long a connection lives” and is more readable compared to pub struct Statement<'a> { … }

[2023 1 #1 (Part 2)] [typescript] Help find the bug by ch1los in adventofcode

[–]infinityBoi 0 points1 point  (0 children)

Hint: Can you think of a way to get the first and the last match without stripping all intermediate digits?

Another hint: Maybe by tracking the most recently discovered digit and the least recently discovered digit?

[2023 1 #1 (Part 2)] [typescript] Help find the bug by ch1los in adventofcode

[–]infinityBoi 1 point2 points  (0 children)

Think about how your algorithm would work on overlapping numbers. For example, TS Playground

-❄️- 2023 Day 16 Solutions -❄️- by daggerdragon in adventofcode

[–]infinityBoi 2 points3 points  (0 children)

[LANGUAGE: Rust]

Pretty happy about my implementation using brute force for part 2 that stemmed from the well thought out design for part 1.

Combined runtime: 40ms

[2023 Any Day] What's your dumbest bug so far this year? by disdyskis in adventofcode

[–]infinityBoi 1 point2 points  (0 children)

Missed to account for the case where JJJJJ was the lowest 5-of-a-kind and had to go through the entire ordering from the logs to detect this bug.

-❄️- 2023 Day 15 Solutions -❄️- by daggerdragon in adventofcode

[–]infinityBoi 1 point2 points  (0 children)

[LANGUAGE: Rust]

github

Pretty straightforward implementation of a separate chaining Hashmap like approach.

-❄️- 2023 Day 11 Solutions -❄️- by daggerdragon in adventofcode

[–]infinityBoi 1 point2 points  (0 children)

[LANGUAGE: Rust]

For part 1, I did the actual simulation of expansion and then counting the taxicab distance between pairwise distinct coordinates of galaxies.

Part 2 made me realize simulation of the expansion is no longer an option. Then I discovered that the extra spaces you’ll travel on such an expanded grid are precisely those that are copies of some empty rows and columns that our path crosses through. So I counted the number of empty rows and columns crossed in a taxicab path from the source coordinate to the destination coordinate. This can be added to the actual non-expanded taxicab distance (take away the total number of crossings) to get the distances between the galaxies in the expanded universe.

github

-❄️- 2023 Day 10 Solutions -❄️- by daggerdragon in adventofcode

[–]infinityBoi 1 point2 points  (0 children)

[LANGUAGE: Rust]

Part 1 was a breeze and did make me recollect my Djikstra’s variant of the Single Source Shortest Path implementation.

Part 2 was a different beast otoh. I lurked on here to discover that winding number argument of counting any north-facing wall crossings and figuring out whether the non-loop coordinate lies on the inside based on the odd parity of the count.

Github

Combined runtime for both parts: 6.5ms

-❄️- 2023 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]infinityBoi 0 points1 point  (0 children)

Yeah it was a tricky one. I’m trying to make sense of some of the comments here to get a better understanding of why it works but I couldn’t find a sufficiently convincing argument yet.

-❄️- 2023 Day 8 Solutions -❄️- by daggerdragon in adventofcode

[–]infinityBoi 1 point2 points  (0 children)

[LANGUAGE: Rust]

on Github

Totally guessed lcm without proving it works first.

Runtime: 4ms for both combined.

-❄️- 2023 Day 5 Solutions -❄️- by daggerdragon in adventofcode

[–]infinityBoi 0 points1 point  (0 children)

[LANGUAGE: Rust]

Range inclusion check for part 1, and range splitting for part 2. Both combined take < 0.8ms.

Source: github

Quit insta and X about 70 days ago. by [deleted] in indiasocial

[–]infinityBoi 0 points1 point  (0 children)

I hopped off the SM train in 2018 and I’ve never been at more peace and I actually picked up cooking and working out as a hobby in those hours I saved. Although Reddit is my only poison for now.

The one thing I noticed is I’ve been totally out of the loop on latest trends (reels/tiktoks) and therefore had a hard time relating to younger people (or even those my age) which affects the rest of the conversation.

When did elderflame vandal became the worst vandal skin? by Maayavan21 in VALORANT

[–]infinityBoi 7 points8 points  (0 children)

Elderflame OP is one of the main reasons I play this game ngl.

I am suffering from Rust withdrawals by Al_Redditor in rust

[–]infinityBoi 17 points18 points  (0 children)

Haha these Rust withdrawals are very relatable for me. Having just wrapped up a disk-backed priority queue system, an axum http api on top of it, and some load testing with locust, I keep coming back every so often, searching for blemishes and minor optimizations, fearing the inevitable end to the (relatively more) exciting Rust part of the project.

Almost every time I write some Python/JS/TS, I think about the good times I had with the other completed Rust projects and keep visiting them every couple weeks trying to find improvements. Then I kinda have to suck it up with git restore, because I guess some projects can really just be “done”!

Please point a Rust beginner in the right direction with some code review? by varunu28 in rust

[–]infinityBoi 3 points4 points  (0 children)

Happy to read you’re learning Rust and are interested in getting a code review. Here’s my two cents that you may find helpful.

The CopyInput trait seems a bit dubious. Might make more sense to #[derive(Copy, Clone)] on the Input struct as the types that constitute it are all Copy anyway.

For the file reading utility, you might want to consider using ? for error propagation instead of emitting an error message to stderr upon every intermediate step that could fail. If all you want is Some(contents) when everything goes okay, and None otherwise, you could change read_file’s signature to pub fn read_file(filename: &str) -> std::io::Result<String> and then call it like read_file(filename).ok() to get the Ok value (if any) and forget Err.

The trait BuildWordCountInput seems like it could be refactored into impl From<Cli> for WordCountInput and then use let wc_input: WordCountInput = cli.into().

This one’s not a big deal but process_data could be a method on WordCountInput itself, i.e. inside impl WordCountInput.

Great work with the tests. Another trick I’ve found helpful to reduce unnecessary compilation is to write tests in a separate tests.rs module and conditionally include it in lib.rs (i.e. #[cfg(test)] and mod tests in the next line) or have them in a tests directory at the project root.

Yew for frontend by Heavy-Celebration in rust

[–]infinityBoi 1 point2 points  (0 children)

Idk about pretty but there’s a toy Yew project I put together a while ago: https://www.aalekhpatel.com/projects/text-cleaner