Readit News logoReadit News
rjmill commented on Using Python for Scripting   hypirion.com/musings/use-... · Posted by u/birdculture
rjmill · 5 days ago
Odd, I don't see any mention of subprocess.run, the workhorse of python scripting.

Quick rundown for the unfamiliar:

Give it a command as a list of strings (e.g., subprocess.run(["echo", "foo"]).)

It takes a bunch of flags, but the most useful (but not immediately obvious) ones are:

  check=True: Raise an error if the command fails
  capture_output=True: Captures stdout/stderr on the CompletedProcess
  text=True: Automatically convert the stdout/stderr bytes to strings
By default, subprocess.run will print the stdout/stderr to the script's output (like bash, basically), so I only bother with capture_output if I need information in the output for a later step.

rjmill commented on Await Is Not a Context Switch: Understanding Python's Coroutines vs. Tasks   mergify.com/blog/await-is... · Posted by u/remyduthu
raincole · 21 days ago
> So the author's point is that "other" can never appear in-between "parent before" and "child start".

But isn't it true for JavaScript too? So I don't really get the author's point... am I missing something or the author('s LLM?) forced a moot comparison to JavaScript?

Edit: after reading the examples twice I am 99.9% sure it's slop and flagged it.

Edit2: another article from the same author: https://mergify.com/blog/why-warning-has-no-place-in-modern-...

> This isn’t just text — it’s structured, filterable, and actionable.

My conclusion is that I should ask LLM to write a browser userscript to automatically flag and hide links from this domain for me.

rjmill · 21 days ago
> But isn't it true for JavaScript too?

I don't think so. It's been a while since I've bled on tricky async problems in either language, but I'm pretty sure in JS it would be

  [...]
  parent_before
  parent_after
  child_before
  [...]
In JS, there are microtasks and macrotasks. setTimeout creates macrotasks. `.then` (and therefore `await`) creates microtasks.

Microtasks get executed BEFORE macrotasks, but they still get executed AFTER the current call stack is completed.

From OP (and better illustrated by GP's example) Python's surprise is that it's just putting the awaited coroutine into the current call stack. So `await` doesn't guarantee anything is going into a task queue (micro or macro) in python.

rjmill commented on Marble Fountain   willmorrison.net/posts/ma... · Posted by u/chris_overseas
kazinator · a month ago
Designers of marble fountains who don't use computing to design the paths run into reliability issues: sometimes balls derailing out of their track. They have to observe the contraption, identify problems (balls getting jammed up or jumping out) and then guess at the root causes and make manual adjustments.

That's the thing here: he has it running for hours presumably without any ball jumping out.

Most of the tracks consist of two rails, so the ball has two contact points. I'm no physicist but it seems like the goal would be to have ideally nearly equal forces at the two contact points at all times during the ball's descent. In other words, the track has to be perfectly banked so that the gravity and centripetal acceleration vector are balanced by a normal vector perpendicular to the rails. During a derailment, the ball has to lift away from one of the two contact points, so the normal force must have dropped to zero.

rjmill · a month ago
Not to dimish the achievement, but TFA is pretty clear about the limitations of the piece:

> I was able to get it working consistently, although it did lose 2-3 balls an hour and could only run for a few hours without the motor overheating.

IMO that's more impressive to hear than if he hadn't mentioned it at all. (I would have assumed more marbles getting lost.)

rjmill commented on A Python dict that can report which keys you did not use   peterbe.com/plog/a-python... · Posted by u/gilad
boothby · 5 months ago
Just a heads up, this fails to track usage of get and setdefault. The ability to iterate over dicts makes the whole question rather murky.
rjmill · 5 months ago
Indeed. Inheriting from 'collections.UserDict' instead of 'dict' will make TFA's code work as intended for most of those edge cases.

UserDict will route '.get', '.setdefault', and even iteration via '.items()' through the '__getitem__' method.

edited to remove "(maybe all?) edge cases". As soon as I posted, I thought of several less common/obvious edge cases.

rjmill commented on Defending adverbs exuberantly if conditionally   countercraft.substack.com... · Posted by u/benbreen
gadders · 6 months ago
The thing I have noticed is that most US-English speakers drop the "ly" from the end of adverbs.

Is that grammatically correct for US English, or is it slang?

rjmill · 6 months ago
Can you give an example? I've never noticed that (except for certain specific dialects and slang) but I may be blind to it.
rjmill commented on Root for your friends   josephthacker.com/persona... · Posted by u/rez0123
foobarbecue · 7 months ago
In my first few years on the job, I would fill out peer evaluations honestly. We have peer evaluations where you rate people out of 5 on various performance elements like "innovative" and "leader" or whatever. Then I survived a couple of rounds of awful layoffs where really good people lost their livelihoods.

Since then, I put 5 out of 5 on everyone for everything always, and say something nice in all the boxes.

rjmill · 7 months ago
Goodness, yes. The last time I put (genuinely constructive) criticism in a peer evaluation, it turned out to be the only non-positive thing that was said about that coworker. So it became a focus of his yearly review.

He later told me about how his review went (casually at a conference; he had no idea I was the source), and I fessed up and clarified what I actually meant. The HR process had twisted it to a much more extreme version of what I was getting at, completely undermining the utility of the feedback.

Nowadays, I'm just gonna give perfect scores and if I have feedback that needs to be given, I'll just tell the coworker directly. (And if I'm not comfortable doing that, then the feedback probably isn't important enough.)

rjmill commented on I failed a take-home assignment from Kagi Search   bloggeroo.dev/articles/20... · Posted by u/josecodea
danpalmer · 7 months ago
Take home assessments can be a valuable part of an interview process but they absolutely need a time limit. I think 2-3 hours is going to give you all the information you need, unless what you're selecting for is new grads with no dependents, hobbies, or responsibilities.

If this had been limited to 3 hours then the worst case is that the candidate would have lost 3 hours, but far more likely is that they would have come up with an entirely different proposal and/or solution that was appropriate for that timeline, and that extra information would have made it clearer what the company was looking for.

The other point I'd always encourage applicants to confirm is: are you looking for any answer, or are you looking for a good answer. Some take-home tests are purely about passing a test suite and how you manage it doesn't matter, some would prefer that you meet 80% of the requirements but write better code. I've seen applicants do the wrong thing on both sides of this.

rjmill · 7 months ago
How do you know that interviewees aren't spending more time on it?

Because you can't guarantee all candidates are spending the same amount of time, it becomes a game theory problem where the candidates will typically lose in some form. In many cases, the right answer is to spend extra time making a really polished (but not too polished!) solution and pretend like you stayed in the time limit. And every candidate is either a) doing that, or at least b) worried that their competition is doing that.

Even if we ignore that dynamic, 3 hours is a long ass time for a candidate to spend when they're not even sure they'll get to talk to another human about it.

In a 1-hour interview, you can run a candidate through a programming exercise and be guaranteed they're not wasting extra time on it. And if they happen to prefer doing take home assessments, you can always let them send you an updated answer later. (But often by the time a candidate asks me if they can do that, I've already developed a favorable view of their skills and can tell them, "go for it if you want, but you've already 'passed' my test.")

By keeping the candidate-interviewer time investment the same, you guarantee that you're respecting the candidate's time as you would your own (because you're sitting there with them.) I can help them skip over the parts I'm not interested in (e.g., by feeding them info they'd be able to find via search or telling them not to worry about certain details.)

If a hiring manager doesn't respect their candidates' time, how likely are they to respect their employees' time?

rjmill commented on The Frontend Treadmill   polotek.net/posts/the-fro... · Posted by u/Kerrick
rjmill · 9 months ago
Great advice, but my case is different because our framework is REALLY hurting us.

/s

It's wild how easy it is to fall into this trap. IMO, if you're considering switching frameworks (especially for perf reasons), your time would be better served by getting parts of your app off framework completely (assuming there's truly no way to get the results you want in your current framework.)

rjmill commented on TSMC expected to announce $100B investment in U.S.   wsj.com/tech/trump-chip-m... · Posted by u/perihelions
tnt128 · 9 months ago
The idea that the US protects Taiwan from a possible Chinese invasion over chips is one of those things that sounds believable but really isn't going to happen.

From China’s perspective, the cost of war is much higher than the cost of developing these chips themselves. In the worst-case scenario, they would be 2-3 years behind the cutting edge, which is not mission-critical. Most electronics (civilian or military) don’t really need cutting-edge chips, and China has already proven that they don’t need the latest chips to be a significant AI competitor.

From the US’s perspective, if a war with China were to break out now, there are only three possible scenarios: 1. China takes Taiwan quickly. In this case, there would be nothing for US to defend, and the US would have to try to take Taiwan back militarily—unlikely to happen. 2. Stalemate. Taiwanese people fight bravely, and Chinese forces turn out to be weaker than expected. In this case, the US would be in a comfortable position to send aid and weapons to help Taiwan, prolonging the war to weaken China. With some luck, a regime change could happen without firing a shot. 3. Taiwan successfully defends itself, repels the Chinese invasion, and possibly even takes back some territory—an unlikely scenario, but this is the only one where the US would send troops to help defend Taiwan. If the US gets involved at this stage, it secures a sure win, puts a military base on the island, and further cements its role as the protector of taiwan.

If you believe the US will or should only act in its own interest, then its interest is to remain the only superpower. Rushing into a war on foreign turf and losing is the quickest way to cede the Asia-Pacific region to China. So, despite what politicians might have you believe, the US is not going to help defend Taiwan, no matter who is in the White House.

rjmill · 9 months ago
I wonder if Bacardi might be a better analogue for what TSMC gets from this deal.

Bacardi started a distillery in Puerto Rico (iirc, to sell in the US without tariffs) well before the Cuban Revolution. When the Cuban government seized Bacardi's assets, they were able to move everything to their other sites in Puerto Rico and Mexico.

As you point out, I highly doubt this deal moves the needle on whether or not US provides military aid to Taiwan. But it does help give them more options if the situation in Taiwan becomes untenable.

rjmill commented on Show HN: I created a language called AntiLang – breaking all the conventions   siruscodes.github.io/Anti... · Posted by u/SirusCodes
rjmill · 10 months ago
I love it. I want a python-esque version that's whitespace sensitive. But only for trailing whitespace.

u/rjmill

KarmaCake day801April 11, 2016
About
github.com/rjmill
View Original