Page 1 of 2

Working with Cookies in JavaScript

Working with Cookies in JavaScript
0

For those of you working with JavaScript, and the ability to store some data on the client side (browser) with the help of Cookies; here a short description what cookies are, what kinds there are, and how to work with them.

Since I rarely use it, I keep forgetting the details, so I figured; well, put it on my website so I can find it again when I need it in the future and maybe others will benefit from this as well.

It really is an easy process, and I’m honestly surprised that JavaScript and jQuery do not offer some simple functions for this right out of the box. For jQuery several cookie plugins can be found – just too bad it’s not right away included.

Chmod Calculator – Set file permission with chmod

Chmod Calculator – Set file permission with chmod
0

For most of us, working in Linux or in a shell is not necessarily a daily activity, and that’s totally OK.
I’m not daily working with it either, but occasionally I use one of those funny commands to set the access rights to certain files and/or directories.

This command, chmod, is not super complicated to work with, and is commonly used when working in a shell or terminal on both the MacOS X and Linux platforms. But we need a “magci number” to set these rights. The “magic number” for chmod is also commonly used with FTP programs.

Whenever I use this command, I need to refresh my mind on how to calculate the “magic number”, and I find myself looking for a chmod calculator.
Since I’m lazy at times, I figured: why not have one on my own website?

So I started playing with JavaScript and created this chmod calculator.

WordPress – Copy & Paste with link back to your website

WordPress – Copy & Paste with link back to your website
0

For those of you writing articles or blog posts, you’ll find that it takes a lot of work to write a good article. Even a tiny post can take up a lot of time.

And what is the most annoying part? Folks just bluntly copying your work, without even asking or giving credit (there are a very few exceptions). It seems that the majority on the Internet is replicated that way. Copy, and Paste.

For WordPress users (and if you only take out the JavaScript part, this might work for others as well) can, with a little trick, automatically add a “source” link below what has been copied. Not only will this be a reminder for the “copier”, but (if left intact) a good way to boost SEO for your website.

WordPress – Quick and Easy Ad Widget (sidebar)

WordPress – Quick and Easy Ad Widget (sidebar)
0

Wouldn’t it be nice to have a widget to place an advertisement, for example from Google Adsense, into the sidebar of your WordPress website?

After all; the layout of your sidebar(s) could be managed from the WordPress admin pages, and allows you to place ads in the sidebar where and as many times as you see fit.

There are probably plenty plugins for this, but I dislike plugins.
So here the simple code for the “functions.php” that creates your own WordPress Ad Widget.

WordPress – Inject Ads into your Posts

WordPress – Inject Ads into your Posts
0

Unfortunately, when running a website, some kind of income is needed to cover the hosting expenses. Often this is done by placing ads.
Like most other websites, even Tweaking4All has to resort to placing ads, although I’d rather have zero adds, but donations alone isn’t covering the costs.

The downside of ads, besides being annoying at times, is that they only generate revenue when placed strategically, so folks will click on them (hint!).

Now, I will not claim to be the right person to ask where you should place ads, but in my opinion there are 3 reasonably “good” locations.
At the beginning and end of an article, and … in the smack middle of an article.

In this article, I’ll show you how you can automatically have an ad placed in your content, on the fly. With this code you can place an ad just before the nth <H2> tag. We will not use a plugin, and the code is simply added to the “functions.php” file of your theme.

MacOS X – How to take Screenshots and add Annotations

MacOS X – How to take Screenshots and add Annotations
2

I’ve been asked several times in the past, on how to take screenshot and annotate them afterwards, or how to do a so called “print-screen” to a printer for a hardcopy.

Some users, use screenshots for illustrating manuals, or articles for their website. Some use it to print error messages or odd things happening on their screen. And as with regular paper, some of us would like to annotate the images – add notes, comments, arrows, numbers or circle the important part of the image.

Annotating images is relatively easy, once you know where to find the tools to do this.

So in this article, for Mac OS X users: How to take screenshots, how to add annotations, and some additional related tips and tricks.

WordPress – Preserve Backslash in Posts

WordPress – Preserve Backslash in Posts
0

Preserve backslashes in WordPress brings us to one of the annoying features of WordPress: it strips backslashes.
It has it’s place an reason of course, but it can be a PITA when you’re trying to post code examples.

In this very short article, I’ll show you how to preserve your backslashes with a very small function which replaces each backslash with an HTML entity, which should make it safe to work with in your database and not loose the backslash. Even my code highlighter does not seem to be bothered by it and displays the code correctly (ie. not showing the HTML entity, but rather show the desired backslash).

Note that manually entering the HTML entity in the HTML code of your article (Text view) works only once! When loaded again in the tinyMCE editor, the HTML entity will be converted to a backslash again and posting an update would remove that backslash again. This function prevents the loss of the backslash by doing it’s work each time you save your work.

Retrieve Google and AWIS Alexa Page Rank for WordPress

Retrieve Google and AWIS Alexa Page Rank for WordPress
2

For whatever reason you can think of, for the fun of it, or to show off how well your website is doing; displaying the Google pagerank and/or the Alexa ranking of your website is kind-a nice to have. This article is an updated version of a previous article I wrote, but since the Alexa link no longer works, the official (free up to 1,000 queries a month) Amazon AWIS API needs to be used and we won’t be exceeding the 1,000 free queries per month with this method.

I have seen several useful PHP scripts that can help with that, but they all kind-a rely on the fact that a page is being loaded, and while loading the Google Rank and Alexa Rank are begin retrieved, over an over again. This is not only causing an unneeded load on the Google and Alexa servers, but it’s also slowing down the loading of your website (even though it might not be noticeable by the end-user).

Both Google Rank and Alexa do not refresh multiple times per day, so a once a day refresh would be good enough.
In this article I’ll show you how I have implemented this in WordPress.

P.s. for those who’d like to see this as a video training, Webucator was kind enough to make this article available as a video as well, you can find it at the end of this article.

WordPress – Mod_security problems with posts and comments fixed

WordPress – Mod_security problems with posts and comments fixed
6

In the world of WordPress, this situation does not seem uncommon;

A user posts a comment, and instead of actually posting the comment, gets redirected to the main page of your website. Not just annoying for webmasters, but a very unpleasant experience for visitors that like to actively contribute.

Quite often, with WordPress, this is caused by a false-positive being triggered by mod_security.

In this short article, I’ll show you what might be causing this issue, how to identify it, and how we can fix it.

WordPress – Auto Chapter Anchors and Overview

WordPress – Auto Chapter Anchors and Overview
2

This is one of those funny little things you run into when writing a longer post or article.
You’d like to present an overview in the beginning of that particular WordPress post, so users have the ability to see at a glance what to expect and, if needed, quickly jump to the location where they’d like to be.

Things get even crazier when you have a topic, say a course of some sorts, that covers multiple posts, where you would still like to show the user where to find what in a content overview of the entire “course” or group of articles. I’ve grouped them in this case in a dedicated category …

If you’ve ran into something like this before, then you’ll know the cumbersome experience of keeping everything correct and nicely ordered.

Since this seems a good task for a computer to solve, I figured; why not write some code that does this for me (yes, I know there re plugins that do something similar, but not quite to my licking). Before I knew it, this got quite out of hand and I created some code for using a WordPress shortcode in my posts for just this purpose.

Retrieve Google and Alexa Page Rank for WordPress

Retrieve Google and Alexa Page Rank for WordPress
9

For whatever reason you can think of, for the fun of it, or to show off how well your website is doing; displaying the Google pagerank and/or the Alexa ranking of your website is kind-a nice to have.

I have seen several useful PHP scripts that can help with that, but they all kind-a rely on the fact that a page is being loaded, and while loading the Google Rank and Alexa Rank are begin retrieved, over an over again. This is not only causing an unneeded load on the Google and Alexa servers, but it’s also slowing down the loading of your website (even though it might not be noticeable by the end-user).

Both Google Rank and Alexa do not refresh multiple times per day, so a once a day refresh would be good enough.
In this article I’ll show you how I have implemented this in WordPress.

Automatic MySQL backup by using Replication

Automatic MySQL backup by using Replication
11

The past few days I have been working on setting up a second QNAP NAS as a backup for my files on my primary QNAP, using realtime syncing – which works ridiculously smooth. I have some MySQL databases on my primary QNAP as well, but syncing the data doesn’t seem to be part of the plan of the backup tools provided by QNAP.

Lucky me: MySQL has a great replication mechanism build in, so you can replicate one database (master) to another (slave). The setup is easy, albeit confusing when you just start looking into this. Synchronisation is done asynchronous, meaning: changes in the data on the master will be applied to the data on the slave, but the slave doesn’t need to be permanently connected. Missed changes, when not connected, will be “saved” and when a connection is established again, will be applied.

In this article I’ll show you how to do this for two MySQL setups (QNAP), where one serves as Master (Original) and the other as Slave (Backup).

MySQL Export and Import Data: How to backup databases

MySQL Export and Import Data: How to backup databases
2

MySQL is one of the most commonly used database engines, not just because it’s free but mostly because it’s fast, reliable and widely supported. That doesn’t mean you should not make backups …

Backups of your MySQL setup can be needed for several reason. You want a backup for safe keeping, you want to move a database to another server, just before you make some major changes, or you just want to wipe your server clean and setup everything from scratch without loosing your data.

Making a one time backup of your database(s) can be a bit unclear, so in this article a description of 3 possible methods to make a backup of one or more databases and how to import them at a later time (to the same or another MySQL server).

WordPress – Increase Maximum Upload Size for Media Library File

WordPress – Increase Maximum Upload Size for Media Library File
0

My latest issue with WordPress has been the limited maximum Media Library Upload Size when I tried uploading a few videos for an Arduino article.

In this article I’ll show you several methods to increase the Maximum Upload Size for the WordPress Media Library, either by modifying php.ini, functions.php or the .htaccess file. WordPress MU/Multisite/MS use will be addressed as well.

WordPress – Open links in comments in a new Window or Tab

WordPress – Open links in comments in a new Window or Tab
0

WordPress is a great Content Management System, not just for bloggers …

One of the downsides I have run into is that links in comments automatically get reformatted and the HTML “target=_blank” gets stripped away so a link in a comment will always open in the same window as you website. Personally I prefer such a link to open in a new window …

So in this article a simple piece of code to make links in WordPress comments automatically open in a new window or a new tab by automatically adding “target=_blank” to links in comments.

1 2