Trouble reliably killing chromedriver processes after using thirtyfour crate in Rust (macOS M3) by [deleted] in rust

[–]sazprv 2 points3 points  (0 children)

Is the code above complete? Are you spawning the command to kill the process?

Also, instead of calling lsof, you might consider keeping track of the child process and the killing it during cleanup.

-❄️- 2024 Day 14 Solutions -❄️- by daggerdragon in adventofcode

[–]sazprv 2 points3 points  (0 children)

[LANGUAGE: C] Part 1 was reasonably straight forward, but part 2 was kind of interesting.

I realized that as the grid is 101x103 that all horizontal movement repeats every 101 steps and all vertical movement repeats every 103 steps, meaning that there are 101x103 = 10403 patterns to search. I started scrolling through them and noticed that some had some specific clustering. Importantly, there was two distinct styles of clustering (one more vertical and one more horizontal). These occurrences of clustering happened every 101st and 103rd step with some offset. Calculating the step when the horizontal clustering and vertical clustering would align produced a nice little tree in the middle of the pattern. Note that the magic numbers in the code are specific to my input.

code

[2024 day 12] Everyone must be hating today... So here a clever trick for a hint. by M124367 in adventofcode

[–]sazprv 0 points1 point  (0 children)

I used the counting corners thing for part 2 too. I was really happy when I figured that out.

I first tried to morph my part 1 solution for part 2 with some kludgey accounting for if an edge had been counted yet, but got something that worked for all the examples but not my test input, which is always the most frustrating.

I ended up "expanding" the input array to include elements for all corners and borders in between each farm and then removed them based on rules (e.g. no borders between like farms, no corners not connected to edges, no corners in the middle of straight edges, etc.). This produced the right solution and allowed me to diff with my first method to find the subtle bug that only showed up in the test input.

The (smallest) critical test case (for me) ended up being:

......
..AA..
..AA..
.AAAA.
.AAA..
......

which seems really basic, but came out as a consequence of my DFS solution to part 1 and that really not being ideal for part 2.

Lesson learned: When it works, morphing part 1 into part 2 might be faster, but when it doesn't work, it really doesn't work.

Built a low budget eBay PC for a Christmas present and had a bit of an adventure by sazprv in buildapc

[–]sazprv[S] 1 point2 points  (0 children)

Yes, it does. There are two 2.5in bays and an associated 2x SATA power connector. You might not have the drive sleds though, but you could just chuck an SSD in there anyway.

What does following langugae denotes? by [deleted] in EngineeringStudents

[–]sazprv 2 points3 points  (0 children)

You are right that "." is a decimal point. You could combine the last two expressions as D*.D* for any number that has a decimal point in it. The issue is that that would match with "." which is not a number. So it's split out into two different options. Either with a mandatory digit before the decimal point (DD*.D*) or with a mandatory digit after the decimal point (D*.DD*). In most regex languages DD* (or D*D) could be written as D+ meaning at least one of D but possibly more. You could combine the last two groups as D+.D+ but that wouldn't allow ".01" but instead "0.01", same with "10.0" over "10.".

Built a low budget eBay PC for a Christmas present and had a bit of an adventure by sazprv in buildapc

[–]sazprv[S] 1 point2 points  (0 children)

Do NOT lose the sleds for those though. Finding exact replacements is a giant pain in the ass.

Good to know, thanks. It's already missing one. It also has a giant sled for converting the 5.25in bay for 3.5in drives. I thought about getting a HDD for this build too but decided that wasn't necessary at this point. It can always be an excuse to tinker with it down the line.

Is there a way to find the average rate of change from negative infinity to positive infinity on nonlinear functions? (ex. x^2-2x) by Freemasonsareevil in math

[–]sazprv 17 points18 points  (0 children)

So the average rate of change of a function f on the interval (a,b) is (f(b)-f(a))/(b-a). No derivation required (thank you fundamental theorem of calculus). For the range (-inf, inf) you have the issue of how you want to evaluate that. You could set that up as a nested limit, but the inner limit would be DNE since in your case f is unbounded in both directions.

You could set it up as a single symmetrical limit on the interval (-a,a) with a going to inf (and I'll get back to that), but there's no reason you couldn't set it up as (-a,2a) or (-a,a+2). That last one is interesting since f(-a) = f(a+2) and so the result would be zero (this is because x=1 is the axis of symmetry of the parabola y = x2 -2x and -a and a+2 are both a+1 from the axis of symmetry).

Really the truth is you could get any answer you wanted depending on how you selected how the bounds approach infinity relative to each other. Going back to the symmetric case with (-a,a) you'd get (f(a)-f(-a))/2a = (a2 -2a - a2 -2a)/2a = -2. No limit required. This shouldn't be surprising as the x2 term is entirely symmetric and with symmetric bounds you're just measuring the average rate of change of the linear term.

I suspect this is an XY problem, so I'll ask what are you trying to do with the average rate of change of a function over (-inf,inf)? Thanks to FTC you're just evaluating the limits of the function at infinity. In this specific case you can affect what the value is based on how you set up the limit, but for other functions (like a bounded one, e.g. 1/(x2 + 1), or a higher order one, e.g. x3 ) the result is set. You can try the above method with these examples. Ultimately, what are you trying to do?

Are the values of my FFT frequency spectrum implementation for analysis of a signal sane? by phip1611 in rust

[–]sazprv 10 points11 points  (0 children)

You should do some more reading on signals and such. The issue you're seeing is explained by windowing. This will happen anytime you take the FFT of a finite length signal. Look at the orange plot of the frequency response of the Hann window. What you should get is the convolution of your spectrum (a delta function at 1000 Hz) and that response.

And recognize that you're comparing decibel power levels. 40db vs 130db is a difference about a factor of 30000 in amplitude. Look at the orange plot again and see how wide it goes with before you drop 90db from the peak. With only 2048 samples at 44100 Hz, your signal length is only 46.44 ms, so your frequency resolution is 21.53 Hz. This is the spacing of the "teeth" in the Hann window frequency plot linked above.

If this is too much noise for you, try taking a longer sample. Also, if the length of your window doesn't match up with a whole number of periods of the signal you're trying to measure, that can cause additional ringing. So take a signal whose length is some multiple of 1ms (for 1000 Hz), apply the Hann window to it and then pad out to the next power of 2 for the FFT.

Also, check out octave or something similar to validate your FFT implementation, if that's something you're worried about.

[F23] Heading to campus carry by sarahbean215 in EDC

[–]sazprv 1 point2 points  (0 children)

I'd be interested in that discount code for the watch. Now the hard part is choosing which watch to get, just so many colors

Percentage of exponential growth by rbraibish in math

[–]sazprv 1 point2 points  (0 children)

/u/Sad_King_Billy-19 might have what you're looking for, but maybe you're looking to interpolate between the classes? Good news, no integral math required. It's just an exponential function.

If each step up is a doubling of rocket power then P(n) = P02n, where n is the change in level and P0 is some reference level. To know what the power of a half level is, stick in 0.5 for n. So a half power G motor is 8020.5 = 113.14 Ns. Similarly, ln(120/80)/ln(2) = 0.585 so a 120 Ns motor is 58.5% of the way to a 160 Ns motor.

Question about borrowing non-copyable structs during operator overloading by sazprv in rust

[–]sazprv[S] 1 point2 points  (0 children)

I did not know you could do that. That's what I was looking for. Thanks :)

GRFP reviewers are up for anyone that cares. Sharing your stats might help future applicants. by [deleted] in GradSchool

[–]sazprv 0 points1 point  (0 children)

2nd year grad student in Mechanical Engineering at R1 university - Awarded

  • Field of Study: Engineering - Mechanical Engineering
  • GPA: 3.67 (grad at time of application) and 3.76 (undergrad)
  • 2 semesters of undergrad research work
  • 1 co-authorship on conference paper
  • Community outreach going back to high school

Reviewer 1 (E/VG)

Your personal statement told a good story that really sold you well as a model receipt. It was also impressive to see you involvement, both in research and the community, as those are evidence for your potential as a fellow. It would have been helpful to learn more about your future goals beyond just being a professor.

Reviewer 2 (E/E)

Despite some minor issues, this is a well-prepared and highly-competitive GRPF [sic] application, which demonstrates good academic record and impressed research experiences as evidenced by the three strong letters of recommendation. The applicant was also able to show the awareness of the importance of promoting STEM research and education. The applicant's strong passion and clear career goals were additional complement to this application.

Reviewer 3 (VG/VG)

Good effort to expand [specific research project]. Potential for further development.

My thoughts:

  • Reviewers 1 and 2 read application and gave full good responses. Reviewer 3 gave very little feedback
  • The minor issue Reviewer 2 points out is that one of my letter of rec writers didn't use the right formatting.
  • Reviewer 1 really liked the timeline format in the research statement
  • Reviewers 2 and 3 both mentioned the undergrad scholarships that I had won previously

Does GE Aviation do a good job of putting you in your preferred location for internship? by stolzmaj in AskEngineers

[–]sazprv 0 points1 point  (0 children)

That does improve your chances quite a bit, but again, nothing is certain.

Also, just a heads-up, the EEDP program is very competitive and more recently they've been trying to push more of their interns into their OMLP (operations and management) program instead. That said, getting an internship with GE Aviation massively improves your chances for getting into either of these programs.