
Dec 30, 2008

Creating an XML document in Python can be accomplished by executing:
from xml.dom import minidom
doc = minidom.Document()
testElem = doc.createElement("test")
testElem.setAttribute('id', '1234')
doc.appendChild(testElem)
print doc.toxml()
The example above creates an XML document, creates a child element, sets an attribute and then appends the child element to the document.
The XML document in the above example looks like:
<?xml version="1.0" ?><test id="1234"/>

Dec 30, 2008

Parsing an XML document in Python is easy. Below is a simple example that loads an XML document from a file, parses and prints:
from xml.dom import minidom
dom = minidom.parse('test.xml')
print dom.toxml()
For more information, see the Python minidom documentation.

Dec 23, 2008
Formatting the date output in bash is simple:
date + "%Y-%m-%d";
An example of assigning to a variable and using:
now=`date + "%Y-%m-%d"`;
cp /etc/hosts ~/hosts_${now};
For more information, see the manual.

Dec 20, 2008

The Amazon Web Services blog has a good post on how to setup an EBS volume using ElasticFox:
Amazon EBS (Elastic Block Store) – Bring Us Your Data
I do not see a way to schedule snapshots through the UI so, you may have to write a script to accomplish this feat.
Once you have created your EBS volume you still have to mount the new device. First add the following line to /etc/fstab:
/dev/YOUR_DEVICE_NAME /data ext3 defaults 0 0
E.g.
/dev/sde /data ext3 defaults 0 0
Next, you need to format the device. This is accomplished by executing:
mkfs.ext3 /dev/YOUR_DEVICE_NAME
E.g.
mkfs.ext3 /dev/sde
This post assumes you are using the ext3 filesystem. Next, you need to mount the device. This is done by issuing:
mount -t ext3 /dev/YOUR_DEVICE_NAME /DIRECTORY_TO_MOUNT_IN
E.g.
mount -t ext3 /dev/sde /data
After you mount the device you should be good to go. If possible, reboot your instance to make sure the process mounted properly on a restart.

Dec 19, 2008

If you are looking for a simple GUI for Amazon’s S3 servcie, there is a pretty good (free) browser plugin product available for Firefox:
S3 Firefox Organizer
Warning: The author of the product states very clearly that he is not responsible for deleted files. He also mentions that he may not continue to maintain the application. Of course, you can still access your files in S3 with another client if he decides to stop working on this free app.

Dec 13, 2008

Below is a handy reference link about BDB JE (Berkeley Database Java Edition) locks, blocks and transactions:
After running some tests, we were amazed by the performance of the concurrent locking mechanism in BDB JE.

Dec 9, 2008

Updating a block of rows in MySQL can be accompished by using the “limit” function:
update TABLE_NAME set COLUMN_NAME=VALUE limit MAX;
E.g.
update products set state=false limit 10;

Dec 3, 2008

Rebuilding an InnoDB table index is easy in MySQL 5.0. Simply type:
mysql> ALTER TABLE table_name ENGINE=InnoDB;
Warning: When dealing with large databases, this can place a lot of load on your DB.