How To

How-to's and tutorials: Here we explain how to use the technology we employ at Adlibre.

OS X won't sleep on power

Today I came across an issue where a Mac running OS X wouldn't sleep on power, but would sleep fine when on battery. The root cause was a stuck print job in the printer queue. Read on for instructions on how to troubleshoot power and sleep issues on OS X.

In OS X the pmset -g assertions command gives you a summary of the power management assertions in affect.

bob@mymac:~$ pmset -g assertions
22/04/12 12:13:18 PM AE 
Assertion status system-wide:
   ChargeInhibit                           0
   PreventUserIdleDisplaySleep             0
   PreventUserIdleSystemSleep              0
   NoRealPowerSources_debug                0
   CPUBoundAssertion                       0
   EnableIdleSleep                         1
   PreventSystemSleep                      1 ...

— Andrew

Automatically print a PDF generated with ReportLab using JavaScript

It seems everyone is asking how to embed JavaScript in a PDF created with ReportLab.

Google also use this PDF feature to allow for printing of proprietary office documents from their Gmail service. Google's method is somewhat different and they bind the JavaScript to the first object in the document and trigger it by referencing it with the Names entity as shown below.

1 0 obj
2 0 obj
<</Names[(0000000000000000) 1 0 R]>>
3 0 obj

I was not able to use the ...

— Andrew

How to resize a VMDK using Qemu tools

It is possible to resize a VMware .VMDK file without using the VMware tools.

The QEMU disk image utility comes with qemu-img a tool which allows you to convert virtual disk formats.

To resize a VMDK using qemu-img

# First convert the vmdk to raw format
# NB. Make sure you reference the actual disk image and not the .vmdk descriptor file
qemu-img convert linux-flat.vmdk linux.raw

# Extend the vmdk using dd. 
# Here we are extending the disk to 16G using dd. The resulting file will be sparse
dd if=./linux.raw of=./linux-16G.raw BS=1M seek=16384 oflag=append ...

— Andrew

Extracting all the links from a website using wget

Today I found myself needing to extract all the page links from a website to ensure that when we restructured the site, all the old links were redirected to the new page locations and there we no nasty 404's.

So here I present, my "Quick and dirty website link extractor". Complete with gratuitous command piping, ready to run on any Linux box with the appropriate programs installed:

MYSITE='';wget -nv -r --spider $MYSITE 2>&1 | egrep ' URL:' | awk '{print $3}' | sed "s@URL:${MYSITE}@@g"

Obviously you'll need to replace with your own ...

— Andrew

How to install and setup a Python Django development environment on Windows 7

Step 1: Install Cygwin & Python

To get started we need to setup a Python environment running under Cygwin. First make your way over to and run their installer.

Most of the installation is just clicking next, and accepting the defaults:

Cygwin Python Installation 1

Click next:

Cygwin Python Installation 2

Click next:

Cygwin Python Installation 3

Click next:

Cygwin Python Installation 4

Click next:

Cygwin Python Installation 5

Choose your closest Mirror. We like Internode!

Cygwin Python Installation 6

This is where we stop clicking next and select our packages.

Select Python:

Cygwin Python Django Installation - Package Selection 1

We'll probably need to install a Subversion client, so also select that:

Cygwin Python Django Installation - Package Selection 2

wget will make installing the Django stuff easier:

Cygwin Python Django Installation - Package Selection 3

gcc and gcc++ will be needed later to compile ...

— Andrew

How to Install WordPress on CentOS 5 in five minutes flat

Ok, so you need to install WordPress on a CentOS or Red Hat server, and the boss has only given you five minutes, then read on because here you can do it in less...

This how to assumes that you have a clean installed CentOS 5 or Red Hat server, but it will probably work just fine with Fedora as well. If you already have MySQL or Apache installed then you might need to make provisions for the existing setup to avoid any conflict.

So without further waffle, here it is. Fire up a root shell and continue:

Install the ...

— Andrew

How to Install Drupal on CentOS 5 in five minutes flat

Ok so you're in a hurry to install Drupal. Don't fret. It is esay as pie!

Run the following commands from a root shell!

yum -y install mysql-server httpd php php-mysql unzip wget

chkconfig httpd on
chkconfig mysqld on

/etc/init.d/mysqld start
/etc/init.d/httpd start

echo 'CREATE DATABASE drupal;' | mysql
echo "GRANT ALL PRIVILEGES ON drupal.* TO 'drupal'@'localhost' IDENTIFIED BY 'drupal';" | mysql
echo "FLUSH PRIVILEGES;" | mysql

cd /var/www/html/
tar -xzf drupal-6.16.tar.gz --strip-components=1
rm drupal-6.16.tar ...

— Andrew

How to install Django-CMS on CentOS 5.4 with Python 2.6

The other day I was playing around with Django CMS and battling to get it installed on CentOS 5.4. I thought I'd put these notes together in the hope that someone might find them useful. NB. These instructions are not 100% polished, but should be sufficient to get you up and running.

This will install Django 1.1.1 and Python 2.6 on CentOS 5.4, using Apache and mod_python!

Special thanks to fink from #django-cms on for his patience and advice, and the other bloggers around the globe that have written useful articles ...

— Andrew

How to Configure Eaton Ellipse ASR UPS with CentOS 5

Here's a quick post showing how to configure and setup an Eaton Ellipse ASR 1500 UPS with CentOS 5 using NUT in about 5 minutes flat!

Firstly install NUT. To do that we'll need to install Fedora EPEL.

# rpm -Uvh

Then we install NUT.

# yum install nut
# chkconfig ups on

Add the following to /etc/ups/ups.conf.

    driver = usbhid-ups
    port = auto
    desc = "Eaton Ellipse ASR 1500"

Add a UPS user to /etc/ups/upsd.users. Please change your password to something sensible.

            password ...

— Andrew

How to Virtualize Windows 2008 SBS with Xen on CentOS 5

Installing Windows SBS 2008 as a Xen Fully Virtualized guest using the XEN hypervisor on CentOS 5 is fairly straight forward.


Starting off we need a CentOS 5 server with at least 4GB of free RAM and enough hard disk space to support SBS. The processors must support x86 Virtualization either Intel VT or AMD V. Virtualization must also be enabled in the system BIOS. If you server supports Hyper-threading you may want to turn it off, as this might improve performance with a Windows 2008 VM. The Xen hypervisor presents the individual hyper-threaded cores as physical cores to ...

— Andrew

Page 1 of 2 1 2 »

Site theme originally by