Better HN
topnewbestaskshowjobs
Log inSign up

MathMonkeyMan

2,676 karma · joined Nov 28, 2019 (7y ago) · 1,131 submissions

Submissions

comment 2y ago · link · parent

Strictly speaking, the energy gained by a charged particle along any path is the integral of the dot product between the electric field and the line element along the path (edit: times the charge). In the absence of changing magnetic fields, this is always the difference between the voltage at the starting and ending points.

What I was getting at is that there's only so much energy a field can put into a particle. Either the voltage will drop because the machine can't "keep up," or the particle will reach a terminal velocity where the force applied by the field is insufficient to accelerate the particle any more. But, barring those two things, the particle will continue to accelerate.

comment 2y ago · link · parent

Hm, good point. I suppose you could use [more git commands][1] to enforce a "nothing older than N commits" policy. But now the solution lacks that dead simple allure.

[1]: https://www.reddit.com/r/git/comments/wk2kqy/delete_files_un...

comment 2y ago · link · parent

This gives me an idea.

Use git to manage versions of the static files.

Use [git worktree][1] to have multiple separate working trees in different directories.

Use [openat()][2] in your app whenever serving a request for a static file. On each request, open the directory, i.e. `/var/www/mysite.com`, and then use `openat()` with the directory's file descriptor when looking up any files under that directory.

`/var/www/mysite.com` is a symbolic link to some working tree.

When modifying the site, make modifications to the git repository. Then check out the modified working tree into a new directory.

Create a symbolic link to the new directory and `mv` (rename) it to `/var/www/mysite.com`.

Then some time later, `rm -r` the old working tree.

[1]: https://git-scm.com/docs/git-worktree

[2]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/o...

comment 2y ago · link · parent

One thing that comes to mind is that the voltage difference determines the force on the charged particle, but in principle if the voltage can be maintained, then the same force could be used put an arbitrary amount of energy into the particle. So, at most 350 keV the first time around, but then at most 350 keV the second time around, and the third...

I know almost nothing about particle physics.

comment 2y ago · link · parent

None of those are government websites.

comment 2y ago · link · parent

The coffee is pretty good, though.

comment 2y ago · link · parent

> allocates new memory, creates the new element and only then deallocates it.

Ah, I'll have to check the standard. Thanks.

comment 2y ago · link · parent

Why is `f3` safe?

My thought (which is apparently wrong) is that the `const int& x` refers to memory that might be freed during `vector::push_back`. Then, when we go to construct the new element that is a copy of `x`, it might be invalid to read `x`. No?

Is this related to how a reference-to-const on the stack can extend the lifetime of a temporary to which it's bound? I didn't think that function parameters had this property (i.e. an implicit copy).

comment 2y ago · link · parent

In the case of a Logger, though, it is likely passed around by reference or pointer. So users of the Logger (reference/pointer) do not have to change if its definition changes to that of an interface.

The "Server" class, or whatever instantiates the Logger, will have to change, but that might not be such a big deal.

So yes, the author was wrong about not having to modify any code, but likely you won't have to modify most code.

comment 2y ago · link · parent

I have no idea, but the in-house pub/sub tech at a previous job used [PGM][1] together with some hand-written brokers and a client library. The overall delivery guarantee is at-most-once, but in over ten years and across tens of thousands of machines in multiple datacenters, they never saw a single dropped message. Not sure how they measured that, but I was told the measurements were accurate.

Well, except for that one major outage where everything shit the bed due to some misconfiguration of IP multicast in the datacenters, or so I was told.

So, maybe if your mission isn't life critical, you can just wrongfully assume exactly-once delivery.

[1]: https://en.wikipedia.org/wiki/Pragmatic_General_Multicast

comment 2y ago · link · parent

You make good points. The only part I disagree with is "forcing your readers to learn more shell syntax." Who am I to say what the reader does or doesn't know about the shell? I don't even know what I don't know about the shell. The language is a minefield. I always have to look up the rules for how prefix/suffix substitution works, or the finer points of heredocs, or just when exactly something should be quoted, or the precedence of boolean operators, or the difference between "[" and "test", or ...

Yes, let's be considerate and not use these features. But then we must agree on the specifics of the subset. If we're going to do that, then let's just learn the language proper instead. Or, avoid shell scripts entirely.

Maybe there's an analogy with writing prose. I _could_ use rare words and uncommon syntax, but the modern style is a better approach. Is "abstruse" a rare word? Will a reader be frustrated to necessarily learn about split infinitives? What about I/O redirection at the beginning of a command?

comment 2y ago · link · parent

IO redirection doesn't construct a pipe, but piping does.

    # Open foo.txt and use it as fd 0 in jq
    <foo.txt jq '[1,2,3]'
    # Create a pipe(). Use the write end as cat's fd 1 and the read end as jq's fd 0
    cat foo.txt | jq '[1,2,3]'
Best thing would be a directed graph where each node is a process or a file. A process has at most one edge going into it (stdin) and at most two coming out (stdout and stderr). A file has exactly one edge touching it.

Hard to do in text, though. Would look like lisp.

comment 2y ago · link · parent

My coworker said the same thing. But now that you know, will it give you pause?

Shell has tricky and arcane corners that are best to avoid, but you still do better to know about them, lest they bite you (shellcheck helps).

I don't think that "I/O redirection can precede the command name" is particularly tricky or arcane.

What bothers me is that it doesn't work with loops:

    <input.txt while read -r line; do thing; done # error

    while read -r line; do thing; done <input.txt # fine
The shell's grammar is quite a thing.

comment 2y ago · link · parent

Both of the features that you mention are specified in POSIX, which means that bash, ksh, zsh, sh, ash, dash, etc. implement them.

I find myself googling "OpenGroup shell command language" pretty often to check this sort of thing.

comment 2y ago · link · parent

Many schools are prisons, same as ever.

comment 2y ago · link · parent

And, again, issue threads are only helpful if the people corresponding in them are good communicators who put in the work to leave a legible record of what happened.

Many Github issue threads that I read are incomprehensible. The thread is not where the story is (it's in the memories of the people involved). Explaining is work. This is why they make kids write reports as assignments in school.

comment 2y ago · link · parent

> Remember when being a “Senior Software Engineer” actually meant something?

Nope.

I'm only 35, but within my career I saw "developers" become "engineers" because that's what Facebook and Google were doing.

Titles never meant anything. Today, they're a class-like system for labeling pay in large organizations.

You can't address title inflation. Years ago, I interviewed at Subway for the position of "sandwich artist." I thought it was cute, but the person who interviewed me seemed to take the title quite seriously.

If you get hired as a Principal Wizard Non-Commissioned Bit Slayer, good for you. The title will be used to justify your pay to coworkers and future employers. Maybe you're a wizard bit slayer, and maybe you're not.

comment 2y ago · link · parent

What do Palestine, Russia, and the U.S. have to do with the Internet Archive? The Internet Archive is a supremely boring target politically.

comment 2y ago · link · parent

sounds like a bug

comment 2y ago · link · parent

One definition for the randomness of a finite string is the size of the smallest program that produces it. The definition is dependent on how programs are interpreted.

If my string is "aaaa", does that mean its entropy is zero? There is at least information about its length. And by your definition, how do we know that this password isn't from a 256 character set? Does "Aaab" have 26 times the entropy of "aaab"?

Topics like this make more sense to me when the strings are infinite, or when the population of strings is known.

comment 2y ago · link · parent

Strep is a bacterial infection, and I'm glad you recovered without antibiotics.

comment 2y ago · link · parent

I wonder if there's some conservation law for "concerted mental effort." As if by spending time and energy on the often exasperating task of keeping documentation relevant, you reduce the time and energy required to comprehend the system.

You're right, it is a matter of culture and discipline. It's much harder to maintain a consistent and legible theory of a software component than it is to wing it with your 1-2 other teammates. Naming things is hard, especially when the names and their meanings eventually change.

comment 2y ago · link · parent

I was going to say that unit tests have the benefit of breaking when the truth changes.

But then I realized that a lot of what makes a set of tests good documentation is comments, and those rot, maybe worse than dedicated documentation.

Keeping documentation up to date is a hard problem that I haven't yet seen solved in my career.

comment 2y ago · link · parent

I've heard something along the lines of "the standard is to define facilities that will be used in most programs, and to codify widespread existing practice." That was in the context of "I don't like this proposed feature," though. This was for C++, not C.

A lot of stuff in the C++11 standard library was based on widespread use of Boost. Since then, I don't know. Also, were things like templates and lambdas implemented as compiler extensions before standardization? I don't know, but I doubt it. Maybe "we're a committee of people who will decide on a thing and we hope you like it" was always the norm in many ways.

comment 2y ago · link · parent

My brief foray into microcontroller land has taught me that C and C++ are very much mixed.

It's telling that every compiler toolchain that compiles C++ also compiles C (for some definition of "C"). With compiler flags, GCC extensions, and libraries that are kinda-sorta compatible with both languages, there's no being strict about it.

_My_ code might be strict about it, but what about tinyusb? Eventually you'll have to work with a library that chokes on `--pedantic`, because much (most?) code is not written to a strict C or C++ standard, but is "C/C++" and various extensions.

comment 2y ago · link · parent

It would be an interesting piece to learn why.

Maybe it was for ::reasons::.

comment 2y ago · link · parent

His is a very American perspective.

Also, a comedian spinning his experience into material.

comment 2y ago · link · parent

David Cross has a funny [bit][1] about whether the reverse is true.

[1]: https://youtu.be/z09So1j4kpk?t=378

comment 2y ago · link · parent

repurposed!

comment 2y ago · link · parent

I don't remember if he was trying to save space on his Google Drive or on his phone. His question was, mostly, that if he deleted files in one place, where would the space savings appear? I immediately thought of Windows' OneDrive and how it's sort of an automated rsync setup. I didn't know enough about his phone, which apps he was using, or about Google Drive to give an answer better than "I don't know, and I detect that some of your assumptions are probably wrong."
1
181920
38