wp post meta update _yoast_wpseo_meta-robots-noindex 1
You can use url_to_postid to convert a URL to its post id in the wp shell, or by creating a wp command.
for url in $(cat /tmp/urls-to-noindex); do
id=$(wp url2id $url)
if [ "$id" == "0" ]; then
echo $url - no post found
else
wp post meta update $id _yoast_wpseo_meta-robots-noindex 1
fi;
done
Create scaffolding for a command with wp scaffold plugin.
I’m copying the Lustre Manual to my site because the Intel robots.txt prevents Google from indexing it, and it makes it difficult to search: http://kitwestneat.com/lustre_manual.xhtml
Sometimes you need to convert a pdf to jpg, mess around with it, then recreate a pdf. Here’s the method I use:
convert -density 400 file.pdf -alpha remove file.jpg # this create file-0.jpg, file-1.jpg, etc. Between 300-600 is a good density, alpha remove is needed if there is transparency in the pdf
gimp file-0.jpg
convert -units PixelsPerInch -density 400 -quality 25 $(ls -v file-*.jpg) file.pdf # gimp usually uses a dpi of 72, so need to change resolution back to 400, a high quality = large file
That’s it! Almost. If there’s transparency in the pdf, jpg won’t like it so you’ll need to use png. But PNG doesn’t automatically add numbers, so you need to do:
If you are ever in a situation where you need to run an xmlrpc request against a specific WordPress server using the python xmlrpc library, it can be somewhat difficult. The Python xmlrpc library doesn’t give you an easy way to override the Host header in the request, so you can only pick the server or the Host, but not both. Luckily, the library allows you to override the HTTP transport class it uses, so you can provide your own. Here’s a transport that seems to work for connecting locally with any given host. It would be fairly easy to modify to connect to any server.
class LocalTransport(xmlrpclib.Transport):
def make_connection(self, host):
self.real_host = host
return xmlrpclib.Transport.make_connection(self, '127.0.0.1')
def send_request(self, connection, handler, request_body):
try:
import gzip
except ImportError:
gzip = None #python can be built without zlib/gzip support
if (self.accept_gzip_encoding and gzip):
connection.putrequest("POST", handler, skip_host=True, skip_accept_encoding=True)
connection.putheader("Accept-Encoding", "gzip")
else:
connection.putrequest("POST", handler, skip_host=True)
connection.putheader("Host", self.real_host)
VPS providers only support a set of kernels. Yum updates can sometimes remove old kernels, which can cause problems if the VPS provider doesn’t support the newer kernels yet. Yum supports pinning a certain kernel, so you can be sure that the system can boot after an upgrade and have an orderly kernel upgrade when the time comes.
From this article:
# prevent yum from deleting old kernel
yumdb set installonly keep kernel-core-3.17.4-301.fc21.x86_64
# allow yum to delete old kernel
yumdb del installonly kernel-core-3.17.4-301.fc21.x86_64
Basically a way to split up WordPress requests among multiple database servers. So you could have all writes go to your primary, and have reads split among your replicating and primary servers.
I’ve been working on creating a new master-slave setup out of an existing monolithic database server. I’ve been following Digital Ocean’s guide to replicatoin, but have had to figure out some other steps and caveats.
Random notes:
* relay-log needs to be defined
* if the slave gets into a bad state, you can use ‘RESET SLAVE;’ to get it healthy.
Here are those steps:
create the backup on the original server: mysqldump --all-databases -u root -p > ./full-backup-2015.02.03-bak
import it on the new master: cat full-backup-2015.02.03-bak | mysql -p
re-export it with the “master data”: mysqldump --all-databases --master-data -u root -p > full-backup-2015.02.03-bak
modify the master data in the backup to include the user/password that will be doing the replication
make sure ansible ACTUALLY adds the replication user with the correct host
run START SLAVE on the slave
if ansible user creation makes it so there are slaves users on both servers, do: stop slave; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; start slave; to skip it.