This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Display summarized (s) human-readable (both h) sizes of sub-directories sorted descending | |
| # - remove / to include files in that folder | |
| # - remove r to sort ascending by size | |
| du -sh */ | sort -hr | |
| # Remove broken symlinks (leverages zsh) | |
| rm -- *(-@D) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Script to backup the home directory to an external hardrive mounted at /media/backup | |
| # Uses rsync, dpkg, and mail (for error logging) | |
| SRC='/home/*' | |
| DEST='/media/backup' | |
| RSYNC_OPTS='-haAXuv --delete' | |
| EXCLUDE='*/.cache/* */.thumbnails/* */.config/google-* lost+found .gvfs' | |
| EXCLUDE="$(echo $EXCLUDE | sed 's/\(\S\+\)/ --exclude \1/g')" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var zeroPad = function(str) { | |
| return ('0'+ str).slice(-2); | |
| }; | |
| var dateLocal = function() { | |
| var d = new Date(); | |
| var s = d.getFullYear() + '-'; | |
| s += zeroPad(d.getMonth()) + '-'; | |
| s += zeroPad(d.getDate()) + 'T'; | |
| s += zeroPad(d.getHours()) + ':'; | |
| s += zeroPad(d.getMinutes()) + ':'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function rand_string(n) { | |
| if (n <= 0) { | |
| return ''; | |
| } | |
| var rs = ''; | |
| try { | |
| rs = crypto.randomBytes(Math.ceil(n/2)).toString('hex').slice(0,n); | |
| /* note: could do this non-blocking, but still might fail */ | |
| } | |
| catch(ex) { |
NewerOlder