Backup all MySQL databases

#! /bin/bash

TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S`
BACKUP_DIR="/backup"
BACKUP_TIMESTAMP_DIR="$BACKUP_DIR/$TIMESTAMP"
MYSQL=/usr/bin/mysql
MYSQL_USER="user"
MYSQL_PASSWORD="pass"
MYSQLDUMP=/usr/bin/mysqldump

mkdir -p "$BACKUP_TIMESTAMP_DIR"

echo "Starting MySQL Backup";
echo `date`;

databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|mysql|information_schema|performance_schema)"`

for db in $databases; do
  echo "Dumping database: $db"
  $MYSQLDUMP --force --opt --skip-comments --compact --user=$MYSQL_USER -p$MYSQL_PASSWORD --single-transaction --databases $db | gzip > "$BACKUP_TIMESTAMP_DIR/$db.sql.gz"
done

tar -zcf "$TIMESTAMP.tar.gz" -C "$BACKUP_TIMESTAMP_DIR" .
rm -rf "$BACKUP_TIMESTAMP_DIR"

find "$BACKUP_DIR" -name "*.tar.gz" -mtime 182 -exec rm -f {} \;

echo "Finished MySQL Backup";
echo `date`;

Swift UIColor extensions

extension UIColor {
    convenience init?(rgb: Int) {
        self.init(
            red:    CGFloat((rgb & 0xFF0000) >> 16) / 255.0,
            green:  CGFloat((rgb & 0xFF00) >> 8) / 255.0,
            blue:   CGFloat(rgb & 0xFF) / 255.0,
            alpha:  1.0)
    }

    convenience init?(rgba: Int) {
        self.init(
            red:    CGFloat((rgba & 0xFF000000) >> 32) / 255.0,
            green:  CGFloat((rgba & 0xFF0000) >> 16) / 255.0,
            blue:   CGFloat((rgba & 0xFF00) >> 8) / 255.0,
            alpha:  CGFloat(rgba & 0xFF) / 255.0)
    }
}

Usage

var color1 = UIColor(rgba: 0x435363FF)
var color2 = UIColor(rgb: 0x435363)