June 11th, 2008 at 11:03 am

Shell script to optimize all tables in all databases (MySQL)

If you have many databases with many write operations, it may be that the table overhead takes a good amount of space. (This is due to the fact that MySQL doesn’t free the space of deleted entries.) With “optimizing” the tables, you can free that space.

Save the following script as /usr/local/sbin/optimizealltables.sh, make it chmod 700 (very important!), then replace YOURPASSWORD with your root MySQL password.

#!/bin/bash
 
MYSQL_LOGIN='-u root --password=YOURPASSWORD'
 
for db in $(echo "SHOW DATABASES;" | mysql $MYSQL_LOGIN | grep -v -e "Database" -e "information_schema")
do
        TABLES=$(echo "USE $db; SHOW TABLES;" | mysql $MYSQL_LOGIN |  grep -v Tables_in_)
        echo "Switching to database $db"
        for table in $TABLES
        do
                echo -n " * Optimizing table $table ... "
                echo "USE $db; OPTIMIZE TABLE $table" | mysql $MYSQL_LOGIN  >/dev/null
                echo "done."
        done
done
May 7th, 2008 at 10:57 pm

Donations Clouds 0.1.1

[lang_de]Das WordPress-Plugin Donations Clouds ist in der Version 0.1.1 verfügbar, die einige kleine Fehler behebt und das Plugin Widget-fähig macht.[/lang_de][lang_en]The WordPress plugin Donations Clouds is available in version 0.1.1 which fixes some minor bugs and adds widgets capability to the plugin.[/lang_en]

April 17th, 2008 at 2:48 pm

Donations Clouds

Your website has cool stuff and encourages people to donate for it, but nobody ever gives a penny? Give them something that they get only for a donation, e.g. a link on your website. However, maintaining a link list is tedious, and it’s not really appealing. Therefore, we are proud to present the donations cloud (similar to a tag cloud) concept along with an easy to use WordPress plugin. Read on to learn how you really get some donations, and how to go about it with your WordPress blog.

April 16th, 2008 at 11:20 am

Clear a sized select field

If you have have a select form element with a size attribute, one common option for the user is to leave it empty (especially in combination with multiple). The problem is, as soon as one or more options are selected, it is quite impossible in most browsers, to not select anything at all. And even if there is a way, it is not easy to accomplish. Try for yourself to deselect all items:

With a little JavaScript magic, we can offer a button to clear the select field:

function nl_clear_select(element)
{
	var opt_length = document.getElementById(element).options.length;
	for (var i = 0; i < opt_length; i++)
		document.getElementById(element).options[i].selected = false;
}

Now try again to clear the select field. Hint: clicking on "Clear selection" will help a lot. ;)

Clear selection

Neat, eh?

April 10th, 2008 at 12:14 pm

Get radio button value in JavaScript

Here’s how to get the currently checked value of radio button section. The parameter elementName is the name attribute of the radio input.

function getRadioValue(elementName)
{
	var i, element = document.getElementsByName(elementName);
 
	for (i = 0; i < element.length; i++)
		if (element[i].checked == true)
			return element[i].value;
}
April 3rd, 2008 at 12:06 pm

Calculate interest rates with a shell script

If you put your cash to a bank account, you will want to know how much money you get with a certain amount at a given rate within a given period. Save the following Bash script as /usr/local/bin/loancalc (or something like that), make it executable, and you will be able to calculate the return on your investments with a single one-liner.

#!/bin/bash
 
function calc()
{
	return $(echo "scale=$2; $1" | bc)
}
 
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
	echo "$0 calculates the interest loan of a given amount with a given rate for a given duration."
	echo "Usage: $0 AMOUNT RATE DURATION"
	exit 0
fi
 
if [ -z "$3" ]; then
	echo "Please enter the amount, the rate and the duration (in this order)."
	exit 1
fi
 
AMOUNT=$1
ZINS=$2
DURATION=$3
 
echo "Investment: $AMOUNT bucks at a rate of $ZINS% for $DURATION years."
echo "          Loan            Total"
 
for i in $(seq 1 $DURATION); do
	INTERESTLOAN=$(echo "scale=10; ($AMOUNT/100)*$ZINS" | bc)
	AMOUNT=$(echo "scale=10; $AMOUNT+$INTERESTLOAN" | bc)
	printf "Year ${i} %8.2f " $INTERESTLOAN; printf " %14.2f\n" $AMOUNT;
done
 
printf "Final amount: %1.2f bucks.\n" $AMOUNT

For example:

you@yourmachine ~ $ loancalc 3000 3.5 5
Investment: 3000 bucks at a rate of 3.5% for 5 years.
          Loan            Total
Year 1   105.00         3105.00
Year 2   108.68         3213.68
Year 3   112.48         3326.15
Year 4   116.42         3442.57
Year 5   120.49         3563.06
Final amount: 3563.06 bucks.
March 19th, 2008 at 1:24 pm

Polyglot editor integration in 5 minutes

Polyglot is a great WordPress plugin by Martin Chlupac, which allows WordPress users to offer multilanguage versions of virtually any content. (I’m using it on this website, too.)

Unfortunately, Polyglot lacks a quite important feature: A proper integration into the WordPress editors, i.e. TinyMCE and Quicktags (The buttons above the editor which you see when WYSIWYG is deactivated). I’m certainly not the first to notice this problem, but I might have been the first to create a proper solution. :mrgreen:

Here you have it, code and documentation in a little package:

polyglot_editor_integration.zip
polyglot_editor_integration.tar.gz

(Follow the instructions in the file HOWTO. Note that the TinyMCE integration is based on TinyMCE 3, hence it requires WordPress 2.5 or higher. If there is enough request, I might also create a TinyMCE 2 solution.)

Integrate Polyglot with your WordPress editors. It’s just a matter of 5 minutes!

March 6th, 2008 at 12:21 am

Have fun with WordPress SVN

Many people would like to try the very latest WordPress developments, which are usually available via the WordPress SVN server. But not everybody is able to use SVN, and of course nobody will bother to scrape the files together via the the web SVN interface.

So I’ve set up a little script on this server that will create a package of the latest SVN code once an hour and make it available for download. The files will be found under the following URLs:

http://www.zirona.com/download/wpsvn/wpsvn.zip
http://www.zirona.com/download/wpsvn/wpsvn.tar.gz
http://www.zirona.com/download/wpsvn/md5sums
http://www.zirona.com/download/wpsvn/current_revision

The packages are to be installed just as a regular WordPress package. You can also use it to upgrade an existing WP installation; note however that it’s not recommended to run development code on production sites.

You can download the script itself, too:
http://zirona.com/download/wpsvn/wpsvn.sh

Enjoy!

Btw, if you just want to see the latest WP without installing it, you can view the development version (especially the admin area) at Chris Johnston’s test site.

P.S. (06.03.2008, 15:40 CET): I just learnt that you can download a trunk snapshot from WP Trac directly. Therefore, this service appears a bit needless now. Anyway, I’m keeping it online; it doesn’t hurt me or my server, and maybe it serves a purpose for somebody.

February 12th, 2008 at 7:50 pm

InstantUpgrade video

How cool is that! Jim from The Kaizen Business has created a screencast of a WordPress upgrade with the InstantUpgrade plugin and posted it on YouTube. Enjoy! :)

February 11th, 2008 at 12:38 am

InstantUpgrade: 1.0 beta

Changelog for this page:

  • 14.02.08, 00:16 CET: beta2 uploaded, download links updated.
  • 15.02.08, 22:07 CET: 1.0 beta2 has now been put on the official Instant Upgrade page, v0.2 has been moved. This page is now obsolete.
  • 16.02.08, 10:44 CET: Moved the comments to the new page, too.

The popular InstantUpgrade plugin has become one of the most popular WordPress plugins — even though it is not too easy to use. The next version of InstantUpgrade will hopefully be as popular as the current one, but it is much easier to use!

How come? InstantUpgrade does now offer the possibilty to transfer files via FTP, with the blog owner’s FTP account data. So, you do no longer have to make all WordPress files writable, and you don’t need a chmod procedure once you want to get rid of the plugin. Simply insert the FTP account data, and you are ready to upgrade.

Attention: This version of the plugin is a beta release. If you want to play safe, please use the older, but extensively tested version. This beta release is for experienced users!


Installation

Please note: Upgrading a web application is a critical task. Of course we did our best to create a stable and careful software. Still, please be sure to have working backups. If you encounter problems with this beta version, leave a comment on this page.

Download

Please consider coming back for a donation. You’ll support our efforts and receive a backlink.

Have problems unpacking archives? Try the latest 7zip.

  • Download it.
  • Unpack it and upload it into your WordPress plugins folder.
  • Activate the plugin in your admin panel.
  • Go to Options » InstantUpgrade and pick an upgrade method. FTP is usually recommended.
  • For FTP: Enter your FTP account data.
  • For HTTP: You will very likely have to make lots of files writable. Follow the instructions.

As soon as the plugin is installed and the configuration is done, you can go to Manage » InstantUpgrade and perform the actual upgrades.

Please: If you use this beta release, come back and tell us if you were successful, and if not, what errors you encountered. Thank you.