Last active
December 17, 2015 21:19
-
-
Save zircote/5673874 to your computer and use it in GitHub Desktop.
cli warehouseA place for me to keep snippets I like but can never readily remember
This file contains 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
ls data/some_path_with_spaces_in_the_name/*.csv| while read name; do | |
./bin/load_csv.sh "$name" table_name | |
done | |
# Only show lines when the value in column number 6 changes. | |
tail -f some-logfile.log | awk '{if (last!=$6) {print $0}; last=$6}' | |
#generates php class properties from a tables columns | |
mysql -B -N -u root my_db -e 'describe table_to_use'|awk '{printf(" \"%s\" => null,\n", $1) }' | |
# rename a mysql-db | |
mysql -u root -e "CREATE DATABASE \`new_db\`;" | |
for table in `mysql -u root -B -N -e "SHOW TABLES;" old_db` | |
do | |
mysql -u root -e "RENAME TABLE \`old_db\`.\`$table\` to \`new_db\`.\`$table\`" | |
done | |
mysql -u root -e "DROP DATABASE \`old_db\`;" | |
ptoken_regex= '/([!#$%&\'\(\)*+-./[0-9]:<=>?@[a-zA-Z]\[\]^_`{\}~]|)/' | |
pathmunge () { | |
if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then | |
if [ "$2" = "after" ] ; then | |
PATH=$PATH:$1 | |
else | |
PATH=$1:$PATH | |
fi | |
fi | |
} | |
pathmunge /usr/local/blah/bin | |
pathmunge ~/bin | |
export PATH | |
black='\033[0;30m' | |
blue='\033[0;34m' | |
green='\033[0;32m' | |
red='\033[0;31m' | |
cyan='\033[0;36m' | |
purple='\033[0;35m' | |
brown='\033[0;33m' | |
yellow='\033[1;33m' | |
light_gray='\033[0;37m' | |
white='\033[1;37m' | |
endColor='\033[0m' | |
for i in $(cat sgs.json|jq .SecurityGroups[].GroupName|sed 's/\"//g'); do aws ec2 create-security-group --group-name $i --description $i --vpc-id vpc-870ab8e2; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment