Skip to content

Instantly share code, notes, and snippets.

@iangreenleaf
iangreenleaf / gist:535897
Created August 18, 2010 19:35
MySQL import with file names and progress bar
# Usage: reload-db /path/to/sqldump dbname
function reload-db {
for f in "$1"/*.sql; do
printf "%-${COLUMNS}s" "$f">&2;
cat "$f";
done \
| pv -s `du -sb "$1" | awk '{print $1}'` \
| mysql -uroot "$2";
if [ $? != 0 ]; then echo 'ERRORS!!!!!!!!!!!!!'; return $?; fi
@iangreenleaf
iangreenleaf / funcs.sh
Created August 13, 2010 20:51
Git unsigned merge hook
function error_message {
echo -e >&2 \
"---------------------------------------------------------------------------------------------------------" \
"\n$1" \
"\n---------------------------------------------------------------------------------------------------------"
}
function undo_merge {
error_message "Undoing your merge. Please fix the problem and try again."
@iangreenleaf
iangreenleaf / rsync-retry.sh
Created January 18, 2010 07:12
rsync with retries
#!/bin/bash
### ABOUT
### Runs rsync, retrying on errors up to a maximum number of tries.
### Simply edit the rsync line in the script to whatever parameters you need.
# Trap interrupts and exit instead of continuing the loop
trap "echo Exited!; exit;" SIGINT SIGTERM
MAX_RETRIES=50
@iangreenleaf
iangreenleaf / svn_safe.sh
Created January 18, 2010 06:50
svn switch disaster prevention
#!/bin/bash
### Copyright 2009 Ian Young
### Available under the terms of the MIT license
### ABOUT
### Prevents you from svn switching to a mismatched directory in a different branch.
### See http://blog.iangreenleaf.com/2009/11/avoiding-disaster-when-using-svn-switch.html
### USAGE