Skip to content


Just finished pushing a very simple zoom app in GitHub, I couldn’t find a nice script that would allow the image to take up the full size of it’s parent element when zoomed in, and would handle updating the image dynamically.  So I wrote one for myself.

Get the files on GitHub.

See a preview:

Add tracking tokens to WordPress

Just had to do a search and replace to add in tracking tokens site-wide to a wordpress site.  I tried some search & replace plugins, but I found them all a bit buggy, so I opened up PHP My Admin to handle it. I had a list of links so I just ran them all like:

UPDATE wp_posts SET post_content = REPLACE (post_content,'','');

then ran the following, because I knew a few links already had the tracking token added:

UPDATE wp_posts SET post_content = REPLACE (post_content,'?UTM=token?UTM=token','?UTM=token');

And, last but not least I verified that all links where updated by running:

SELECT post_content FROM wp_posts WHERE (CONVERT(`post_content` USING utf8) LIKE '%%' AND CONVERT(`post_content` USING utf8) NOT LIKE '%%UTM%%')

So, I’m basically just checking that every post with that domain also has the token code in it somewhere.

You can be a bit more thorough by using regex, but that should do the trick if you only have a few links to update.

UPDATE 6/2016

I just needed to do a similar task, but I needed to add a tracking token to all links to a domain, so I needed a bit of regex.  This time I found a nice search and replace plugin that supports regex. And I used these commands to first add in the token:

Search pattern: ((<a href="(http://)?(www.)?*?))")
Replace pattern: $1?UTM=token

This will pick up all links, weather they have http or not, and weather they have www. or not.  And again I ran this kind of replace to fix any links that already had tracking added to them:

Search pattern: ?UTM=token?UTM=token
Replace pattern: ?UTM=token

Monitoring & Understanding Server Load

I have a site whose performance could stand some improvement.  I want to be able to make sure that any changes I make are actually having an impact, so I’m going to start with setting up some monitoring tools. I found a very nice and free monitoring application called Load Average. After I got that all set I did a bit of research so I can fully understand and make the most out of the numbers I see in there.


First off, I needed to get a handle on how CPU Load is measured. If you run “cat /proc/loadavg” on a Linux server you will get a string similar to this:

0.02 0.03 0.00 1/437 21084

The first three numbers are the average CPU Load over 1 minutes, 5 minutes, and 15 minutes.

The lower the numbers the better, and the highest it should be is equal to the number of cores you have.  With one core it would be bad if it went over 1, but if you had 8 cores then a value of 1 wouldn’t be a problem, but 8.5 would.  To find out how many cores you have you can run “nproc.”


Check how much memory you’re using by running “free -m.” You’ll get a readout like this:

             total       used       free     shared    buffers     cached
Mem:         11909      10785       1124          1        234       9372
-/+ buffers/cache:       1178      10731
Swap:            0          0          0

The number you want to watch out for here is the used buffer/cache, here it’s “1178.”  That’s the memory that’s being used by the applications currently running on your server.  That number should be less then the total memory + swap memory, here’s that’s “11909.”



HTTPS subdomains

This is pretty much just ripped from this article.  But it took me forever to find a solution, so I’m writing this down!

It is possible to secure a sub-domain without a separate IP or SSL certificate but only if it is a wildcard certificate!  Just Host offers these, but what it doesn’t offer is decent support on the matter 😛

When you make a subdomain, say “”  going to – will be just fine.  But, going to will load up the contents of your default directory (a.k.a. public_html)  So, in order to get that to work you have to force it to point to the right directory using .htacces, like so:

RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{REQUEST_URI} !^/sub-folder/
RewriteRule ^(.*) /sub-folder/$1

iDrive and hidden files

I’ve been trying to backup all my files to iDrive since August >.o It’s about 500GB so I suppose I shouldn’t be too surprised it’s taken forever, and apparently iDrive is slow, but just yesterday I was cleaning up some files and noticed there were some problematic files that haven’t been helping in the backup process. (over 210K of them in fact!) So I took some time and did 4 things to help get my backups rolling.

#1 Delete all .AppleDouble files

I was working on a Mac for a few years, and have some back-ups from them, and after going through the logs I notice a ton of “.AppleDouble” files. Apparently Macs make an AppleDouble of every.single.file. So…there were literally twice as many files to back up. I can just tell iDrive to ignore those files, and I did, but I also wanted to get rid of them all, since I’m no longer on a Mac. So I loaded up the shell from my QNAP, and ran this command:

rm -rf `find -type d -name .AppleDouble`

Which deletes all directories and their contents named “.AppleDouble” under the current directory.

Also, iDrive came up with a few of these odd errors:

#2 Delete all Icon\r files

IOERROR [/share/MD0_DATA/…/Icon], : No such file or directory

I also found about 20 of these odd Icon files, apparently their placeholders so Mac’s can change the icon of the folder. But their names are awkward so iDrive can’t handle them and I can’t delete them normally. They’re actually named “Icon\r” so I had to log into the shell again and run this command in order to delete them all:

rm $’Icon\r’

#3 Stop generating thumbnails

And last, but not least is my QNAP’s fault, by default file manager it generates .@__thumb folders with icons for every single image. Of which I have quite a few. Log in as admin, and you can disable the file generation this way:


That will stop new ones from being created, but not delete all the old ones, you can fire up the shell again and run this command to do that:

rm -rf `find -type d -name .@__thumb`

#4 Upgrade to the latest iDrive

I also noticed that the version of the iDrive app in QNAP’s App Center is out of date, so I grabbed a the latest version here:

The only problem is you have to download the right one for your NAS, but no matter where I looked I couldn’t find what mine is running. I ended up finding out by opening the iDrive in the App Center, I hovered over the download link, and voila!  It has the version right in the file name.  A little backwards to do it, but I couldn’t find the answer anywhere on the QNAP site.

Screenshot (109)