HNHacker News
TopNewBestAskShowJobs

thestoicattack

680 karma · joined April 16, 2010

submissionscomments
thestoicattack··on Entering text in the terminal is complicated
> the readline keybindings come from Emacs

> Because I’m a vim user, It took me a very long time to understand where these keybindings come from

libreadline supports a basic vi mode. In bash, `set -o vi` lets you use vim-style editing. It is a lifesaver.

thestoicattack··on Book Review: "Tidy First?" By Kent Beck
git blame does include --ignore-rev and --ignore-revs-file, so maybe if people updated such a file when making small edits, it would make your life easier.
thestoicattack··on Two GitHub bots not talking to each other on a PR
Dead github theory.
thestoicattack··on How to check if any word is zero (2021)
GCC turns a fold over a parameter pack into test/sete and turns std::min == 0 into cmp/cmovg: https://godbolt.org/z/TjK7Gz74M
thestoicattack··on Hollywood doesn’t make movies like ‘The Fugitive’ anymore (2018)
In the novel, Rico is Filipino.
thestoicattack··on U.S. court rejects Tether’s bid to conceal reserve records from the public
Yeah, I had to click through that article, which didn't link the docket, to get to a tweet with an image of a scan of a two-page order granting leave to file. It seems completely unrelated to the headline. Even the word "reject" is the opposite of what happened.
thestoicattack··on Lies we tell ourselves to keep using Golang
Ada too, I think.
thestoicattack··on -h –Help -help Help –? –?
> No doubt it's similarly easy using the vi keybindings.

I'd do kbihelp for the first and k2bdwA for the second.

thestoicattack··on Bitcoin Threw a Party in Miami and I Crashed It
> Emmy Noether, Lisa Randall, Elise Meitner, Vera Rubin

Chien-Shiung Wu!

thestoicattack··on Newly Measured Particle Seems Heavy Enough to Break Known Physics
A new analysis from Fermilab measures the W boson as 76 MeV heavier than the Standard Model predicts. The uncertainty in the measurement is 9 MeV.
thestoicattack··on Learning Standard C++ as a New Language [pdf]
(1999)

> Published in the May 1999 issue of "The C/C++ Users Journal"

thestoicattack··on Moving the Linux Kernel to Modern C
The article does mention at least one advantage, so it's not as if the ladder is being pulled up for no reason.
thestoicattack··on Linuxgems – A succinct cheat sheet for newbie Linux coders and sysadmins
As a note,

    find . -type f -exec grep stuff {} \;
will also invoke a new grep process for every file, which can be slow. If you think find is going to return a lot of files, it is often better to use

    find . -type f -exec grep stuff {} +  # note plus sign
which will replace {} with as many filenames as allowed (all correctly quoted, etc).
thestoicattack··on Warp: Fast, Rust-based terminal (waiting list)
I can't remember my terminal emulator ever crashing, much less crashing due to memory corruption. Maybe I've just been lucky.
thestoicattack··on Michael Collins, Apollo 11 astronaut, has died
I'm glad his memoir, "Carrying the Fire", got mentioned. It's one of the best astronaut memoirs.
thestoicattack··on 2020 Census Apportionment Results
House seat changes by state:

    (+2) TX
    (+1) CO, FL, MT, NC, OR
    (-1) CA, IL, MI, NY, OH, PA, WV
     (0) everyone else
thestoicattack··on C++ Alternative Operator Representations
You could also use std::bit_not

https://en.cppreference.com/w/cpp/utility/functional/bit_not

thestoicattack··on Illegal Prime Numbers
We do have such a digit-extraction algorithm: https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%9...
thestoicattack··on Performance comparison: counting words in Python, Go, C++, C, Awk, Forth, Rust
std::move_iterator was my first thought too, but I'm not sure if it works, since the key type for std::unordered_map is defined to be const, so you may have to make a copy anyway.

Maybe use a vector-of-pointer-to-pair, since we're leaving the map around and we don't really need the vector to own anything.

thestoicattack··on The Ten Commandments for C Programmers (1987)
That's basically modern C++, if you cut out all the things that aren't slices, destructors, and copy/move semantics.
thestoicattack··on Fork() can fail: this is important (2014)
Sorry, I see I didn't answer your question. I am not one of those programmers that would deliberately ignore an error code, so I don't know what they're thinking.

My suspicion (and naive hope) is that most people would not ignore that case if they knew it was dangerous. But I would expect them to ignore it if they didn't know it existed. Hence this article, I guess, which serves to remind everyone that it can in fact happen and is quite dangerous (due to a potential later interaction with kill).

thestoicattack··on Fork() can fail: this is important (2014)
If I didn't know it could fail, I wouldn't check for an error in its return code.
thestoicattack··on Fork() can fail: this is important (2014)
If by ignoring, you mean non catching anything, I'm often okay with that. If an exception makes it top-level, you'll get a std::terminate and be done.

The "canonical" example people use a lot is std::bad_alloc. Often, there is no point in catching it -- what cleanup or fallback work are you planning to do when you can't even allocate memory?

Of course, silently swallowing exceptions with an empty catch-block is terrible.

thestoicattack··on Fork() can fail: this is important (2014)
Did you detect any crashes after the change?
thestoicattack··on I Want Off Mr. Golang's Wild Ride
C and C++ don't have good stories for working on embedded systems without a standard library?
thestoicattack··on Implement with types, not your brain (2019)
I agree that the result, while cool, is not readable. An obvious next step would be to demonstrate how the type-checked lambda-heavy implementation can be refactored into something that also makes sense to a human.

> just because the types check out doesn't mean it's free from bugs

That's certainly true in the general case. In fact, the author gives a type-checked-but-wrong example of "we need an Int, so just return zero."

But in some specific cases, as the author writes, "One of those facts we can infer [from a type signature] is often the the only possible implementation." The article demonstrates that "possible" includes "also makes use of all the values available (or else the signature would be simpler)."

thestoicattack··on Microsoft begins showing an anti-Firefox ad in the Windows 10 start menu
I'm not scared of a "model" "trained" on the long tail of Github code any more than I'm scared of someone who can search stackoverflow faster than I can.
thestoicattack··on Bail – Get out of your plans, guilt free
This could leak information to the other party if bailing is still available during the event. By trying to bail myself after you show up I could "prove" you really didn't want to be here after all.
thestoicattack··on Sorting Algorithms in C
So I was all set to bash include/data-swap.c for allocating on the heap every time you need to swap memory. Turns out that gcc can optimize out that temporary, and it ends up the same as std::swap.

But if we use operator new/delete instead of std::malloc the optimization doesn't take place: https://godbolt.org/z/vtxqD2

thestoicattack··on C++20 Reference Card
To avoid this insidious bug:

    std::lock_guard<std::mutex>(m);  // guard is immediately thrown away
versus the correct

    std::lock_guard<std::mutex> g(m);  // hold mutex til end of scope
Page 1 of 4Next →