Keep XML-RPC enabled under Maintenance

Standard

If you usually work with WordPress, you should know what a maintenance plugin is.

Well, under maintenance mode, each request will get the same answer: an under-maintenance landing page.

Of course, if you’re working with XML-RPC this could be annoying, so I implemented a trick for the dpMaintenance Lite plugin:

Edit wp-content/plugins/dpMaintentanceLite/dpMaintenanceLite.php rewriting the dpMaintenance_initial_run function at line 26 this way:

function dpMaintenance_initial_run () {
	global $dpMaintenance;
	if ($dpMaintenance['active']) {
		if ($_SERVER['REQUEST_URI'] == '/xmlrpc.php')
			return;
	
		// keep xmlrpc enabled
		dpMaintenance_activate();
	}
}

Leave a comment for other maintenance-plugins implementations.

Build V8 Javascript Engine under Ubuntu

Standard

Remember that this method (using scons) is deprecated. Btw, go ahead to get instructions.

#######################################################
# WARNING: Building V8 with SCons is deprecated and   #
# will not work much longer. Please switch to using   #
# the GYP-based build now. Instructions are at        #
# http://code.google.com/p/v8/wiki/BuildingWithGYP.   #
#######################################################

Instructions:

# install dependencies
sudo apt-get install libc6-dev-i386 subversion scons libreadline-dev

# sync svn
svn co http://v8.googlecode.com/svn/trunk v8
cd v8/

# run scons, adding option arch=x64 only for x64 architectures
scons console=readline d8

# compile shell
g++ ./samples/shell.cc -o v8-shell -I include libv8.a -lpthread

# be happy
./v8-shell

Unlock /var/lib/dpkg/lock when you’re locked out

Standard

You must have seen this (that’s why you’re here after all!)

E: Could not get lock /var/lib/dpkg/lock - open (11 Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

This often happens if you try to install a package (say, ) while you are installing another. As an example, this may happen when you try to run
$ sudo aptitude install in the terminal while you have Synaptic package manager open (or vice versa) or in another terminal you are installing another package . The easiest solution is just to wait for the other installation(s) to finish and close the package manager if you are done with it. However, if the package manager is crashed in the middle some stuck-up processes may still be using the lock (/var/lib/dpkg/lock).

In that case, use fuser to find out the runaway process(es); and while you’re at it, you may use -k flag which will kill the process that is still using /var/lib/dpkg/lock. Then configure (–configure) all the packages (-a) which are yet unpacked and unconfigured, using dpkg:

$ sudo fuser -vki /var/lib/dpkg/lock; sudo dpkg --configure -a

In the first command (fuser), the -i flag asks for user confirmation, and -v is for verbose mode.

After that, proceed to the usual installation step of the package that you want to install.

from: http://nixtricks.wordpress.com/2009/10/02/ubuntu-unlock-varlibdpkglock-when-youre-locked-out/

PHP tricky comments

Standard

There are few examples about what a mind-fucked developer can produces with some pieces of code, mind about 140byt.es, 1kjs and so on.

That’s true, they are so crazy, but what a mind-fucked can produce about comments in php? A piece of code like this, for example:

PHP tricky comments

<?
//*
$instance->doSomething ();
/*/
$instance->doSomethingElse ();
/**/

It’s easy, tricky, lazy.. imho totally awesome.
It’s from a cool developer also known as _lamemind. He rocks.

Leave it as is, and the first piece of code is active instead of the second one, but try to remove the first slash and look! The first piece will be disabled instead of the second one.

Feel free to love it,
M.