fallocate -l 512M /mnt/swap ; \ dd if=/dev/zero of=/mnt/swap bs=512 count=1048576 \ ; mkswap /mnt/swap ; swapon /mnt/swap ; swapon -s ; free -m
ansible: ‘Sending passwords in plain text without SSL/TLS is extremely insecure’
ansible MySQL replication fails to change master with the following error: ‘Sending passwords in plain text without SSL/TLS is extremely insecure.’
To fix the problem open /usr/lib64/python2.6/site-packages/MySQLdb/cursors.py and change:
defer_warnings = False
to
defer_warnings = True
This is ugly but it works.
Postfix warning: database /etc/postfix/virtual.db is older than source file /etc/postfix/virtual
Fire:
postmap /etc/postfix/virtual
Once done :
service restart postfix
That’s it.
rpm: show packages with names only
Sometimes it’s needed to get only packages names only using rpm. This is how it can be done:
rpm -qa --qf "%{NAME}\n"
sed: replacing multiple empty lines with one
As simple as:
sed -e '/^$/N;/^\n$/D' <file>
MySQL: Removing applied relay logs
Run:
set global relay_log_purge=1;
And flush the logs:
flush logs;
OpenSSL: How to check if a certificate matches a private key
openssl x509 -noout -modulus -in example.crt | openssl md5 openssl rsa -noout -modulus -in example.key | openssl md5
Should be equal.
VPN: pptp Centos config for iPhone / iOS
name pptpd ms-dns 8.8.8.8 proxyarp debug lock nobsdcomp novj novjccomp nologfd nopcomp noaccomp mtu 1400 mru 1400 default-asyncmap
How to setup port forwarding in Windows
To start:
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=80 connectaddress=127.0.0.1
And to remove:
netsh interface portproxy delete v4tov4 listenport=8080 listenaddress=0.0.0.0
You can also use:
netsh interface portproxy reset
or
netsh interface portproxy delete
to drop the forwarding. If you face some issue setting this up please refer to this.
How to get and debug WordPress SQL queries
WordPress provides handy way to get all queries and to debug them easily.
To enable queries collecting add the following in your wp-config.php:
define('SAVEQUERIES', true);
Next should be added to your theme footer (wp-content/themes/<your_theme>/footer.php)
<?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds. <?php if (current_user_can('administrator')){ global $wpdb; echo "<pre>"; print_r($wpdb->queries); echo "</pre>"; } ?>
At the end you should be able to get something like:
134 queries in 0.301 seconds.
and a bunch of SQL queries.