Skip to content

Instantly share code, notes, and snippets.

@peterc
Last active May 4, 2025 14:19
Show Gist options
  • Save peterc/1e922b23eeffd314d2e30b35a2a14e55 to your computer and use it in GitHub Desktop.
Save peterc/1e922b23eeffd314d2e30b35a2a14e55 to your computer and use it in GitHub Desktop.
Useful random stuff

Make macOS dock instantly appear/disappear: defaults write com.apple.dock autohide-time-modifier -int 0;killall Dock

Truncate an MP3 to 10 minutes: ffmpeg -t 600 -i in.mp3 -acodec copy out.mp3

All the TLDs: http://data.iana.org/TLD/tlds-alpha-by-domain.txt

Poor man's dark mode in CSS: filter: invert(100%) hue-rotate(180deg);

AWS's IP ranges: https://ip-ranges.amazonaws.com/ip-ranges.json

Get your publicly presenting IP address: curl ifconfig.me

Doing a DNS request over HTTPS: curl https://8.8.8.8/resolve\?name\=example.com\&type\=TXT

Or how about over HTTP/2: curl --http2 -H 'accept: application/dns-json' https://1.1.1.1/dns-query\?name\=cloudflare.com

List all files ever added to a git repo: git log --pretty=format: --name-only --diff-filter=A | sort -u

Create a tiny low res version of a JPEG: convert in.jpg -quality 10 -interlace Plane -sampling-factor 2x2 -strip -resize 50% -define jpeg:dct-method=float out.jpg

Cute responsive text trick: font-size: min(max(1em, 1.3vw), 1.3em);

See the newest fonts added to Google Fonts: curl 'https://fonts.google.com/metadata/fonts' | jq '.familyMetadataList | sort_by(.dateAdded) | reverse | .[:5]'

Create a 1GB RAM drive in macOS: ``diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nobrowse -nomount ram://2097152```

MacOS friendly zipping: ditto -ck --rsrc --sequesterRsrc folder file.zip

Rsync from local to remote: rsync -chazP "/whatever" server1:

Audio loudness normalization: ffmpeg -i a.wav -af loudnorm=I=-23:LRA=1 -ar 44100 b.wav

Create a waveform image of audio: ffmpeg -i in.wav -filter_complex ""aformat=channel_layouts=mono,showwavespic=s=1000x200"" -frames:v 1 out.png

Strip metadata from MP3: ffmpeg -i tagged.mp3 -vn -codec:a copy -map_metadata -1 out.mp3

See all open IPv4 and v6 network connections and listening ports: lsof -Pnl +M -i4 -i6

100 random integers between 1 and 10: jot -r 100 1 10

Play .wav from macOS terminal: afplay audio.wav

See disk use of subdirectories, hiding empties: du -d 1 -h | sort -hr | egrep -v ^0

Disable macOS sound effects: defaults write com.apple.systemsound "com.apple.sound.uiaudio.enabled" -int 0

Blocked IPs by Wikipedia: https://meta.wikimedia.org/w/api.php?action=query&format=json&list=globalblocks&bglimit=500

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment