Extended Live Archives and WordPress 3.0

The Extended Live Archives Plugin does not work with WordPress 3.0, opposed to the plugin page. I still like this plugin as seen here, so here is my solution:

  • Download the archive
  • Open includes/af-extended-live-archive.js.php and includes/af-ela.php in your favorite editor
  • Replace in both files
    require('../../../../wp-blog-header.php');

    with

    require_once('../../../../wp-config.php'); 		
    $wp_did_header = true;
    $wp->init();

    and you’re good to go.

If anyone has a better idea, please write a comment.

| Comments (1) »

21-Jun-10


Using SQL*Plus without tnsnames.ora

As often, a quick reminder for me. I’m using the Oracle Instaclient on my Mac without a tnsnames.ora and i keep forgetting the connectstring syntax:

sqlplus USER/PASS@//HOST:PORT/SID

Extra bonus points: Through in rlwrap to get a nice commandline history and completion as used to in a standard shell:

rlwrap sqlplus USER/PASS@//HOST:PORT/SID

| Comments (0) »

29-Mar-10


Linux: Persistent wake-on-lan

Just a quick reminder for myself: You need to enable wake-on-lan on the nic in most linux distributions via ethtool.

If your nic supports WOL, it probably needs to be enabled in your computers BIOS first.

Most WOL tools use the “MagicPacket(tm)” method, so the right command to enable it on the nic “eth0” would be

ethtool -s eth0 wol g

This is not a persistent setting and it is gone after a reboot. Most tips around recommend creating a runlevel script for executing this command after boot or before shutdown.

I’ve added the command as a hook in my network scripts:

auto eth0
iface eth0 inet dhcp
        pre-down ethtool -s eth0 wol g

You can also use post-up. I like this method because i tend to forget about my runlevel scripts and so i keep the network stuff in one place 😉

If you are a debian user, you maybe need to stop your system from turning off the nic on HALT. To do so, add

NETDOWN=no

to “/etc/default/halt”.

| Comments (2) »

03-Mar-10


Oracle: Drop table if exists replacement

Mysql has a nice “if exists” addition to the drop table statement. If the table to be dropped does not exists, it doesn’t raise an exception but only creates a warning.

In Oracle RDMBS you can emulate this behavior like so:

BEGIN EXECUTE immediate 'drop table INSERT_TABLE_NAME_HERE'; EXCEPTION WHEN others THEN IF SQLCODE != -942 THEN RAISE; END IF; END;
/

Ugly, but it works very well.

| Comments (0) »

16-Feb-10


An iterable array

Java has the nice Iterable interface (since Java 5, i guess) that allows object oriented loops like

List<String> strings = new ArrayList<String>();
for(String string : strings) 
	System.out.println(string);

but guess what, a simple array is not iterable…

In case you need one, feel free to use this one:

package ac.simons;
 
import java.util.Iterator;
 
public class IterableArray<T> implements Iterable<T> {
	private class ArrayIteratorImpl implements Iterator<T> {
		private int position = 0;
		@Override
		public boolean hasNext() {
			return data != null && this.position < data.length;
		}
 
		@Override
		public T next() {
			return data[position++];
		}
 
		@Override
		public void remove() {
			throw new UnsupportedOperationException();
		}		
	}
 
	private final T[] data;
 
	public IterableArray(T[] data) {
		this.data = data;
	}
 
	@Override
	public Iterator<T> iterator() {
		return new ArrayIteratorImpl();
	}	
}

| Comments (0) »

12-Jan-10