Skip to content

Instantly share code, notes, and snippets.

@olegafx
Last active February 14, 2018 10:36
Show Gist options
  • Save olegafx/6826479 to your computer and use it in GitHub Desktop.
Save olegafx/6826479 to your computer and use it in GitHub Desktop.
Useful bash commands
# Replace all `arg1` with `arg2` in previous command
!!:gs/arg1/arg2
# Emulate brew cask upgrade https://github.com/phinze/homebrew-cask/issues/309#issuecomment-36743989
brew update
for c in `brew cask list`; do ! brew cask info $c | grep -qF "Not installed" || brew cask install $c; done
# Set network speed
sudo ipfw pipe 1 config bw 56Kbit/s delay 200 plr 0.2
# Convert video to mp4 without re-encoding
ffmpeg -i input.mkv -vcodec copy -acodec copy output.mp4
# Find biggest directory/file in current directory
du -ks *|sort -n
# Print listening sockets
netstat -ntlp
# Show my public IP
curl ip.appspot.com
# Password generator
dd if=/dev/random bs=16 count=1 2>/dev/null | base64 | sed 's/=//g'
# Show hidden directories/files only
ls -d .* --color=auto
# Get message for your commit
curl -s http://whatthecommit.com/index.txt
# Export gzipped MySQL dump
mysqldump -u user -p database | gzip > database.sql.gz
# Import gzipped MySQL dump
gunzip < database.sql.gz | mysql -u user -p database
# Find all files with BOM
grep -rlI $'\xEF\xBB\xBF' .
# Get wifi password on OSX
security find-generic-password -ga networkName | grep password
# Run script in background with no error output
nohup node server.js > /dev/null 2>&1 &
# Fix NodeJS permissions
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment