HNHacker News
TopNewBestAskShowJobs

badmintonbaseba

365 karma · joined October 7, 2024

submissionscomments
badmintonbaseba··on Debugging: Indispensable rules for finding even the most elusive problems (2004)
git bisect --first-parent
badmintonbaseba··on Debugging: Indispensable rules for finding even the most elusive problems (2004)
git bisect supports --first-parent, no need to squash if you just merge.
badmintonbaseba··on Tricking c64 basic into clearing a hi-res screen quickly
Too much growth can be a problem too, according to this other article strings are at most 255 bytes long:

https://retro64.altervista.org/blog/garbage-collection-commo...

Which would limit the loop to 1 + 2 + 4 ... 128 = 255. You could start off with this, but making it work and filling exactly 8000 might be too complicated.

badmintonbaseba··on Dear OAuth Providers
Ah, yes fixing problems of one specific language at the protocol layer (and violating the spec). JSON isn't inherently limited to 2^52, JSON parsing in some languages and libraries are.
badmintonbaseba··on Deciphering C++ compiler errors: Nonsensical errors from a function declaration
The error is coming from a WinRT header, not something they can easily control. It's similar to having something like `#define string(x) something` and then including <string>.
badmintonbaseba··on Making memcpy(NULL, NULL, 0) well-defined
My mistake.
badmintonbaseba··on Making memcpy(NULL, NULL, 0) well-defined
I just skimmed through the proposed wording in [N3322]. It looks like it silently fixes a defect too, NULL == NULL was also undefined up until C23. Hilarious.

[N3322] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3322.pdf

badmintonbaseba··on Making memcpy(NULL, NULL, 0) well-defined
Still technically UB according to the proposed wording. The proposed wording only deals with allowing null pointers explicitly.
badmintonbaseba··on The Google Willow Thing
Maybe a working quantum algorithm for weather prediction would outperform currently used classical simulations, but I wouldn't expect it to be bang on every time. Inputs are imperfect. So at best you could benchmark it, and gain some confidence over time. It could very well be good enough for weather prediction though.

Also I doubt that a quantum algorithm is possible that provably solves the Navier-Stokes equations with known boundary and initial conditions. At least you need some discretization, and maybe you can get a quantum algorithm that provably converges to the real solution (which alone would be a breakthrough, I believe). Then you need some experimental lab setup with well controlled boundary and initial conditions that you can measure against.

In any case the validation would be at a very different standard compared to verifying prime factorization. At most you can gain confidence in the correctness of the simulation, but never absolute certainty.

badmintonbaseba··on How to pack ternary numbers in 8-bit bytes
To be able to reversibly encode an N-trit ternary number into an M-bit binary number, the number of possible N-trit numbers must be less or equal to the number of possible M-bit binary numbers. Otherwise there would be two input ternary numbers that would map to the the same binary number (pigeonhole principle). Which means that 3^N <= 2^M.

  3^N <= 2^M
  log(3^N) <= log(2^M)
  N*log(3) <= M*log(2)
  log(3)/log(2) <= M/N
where M/N is the bits per ternary digit.
badmintonbaseba··on Why America's economy is soaring ahead of its rivals
Your argument hinges on my work being more profitable than a care assistants. While that's maybe true, the difference showing in GDP is not the difference of profitability or "value" in our work. What if I'm a care assistant myself? Imagine two care assistants and two scenarios:

1. They are working from Monday to Saturday. They can't take Saturday off, so they hire a care assistant to take care of their grandma on Saturdays, they happen to hire each other.

2. They are working from Monday to Friday. They take care of their own grandma over the weekends.

Scenario 1 adds more to the national GDP.

badmintonbaseba··on Show HN: my party game where AI decides if you’re funny
Works without, although the "conversations" are somehow quite depressing.
badmintonbaseba··on The GNU make jobserver Implementation (2015)
I'm not seeing python creating a self-pipe for `loop.add_signal_handler`.

edit: Oh, it uses `signal.set_wakeup_fd`, interesting.

https://docs.python.org/3/library/signal.html#signal.set_wak...

edit2: it looks like the fd comes from a self-socket, but yeah, it's the same approach. The function is even called `_make_self_pipe`.

https://github.com/python/cpython/blob/bf21e2160d1dc6869fb23...

badmintonbaseba··on The GNU make jobserver Implementation (2015)
I wonder how this fails then:

  import asyncio
  import os
  import signal
  import sys
  
  
  async def get_stdin_reader():
      loop = asyncio.get_running_loop()
      reader = asyncio.StreamReader()
      protocol = asyncio.StreamReaderProtocol(reader)
      await loop.connect_read_pipe(lambda: protocol, sys.stdin)
      return reader
  
  
  async def amain():
      print(f'pid: {os.getpid()}')
  
      sig_queue: asyncio.Queue[None] = asyncio.Queue()
      def sig_handler() -> None:
          sig_queue.put_nowait(None)
  
      loop= asyncio.get_running_loop()
      loop.add_signal_handler(signal.SIGUSR1, sig_handler)
      reader = await get_stdin_reader()
  
      task1 = loop.create_task(reader.read(1))
      task2 = loop.create_task(sig_queue.get())
      pending = {task1, task2}
      while True:
          done, pending = await asyncio.wait(pending, return_when=asyncio.FIRST_COMPLETED)
          if task1 in done:
              task1 = loop.create_task(reader.read(1))
              pending.add(task1)
              print('got char on stdin')
          if task2 in done:
              task2 = loop.create_task(sig_queue.get())
              pending.add(task2)
              print('got signal')
  
  
  asyncio.run(amain())
badmintonbaseba··on The GNU make jobserver Implementation (2015)
It's interesting that waiting on a signal and a pipe read at the same time is the hard part. Would be interesting to track down how this happens to be implemented if you do this from a higher level async framework, like python's asyncio.
badmintonbaseba··on Spotify has shut down several API endpoints
Owning your music files doesn't necessarily imply that you have to by them physically on CDs. Of course the music you are interested in might not be available in your preferred format or on your preferred streaming platform.
badmintonbaseba··on Don't Fuck with Scroll
shift + mouse scroll for horizontal scroll works too, at least on Firefox.
badmintonbaseba··on PRoot: User-space implementation of chroot, mount –bind, and binfmt_misc
So this works by intercepting file-related syscalls. Does it intercept io_uring?
badmintonbaseba··on PRoot: User-space implementation of chroot, mount –bind, and binfmt_misc
Nowadays you have unprivileged options with mount namespaces. And from an unprivileged user namespace you can probably invoke chroot just fine as "root".

`chroot`, the function, has probably some baggage that makes it impossible to enable straight from an unprivileged program? Anyway, a chroot-like program seems to be implementable on top of user namespaces. Rootless docker is mostly that, with more namespace and cgroup isolation.

badmintonbaseba··on The WTF-8 Encoding
Invalid UTF-16 with unpaired surrogates. Or rather WTF-8 is an alternate encoding of UCS-2. The subset of UCS-2 that is valid UTF-16 encodes to valid UTF-8 when encoded with WTF-8. The encoding is invertible, valid UTF-8 decodes to valid UTF-16, otherwise any byte sequence decodes to UCS-2.
badmintonbaseba··on The two factions of C++
You can use `unique_ptr` with a custom deleter for wrapping C libraries.

  using snd_pcm_T = std::unique_ptr<
    snd_pcm_t,
    decltype([](void* ptr){snd_pcm_close(ptr);})
  >;
  auto pcm_handle = snd_pcm_T(snd_pcm_open(...));
The lambda in decltype is C++20, otherwise the deleter type could be declared out-of-line.
badmintonbaseba··on The two factions of C++
Use-after-free (or reference/iterator invalidation in general) is the main issue. RAII doesn't help there at all. RAII helps with deterministically cleaning up resources, which is important, but barely related to safety.
badmintonbaseba··on The two factions of C++
Well, can't really blame them in 2012. Especially that C++11 did bring an ABI break. Looks like they keep it fresh, although C++17 is getting a bit dated. Migration from C++17 to 20 or even 23 is probably a breeze though compared to migrating 03 to 11.
badmintonbaseba··on The two factions of C++
Keyword is "sane". You can probably count all "sane greenfield C++ startups" on one hand.
badmintonbaseba··on The two factions of C++
The expressiveness of const generics (NTTPs) in C++ wouldn't go away if it adopted lifetime annotations and "safe" scopes. It's entirely orthogonal.

Rust decided to have more restrictive generic programming, with the benefit of early diagnostic of mistakes in generic code. C++ defers that detection to instantiation, which allows the generics to be more expressive, but it's a tradeoff. But this is an entirely different design decision to lifetime tracking.

badmintonbaseba··on Query Your Python Lists
I would prefer something like `{"name": contains("k")}`, where contains("k") returns an object with a custom __eq__ that compares equal to any string (or iterable) that contains "k". Then you can just filter by equality.

I recently started using this pattern for pytest equality assertions, as pytest helpfully produces a detailed diff on mismatch. It's not perfect, as pytest doesn't always produce a correct diff with this pattern, but it's better than some alternatives.

badmintonbaseba··on Desktop icons are surprisingly hard
> If you let the user arrange their icons in the preferred shape, for each screen resolution they use, and save that, the problem is solved.

Users normally place their icons using a given, single resolution, so that would only give you one initial saved icon position. You need some heuristic when the user first changes resolution with that icon present on the desktop.

badmintonbaseba··on Desktop icons are surprisingly hard
But can you arrange by p**s?

https://www.youtube.com/watch?v=uRGljemfwUE

badmintonbaseba··on Thunderbird Turns 20 Years Old
Is "send later" a simple function? It's probably avoided, because it's unintuitive. I assume you need to have your client running at the scheduled "send later" time (unless there is some obscure SMTP extension), which is not a problem if it's running all the time. But possibly it doesn't match the workflow of a significant chunk of the user base.
badmintonbaseba··on Show HN: SuperSplat – open-source 3D Gaussian Splat Editor
It's neat to explore how Gaussian splats represent different optical phenomena, like how the reflections seen in the eyes are represented as splats suspended within the object, with the surface of the eye being semi-transparent.
← PreviousPage 4 of 6Next →