Two simple ways to version control your MariaDB schema changes

Over on Two simple ways to version control your MariaDB schema changes I learned a neat hack you can use to check for database schema revisions by reporting off the binlog.

The example command given was:

$ mysqlbinlog --no-defaults -R -u foo -p -d foodb -h db.home.arpa mysqld-bin.000001 > foodb.txt

pwned

I wrote the below BASH function today. It’s good because it performs super well compared to the alternative commands (which are commented out below above the new commands):

own() {

  echo "Taking ownership..."
  #chown -R jj5:jj5 .
  find . \! -user jj5 -or \! -group jj5 -execdir chown jj5:jj5  "{}" \;
  [ "$?" = 0 ] || { echo "Could not take ownership in '$PWD'."; exit 1; }

  echo "Fixing directory permissions..."
  #find . -type d -execdir chmod u+rwx "{}" \;
  find . -type d -and \( \! -perm /u=r -or \! -perm /u=w -or \! -perm /u=x \) -execdir chmod u+rwx "{}" \;
  [ "$?" = 0 ] || { echo "Could not fix directory permissions in '$PWD'."; exit 1; }

  echo "Fixing file permissions..."
  #find . -type f -execdir chmod u+rw "{}" \;
  find . -type f -and \( \! -perm /u=r -or \! -perm /u=w \) -execdir chmod u+rw "{}" \;
  [ "$?" = 0 ] || { echo "Could not fix file permissions in '$PWD'."; exit 1; }

}

The basic premise is don’t do work which doesn’t need to be done!

Passing selected value into HTML select onchange handler

So you have a <select> element and you want to call a handler, but you need to pass the selected value to the handler because you have multiple instances of the same <select> and can’t access them by ID (because there is many, one of which will have the new selected value, but you don’t know which). The solution is to pass in the newly selected value, like this:

<select onchange='handle_change( this.value )'>

Easy-peasy!