Skip to content

Instantly share code, notes, and snippets.

@japboy
Created September 7, 2012 02:07
Show Gist options
  • Save japboy/3662565 to your computer and use it in GitHub Desktop.
Save japboy/3662565 to your computer and use it in GitHub Desktop.
Useful commands that I can easily forget :P
#!/bin/sh
# Change file permission recursively
find /path/to/dir -type f | xargs chmod 644
# Or this is also same as above
find /path/to/dir -type f -exec chmod 644 {} \;
# Or change file and directory permission recursively and appropriately
# 644 for files, and 755 for directories
chmod -R u=rwX,g=rX,o=rX /path/to/dir
#!/bin/sh
# Transcode files recursively
for f in *.MTS; do ffmpeg -i ${f} -vcodec copy -acodec copy ${f}.MP4; done
#!/bin/sh
# Snapshot all the files from the specified revision
git archive --format=tar HEAD | tar xf - -C /path/to
# Remove all of globally installed node modules
git submodule update --init
# Update a specific branch to include content from specific directory
BRANCH='gh-pages'
DIRECTORY='gh-pages'
BRANCH_SHA=$(git show-ref -s refs/heads/${BRANCH})
DIRECTORY_SHA=$(git ls-tree -d HEAD ${DIRECTORY} | awk '{print $3}')
COMMIT=$(echo 'Auto-update.' | git commit-tree ${DIRECTORY_SHA} -p ${BRANCH_SHA})
git update-ref refs/heads/${BRANCH} ${COMMIT}
#!/bin/sh
# Remove all of globally installed node modules
npm -g ls | grep -v 'npm@' | awk '/@/ {print $2}' | awk -F@ '{print $1}' | xargs npm -g rm
#!/bin/sh
# Generate a set of self-signed SSL certificate
# Secret key
openssl genrsa -out spdy-key.pem 1024
# Public key
openssl req -new -key spdy-key.pem -out spdy-csr.pem
# Certificate
openssl x509 -req -in spdy-csr.pem -signkey spdy-key.pem -out spdy-cert.pem
#!/bin/sh
# Remove only files recursively
find . -type f -exec rm -f {} \;
#!/bin/sh
# Remove all of installed gems
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
#!/bin/sh
# Display HTTP requests and responses in ASCII format
tcpdump -A -tttt host example.com port 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment