Thursday, September 22, 2011

Add Author Information into Word Document

This trick shows you how to add some additional information to a Microsoft Word document. The information can be the name of the author, company, title, revision number, etc... When you open the folder which contains your document, and point the mouse to the document, the information will be displayed.

Here's a sample

Here's how

  1. Open the folder that contains the document.
  2. Right-click on the document and select "Properties".
  3. On the "Properties" dialog, select the "Summary" tab.
  4. Under the "Summary" tab, the fields are listed by two columns "Property" on the left and "Value" on the right.



  5. Click on a field (i.e. "title") you want to edit, then edit its value. Then click "OK"

Find Product Key for Windows and Office

If you are looking for a way to retrieve the product keys of your MS Windows or MS Office, you are on the right page!
The following is a tool to detect the product keys of Microsoft Windows and Microsoft Office installed on your machine. This tool is free to download at Magical Jelly Bean.
Here's a screenshot


The tool also provides some nice features let you change your Windows product key, or detect the key remotely to another computer.

To download a copy of this tool. Click Here.

Convert Any Document or Web Page to PDF

Somebody just told you that you need to have Adobe Acrobat (Writer) to create a PDF file? Guess what, you can get away from that pricey piece of software if you just need to convert some documents to pdf, without a need of fancy editing the pdf document.
Here's how. Thanks to the BullZip, who provides a Free Pdf printer. With this free tool, you can simply "print out" your document or webpage to a pdf file, just about the same way as you print it out to a printer.

You can visit BullZip.com for more information about the software.
Here the direct link to BullZip downloads page: Downloads
  1. To get started, first follow the link above and download Free Pdf Printer from BullZip, then install it to your computer.
  2. Once you're done, you might need to close the program (or the web browser) which you're currently viewing the document. This helps refreshing the list of available printers on your computer.
  3. Once you get back to the document you want to convert, perform the same steps are you print out the document, i.e. File > Print ...
  4. When you see the Print window pop-up, select "Bullzip PDF Printer" under "Printers", then click "OK".
  5. BullZip PDF Printer will then start to analyze your document and display a new pop-up window, where you can direct it to the location you want to save the pdf file.
  6. Follow the pop-up windows and.. hola! The PDF document is created!

Add Watermark to an Excel Document

Unfortunately, the printed watermark feature is not available on any version of Excel (including Excel 2007, 2010). However, there are some workaround methods to add text or images into an Excel document that would result something similar to a watermark.

The followings are examples of Excel Documents with text and image "watermark":





Step-by-step to add a watermark to an Excel document (applied for Microsoft Word 97-2010):
A. TEXT WATERMARK:
The trick is to place a WordArt on the background of the Excel sheet.

Microsoft Excel 97/2000/XP (2002)/2003:
  1. Open the Excel document that you want to add watermark to.
  2. Select "Insert" from the top menu, then select "Picture" > "WordArt...".
  3. In the "WordArt Gallery" dialog, select a WordArt style that you like then click "OK".
  4. In the "Edit WordArt Text" dialog, type in your desired text, select the font style and size, then click "OK".
  5. Right-click on the newly inserted WordArt on the Excel document, then select "Format WordArt...".
  6. In the "Format WordArt..." dialog, select "No fill" for "Fill"/"Color".
    Also select a brighter color (i.e. gray) for "Line"/"Color" then click "OK".
  7. Right-click on the WordArt on the Excel document, then select "Order." > "Send to Back".
  8. Click and drag the WordArt to position it where you like.
    Note: The WordArt needs to be manually placed on each page of the document.
Microsoft Excel 2007/2010:
  1. Open the Excel document that you want to add watermark to.
  2. Select the "Insert" tab from the top menu, then in the group "Text", select "WordArt".
  3. Select the WordArt style you want, then type the text for your watermark.
  4. Under "Drawing Tools", select "Format".
  5. In the group "WordArt Styles" change "Text Fill" to "No fill".
  6. Also in the same group "WordArt Styles", change "Text Outline" to "Automatic".
  7. In the group "Arrange" select "Send to Back".
  8. Click and drag the WordArt to your preferred position.
    Note: The WordArt needs to be manually placed on each page of the document.


B. IMAGE WATERMARK:
To insert an image watermark, use the header feature in Excel as follows...

Microsoft Excel 97/2000/XP (2002)/2003:
  1. Open the Excel document that you want to add watermark to.
  2. Select "View" from the top menu, then select "Header and Footer".
  3. In the "Page Setup" dialog, click on the "Custom Header..." button in the middle of the dialog.
  4. In the "Header" dialog, click on the middle box "Center section"
  5. In the middle of this dialog box, there are some tool buttons. We're going to use the last two buttons to insert and format the image.
  6. Click on the Insert Picture button (the second-to-last button with an image of a mountain)
  7. Navigate to the folder where your watermark image is located. Select the image and click "Insert".
  8. A text "&[Picture]" is now placed in the middle box named "Center section".
  9. Click on the Format Picture button (the last, right-most button).
  10. Adjust the scale and size if you wish, then select the "Picture" tab. Change the "Color" under "Image Control" to "Washout", then click "OK".
  11. At this point, you can click "OK" to finish, and do a "Print Preview" to see your watermark. However, you will notice that the image is placed far on the top of the page, which doesn't look usual for watermarks. To fix this, click on the middle box named "Center section" again and enter a few blank lines before the text "&[Picture]".
  12. Once you're all done, click "OK" to exit and open "Print Preview" to see your watermark. (The watermark will not be displayed in normal view.)
Microsoft Excel 2007/2010:
  1. Open the Excel document that you want to add watermark to.
  2. Select the "Insert" tab from the top menu, then in the group "Text", select "Header & Footer".
  3. Excel will now switch to Page Layout view, and the cursor will be moved to the center top of the page.
  4. On the "Design" Tab, in the group "Header & Footer elements" Select "Picture".
  5. Navigate to the folder where your watermark image is located. Select the image and click "Insert".
  6. A text "&[Picture]" is now placed in the middle box of the header.
  7. To move the picture down on the page, click on the header and place the cursor before the text "&[Picture]", then hit Enter a few times.
  8. To see the watermark, either open the "Print Preview" or click on any cell of the document.

Add Watermark to a Word Document

You can insert a watermark into a Microsoft Word document as either text or image.
Here is a sample Word Document with text watermark:


And here is an example of picture watermark:



Step-by-step to add a watermark to Word document (applied for Microsoft Word 97-2010):
Microsoft Word 97/2000/XP (2002)/2003:
  1. Open the Word document that you want to add watermark to.
  2. Select "Format" from the top menu, then select "Background", then "Printed Watermark".
  3. In the "Printed Watermark" dialog:

    A. To insert a text watermark:
    • Select the "Text watermark".
    • Then, either select a pre-defined text from the drop-down, or type in your desire text on the "Text" field.
    • Customize your watermark with other options in this dialog such as text size, text color, etc, then click "OK".
    • Watermark is now inserted into your document.

    B. To insert an image watermark:
    • Select the "Picture watermark".
    • Then click on the button "Select Picture...".
    • Navigate to the directory where your watermark picture is located. Select it and click "Insert".
    • Select a customized scale if desired, then click "OK".
    • The image is now inserted into your document as watermark.


Microsoft Word 2007/2010:
  1. Open the Word document that you want to add watermark to.
  2. Select the "Page Layout" Tab from the top menu
  3. In the "Page Background" group, select "Watermark".
  4. You can now select one of the pre-defined watermarks, or if you wish to use your own text/image, select "Custom Watermark" at the bottom.
    At the "Printed Watermark" dialog:

    A. To insert a text watermark:
    • Select the "Text watermark".
    • Then, either select a pre-defined text from the drop-down, or type in your desire text on the "Text" field.
    • Customize your watermark with other options in this dialog such as text size, text color, etc, then click "OK".
    • Watermark is now inserted into your document.

    B. To insert an image watermark:
    • Select the "Picture watermark".
    • Then click on the button "Select Picture...".
    • Navigate to the directory where your watermark picture is located. Select it and click "Insert".
    • Select a customized scale if desired, then click "OK".
    • The image is now inserted into your document as watermark.

Wednesday, September 14, 2011

Graphing memory usage during an MTR run

In order to optimally size the amount of RAM to allocate to a set of new machines for running MTR, I ran a few tests to check the memory usage of an MTR run for mysql-trunk and cluster-7.1. As using a RAM disk considerably speeds things up, I set the vardir to be on /ramdisk and logged the usage of that too.
The tests were performed on an 8-core E5450 @ 3.00GHz with 24GB RAM, with 8GB allocated to /ramdisk. Each branch ran the default.daily collection, which generally contains the most testing we do per-run. Between each run I rebooted the machine to clear the buffer cache and /ramdisk
I used something like the script below, which saved the per-second usage of /ramdisk, the total RAM used, and the RAM used minus buffers.
#!/bin/bash

BRANCH="mysql-trunk"
BUILDDIR="mysql-5.6.3-m5-linux2.6-x86_64"
TESTDIR="${HOME}/mtr-test/${BRANCH}

stats()
{
  i=1
  rm -f ${TESTDIR}/stats-${BRANCH}
  while [ -f ${TESTDIR}/running ]; do
    rd=$(df -k /ramdisk | awk '/^\// {print $3}')
    mem=$(free | awk '/^Mem/ {print $3}')
    mem1=$(free | awk '/cache:/ {print $3}')
    echo "${i} ${rd} ${mem} ${mem1}" >>${TESTDIR}/stats-${BRANCH}
    i=$((i+1))
    sleep 1
  done
}

export TMPDIR="${TESTDIR}/tmp"
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}

>${TESTDIR}/running
stats &

(
  cd ${TESTDIR}/${BUILDDIR}/mysql-test

  perl mysql-test-run.pl ... --parallel=8 --vardir=/ramdisk/mtr-${BRANCH}/...
  mv /ramdisk/mtr-${BRANCH}/* ${TMPDIR}/
  ...
)

sync
rm -f ${TESTDIR}/running
wait
First I graphed a straight run of the two branches, using the following gnuplot script:
set terminal png enhanced font "Times,11" size 640,768
set output "mtr-ram.png"
set title "MTR memory usage (8-core Xeon, 24GB, 8GB RAM disk)"
set xlabel "Time (minutes)"
set ylabel "Memory usage (GB)"
set yrange [0:16]
set xtics 10
set key top box
set grid
plot "stats-mysql-trunk" every 60 using (($1)/60):(($2)/1024/1024) \
        title 'mysql-trunk /ramdisk usage' with lines, \
     "stats-mysql-trunk" every 60 using (($1)/60):(($3)/1024/1024) \
        title 'mysql-trunk RAM (inc buf)' with lines, \
     "stats-mysql-trunk" every 60 using (($1)/60):(($4)/1024/1024) \
        title 'mysql-trunk RAM (exc buf)' with lines, \
     "stats-mysql-cluster-7.1" every 60 using (($1)/60):(($2)/1024/1024) \
        title 'cluster-7.1 /ramdisk usage' with lines, \
     "stats-mysql-cluster-7.1" every 60 using (($1)/60):(($3)/1024/1024) \
        title 'cluster-7.1 RAM (inc buf)' with lines, \
     "stats-mysql-cluster-7.1" every 60 using (($1)/60):(($4)/1024/1024) \
        title 'cluster-7.1 RAM (exc buf)' with lines

I then performed a valgrind run on mysql-trunk using similar scripts. As valgrind takes considerably longer (and uses more RAM) I kept it separate as the combined graph isn’t very clear:

So, based on these results, the host machine (16GB RAM + 8GB RAM disk) is probably a sensible guide for now, and allows for some future growth.

Creating chroots for fun and MySQL testing

Virtualisation is all the rage today, however there are still a few cases where good old-fashioned Unix chroot is still applicable, and testing MySQL across multiple platforms and architectures is one of those cases.
At Oracle we do full automated package verification testing of our MySQL server binaries prior to release, which attempts to install the package, start the server, run some functionality testing, then uninstall. It is of course highly desirable that the testing environment this is performed in is as close to a clean install of the target operating system as possible, to avoid problems such as our packages depending upon some local changes or packages we may have installed which won’t be available on a customer system.
Given the large number of platforms and architectures that MySQL supports, going the virtualisation route would mean having to use many different products: VirtualBox for x86, zones for SPARC, qemu for ia64/PA-RISC/others (if it even supports them), and this gets complicated quickly and is not very maintainable. Thus I chose to use chroot as much as possible. In addition, it’s much faster and less intensive on resources to use a chroot than boot up an entire OS image each time.
I built all images directly from the original installation images (DVD, ISO, RPM, etc), to ensure that there was no contamination from our build environment or local install scripts in the image – they should be as close to what a normal user or customer will be running in their setup. From the install image, the packages are installed to a temporary directory, some final modifications are made, then the directory is tarred up ready to be extracted by the test framework and used.
Here are some operating system specific examples, which set up an extracted chroot image into ${CHROOTDIR}. There may be additional steps required to get a fully functioning chroot, such as copying device files (/dev/zero and /dev/null are usually the minimum requirements) and adding users.

FreeBSD

FreeBSD 7 and 8 come as a number of sets in tar format, and for our purposes we only need to extract the base set. You may wish to add more sets if you want to use your chroot for building packages:
mdunit=$(mdconfig -a -t vnode -o readonly -f /path/to/dvd1/of/freebsd.iso)
mount_cd9660 /dev/${mdunit} /mnt
cat /mnt/*/base/base.?? | tar -xpzf - -C ${CHROOTDIR}
umount /mnt
mdconfig -d -u ${mdunit}

HP-UX

HP-UX has since been EOL’d for MySQL, however this information might still prove useful. The HP-UX installation media contains per-directory packages, with the contents representing how they are laid out on the destination file system with each file gzip compressed.
cd /path/to/extracted/hpux-dvd1
for pkg in $LIST_OF_PKGS
do
  for subpkg in ${pkg}/*
  do
    if [ ! -d "${subpkg}" ]; then
      continue
    fi
    for d in $(find ${subpkg} -type d)
    do
      mkdir -p ${CHROOTDIR}/$(echo ${d} \
        | sed -e "s#${subpkg}/##g" \
              -e "s#usr/newconfig/##g")
    done
    for f in $(find ${subpkg} -type f)
    do
      gzip -dc ${f} >${CHROOTDIR}/$(echo ${f} \
        | sed -e "s#${subpkg}/##g" \
              -e "s#usr/newconfig/##g")
    done
  done
done
Once this is done you’ll need to fix up permissions in bin and lib directories (make files executable), as well as create a bunch of symlinks for e.g. /bin and /lib.

OSX

For OSX we don’t actually use a chroot tarball but instead create a sparse disk image. Currently the size of the “chroot” is very large as there’s no easy way to strip down an OSX install, so mounting a disk image is faster than unpacking a chroot, plus it preserves various HFS-specific attributes.
You will likely need at least the BSD, BaseSystem, and Essentials packages.
# Create a sparse image to hold the chroot (which isn't really a directory)
hdiutil create -fs HFS+ -size 8g -type SPARSE -volname osx-chroot ${CHROOTDIR}
hdiutil attach -mountpoint ${CHROOTDIR} ${CHROOTDIR}.sparseimage
# Either attach a DVD image or the real thing
hdiutil attach -mountpoint /Volumes/osx-install /path/to/dvd
# Install packages
for pkg in BSD BaseSystem Essentials
do
  installer -verbose \
   -pkg /Volumes/osx-install/System/Installation/Packages/${pkg}.pkg \
   -target ${CHROOTDIR}
done
# Unmount
hdiutil detach ${CHROOTDIR}
hdiutil detach /Volumes/osx-install

Red Hat / Oracle Linux / SuSE

For RPM-based distributions we use rpm to directly install packages into the chroot. The list of RPMs we install varies quite a lot from release to release, usually by having to increase the number (RH3: 81, RH4: 85, RH5: 114, RH6: 203 – for the same functionality).
# Kludge for 'setup' RPM to install
mkdir -p ${CHROOTDIR}/var/lock/rpm
# If installing from an ISO:
mount -o loop /path/to/iso /mnt
# Path varies from release to release
cd /mnt/path/to/RPMs
rpm --root=${CHROOTDIR} -Uvh ${LIST_OF_RPMS}

Solaris

Similar to RPM, we use the native package manager to install packages directly into the chroot directory:
# Avoid prompts
sed -e "s/ask$/nocheck/" /var/sadm/install/admin/default > /tmp/admin-$$
pkgadd -a /tmp/admin-$$ -R ${CHROOTDIR} -d . ${LIST_OF_PKGS}
rm /tmp/admin-$$

Windows

Ok, so of course we can’t use chroot images for Windows, as it doesn’t have chroot(2). So here we use VirtualBox and its snapshot ability to load a clean snapshot of a basic Windows install, do the tests, then shut down the virtual machine, restore the snapshot, and boot up again.