Skip to content

Instantly share code, notes, and snippets.

@nvd916
Last active December 19, 2019 20:18
Show Gist options
  • Save nvd916/ee5859233a4693350d530a0c1fcd7a1f to your computer and use it in GitHub Desktop.
Save nvd916/ee5859233a4693350d530a0c1fcd7a1f to your computer and use it in GitHub Desktop.
Useful Scripts
# revert a merge while keeping local changes
git reset --merge ORIG_HEAD
# export a stash
git stash show -p > /directory/your-stash.diff
# avoid deleting both 'master' and currently checked out branch, and will, in the same step, clean pointers to remote branches which no longer exist
git branch --merged master | grep -v -e 'master' -e '\*' | xargs -n 1 git branch -d && git remote prune origin
# If new commits are added to the remote branch (by some team member), this command would not update the remote branch (and not overwrite any work).
git push --force-with-lease
# To force skip a file that already contains unstaged changes. If not go to .gitignore or .git/info/exclude first.
git update-index --skip-worktree [<file>...]
# count number of files in a directory. It's ls -[ONE], not ls -[L]. ls -[L] gives you an extra count.
ls -1 | wc -l
# List size of each directory in current directory
du -hd 1 .
# Make devices-compatible video from audio and image
ffmpeg -loop 1 -i image.jpg -ss [HH:]MM:SS[.m...] -t 60 -i audio.m4a -c:v libx264 -tune stillimage -c:a aac -b:a 94k -pix_fmt yuv420p -shortest video.mp4
# Watch the size of club_prod.sql every 5 seconds
watch -n 5 "ls -lh club_prod.sql | awk '{print \$5}'"
# Pipe output to "normal" clipboard
echo 123 | xclip -sel clip
@nvd916
Copy link
Author

nvd916 commented Jun 11, 2018

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