mysqldump --lock-all-tables -u root --all-databases | ssh remoteuser@remotehost mysql -u root
Ruby Ranges ../… excluding ends
(Date.new(2020,1,1) .. Date.new(2020,1,10)).overlaps?(Date.new(2020,1,10) .. Date.new(2020,1,20))
=> true
(Date.new(2020,1,1) ... Date.new(2020,1,10)).overlaps?(Date.new(2020,1,10) ... Date.new(2020,1,20))
=> false
virtualmin – multiple php versions, using fcgid – problem with php handler [SOLVED]
Want multiple php versions on the same virtualmin host?
Follow instructions here:
https://www.virtualmin.com/documentation/web/multiplephp
and
Installing PHP 5.6.x and 7.0.x with Ubuntu 14.04 and Virtualmin 5.0gpl using a PPA
Use fcgid as “Default PHP Execution Mode” …
And tada …. php files are being downloaded instead of being executed …
If this happens go to:
vi/nano/mmcedit /etc/apache2/mods-enabled/php7.0.conf
and comment the following 2 lines:
# SetHandler application/x-httpd-php
...
# SetHandler application/x-httpd-php-source
restart apache2, and it should work
find all MyISAM tables
SELECT TABLE_SCHEMA as DbName ,TABLE_NAME as TableName ,ENGINE as Engine FROM information_schema.TABLES WHERE ENGINE='MyISAM' AND TABLE_SCHEMA NOT IN('mysql','information_schema','performance_schema');
And maybe you want to convert them to InnoDB, this script generates you the queries:
SELECT CONCAT('ALTER TABLE ', TABLE_SCHEMA, '.', TABLE_NAME,' ENGINE=InnoDB;')
FROM Information_schema.TABLES WHERE TABLE_SCHEMA = 'yourDBName' AND ENGINE = 'MyISAM' AND TABLE_TYPE = 'BASE TABLE'
switching to a new git remote
easy 🙂
git remote set-url origin ssh://gituser@host:sshport/repository-path.git
Gogs rulz!!!
More Rails sugar :)
['one', 'two', 'three'].to_sentence => "one, two, and three"
and also some flexibility:
['one', 'two', 'three'].to_sentence(words_connector: ', ', last_word_connector: ' and ') => "one, two and three"
dump mysql database and import remote in one step
mysqldump --socket=/localsocket --user=localuser --password=locapassword local_database_name | ssh -p remote_ssh_port remote_system_user@remote_host 'mysql remote_database_name'
Ports should be open, mysql permissions granted, etc….
use lfd to scan logfiles for custom auth failures
2 examples:
/var/log/mail.log
scan for smtp auth failures like
Jul 14 08:34:54 ns1 postfix/smtpd[20888]: warning: unknown[xx.xx.xx.xx]: SASL LOGIN authentication failed: UGFzc3dvcmQ6
/var/log/auth.log
scan for dovecot imap login failures like
Jul 14 08:34:05 ns1 auth: pam_unix(dovecot:auth): authentication failure; logname= uid=0 euid=0 tty=dovecot ruser=contact rhost=xx.xx.xx.xx
in /etc/csf/csf.conf define
CUSTOM1_LOG = "/var/log/mail.log"
CUSTOM2_LOG = "/var/log/auth.log"
in /etc/csf/regex.custom.pm
add
if (($lgfile eq $config{CUSTOM1_LOG}) and ($line =~ /^\S+\s+\d+\s+\S+ \S+ postfix\/smtpd\[\d+\]: warning:.*\[(\d+\.\d+\.\d+\.\d+)\]: SASL [A-Z]*? authentication failed/)) {
return ("Failed SASL login from",$1,"mysaslmatch","5","list of ports to block this IP","14400");
}
if (($lgfile eq $config{CUSTOM2_LOG}) and ($line =~ /^\S+\s+\d+\s+\S+ \S+ auth:\ pam_unix\(dovecot:auth\): authentication failure; .* rhost\=(\d+\.\d+\.\d+\.\d+)/)) {
return ("Failed dovecot auth login from",$1,"dovecot_auth_match","5","list of ports to block this IP","14400");
}
String interpolation in Rails
I18n.interpolate ‘Jeni eats %{what}’, {what: ‘potatoes’}