Mac OS X
March 15, 2018

Preferences

Preview for PDFs - Incorrect Pages are Bookmarked

Turn off logical page numbers by going to Preferences > PDF and then unticking the Viewing documents: Use logical page numbers box.

Hidden Utilities

afplay - Audio File Play

afplay [option…] audio_file

1
2
3
4
#loop a file
$ while :; do afplay "file.mp3"; done;
#individually play all file in a directory
$ find . -name '*.mp3' -exec afplay '{}' \;

Install transmission

1
brew install transmission-cli watch

Launch the daemon

1
transmission-daemon

Start the download

1
transmission-remote -a "magnet:link"

To have a visual update write: (add the -n flag to specify an interval, the standard is 2 seconds)

1
watch "transmission-remote -l"

Stop the daemon

1
transmission-remote --exit

or create a magnet.links file including magnet: link list of files you want to download, and then run below script to download all.

1
2
3
4
5
file="magnet.links"
while IFS= read -r line
do
transmission-remote -n 'transmission:transmission' -a $line
done <"$file"

Some options:

To target to a directory

1
transmission-remote -a magnet:?xt=urn:btih:e249fe4dc957be4b4ce3ecaac280fdf1c71bc5bb&dn=ubuntu-mate-16.10-desktop-amd64.iso -w ~/Downloads

To download torrent file

1
transmission-remote -a ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads
1
transmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads

To enable a peer blocklist: Since transmission-cli works different than its GTK counterpart, it often doesn’t save settings. This means peer blocklists need to be specified each time before use. The -b switch enables a blocklist.

1
transmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -b http://john.bitsurge.net/public/biglist.p2p.gz

To download with encryption: It is possible to encrypt the traffic while downloading.

1
transmission-remote -a http://releases.ubuntu.com/16.10/ubuntu-16.10-desktop-amd64.iso.torrent -w ~/Downloads -er

To remove a torrent

1
2
3
4
5
6
#remove a torrent with ID 3
transmission-remote -t 3 -r
#remove a torrent with ID 3 and 4
transmission-remote -t 3,4 -r
#remove all torrents
transmission-remote -t all -r

Free NTFS read and write on Mac

Edit fstab file

1
sudo nano /etc/fstab

Add below line where DRIVE_NAME is the name of the drive. The drive’s name should contain no spaces, as adding a space to the configuration file would tell your Mac to interpret whatever’s after that space as a separate command. If your DRIVE_NAME is made up of two words separated with a space, for example, “NO NAME”, you have to add a “\” before the space for the system to recognize the space. For example, “NO\ NAME”.

1
LABEL=DRIVE_NAME none ntfs rw,auto,nobrowse

Instead of using above, we can use the following command line.

1
UUID=Universal Unique Identifier none ntfs rw

Open Disk Utility and check File System UUID by opening Volume Info. Go back to Disk Utility to Unmount then Mount the NTFS disk to see if it is able to read and write to NTFS Disk.

Download from youtube

Download all content as mp3 format

1
yt-dlp --extract-audio --audio-format mp3 'https://www.youtube.com/watch?v=J5oZ80Daduc'

Download all content as mp4 format

1
yt-dlp -S res,ext:mp4:m4a --recode mp4 'https://www.youtube.com/watch?v=J5oZ80Daduc'

Trim a video without downloading it entirely

1
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 1313 -to 1330"
  • -ss HH:MM:SS : start time to take
  • -to HH:MM:SS : end time
  • -t HH:MM:SS : time length to take

Fastest: It will only download the section specified (to the nearest keyframe).

1
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*6:02-6:22"

Exact Key Frame: inf means to the end of the video.

1
yt-dlp 'https://www.youtube.com/watch?v=J5oZ80Daduc' --download-sections "*1:22:22-inf" --force-keyframes-at-cuts

Sections: Download a section titled “03. Symphony No. 6, Op. 68 (Pastoral): III. Allegro”:

1
yt-dlp 'URL' --download-sections "03.*"

Multiple Sections: Download multiple sections:

1
yt-dlp 'URL' --download-sections "03.*" --download-sections "05.*" -o "%(title)s-%(section_title)s.%(ext)s"

Verifying SHA256 checksum with shasum

A checksum is basically a string of letters and numbers that can be used to determine file integrity, like whether an error occurred during transmission, or whether a file was tampered with. For example, if the file checksum matches on your end with the checksum posted by where you received the file, you can be sure the file is identical.

1
shasum -a 256 /path/to/file