The Random Information Post
2015-06-18
This is a sort of catch-all post that will house random coding/sysadmin things I don't use enough to memorize.
Network Drives
Mount a volume over SSH
sshfs -p 2345 -o IdentityFile=~/.ssh/id_rsa user@domain.com:/remote/path /target/path
SQL
Compress a mysqldump
mysqldump -u user -p -B database_name | gzip > ~/backups/backup1.gz;
Video
Merging AVI files
mencoder -noskip -oac copy -ovc copy `ls 20150203*avi` -o digest.avi
add -mc for audio sync
Renaming files using regular expressions
I had a bunch of backed up files with names like:
* 201506.pdf_2015_10_08_160622
* 201507.pdf_2015_10_08_160622
To remove the timestamp suffix, I used the rename
utility. I had to install it with homebrew in Mac OS, but it works great:
rename 's/_2015_[0-9]{2}_[0-9]{2}_[0-9]{6}//' 2015*
ran in the above directory will give files named
* 201506.pdf
* 201507.pdf
Securely Wipe Drive
dd if=/dev/zero of=/dev/sdX iflag=nocache oflag=direct bs=4096
Convert all mkv files to mp4 in folder
for f in *.mkv; do avconv -i "$f" -codec copy "${f%.mkv}.mp4"; done