Skip to content

Instantly share code, notes, and snippets.

@commuterjoy
Created November 8, 2011 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save commuterjoy/1347412 to your computer and use it in GitHub Desktop.
Save commuterjoy/1347412 to your computer and use it in GitHub Desktop.
Dropbox
# Add this to /etc/profile and source it, then you can type `drop [file|folder]` to transfer
# files to some remote host, or 'drops' to list all drops, or 'undrop [file]
export DROPHOST=example.com
export DROPUSER=username
export DROPPATH=/home/path/to/folder
export DROPWEBROOT=/drop
# drop a file or folder & copy the resulting url to your clipboard
function drop() {
echo "copying $1 to remote";
scp -r -P 86 $1 ${DROPUSER}@${DROPHOST}:${DROPPATH};
echo "http://${DROPHOST}/${DROPWEBROOT}/$1" | pbcopy;
pbpaste;
}
# list current drops
function drops() {
ssh -p 86 -l ${DROPUSER} ${DROPHOST} "ls -1 ${DROPPATH}";
}
# undrop (delete a drop)
function undrop() {
ssh -p 86 -l ${DROPUSER} ${DROPHOST} "rm -iR ${DROPPATH}/$1";
}
# tar & gz a before it's dropped
function dropgz() {
tar -cvzf "/tmp/$1.tar.gz" "$1";
cd /tmp;
drop "$1.tar.gz";
cd -;
}
@commuterjoy
Copy link
Author

  • tarbal/gz is easy enough as we can carry that out in the /tmp folder
  • invite only drops we can do by generating a random string and scp'ing to that folder
  • private drops we can drop in to a /private folder that's not in web space or has http auth on it
  • scp has built in bandwidth limiting, specified in Kbit/s, so that will do for "Dropbox won't hog your connection"

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