candidates=$(echo "show databases" | mysql -u root | grep -Ev "^(Database|mysql|performance_schema|sys|information_schema)$") mysqldump -u root --databases $candidates > full-backup-without-system-tables-$(date +%F).sql
Slow Assets Fix
To improve compile Sometimes you just need to cleanup the assets cache
rake assets:clobber rake assets:precompile
Bundle Hangs on bundle update
I finally found a reason why sometimes my 'bundle update' hangs infinitely.. It keeps showing dots... and takes forever..
bundle audit Resolving dependencies........... *sigh* ...
I have some gems that are available only for authorized users.
When the ssh keychain is still locked (haven't entered a password for my ssh-key yet) Bundler keeps running infinitely without showing any password entry...
FreeBSD Set Timezone and Time to chmos clock
The following commands can be used to change time zone.
When the file /etc/wall_chmos_clock exists, it wil interpret the chmod time as local time.
Else it interprets the systemtime as UTC time
cp /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime touch '/etc/wall_cmos_clock' adjkerntz -i
Emoticons in Rails Database
To support emoticons in a MySQL database you must use the utf8mb4 character set.
This isn't a rails default.
To make sure the database uses the correct format I use the following migration to change the default charcter set
class InitDatabase < ActiveRecord::Migration[5.2] def up execute "ALTER DATABASE `#{connection.current_database}` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci" end end
More info about the reason why I choose to use utf8mb4_unicode_ci as collection
https://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci/766996#766996
And force rails in using max string length of 191 which is required for the keylength of 767.
You can add the following monkey patch to the initializer
# config/initializers/monkey_patch_mysql_utf8mb4.rb require 'active_record/connection_adapters/abstract_mysql_adapter' module ActiveRecord module ConnectionAdapters class AbstractMysqlAdapter NATIVE_DATABASE_TYPES[:string] = { name: "varchar", limit: 191 } end end end