Skip to content

Instantly share code, notes, and snippets.

@rezonn
Last active June 5, 2022 10:49
Show Gist options
  • Save rezonn/c7b58195769749c2c8089c2340a0f977 to your computer and use it in GitHub Desktop.
Save rezonn/c7b58195769749c2c8089c2340a0f977 to your computer and use it in GitHub Desktop.
macOS terminal tips
#update nodejs
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
#macos python -> ssh -> win10
cat helloworld.py | ssh username@192.168.1.4 python -
#all webm to mp4
for f in *.webm; do ffmpeg -fflags +genpts -i "$f" -r 24 "$f.mp4"; done
#curl with TOR
curl --socks5-hostname localhost:9150 https://google.com
#sort folders by size
du -sh -- * | sort -h
#download m3u8
ffmpeg -i "https://..." -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 video.mp4
nano ~/.crontab
* */2 * * * /usr/local/bin/node file.js
crontab ~/.crontab
#goto script folder
cd "${0%/*}"
#push to github
cd "${0%/*}"
git init
git commit -am 'commit'
git push -u origin master
#server
(node server.js; open http://localhost:8001 ) | (python3 -m http.server 8000; open http://localhost:8000)
#steam in home local
connect_remote <local_ipaddress>:27036
#desktop screen
ffmpeg -f gdigrab -i desktop -framerate 10 -vcodec libx264 YOUR_NAME_HERE.mp4
#list of users
dscl . list /Users | grep -v '^_'
#list processeses
ps -ax
ps -ax | grep Skype
#stop process
kill 14530
#safari reader list
/usr/bin/plutil -convert xml1 -o - ~/Library/Safari/Bookmarks.plist | grep -E -o '<string>http[s]{0,1}://.*</string>' | grep -v icloud | sed -E 's/<\/{0,1}string>//g'
#REMOVE
##find bom
cd /Library/Receipts/
ls
cd /var/db/receipts/
ls
##list
lsbom -fls /var/db/receipts/AppName.bom | (cd /; sudo xargs rm)
lsbom -dls /var/db/receipts/AppName.bom | (cd /; sudo xargs rmdir -p)
sudo rm AppName.bom AppName.plist
##
~/Library/Application Support/(App Name)
Preferences are stored at:
~/Library/Preferences/(App Name)
Caches are stored in:
~/Library/Caches/(App Name)
##big folders
~/Library/Developer/Xcode/DerivedData
iTunes -> Pref. -> Devic. -> Rec.
caches
Application Support
MobileDevices
Safari
Preferences
Containers
#server http://127.0.0.1:8000/
#python -m SimpleHTTPServer 8000
python3 -m http.server 8000
#copy all mp4 from folder and subfolders in second folder
find /from/folder/ -iname \*.mp4 -exec cp {} /to/folder \;
#file from first 2000000 bytes input file
dd bs=1 count=2000000 if=input_file of=output_file
#folder to ISO
hdiutil makehybrid -o ~/Desktop/iso.iso ~/Desktop/folder -iso -joliet
#xslt
xsltproc cv.xsl cv.xml -o 1.txt
#FFMPEG
#crop
ffmpeg -i 123.avi -vf crop=900:500:0:0 -b 600k -r 10 -vcodec mpeg4 output.avi
#cut
ffmpeg -ss 685 -t 65 -i 1.mp3 -acodec copy 2.mp3
ffmpeg -ss 00:11:40.0 -t 00:15:51.0 -i output.avi -acodec copy -vcodec copy -async 1 output2.avi
#flv to iphone-mp4
for f in *.flv;
do
ffmpeg -i "$f" -s 640x480 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -acodec ac3 -ac 2 -ar 48000 -ab 192k "$f.mp4"
done
#panasonic v100 mts to mp4
for f in *.MTS;
do
ffmpeg -i "$f" -vcodec h264 -b:v 16000k -acodec ac3 -b:a 192k -filter:v yadif "$f.mp4"
done
#wav to mp3
for f in *.wav;
do
ffmpeg -i "$f" -vn -ar 44100 -ac 2 -ab 192k -f mp3 "$f.mp3"
done
#wmv2mp4
for f in *.wmv;
do
ffmpeg -i "$f" -vcodec h264 -b:v 3000k -acodec ac3 -b:a 96k "$f.mp4"
done
#slo-mo
ffmpeg -i input.mp4 -t 20 -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf 24 output.mp4
#Turn off wifi
networksetup -setairportpower en0 off
#Turn on wifi
networksetup -setairportpower en0 on
#List wifi networks
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport scan
#Join
networksetup -setairportnetwork en0 WIFI_SSID_I_WANT_TO_JOIN WIFI_PASSWORD
#your network name
networksetup -listallhardwareports
#view all disks
diskutil list
#format sd
sudo diskutil unmountDisk /dev/disk2
sudo diskutil eraseDisk FAT32 SDCARD MBRFormat /dev/disk2
#backup sd
sudo diskutil unmountDisk /dev/disk2
sudo dd if=/dev/disk2 of=/Users/$USER/Desktop/sdcard.img bs=32m
# ctrl+t to view progress
#restore sd
sudo diskutil unmountDisk /dev/disk2
sudo dd if=/Users/$USER/Desktop/sd.img of=/dev/disk2 bs=32m
# ctrl+t to view progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment