Compdigitec Labs

(X)HTML

Fixing “Error: window.location.refresh is not a function”

Friday, July 23rd, 2010

If when you try to refresh the page using Javascript back-end and instead of having the page refresh like you want it to refresh, instead it bounces back into your Javascript Console with a cryptic error that reads “Error: window.location.refresh is not a function“. This can be very puzzling, especially if you are not a [...]

XHTML-compliant way to embed Macromedia Flash

Friday, April 30th, 2010

For many years, people have been using complicated, ugly ways to forcibly embed their Macromedia Flash content into their webpages. There have been several ways, usually using the non-standard <embed> element or other fancy IE-only <object> hacks. But now, we have a safe, bug-free, validator-safe way to embed Flash that passes the HTML 5 and [...]

Free and open source XML beautifers to format XML

Saturday, December 26th, 2009

XML is a great format for storing data, but an improperly-formatted XML file (e.g. whole file on one line, unusual breaking, improper line wrap, etc) can be just as difficult to read as a binary blob. In order to make “blob” XML readable, here are some tools you can use to format XML so it’s [...]

Disable WordPress conversion of double-dashes in posts

Friday, July 24th, 2009

Update (2009-08-16): Updated for WordPress 2.8.3.
If you use WordPress (like this blog and many hundreds and thousands of blogs) for your blogging engine and you attempt to post code or programming related posts, you may find that WordPress will mess up your code. This was pointed out to us by a commenter on the aforementioned [...]

Using (X)HTML entities in plain XML files

Tuesday, July 14th, 2009

Update (2009-07-28): Here is a place that you can find accents for English characters.
If you try to use non-ASCII characters (e.g. accents) in directly in a Windows-1252 (ISO-8859-1) encoded web page directly without converting/transforming them into an entity, the web browser may get confused when the header of the web page is sent wrong or [...]

Removing WordPress post revisions feature

Friday, March 13th, 2009

WordPress 2.6 and above’s new feature of post revisions only slows WordPress down and makes it less usable. So here is how to disable post revisions:

Open wp-config.php in your wordpress installation directory with a text editor.
Add the line “define(‘WP_POST_REVISIONS’, false);” anywhere in the file in a new line after the <?php header.
Save it and upload [...]

Simple Template Engine – your lightweight templating engine in PHP

Monday, February 2nd, 2009

The Simple Template Engine is a very lightweight template engine to use in PHP if your webhost does not allow you to run something like Smarty. It is simple, lightweight and fast.
To parse a file:
<?php

// include simple template engine
include("tpl.class.php");

$tpl = new template();

$tpl->assign(Array(‘content’=>"Hello World from Simple Template Engine!"));

// If you want to display it directly
$tpl->display(‘example.tpl’);

// If [...]

Enabling and in MediaWiki

Sunday, September 14th, 2008

If you have a MediaWiki installation and decide to make it Wikipedia-like, you will find that the <ref> tags and the <references /> tags don’t work like they do in Wikipedia. Below is a screenshot of the citation tags not working:

To fix this problem, you need to install the Cite extenstion for MediaWiki. Below is [...]

SimpleXML – solution for XML manipulation in PHP

Sunday, September 7th, 2008

If you ever do get the need to manipulate (read/write) XML, you could try using the PHP DOM API, but it’s very difficult to use the DOM. An good extension-less way to access and manipulate XML instead is SimpleXML. It’s very easy to use compared to DOM and features a easy way to access attributes [...]