Skip to content

Instantly share code, notes, and snippets.

@formidablae
Last active December 9, 2022 20:44
Show Gist options
  • Save formidablae/506ede99d60446c8beca0582bb984cda to your computer and use it in GitHub Desktop.
Save formidablae/506ede99d60446c8beca0582bb984cda to your computer and use it in GitHub Desktop.

cloc

$ cloc count lines of code.

Use as: $ cloc ./ or $ cloc ./*.py

convert

$ convert convert .gif or .mp4 to many png frames

Use as: $ convert -coalesce my_animatedfile.gif my_pngfiles.png

pdftotext

$ pdftotext convert pdf to plain text

Use as: $ pdftotext myfile.pdf

Find empty subdirectories in a directory

Use as: $ find . -type d -empty

Find empty subdirectories in a directory and delete them

Use as: $ find . -type d -empty -delete

Execute git status on multiple repos inside a directory

Use as: $ find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git status -s && echo)' \;

Delete local repo files, resetting git and pulling a clean copy from remote repo (for each of the repos in a directory)

Use as: $ find . -maxdepth 1 -mindepth 1 -type d -exec sh -c '(echo {} && cd {} && git reset --hard origin/main && git clean -fxd && git pull && echo)' \;

Rewrite git history changing username and email maintaining commits

Use as: $ git filter-branch -f --env-filter " GIT_AUTHOR_NAME='newname' GIT_AUTHOR_EMAIL='new@email' GIT_COMMITTER_NAME='newname' GIT_COMMITTER_EMAIL='new@email' " HEAD

$ git push --force --tags origin 'refs/heads/main'

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