Changing your theme

Sometimes you just want to make smaller changes to your theme, it might be a logo that should be different, or a background color. Some themes doesn’t allow you to do this under Appearance – Customize, only in their PRO version. You could do it by altering the themes files, but if you are runnuing a multisite wordpress, your changes might affect several sites.

Instead you can use the Simple Custom CSS plugin, which allows you to write your own css that will override the ones from the theme. Here is an example:

.left_container {
background:none !important;
div { background: red; 
}
}
img#site-title {
content:url("http://photohelge.w.uib.no/files/2017/09/logo-helge-3.gif") !important;
height: 25%;
width: 25%;
}

Where I have changed a background color for class=left_container to none, and also chosen my own image for the logo.

different-logo-than-default-theme-logo

Apache conf serving static files with question mark in filename

If you have files on your filesystem with ‘?’ question mark in them, for example:

index.html?q=somestring

This can occur when you have site-ripped a PHP based website with for instance wget or other tools. If you access an url with ‘?’ in it, the webserver will try to serve the string after the question mark as a query string. This will not work, since there is no PHP, and result will be that you always get the index.html file, not the file named: “index.html?q=somestring”

This can be solved with an Apache rewritecond/rule configuration. Apache can be configured so that the ‘?’ is interpreted as part of the filename and not serving a query string.

Here is an example:
Directory "/var/www/html/path/to/files/";
AddType text/css .css?J
RewriteEngine On
RewriteBase /sites
RewriteCond %{QUERY_STRING} !^$
RewriteRule ^(.*)$ $1\%3F%{QUERY_STRING}? [L]

Convert multiple files from latin1 to utf8 with vim

If you have several files that need to be converted to utf8, you can do it with vim.

First start vim with:

$ vim $(find . -type f -iname '*.htm*')
Which will find all .htm and .html files from the current directory.

Then in vim, use : to go into command mode.

Run these two commands:
:set nomore
:bufdo set fileencoding=utf8 | w

Reference:
https://stackoverflow.com/questions/4544669/batch-convert-latin-1-files-to-utf-8-using-iconv

Use Curl to read your imap emails

You can use the bash command “curl” to read your imap emails like this:

curl --url "imaps://imapserver.somewhere.net" --user "username:password"

Note: your password will be visible on the command line, so don’t use this on a public server.

So it is actually better to create a file, for instance called secret, then write your password in it, and protect it with:

chmod 400 secret

Then you can use this command instead:

curl --url 'imaps://imapserver.somewhere.net' --user 'username:<code>cat secret</code>'

If there is a SSL certificate issue, you can also try (not recommended of course):

curl --insecure --url "imaps://imapserver.somewhere.net" --user "username:password"

You need a newer version of curl, because version before 7.29 have limited imap support.

In order to upgrade curl on a Centos system, you can:

Create a new file /etc/yum.repos.d/city-fan.repo

Then paste the following contents:

[CityFan]
name=City Fan Repo
baseurl=http://www.city-fan.org/ftp/contrib/yum-repo/rhel$releasever/$basearch/
enabled=1
gpgcheck=0

Finally

yum update curl

You can very finally the version of curl:

curl --version

See also:

https://debian-administration.org/article/726/Performing_IMAP_queries_via_curl