Skip to content

Instantly share code, notes, and snippets.

@ok3141
Last active April 14, 2026 16:57
Show Gist options
  • Select an option

  • Save ok3141/be73617da22db70044c410c8ce76ace2 to your computer and use it in GitHub Desktop.

Select an option

Save ok3141/be73617da22db70044c410c8ce76ace2 to your computer and use it in GitHub Desktop.
Linux/Mac Scripts

General

Generate random password

cat /dev/random | base64 | head -c 24 && echo

Generate debug.keystore for Android

keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000

GIT

Delete all local branches

git branch -D $(git branch | cut -c 3-)

FFMpeg

Cut video

ffmpeg -i input.mp4 -ss 00:01:00 -to 00:02:00 -c copy output.mp4

Crop video saving all audio and subtitles

ffmpeg -i input.mp4 -vf "crop=w:h:x:y" -map 0 -c:a copy -c:s copy output.mp4

Scale video

ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4

Remove audio

ffmpeg -i input.mp4 -c copy -an output.mp4

ffmpeg -i input.mp4 -i input.mp3 -c copy -map 0:v:0 -map 1:a:0 output.mp4

ffmpeg -i input.mp4 -i input.wav -c:v copy -map 0:v:0 -map 1:a:0 -c:a aac -b:a 192k output.mp4

Change container, saving codecs

ffmpeg -i input.vob -c:v copy -c:a copy output.mp4

Change aspect ratio

ffmpeg -i input.mp4 -c:v copy -c:a copy -aspect 768:432 output.mp4

Speed up video

ffmpeg -i input.mkv -filter:v "setpts=PTS/60" -an output.mkv

Screen cast Android to PC

adb shell screenrecord --size 270x630 --bit-rate=4m --output-format=h264 - | ffplay -

Video to frames

ffmpeg -i input.mp4 -vf fps=1 out%d.png

Reduce video size

# -b:v 3200k  -- good enough bitrate for 60fps video, use 1600k for 30fps
# -ac 1       -- merge stereo down to mono
ffmpeg -i input.mp4 -b:v 3200k -b:a 256k -ac 1 output.mp4

Concat multiple files

# Source - https://stackoverflow.com/a/11175851
# Posted by rogerdpack, modified by community. See post 'Timeline' for change history
# Retrieved 2026-01-14, License - CC BY-SA 4.0

$ cat mylist.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
    
$ ffmpeg -f concat -i mylist.txt -c copy output.mp4

WMA to MP3

for file in *.wma; do ffmpeg -i "${file}" -acodec libmp3lame -ab 192k "${file/.wma/.mp3}"; done

ZIP

Create Zip with password

zip -er output.zip input.file

#!/usr/bin/env bash
totalLines=0
grepLines=0
for line in $(git grep -I --name-only -e "")
do
tl=$(git blame $line | wc -l)
gl=$(git blame $line | grep "$1" | wc -l)
totalLines=$(expr $totalLines + $tl)
grepLines=$(expr $grepLines + $gl)
done
echo "grep: $grepLines total: $totalLines"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment