Thursday, December 24, 2009

Installing Qt 4.6 in OpenSuse 11.2

This is a quick how-to in installing the latest, as of 12/24/2009, Qt framework 4.6 in OpenSuse 11.2.

By the way, Qt is a cross-platform application and UI framework. It can be used to develop web-enabled applications and user interfaces once and deploy them across Windows, Mac, Linux/X11, embedded Linux, Windows CE and Symbian.

Download the binaries from As of this writing, the latest version is 4.6 which comes with a lot of new features especially the multi-touch aware which is pretty much what is expected from latest generation of smartphone applications.

Change to the directory where the file was downloaded, like:
$: cd /home/username/ $: chmod u+x qt-sdk-linux-x86-opensource-2009.05.bin

What we just did was to make the file executable. Finally, install the application by running the following command:
$: ./qt-sdk-linux-x86-opensource-2009.05.bin

See below for screen capture while installing Qt.

Note that Qt SDK needs additional software to work properly, like gcc and related libraries.


Thursday, November 19, 2009

Emacs common commands

Character Operations:
DELETE : Delete character to the left of point (Also marked ROBOUT)
C-d    : Delete character to the right of (or under) point

Word Operations:
M-d    : Delete one word to the right (C-y yanks it back at point)
Cursor movement:
C-p    : Move to the previous line
C-n    : Move to the next line
C-f    : Move forward one char
C-b    : Move backward one char
M-f    : Move forward one word
M-b    : Move backward one word
C-a    : Move cursor beggining of the line
C-e    : Move cursor end of the line
M->    : End of file
M-<    : Beginning of file

Line operations:
M-m       : Move point to the first non-space in the line

Copying Text:
M-w     : Runs command kill-ring-save. This is like copy in Windows editors

Deleting Text:
C- select text C-w
        : Delete selected text
M-d     : Kill the next word after the cursor

Searching for text:
C-s           : Incremental search forward
C-r           : Incremental search backward

Convenience functions:
        : Repeat [char] [number] of times. Example C-8-0 1, repeat 1 80 times.

M-$     : Check and correct spelling for the word at point

        : Count number line and chars for the selected text
        : Change tabs to space for the currently selected region

Python mode specific shortcuts:
M-/     : Command abbreviation expand
C-M-i   : Complete partial symbol or Intellisense in VS speak 

Emacs Keyboard keys (link)

Friday, October 02, 2009

Prolog reference materials

Prolog tutorial by J. R. Fisher

Prolog compilers/interpreters:
SWI-Prolog is  a Prolog  implementation based  on a  subset of
the  WAM (Warren Abstract  Machine)


Installing VirtualBox guest additions in Fedora 11 guest

This is a short guide on how to install VirtualBox 3.0.6 guest additions in Fedora 11.

It is always a good practice to update your system before installing VirtualBox guest additions, so let us do just that. Open a terminal in Fedora guest, thus say,

Login as root:
$: su
Check for updates and install as necessary
#: yum check-update #: yum update
Note that when I installed Fedora 11, I selected Development machine, so most of the common development tools are already installed by default. But if you have selected Destkop machine, then you have to do the following:
#: yum -y install gcc kernel-devel
You probably need to reboot after all the updates. It is now time to install the Virtual Box guest additions. From the host machine, using Virtual Box main application do, "Devices > Install Guest Additions..." or

You should note that in the guest machine, Fedora 11, will mount the guest addition automatically. Now it is time to install the much needed software. Open a terminal and do the following commands.
$: su #: cd /media/VBOXADDITIONS_3.0.6_52128 #: ./
You should be seeing something like:
Verifying archive integrity... All good. Uncompressing VirtualBox 3.0.6 Guest Additions for Linux installation................................................................................................................................................................................................................................ VirtualBox 3.0.6 Guest Additions installation Building the VirtualBox Guest Additions kernel module... Building the shared folder support kernel module... Building the drm support kernel module... Installing the VirtualBox Guest Additions... Successfully installed the VirtualBox Guest Additions. You must restart your guest system in order to complete the installation.

Reboot your machine as instructed... Congratulations!!! You now have integrated guest additions!!!



Monday, September 28, 2009

Creating new user in Fedora Linux

Creating a user in Fedora now is so much easier that it used to 5 years ago. To do this, do "System > Administration > Users and Group" or through console command "system-config-users" as regular user.

Once the program is run it should ask for root password.

Once the required password is entered, you should see a window as shown below.

Now to create the new user either do "File > Add User" or click on Add User button. Let us try to create a new user with the corresponding information:
User Name: timus
Full Name: Timus Tunes
Password : password
Confirm Password : password
Login Shell: /bin/bash
Leave the rest with the default values.


Fedora 11 Fatal boot failure on vbox

I tried installing Fedora 11 on Virtual Box 3.0.6 and really surprised of the result after the first reboot, I was presented with following fatal error message:
Booting from local disk... FATAL: INT18: BOOT FAILURE
Or this image capture:
Though the issue is easy to work-around, thus say, unmount the DVDROM from VirtualBox but this got me thinking why is it that this issue is not present in Ubuntu 9.04 nor OpenSUSE 11.1? Was this a regression in Fedora or due to VirtualBox?

Note that this issue was reported in Virtual Box and claimed to be an issue with Fedora installer. But this issue was reported way back Fedora 10? :(...

I wish I am brave enough to mess around with probably GRUB or Linux kernel to help fix this minor hiccup.


Saturday, August 08, 2009

Localization related articles

Introduction to Localization (link).

Microsoft articles regarding localizing MFC projects


Windows name to ip resolution order

Oder of resolution for TCP/IP names to IP for Windows environment:
  1.  Local cached information. Can be cleared using ipconfig /flushdns.
  2.  Hosts file
  3. DNS server
  4. NetBIOS over TCP/IP
In older versions of Windows up to NT 4.0, the priority can be configured through system.ini section [DNS]. The said section cannot be found in XP SP3, it might be still working and defaults normal resolution order if the section is not defined.

Link 1
Link 2


Wednesday, August 05, 2009

SHGetFolderLocation C++ sample code

Original code is from MSDN. Sample code demonstrates how to use  SHGetFolderLocation in C++.


int main()
    IShellFolder *psfParent = NULL;
    LPITEMIDLIST pidlSystem = NULL;
    LPCITEMIDLIST pidlRelative = NULL;
    STRRET strDispName;
    TCHAR szDisplayName[MAX_PATH];
    HRESULT hr;

    hr = SHGetFolderLocation(NULL, CSIDL_DESKTOP, NULL, NULL, &pidlSystem);
    if (!SUCCEEDED(hr))
        std::cout << "hr bad" << std::endl;
        return -1;

    hr = SHBindToParent(pidlSystem, IID_IShellFolder, (void **) &psfParent, &pidlRelative);

        hr = psfParent->GetDisplayNameOf(pidlRelative, SHGDN_NORMAL, &strDispName);
        hr = StrRetToBuf(&strDispName, pidlSystem, szDisplayName, sizeof(szDisplayName));
        std::wcout << "SHGDN_NORMAL - " <<< '\n';


    return 0;

Need to link ShlwApi.lib to get this to work (Project Properties | Configuration Properties | Linker | Input | Additional Dependencies)



Sample code on how to use SHGetFolderLocation, shamelessly copied from this link. This code was verified to work in Windows 2000 and VB SP6.
Private Declare Function SHGetFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, ByVal hToken As Long, ByVal dwReserved As Long, ppidl As Long) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" (lpbi As BROWSEINFO) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal pv As Long)

  hwndOwner As Long
  pidlRoot As Long
  pszDisplayName As String
  lpszTitle As String
  ulFlags As Long
  lpfn As Long
  lParam As Long
  iImage As Long
End Type
Private Sub Command1_Click()
' This code is licensed according to the terms and conditions listed here.

' Open the Browse for Folder dialog box and display both the display name and
' the actual name of the folder (if it is not a virtual folder).  Any folder under My Computer
' may be selected.
Dim bi As BROWSEINFO  ' structure passed to the function
Dim pidl As Long  ' PIDL to the user's selection
Dim physpath As String  ' string used to temporarily hold the physical path
Dim retval As Long  ' return value

' Initialize the structure to be passed to the function.
bi.hwndOwner = Form1.hWnd  ' window Form1 is the owner of the dialog box
' Specify the My Computer virtual folder as the root
retval = SHGetFolderLocation(Form1.hWnd, CSIDL_DRIVES, 0, 0, bi.pidlRoot)
' Make room in the buffer to get the [virtual] folder's display name
bi.pszDisplayName = Space(260)
bi.lpszTitle = "Please choose a folder."  ' Message displayed to the user
bi.ulFlags = 0  ' no flags are needed here
bi.lpfn = 0  ' no callback function is being used
bi.lParam = 0  ' not needed
bi.iImage = 0  ' this will be set by the function

' Open the Browse for Folder dialog box.
pidl = SHBrowseForFolder(bi)
' If the user selected something, display its display name
' and its physical location on the system.
If pidl <> 0 Then
  ' Remove the empty space from the display name variable.
  bi.pszDisplayName = Left(bi.pszDisplayName, InStr(bi.pszDisplayName, vbNullChar) - 1)
  Debug.Print "The user selected: "; bi.pszDisplayName
  ' If the folder is not a virtual folder, display its physical location.
  physpath = Space(260)  ' make room in the buffer
  retval = SHGetPathFromIDList(pidl, physpath)
  If retval = 0 Then
    Debug.Print "Physical Location: (virtual folder)"
    ' Remove the empty space and display the result.
    physpath = Left(physpath, InStr(physpath, vbNullChar) - 1)
    Debug.Print "Physical Location: "; physpath
  End If
  ' Free the pidl returned by the function.
  CoTaskMemFree pidl
End If

' Whether successful or not, free the PIDL which was used to
' identify the My Computer virtual folder.
CoTaskMemFree bi.pidlRoot

End Sub


Tuesday, August 04, 2009

Converting CString to CComBSTR

Code below shows how to convert CString to CComBSTR.
// CComBSTR.cpp : Defines the entry point for the console application.

#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
 CComBSTR szDbgMsg;
 CString sMsg;
 sMsg = _T("Hello world new");
 sMsg.Format(_T("%s : %d"), sMsg, 12);
 //szDbgMsg = L"Hello world ";
 szDbgMsg = sMsg.GetBuffer();
 CW2A printstr(szDbgMsg);
 std::wcout << ((CString)szDbgMsg).GetBuffer() << std::endl;
 std::wcout << sMsg.GetBuffer() << std::endl;
 return 0;


List all installed applications in a machine

The script below will list and save all installed applications to a csv file. Save the script as say, save.vbs.

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\software.csv", True)

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
    ("Select * from Win32_Product")

objTextFile.WriteLine "Caption" & vbtab & _
    "Description" & vbtab & "Identifying Number" & vbtab & _
    "Install Date" & vbtab & "Install Location" & vbtab & _
    "Install State" & vbtab & "Name" & vbtab & _ 
    "Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
        & "Version" 

For Each objSoftware in colSoftware
    objTextFile.WriteLine objSoftware.Caption & vbtab & _
    objSoftware.Description & vbtab & _
    objSoftware.IdentifyingNumber & vbtab & _
    objSoftware.InstallDate2 & vbtab & _
    objSoftware.InstallLocation & vbtab & _
    objSoftware.InstallState & vbtab & _
    objSoftware.Name & vbtab & _
    objSoftware.PackageCache & vbtab & _
    objSoftware.SKUNumber & vbtab & _
    objSoftware.Vendor & vbtab & _

Note that this code was copied shamelessly from the internet, can't remember the exact link.


The system cannot execute the specified program

When running a console app written in VS 2005, and you are getting "The system cannot execute the specified program" on a target machine, then it can be one of the following:
a) Target machine does not have VC++ 2005 Redistribuable
b) Project settings may not be correct, see this link.


Monday, July 27, 2009

Using SyntaxHighlighter javascript library

See this link for instructions on how to use SyntaxHighlighter library within Blogger.


Dump PE format string resource

Code below can be used to dump PE string resource using python.

import os
import re
import pefile #
import sys

def DumpStr(fname):
        pe = pefile.PE(fname)
        print sys.exc_info()[0]
        print "Continue to the next exe/dll"

    # The List will contain all the extracted Unicode strings
    strings = list()

    # Fetch the index of the resource directory entry containing the strings
        rt_string_idx = [
   for entry in
    except (ValueError,AttributeError):
    # Get the directory entry

    rt_string_directory = pe.DIRECTORY_ENTRY_RESOURCE.entries[rt_string_idx]

    # For each of the entries (which will each contain a block of 16 strings)
    for entry in

      # Get the RVA of the string data and
      # size of the string data
      data_rva =[0].data.struct.OffsetToData
      size =[0].data.struct.Size

      # Retrieve the actual data and start processing the strings
      data = pe.get_memory_mapped_image()[data_rva:data_rva+size]
      offset = 0
      while True:
        # Exit once there's no more data to read
        if offset>=size:
        # Fetch the length of the unicode string
        ustr_length = pe.get_word_from_data(data[offset:offset+2], 0)
        offset += 2

        # If the string is empty, skip it
        if ustr_length==0:

        # Get the Unicode string
        ustr = pe.get_string_u_at_rva(data_rva+offset, max_length=ustr_length)
        offset += ustr_length*2

    for strx in strings:
        sSearch = "Set Device"
        m =,strx)
        if m:
            print strx

dirList = os.listdir(path)
for fname in dirList:
    m ="exe|dll",fname)
    if m:
        print os.path.join(path,fname)
        fullname = os.path.join(path,fname)


Mouse Invisible in VirtualBox guest

In VirtualBox 3.0.2, I have noticed that most of the times the mouse goes invisible on text areas. For example, if you are in Notepad, once you starting writing some text in the text area the mouse pointer goes into the black hole. The work around is really easy. Go to (Windows XP) Control Panel –> Mouse –> Pointers, then select Windows Black (system scheme).


Monday, July 20, 2009

Partimage invalid compression level workaround

For some reason, some diskimages created using partimage will encounter "invalid compression level" when restored. See below for the workaround to restore the image back.

#: ntfs-3g /dev/sda1 /mnt/windows #: mv /mnt/windows/img/vista.img.000 /mnt/windows/img/vista.img.gz #: gunzip -c /mnt/windows/img/vista.img.gz | partimage restore /dev/sda1 stdin


Sunday, July 19, 2009

Installing Easy Peasy in EEE PC 900 using external hard drive

Easy Peasy is a linux distribution tuned for EEE PC (Asus Netbook) computers.

D:\Software\iso\syslinux\win32>syslinux.exe -m -a -d / i: -f

Working with swapfile

Swappiness ness%27%27

Thursday, July 02, 2009

Windows dialog rc file is using dialog system units

This has never occurred to me before, I have been tweaking win32 API for awhile, but I really never paid much attention with the dimensions as saved in resource files for dialog boxes. Interestingly, the units stored in rc file are not really in pixel but rather in dialog unit. :( My understanding is that this will make the dialog independent of the font size. If user/developer changes the font size, the dialog box will adjust accordingly. Seems like a neat idea but I was dumbfounded at first sight.

It makes my life harder though as I am trying to cross-reference runtime dialog boxes against design time. I was planning to cross ref them using the dimensions but it turns out to be not a good option.

The quest is on...........

Related links:


Wednesday, July 01, 2009

Working with memory leaks

Detecting and Isolating Memory Leaks (link)

Debugging Tutorial
Debug Tutorial Part 3: The Heap (link)

Assembly Language Reference

Webseter: The place on the Internet to Learn Assembly(link)

MASM 6.1 download (link)

Sunday, June 21, 2009

Visual Studio shortcuts

The following are my frequently used keyboard shortcuts in Visual Studio.

- Match braces back and forth
- Go back to the last location
- Delete line
- Go to line number
- Maximize Code Editor

Saturday, June 13, 2009

VC++ 2008 link crash

I am getting the following crash in VC++2008:

Linking... Embedding manifest... Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0 Copyright (C) Microsoft Corporation.  All rights reserved. LINK : fatal error LNK1000: Internal error during IncrBuildImage

It turns out that this a bug of a VC++ 2008 linker, see hotfix 948127 from Microsoft.


Friday, June 12, 2009

JEdit related information

jEdit is a mature programmer's text editor. It is not my favorite but it is interesting.

Key configurations I do in JEdit:
- Remove the .(dot) in the text area, do Utilities | Global Options... | Text Area and unset End of line markers.

Thursday, April 09, 2009

IE Shortcut keys

Alt-DGoto to URL bar
Ctrl-EGoto to Search box

Sunday, March 01, 2009

Office 2007 RibbonX resources

Custom UI Editor : Custom UI Editor for Open XML file format.
XML Notepad 2007 provides a simple intuitive user interface for browsing and editing XML documents.
2007 Office System: XML Schema Reference
RibbonX Resources blog by Savraj Dhanjal.
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 2 of 3)
Customizing the 2007 Office Fluent Ribbon for Developers (Part 3 of 3)
2007 Office System Document: UI Style Guide for Solutions and Add Ins
VSTO version 3.0
How To Create Office COM Add-Ins by Using VBA and Office Developer


Saturday, January 10, 2009

Minimal Debian Lenny install on VirtualBox

- internet connection
- Virtual Box installed on host machine. This exercise will be using Vista as host.

As of this writing, Debian Lenny is still at testing stage. For this exercise we will use RC1, visit for the netinstall iso. Once download is done, create a new virtual machine using Virtual Box, use the following configuration: 512 MB Memory, 120 GB HD, use Intel PRO/1000T server for the network card. For the VirtualBox networking I am using host network configuration. Once VirtualBox guest configuration is set, start the guest machine and then mount the CD-ROM image. In installer boot menu, select Graphical Install. For "Chose the Language" screen, select English or your language of choice. For the country, select whichever you are currently in. In my case, I will be using Philippines. In "Keymap to use" select "American English" or whichever is much appropriate for your system. After this screen, the system should now start detecting your hardware and configures the system for installation. Few seconds later, it should present you with "Configure your network" screen, in my case I am gonna be using "deb5." Since I am using Vista and Internet Connection Sharing, I have as the default domain. Accept this default. This should not matter that much if you are using your system inside a guest machine. In "Partition disks", use Guided - use entire disk. You may use other option if you are confident with playing around with disk partitioning in Linux. Select first HD in your Virtual Box, then select "All files in one partition (recommended for new users)." Then accept the changes to write the partition layout to your HD. Wait while the installation sequence is partitioning your hard drive and installs the base system. In Philippines, one of the nearest mirror sites is Hongkong. We have two mirrors from Hongkong and I will be using In the Http proxy window, you can leave this blank if you are not using HTTP proxy to access outside world. Thus say, if you are using DSL, Cable, WIFI or Wireless connection like HSDPA or the like, leave it blank. After this, the system will pull up installation software from our mirror site. This may take a while depending on the connection speed. Since this is only the few cases where I can help the Debian community, I opted to join the "package survey." I too encourage everyone to participate this survey. Since we want this to be a minimal system, deselect all packaged options. This leaves us with the bare minimum to run our Debian Lenny Linux system. Since this is running of VirtualBox guest, we are sure enough that it is safe to put GRUB boot loader in master boot record. So go ahead, and say Yes. In few moments, installation should complete. Congratulations, you have just installed a minimal Debian Lenny Linux in VirtualBox!!!

Let us now install a minimal GNOME in top of our minimal system. Before we do the installation of desktop environment, it is a good practice to do the ff:
hostname:/# aptitude update hostname:/# aptitude safe-upgrade
But since we have just used netinstall installation, our system should be up to date. Now, let us get our system configured with X, do:
hostname:/# aptitude install less hostname:/# aptitude install xorg gnome-core gdm gdm-themes
The above command install xorg, GNOME and gdm (GNOME Display Manager) and associated gdm themes. Wait and relax as this may pull archives of around 250 MB. After the installation, do a reboot to login to GNOME Display Manager. You will notice here that your graphical login screen maybe bigger than your monitor. This can be fixed by installing virtual additions but we can also work around this one by modifying /etc/X11/xorg.conf as root, like so:
Section "Screen" Identifier "Default Screen" Monitor "Configured Monitor" SubSection "Display" Modes "1024x680" "800x600" EndSubSection EndSection
Let us now install VirtualBox guest additions:
hostname:/# su hostname:/# aptitude install build-essential hostname:/# aptitude install linux-headers-`uname -r` hostname:/# mount /media/cdrom hostname:/# sh
After reboot, you should now have a nicely integrated Debian Lenny with VirtualBox. Now, to make guest machine auto-adjust with the size of main VirtualBox window, update /etc/X11/xorg.conf with:
Section "Device" Identifier "Configured Video Device" Driver "vboxvideo" EndSection


Friday, January 09, 2009

Minimal Ubuntu Gnome Intrepid install on Virtual Box

- internet connection
- Virtual Box installed on host machine. This exercise will be using Vista as host.

Download server edition of Ubuntu Intrepid 8.10 from the nearest mirror. Once done, create a new virtual machine using Virtual Box, use the following configuration: 512 MB Memory, 120 GB HD, enable PAE, use Intel PRO/1000T server network. Start virtual machine of the CD-ROM. During the install sequence, select F4. Select the option which mentions about virtual machine installation. Use the default options, reboot and login to the newly install minimal system.

Update the system and install aptitude, say:
username@hostname:/# apt-get update username@hostname:/# apt-get safe-upgrade username@hostname:/# apt-get install aptitude
Then install minimal Gnome, thus say do:
username@hostname:/# aptitude install xorg gnome-core gdm gdm-themes
My first install of gnome-core didn't work well. Doing
username@hostname:/# apt-get update username@hostname:/# apt-get safe-upgrade username@hostname:/# aptitude install gnome-core
fixed it. Go figure.... Let us now make our minimal Ubuntu look prettier, do:
username@hostname:/# aptitude install gtk2-engines gtk2-engines-pixbuf ubuntu-artwork ubuntustudio-icon-theme
After the installation, log-off then log back in. You should now have a more appealing Ubuntu installation.

See the ff links for related posts:
Installing a minimal Ubuntu installation<@ >.
Now, it is time to install Virtual Box guest additions. From the Virtual Box main menu, select Devices | Install Guest Additions... This will cause the media to be auto-mounted. Open up a terminal then do:
username@hostname:/# sudo su username@hostname:/# aptitude install build-essential username@hostname:/# aptitude install linux-headers-`uname -r` username@hostname:/# cd /media/cdrom username@hostname:/# sh