Skip to content

Instantly share code, notes, and snippets.

@jasonalderman
Last active January 30, 2021 20:54
Show Gist options
  • Save jasonalderman/c6c9813f3ed10c7d52e5c969b82eaae0 to your computer and use it in GitHub Desktop.
Save jasonalderman/c6c9813f3ed10c7d52e5c969b82eaae0 to your computer and use it in GitHub Desktop.

Useful Mac commands

When microphone isn't working in Chrome in Hangouts

  1. sudo killall coreaudiod
  2. Open new Chrome tab.

When you want to start a PHP Dev Server but access it from a phone or other computer

Instead of php -S localhost:8000 use php -S 0.0.0.0:8000 and you'll be able to see the server from http://<your IP address>:8000.

When you want to generate a localhost HTTPS certificate

From Let's Encrypt,

The simplest way to generate a private key and self-signed certificate for localhost is with this openssl command:

openssl req -x509 -out localhost.crt -keyout localhost.key \
  -newkey rsa:2048 -nodes -sha256 \
  -subj '/CN=localhost' -extensions EXT -config <( \
   printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

You can then configure your local web server with localhost.crt and localhost.key, and install localhost.crt in your list of locally trusted roots.

Or just follow these directions?

When you want to find a command you typed in Terminal

history | grep ffmpeg

Where ffmpeg is the command you're looking for. history keeps the last 500 things you typed; they're stored in a user's ~/.bash_history.

If you can't see .dev websites

rm /etc/resolver/dev

When you don't know what's running on port 3000

sudo lsof -i tcp:3000

or on some linux systems or older Macs that allow netstat with -p,

netstat -vanp tcp | grep 3000

(use --tcp on CentOS)

When you've saved a .webarchive from Safari and want to extract it into files

Put the .webarchive into a folder first (because it does not wrap the output in a folder), and then run the following command:

textutil -convert html example.webarchive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment