Skip to content

Instantly share code, notes, and snippets.

@peterc
Last active July 7, 2025 09:20
Show Gist options
  • Select an option

  • Save peterc/1e922b23eeffd314d2e30b35a2a14e55 to your computer and use it in GitHub Desktop.

Select an option

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:

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