Not really a snippet, still a good fix for a big annoyance. Temporarily disable the speaker by removing the driver for it.
```bash
sudo rmmod pcspkr
```
To make the silence more permanent add this line into /etc/modprob.d/blacklist
```bash
blacklist pcspkr
```