Monthly Archives: April 2017

How to upgrade to latest version of Ghostscript on Linux/Unix

For a new project, I need to use the latest verison of Ghostscript (at time of going to pixel, this is v9.21). However the CentOS yum install will only give me version 8.7.

Some Googling gave me some helpful answers, including downloading the latest version from the website and using then building manually. Following the instructions required me open a terminal and type:

./configure

Which would give me the error:

-bash: ./configure: No such file or directory

Turns out, I was downloading the latest x64 binary file from the Ghostscript website (which shouldn’t be used in a live, production environment). Actully what I needed was the source files.

So the full instructions to install the latest version of Ghostscript (v9.21) from a terminal session:

wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs921/ghostscript-9.21.tar.gz

./configure

make

make install

You should be able to execute and check the version:

/usr/local/bin/gs -v

Which outputs:

GPL Ghostscript 9.21 (2017-03-16)
Copyright (C) 2017 Artifex Software, Inc.  All rights reserved.

Voila.

How to find a question mark (?) or other wildcard symbol when searching in Excel

Failed solution:

You use Find & Replace to try and find the question mark (or other symbol like percentage % or asterix *) only to realise that Excel considers it to be a wildcard character (i.e. like a blank tile in scrabble, it can mean absolutely anything) and so every single letter in every cell gets highlighted.

Actual solution:

You need to ‘escape’ the character and to have Excel treat it like a real symbol not a wildcard by placing a ’tilde’ symbol (~) in front. As an example with the question mark, the picture below shows its use:

Excel find and replace wildcard with tilde

Detect Adsense Blocker

You own a website where the income comes from Adsense. But some thoughtless freeloaders are blocking your adverts from appearing when they view your site either from using a blocker or by using the private mode in their browser.

Don’t they realise this is costing you?

Using a script I found that I have modified, detect when Adsense hasn’t loaded and so display a message to the user where the advert would normally appear. This can be customised to display anything – even a fixed advert from another source.

I will go through the code line-by-line, but if you want the finished product then just skip to the end.

1. Create two files.

The first will contain the javascript – I’ve called mine ‘adsense_block_detector.js’.
The second will contain the message to display (this called also have HTML or other code). I’ve called mine ‘message.html’ and inserted some text that says “Please don’t block my adverts”.

2. Within the javascript file, start off by wanting the script to run when the page loads:


window.onload = function() {

};

3. The script should be delayed by a few seconds (in the example I use 2000ms) to give time for the Adsense to load:


window.onload = function() {
setTimeout(function() {

}, 2000);
};

4. Get the status of the ins.adsbygoogle code that Google supplies to load the advert:


window.onload = function() {
setTimeout(function() {
var ad = document.querySelector("ins.adsbygoogle");

}, 2000);
};

5. If no advert has loaded (i.e. due to a blocker) then load the message.html file created above.


window.onload = function() {
setTimeout(function() {
var ad = document.querySelector("ins.adsbygoogle");
if (ad && ad.innerHTML.replace(/\s/g, "").length == 0) {
ad.style.cssText = 'display:block !important';
$('ins.adsbygoogle').load('/path/to/file/message.html');
}
}, 2000);
};

Script complete. All you need to do is to call this javascript file and jQuery from the head section of your desired webpage.


....
....
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="/path/to/file/adsense_blocker_detect.js" type="text/javascript"></script>
....
....