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.

Revisions

  1. peterc revised this gist May 4, 2025. No changes.
  2. peterc revised this gist May 4, 2025. 1 changed file with 20 additions and 1 deletion.
    21 changes: 20 additions & 1 deletion useful.md
    Original file line number Diff line number Diff line change
    @@ -26,4 +26,23 @@ Create a 1GB RAM drive in macOS: ``diskutil erasevolume HFS+ 'RAM Disk' `hdiutil

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

    Rsync from local to remote: `rsync -chazP "/whatever" server1:`
    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

  3. peterc revised this gist May 4, 2025. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion useful.md
    Original file line number Diff line number Diff line change
    @@ -24,4 +24,6 @@ See the newest fonts added to Google Fonts: `curl 'https://fonts.google.com/meta

    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`
    MacOS friendly zipping: `ditto -ck --rsrc --sequesterRsrc folder file.zip`

    Rsync from local to remote: `rsync -chazP "/whatever" server1:`
  4. peterc revised this gist May 4, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,6 @@ 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```
    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`
  5. peterc revised this gist May 4, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion useful.md
    Original file line number Diff line number Diff line change
    @@ -22,6 +22,6 @@ 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``
    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`
  6. peterc created this gist May 4, 2025.
    27 changes: 27 additions & 0 deletions useful.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    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`