2010-12-27

Build Qt 4.7 for armsys-6410

=======================
Install the crossing toolchain
=======================
refer to chapter 4 安装交叉编译器

交叉编译工具链的安装文件为“ARMSYS6410-B基础配置光盘资料\Linux相关\linux2.6标准版\交叉编译器”目录下的 cross-4.2.2-eabi.tar.bz2.

>tar xjvf cross-4.2.2-eabi.tar.bz2 –C /usr/local/arm
>export PATH=$PATH:/opt/toolchains/arm920t-eabi/bin

=======================
Build tslib (touch screen)
=======================

Install necessary tools
> apt-get install autoconf automake libtool

Download souce of tslib from http://tslib.berlios.de/


Build tslib
> tar xzvf tslib-1.4.gz
> cd tslib
>./autogen.sh
>./configure -host=arm-linux -prefix=/usr/local/tslib -enable-input=no (wrong???)
tslib will be install at /usr/local/tslib. If get error, you may comment out the line " '#define malloc rpl_malloc" in config.h
>make
>make install
Reference: http://blog.chinaunix.net/u2/75270/showart_1793535.html

=======================
Build Qt 4.7.1
=======================

Download qt-4.7.1
>wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.1.tar.gz
>tar xfzv qt-everywhere-opensource-src-4.7.tar

Configure the Qt Embedded.
>./configure -prefix /usr/local/qt-4.7.1-armsys-6410 -embedded arm -xplatform qws/linux-arm-g++ -depths 16 -qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib -R /usr/local/tslib/lib -xmlpatterns -exceptions

Build Qt
>make
>make install
Reference: http://doc.qt.nokia.com/main-snapshot/qt-embedded-crosscompiling.html

2010-12-20

A walkaround: assign a static IP to eth0 for nfs remotely start system

I tried to boot the target board "armsys6410" by remotely loading a root file system through nfs. According to the given user manual, the argument of u-boot is

setenv bootargs "root=/dev/nfs nfsroot=192.168.253.2:/hom/localhost/armsys6410/root/ ip=192.168.253.12:192.168.253.2:192.168.253.2:255.255.255.0:armsys.hzlitai.com:eth0:off console=ttySAC0,115200"
Here /home/localhost/armsys6410/root is the file system located at my host machine. 192.168.253.12 is the static ip of board, while 192.168.253.2 should be static ip of host machine.

The problem of mine is I cannot fix a static IP to eth0, when I use at the same time wlan0. I didn't find a ultimate solution for the problem. Here is just walkaround:

Precondition: minicom has been correctly configured, serial port and cross-over cable have been correctly connected between host and target.

1) reset the board
2) press any key to suspend the booting (I use u-boot here)
3) >sudo ifconfig eth0 192.168.253.2 netmask 255.255.255.0 up
4) in minicom, input "reset"


Then the board can start with given root file system

Setup minicom for mini2440


For windows, it is recommended to use Hyperterminal for serial port communication. In order to develop under linux via nfs, a terminal software 'Minicom' is installed and applied instead of Hyperterminal. The USB to serial adapter is used for my laptop. The following items are related for Minicom.
  • Install minicom package
  • Check if there is active serial ports:
>dmesg | grey tty
[    0.004000] console [tty0] enabled
[    1.174860] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[ 2237.927394] usb 3-1: pl2303 converter now attached to ttyUSB0

  • Check read/write permissions on /dev/ttyUSB0 file:
>ls -la /dev | grep ttyUSB0
crw-rw----  1 root dialout 188,   0 2009-10-10 13:59 ttyUSB0

  • If the permissions are not set as above, it can be configured as below:
>chown root /dev/ttyUSB0
>chgrp dialout /dev/ttyUSB0
>chmod 660 /dev/ttyUSB0

  • Add debian user in the dialout group (for me the user is 'lp')
>adduser lp dialout

  • To see which users are members of the dialout group, open the /etc/group file and look for th eline beginning with dialout
>cat /etc/group | grep dialout

  • Start and configure minicom under superuser mode
>minicom -s
>Select 'Select port setup'
>Change Serial Device from '/dev/ttyS1' to '/dev/ttyUSB0'
>Set Hardware Flow Control from 'Yes' to 'No'
>'Save setup as ...' mini2440_config'

  • Start minicom using 'mini2440_config'
>minicom mini2440_config

  • Leave minicom
>Ctrl A->X

IMPORTANT NOTES:
If you use a linux system in vmware, this configuration may not work. You need to
  1. check if your vmware is a bridged network
  2. disable your firewall in your host machine.
  3. read this tutorial.

2010-11-20

Several Patent Search Engines

 

2010-11-17

Build an Angstrom Image & Toolcain for mini2440

According to the tutorial in [1], an Angstrom image has been successfully bitbaked for mini2440. But an Angstrom toolchain is still missing. Analog to [2], the following commands can bitbake a compatible toolchain for this image.

>source source-me.txt
>bitbake meta-toolchain

The toolchain can be found at "angstrom-dev/deploy/glibc/sdk"

angstrom-2010.7-test-20101117-i686-linux-armv4t-linux-gnueabi-toolchain-extras.tar.bz2
angstrom-2010.7-test-20101117-i686-linux-armv4t-linux-gnueabi-toolchain.tar.bz2

To install the toolchains:
> tar -C / -jxvf *.tar.bz2

The toolchain is installed at /usr/local/angstrom/arm/
To use the toolchain, source the script[3]:
>. /usr/local/angstrom/arm/environment-setup

Reference:
[1] http://www.electronics.diycinema.co.uk/embedded/mini2440/configuring-open-embedded-to-bake-angstrom-images-for-the-mini2440/
[2] http://groups.google.com/group/beagleboard/browse_thread/thread/b11d9c53d6f09536/33c537f7d08f1952
[3] http://docs.openembedded.org/usermanual/html/ch05s08.html

2010-10-31

Update date&time in Debian

>sudo apt-get update
>sudo apt-get install ntpdate
>sudo ntpdate  ntp.ubuntu.com

2010-09-29

The first charactor of 'ls -l'

  • -   normal file
  • d  directory
  • s  socket file
  • l   link file
  • c  character special
  • p  fifo (named pipe)
  • b  block speical
Reference:
http://www.thegeekstuff.com/2009/07/linux-ls-command-examples/

Solve Warning of minicom: unable to open an initial console.

The situation is:
I want to use nfs system on my linux host (debian, squezze) to start the embedded device (mini2440). The system can successfully start but the minicom didn't work any more. A warning message was reported:

Warning: unable to open an initial console.


The reason: 
The nfs system on my linux host has no /dev/console.

The solution:
>cp -rf /dev/console $rootf/dev/

Reference:
http://kerneltrap.org/node/6854

2010-09-21

Configure with --host, --target and --build options

When people configure a project like './configure', man often meets these three confusing options, which are more related with cross-compilation

  • --host: In which system the generated program will run.
  • --build: In which system the program will be built.
  • --target: this option is only used to build a cross-compiling toolchain. When the tool chain generates executable program, in which target system the program will run.
An example of tslib (a mouse driver library)
'./configure --host=arm-linux --build=i686-pc-linux-gnu': the dynamically library is built on a x86 linux computer but will be used for a embedded arm linux system.

An example of gcc:
'./configure --target=i686-pc-linux-gnu --host=arm-linux --build=i686-pc-linux-gnu':
  • A gcc compiler is build on x86 linux computer. [--build]
  • The gcc will be executed on an embedded arm linux system.[--host]
  • But the gcc will generate the binary program, which run in a x86 linux system. [--target]

Reference:
http://matrix.wearlab.de/en/wiki/index.php?title=ArmCrossCompiler&redirect=no

Increase fsck fequency at startup

Totally disable forced fsck at startup is a bad idea. But it takes more than 5 minutes to scanning a huge disk for every 24 times boot. Why not just change the fequency of forced fsck? The solution is using tune2fs.

1) Check your disk.
>df
/dev/sda1              7850996   5316724   2135460  72% /
tmpfs                   257324         0    257324   0% /lib/init/rw
udev                    252876       144    252732   1% /dev
tmpfs                   257324         0    257324   0% /dev/shm

So, my disk is /dev/sda1
2) Configure the fequency of forced fsck.
  • sudo tune2fs -c 100 /dev/sda1 (100 boot)
  • sudo tune2fs -i 365d /dev/sda1 (365 day)

Reference:
http://ubuntuforums.org/archive/index.php/t-1066069.html

    2010-09-20

    The Basic of PCM

    PCM stands for "Pulse Code Modulation". In plain text, an analog signal is sampled and the samples is encoded into a stream of PCM word.


    PCM data is relatively immune against noise during transmission because the reciever need only to tell "1" or "0" states of the inputing stream.

    Reference: 

    High impedance of output

    In digital circuit, the output line has usually three states, namely, 0, 1 and high impedance.
    In the state of 0 or 1, the output line has a low impedance. When the output in the high impedance state, the output line will be effectively removed from the rest of circuit. In such way, it allows multiple circuits to share the same output line.

    Arbiter

    Abiter is an eletronic device to determine the order of access to a shared resource, when the resource is almost at the same time requested by several processores.

    How SPI works

    Based on SPI wiki, a short summary of SPI mechimism.

    Four logic signals.
    • SCLK — Serial Clock (output from master)
    • MOSI/SIMO — Master Output, Slave Input (output from master)
    • MISO/SOMI — Master Input, Slave Output (output from slave)
    • SS — Slave Select (active low; output from master)


    Data transimission:

    During each SPI clock cycle, a full duplex data transmission occurs:
    • the master sends a bit on the MOSI line; the slave reads it from that same line
    • the slave sends a bit on the MISO line; the master reads it from that same line

    Scanning algorithm for 3 x 4 Keypad Matrix

    When a keypad is connected with a microprocessor, e.g 8051, a scanning algorithm is used to detect the pressed keys. See shown in [1]


    Scanning algorithm
    1.       Start.
    2.       Make All Pins High.
    3.       Make Column 1 pin low.
    4.       Check if Row 1 is low, if yes then Switch 1 has been pressed.
    5.       Check if Row 2 is low, if yes then Switch 4 has been pressed.
    6.       Check if row 3 is low if yes then Switch 7 has been pressed.
    7.       Check if row 4 is low if yes then Switch 10 has been pressed.
    8.       Make Column 1 Pin high & Column 2 Pin Low.
    9.       Check if Row 1 is low, if yes then Switch 2 has been pressed.
    10.   Check if Row 2 is low, if yes then Switch 5 has been pressed.
    11.   Check if row 3 is low if yes then Switch 8 has been pressed.
    12.   Check if row 4 is low if yes then Switch 11 has been pressed.
    13.   Make Column 2 Pin high & Column 3 Pin Low.
    14.   Check if Row 1 is low, if yes then Switch 3 has been pressed.
    15.   Check if Row 2 is low, if yes then Switch 6 has been pressed.
    16.   Check if row 3 is low if yes then Switch 9 has been pressed.
    17.   Check if row 4 is low if yes then Switch 12 has been pressed.
    18.   Make column 3 pin high
    19.   Stop
    Reference: 
    [1]http://www.dnatechindia.com/index.php/Tutorials/8051-Tutorial/Interfacing-Matrix-Keypad-to-8051.html

    2010-09-19

    Show Laptop battery status on Linux

    gnome-power-manager is good software to manager and show status of battery and power consumption.

    2010-09-18

    Useful tools for the problem 'undefined reference to..'

    ldd: prints the shared libraries required by each program or shared library specified on the command line.
    [example]
    >ldd /usr/lib/libACE.*
        librt.so.1 => /lib/librt.so.1 (0x4819f000)
        libdl.so.2 => /lib/libdl.so.2 (0x481ae000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x481ba000)
        libm.so.6 => /lib/libm.so.6 (0x48295000)
        libc.so.6 => /lib/libc.so.6 (0x48342000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x48469000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x4847d000)
        /lib/ld-linux.so.3 (0x40071000)

    nm: list symbols from object files
    [example]
    >nm -C -u libwx_baseu-2.8.so

    readelf: Displays information about ELF files.
    [example]
    >readelf -s /lib/libdl.so.2                                             

    Symbol table '.dynsym' contains 39 entries:
       Num:    Value  Size Type    Bind   Vis      Ndx Name
         0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
         1: 00000830     0 SECTION LOCAL  DEFAULT   10
         2: 00000000   200 FUNC    GLOBAL DEFAULT  UND strerror@GLIBC_2.4 (4)
    ....

    Solve 'undefined reference to' problem

    To learn how to use scratchbox2 for cross-compilation, I attempted to repeat the steps in the wiki [2]. Everything works fine, until I tested the example 'More complicated example: with libraries'. The example failed to link to library ACE:

    max@dev1:~/work/arena/sheeva_debian/source$ sb2 gcc -lACE test.o -o test
    /home/max/work/arena/sheeva_debian/debian_rootfs/lib/libdl.so.2: undefined reference to `_dl_tls_get_addr_soft@GLIBC_PRIVATE

    The reason is inconsistent version of dynamical libraries installed in  scratchbox system. The scratchbox system has following settings
    I checked the library dependency as followings:
    1) Since the '-lACE' is used, so we check the dependency of libACE by

    max@dev1:~/work/arena/sheeva_debian/source$ sb2 -eR ldd /usr/lib/libACE.so
        librt.so.1 => /lib/librt.so.1 (0x4819f000)
        libdl.so.2 => /lib/libdl.so.2 (0x481ae000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x481ba000)
        libm.so.6 => /lib/libm.so.6 (0x48295000)
        libc.so.6 => /lib/libc.so.6 (0x48342000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x48469000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x4847d000)
        /lib/ld-linux.so.3 (0x40071000)

    2) According to the error messages, libdl.so has a undefined reference, therefore, I continue to check the dependency of libdl.so.2

    max@dev1:~/work/arena/sheeva_debian/source$ sb2 -eR ldd /lib/libdl.so.2
        libc.so.6 => /lib/libc.so.6 (0x4807f000)
        /lib/ld-linux.so.3 (0x40071000)

    3) Obviously, libc.so.6 is a symbolic link to the real library /lib/libc.so.6. You can also check the 'undefined reference' reported in link error by

     max@dev1:~/work/arena/sheeva_debian/source$ sb2 -eR readelf -s /lib/libdl.so.2 | grep -i _dl_tls_get_addr_soft@GLIBC_PRIVATE
        10: 00000000   164 FUNC    GLOBAL DEFAULT  UND _dl_tls_get_addr_soft@GLIBC_PRIVATE (6)


    It seems that two libraries is involved:

    • /usr/lib/libACE.so 
    • /lib/libdl.so.2

    According to statement in [1]:

    When you link a shared library against other shared libraries (e.g. link libwx_baseu-2.8.so against libstdc++.so), the linker records versioned symbols used by libwx_baseu and provided by libstdc++.
    If at runtime you use a different copy of libstdc++ (one which doesn't provide the same versioned symbol(s)), you get a (dynamic) liking error and the program doesn't run at all (this is preferable to a "mystery" crash later on).
    The reason is these two libraries are inconsistent. The solution: reinstall the packages that contains the two libraries.


    After checking the in www.debian.org, I found the involved packages in lenny.
    Let's reinstall it by
    > sb2 -eR apt-get install --reinstall libace-dev libc6-dev

    The example is successfully linked.

    References:
    [1] http://stackoverflow.com/questions/2643738/elf-linking-why-do-i-get-undefined-references-in-so-files
    [2] http://www.plugcomputer.org/plugwiki/index.php/Scratchbox2_based_cross_compiling

    2010-09-17

    Virtualbox comes back to live after upgrade from lenny to squeeze

    After upgrade from lenny to squeeze, the installed virtualbox didn't work any more. Try to load the module manually
     
    >modprobe vboxdrv
    The following messages are shown:

    WARNING: The character device /dev/vboxdrv does not exist. 
             Please install the virtualbox-ose-modules package for your kernel and
             load the module named vboxdrv into your system.
    
             You will not be able to start VMs until this problem is fixed.
     
     

    The most important thing is to installed the right linux-headers packages.  For the updated system (squeeze) with a kernel 2.6.32-5-686,

    >sudo apt-get install linux-headers-2.6-686

    DKMS will build the VirtualBox OSE modules for your system.

    >modprobe vboxdrv
    >virtualbox
    Virtualbox comes back ...

    References:

    apt-get doesn't work anymore

    See http://journalxtra.com/2010/03/fixing-the-dreaded-errors-were-encountered-while-processing-errors/

    Upgrade from Lenny to Squeeze

    1)  Update /etc/apt/source.list

    deb http://ftp.de.debian.org/debian/ squeeze main
    deb-src http://ftp.de.debian.org/debian/ squeeze main

    deb http://ftp.us.debian.org/debian/ squeeze main
    deb-src http://ftp.us.debian.org/debian/ squeeze main


    2) update local package database
    >sudo aptitude update


    3) update package management
    >sudo aptitude install apt dpkg aptitude

    4) update kernel image
    >sudo aptitude install linux-image-2.6-686

    5) reboot computer and start with new kenerl 2.6.32
    6) update all packages
    >sudo aptitude full-upgrade


    Reference:

    Debian kernels version

    Lenny:  2.6.26
    Squeeze: 2.6.32
    Sid: 2.6.32

    2010-09-16

    scratchbox2 repository moves to maemo.gitorious.org

    See the sad announcement http://freedesktop.org/wiki/Software/sbox2
    "I have no further interest in any of this distribution cross-compilation stuff. " 
    New repository of sbox is here. http://maemo.gitorious.org/scratchbox2

    sb2-init: cannot run C compiled programs

    > sb2-init -c /opt/qemu/bin/qemu-arm sheeva_debian /root/opt/toolchains/arm-2010q1/bin/arm-none-eabi-gcc

    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /bin/mkdir -p
    checking for gawk... no
    checking for mawk... mawk
    checking whether make sets $(MAKE)... yes
    checking for gcc... gcc
    checking for C compiler default output file name... a.out
    checking whether the C compiler works... configure: error: cannot run C compiled programs.


    The reason of failed test was the gcc compiler was wrong. See
    I downloaded "Sourcery G++ Lite Edition for ARM" with target OS "EABI". After I switched to the one target OS "GNU/Linux", the error disappeared.

    2010-09-15

    Installation xp on Thinkpad Edge 13"

    • Enter BIOS, set S-ATA(AHCI) to S-ATA(Compatible), otherwise, you will get bluescreen during installation xp on a thinkpad notebook.
    • Find the latest drivers of Thinkpad laptop here.
    • Create an image for system disk after installation of system, driver, hotfix. Ghost 2003 BootCD, whose iso file can be downloaded here, is a good tool to do this job. It also supports USB CD-Rom, which old Ghost may not support. 
    • EASEUS Partition Master - Home Edition is very nice free disk partition software.

    2010-09-08

    Should I refactor?

    A more important question suppose to be "why should I refactor?"

    Becasue we have to constantly change our code. You may ask, "is it possible some computer genius can implement a software just for once, then the software works perfectly and it requires no further efforts?" The answer is NO. If it is a real software, not just a simple programming exercise task, this kind "once forever" story never happens. In this cruel world, we must be ready to change the given code, perhaps quite often, for example fixing new bugs, adding new features or porting to other programs.

    The structure of software becomes more and more complex, even a simple 'notepad' program has hundreds of lines. It is a nightmare for a programmer to changing a spaghetti code mess to make the software work as you wish. Thusfore, we need a good program struture. It can only save a lot of time, effort and money, but more importantly, it makes the software is maintainable, scalable and reliable against to modifications.

    Is it possible that architecture can design a nice structure from top to bottom at the beginning, then programmers just write the code execatly according to this perfect design? Theoretically maybe, in pracice almost IMPOSSIBLE. The truth is that you can only more clearly understand your problem, as you have start to tackle it. In a design phase of a software project, it is diffcult for architectures and developpers to fully understand all requirements, to see all aspects of implmenetation and design a perfect structure, until the implementation really is ongoing and people meet one unexpected problem after the other and little by little have a better idea to implement the software. Don't be frustrated, we are human with a limited perception, even the best programmer.

    As we constantly update our understanding of project and decide to improve the structure, refactor comes into the play. Refactor is a work that make the program have a better inner struture, but doesn't change it external function and behavior.

    "What is a better structure?" I think a good structure is a realization of a right design pattern, so that people can esily understand the code and easily change the code in future.

    Personally, I like to refactor before I have to change the code. For example, I want to implement a new feature of software and I find out that I need to change more than ten classes. It is a smell of bad structure. I'd better refactor the program at first. After refactoring, the program has a better inner strucure, perhaps I only need to write a tiny subclass to implement the feature. Summary: Before you want to change the existing code, think about at first the possiblity of refactor. Believe me, you will largely benifit from this good programming habit.

    Sometimes, if I don't have too much time pressure, I'd like to spend some hours to investigate whether some classes in the project are too big or too complicated. The command below could be useful to show the line number of class files:

    >find -type f -name '*.qml' | xargs wc -l | less

    A class with huge size may be a candidate of refactor, more specifically, decomposition: sperate it into several small classes. Small classes are better, easily to understand and easily to maintain than big ones.

    2010-09-07

    Processing each line of a file by batch

    An example of processing each line of a given file
    @echo off
    for /f "delims=] tokens=1*" %%a in ('find /v /n "" ^<.\newsources.txt') do (
       echo %%b
    )
    

    QML Weather

    Based on Google online API, Max implemented a weather panel using QML (Qt 4.7 declarative).


    The three XmlListModels are used to extract need information for display.


    RssModeInfo.qml
    XmlListModel {
        source: "http://www.google.com/ig/api?weather=forchheim"
        query: "/xml_api_reply/weather/forecast_information"
    
        //forecast information
        XmlRole { name: "city"; query: "city/@data/string()" }
        XmlRole { name: "forecast_date"; query: "forecast_date/@data/string()" }
        XmlRole { name: "current_date_time"; query: "current_date_time/@data/string()" }
    

    RssModeCurrent.qml
    XmlListModel {
        source: "http://www.google.com/ig/api?weather=forchheim"
        query: "/xml_api_reply/weather/current_conditions"
    
        //current condition
        XmlRole { name: "condition"; query: "condition/@data/string()" }
        XmlRole { name: "temp_c"; query: "temp_c/@data/string()" }
        XmlRole { name: "humidity"; query: "humidity/@data/string()" }
        XmlRole { name: "icon"; query: "icon/@data/string()" }
        XmlRole { name: "wind_condition"; query: "wind_condition/@data/string()" }
    
    }
    

    RssModeDailyForecast.qml
    XmlListModel {
        property int index
    
        source: "http://www.google.com/ig/api?weather=forchheim"
        query: "/xml_api_reply/weather"
    
        XmlRole { name: "day_of_week"; query: "forecast_conditions[" + index.toString() + "]/day_of_week/@data/string()" }
        XmlRole { name: "low_f"; query: "forecast_conditions[" + index.toString() + "]/low/@data/string()" }
        XmlRole { name: "high_f"; query: "forecast_conditions[" + index.toString() + "]/high/@data/string()" }
        XmlRole { name: "icon"; query: "forecast_conditions[" + index.toString() + "]/icon/@data/string()" }
        XmlRole { name: "condition"; query: "forecast_conditions[" + index.toString() + "]/condition/@data/string()" }
    
    } 

    2010-09-06

    Google Weather API

    iGoogle Weather Feed API hasn't yet officially support the xml feed of weather. Anyway it can be used by http://www.google.com/ig/api?weather=$city.

    For example, you want the rss feed of shanghai:

    http://www.google.com/ig/api?weather=shanghai

    In the xml, you will get current conditions and 4-days forcast.

    22 Possible condition icons:

    chance_of_rain.gif
    sunny.gif
    mostly_sunny.gif
    partly_cloudy.gif
    mostly_cloudy.gif
    chance_of_storm.gif
    showers.gif
    rain.gif
    chance_of_snow.gif
    cloudy.gif
    mist.gif
    storm.gif
    thunderstorm.gif
    chance_of_tstorm.gif
    sleet.gif
    snow.gif
    icy.gif
    dust.gif
    fog.gif
    smoke.gif
    haze.gif
    flurries.gif

      Reference:

      2010-09-01

      QRegExp Extracts the Content of Online-News

      The following example shows how to extract the string between <div class="yn-story-content"> and </div>.

      ContentExtractor::ContentExtractor(QObject *parent)
          : QObject(parent)
      {
      
          //regexp pattern
          QString escape1 = QRegExp::escape("<div class=\"yn-story-content\">");
          QString escape2 = QRegExp::escape("</div>");
          QString aPattern = escape1 + "(.*)?" + escape2;
          regExp_.setPattern ( aPattern );
          regExp_.setMinimal ( true );
          regExp_.setCaseSensitivity(Qt::CaseInsensitive);
      }
      void ContentExtractor::extractContent(QString text_in)
      {
          if (regExp_.indexIn(text_in) != -1) {
              content_ = regExp_.cap(1);
              content_ = content_.trimmed();
              content_ = content_.remove('\n');
              content_ = content_.remove('\t');
          }
      }
      

      It could be very useful to extract the contents of online news. If the extractor is applied on the page "http://news.yahoo.com/s/ap/20100831/ap_on_re_us/us_obama" and content_ is displayed by Text element in QML, you will get well-formatted news text:


      If you want to get the source, please let me know.

      2010-08-25

      Case-insensitive XPath Search

      An example of case-insensitive xpath search: to find all the contact items whose name contain 'mac', 'MAC', 'Mac' and so on.

      string lookfor = "Mac"
      query = "/contacts/contact" + "[contains(lower-case(name),'"+ lookfor.toLowerCase() + "')]";
      

      Refernece:
      http://geekswithblogs.net/ranganh/archive/2005/09/12/53520.aspx

      2010-08-24

      15 Practical Linux Find Command Examples

      1. Find Files Using Name
      2. Find Files Using Name and Ignoring Case
      3. Limit Search To Specific Directory Level Using mindepth and maxdepth
      4. Executing Commands on the Files Found by the Find Command.
      5. Inverting the match.
      6. Finding Files by its inode Number.
      7. Find file based on the File-Permissions
      8. Find all empty files (zero byte file) in your home directory and it’s subdirectory
      9. Finding the Top 5 Big Files
      10. Finding the Top 5 Small Files
      11. Find Files Based on file-type using option -type
      12. Find files by comparing with the modification time of other file
      13. Find Files by Size
      14. Create Alias for Frequent Find Operations
      15. Remove big archive files using find command

      Reference:
      http://www.thegeekstuff.com/2009/03/15-practical-linux-find-command-examples/

      3D QML

      2010-08-10

      Clone a old version in Mercurial

      >hg clone --rev $version $path $foldname
      For example
      >hg clone --rev 38 https://bitbucket.org/project/sum sum-38

      Reference:
      http://stackoverflow.com/questions/2540454/mercurial-revert-back-to-old-version-and-continue-from-there

      2010-08-05

      'extend' property of Qml State

      The property 'State.extend' holds the base state. When a state extends another state, it inherits all the changes of the base state and you need only specify the difference in your extended state. The usage of this property can largely reduce the code size: See the example below:

      Without using extend (bad)
      states: [
      State { name: "album"
       PropertyChanges { target: but_album; state: 'Selected' }
       PropertyChanges { target: but_radio; state: 'Unselected' }
       PropertyChanges { target: but_rss; state: 'Unselected' }
      },
      State { name: "radio"
       PropertyChanges { target: but_album; state: 'Unselected' }
       PropertyChanges { target: but_radio; state: 'Selected' }
       PropertyChanges { target: but_rss; state: 'Unselected' }
      },
      State { name: "rss"
       PropertyChanges { target: but_album; state: 'Unselected' }
       PropertyChanges { target: but_radio; state: 'Unselected' }
       PropertyChanges { target: but_rss; state: 'Selected' }
      }
      ]
      



      Using extend (good)
      states: [
      State { name: "default"
       PropertyChanges { target: but_album; state: 'UnSelected' }
       PropertyChanges { target: but_radio; state: 'Unselected' }
       PropertyChanges { target: but_rss; state: 'Unselected' }
      },
      State { name: "album"; extend: 'default'
       PropertyChanges { target: but_album; state: 'Selected' }
      },
      State { name: "radio"; extend: 'default'
       PropertyChanges { target: but_radio; state: 'Selected' }
      },
      State { name: "rss"; extend: 'default'
       PropertyChanges { target: but_rss; state: 'Selected' }
      }
      ] 

      Reference:
      http://doc.qt.nokia.com/4.7-snapshot/qml-state.html#extend-prop

      2010-08-02

      Merge in Mercurial

      >hg push (fail due to different heads, merge is required)
      pushing to http://joel.example.com:8000/
      searching for changes
      abort: push creates new remote heads!
      (did you forget to merge? use push -f to force)
      >hg pull
      >hg merge (manually merge is sometimes required to solve the conflict)
      >hg com -m "merge"
      >hg push

      Reference: 
      http://hginit.com/top/04.html

      2010-07-18

      Use KDiff3 in Mercurial

      Firstly install KDiff3 by
      >sudo apt-get install kdiff3

      Then, add ~/.hgrc

      [extensions]
      hgext.extdiff =
      
      [extdiff]
      cmd.kdiff3 =
      
      [merge-tools]
      kdiff3.args = $base $local $other -o $output

      Now it should work. Try
      >hg kdiff3

      Reference:

      GSpace for Online Disk

      I setup a 7G Gspace online disk. Actually, what you need is a free gmail acount and installation of an add-on on your firefox browser. See the http://www.getgspace.com/ for installation and usage.

      2010-07-13

      Use Firefox 3.6.3 under Debian

      See the article:
      http://www.shellperson.net/install-firefox-3-6-in-debian-lenny/

      2010-06-29

      Setup USB-Mouse under Debian

      Machine: Thinkpad510SL
      System: Debian Lenny
      Kernel: 2.6.26-2-686

      > sudo modprobe usbmouse

      If you want to load the module at boot time, add 'usbmouse' into /etc/modules.

      Sometimes the scrolling doesn't work so well, I update the /etc/X11/xorg.conf
      =================

      Section "InputDevice"
              Identifier      "USB Mice"
              Driver           "mouse"
              Option          "Device" "/dev/input/mice"
              Option          "Protocol" "IMPS/2"
              Option          "ZAxisMapping" "4 5"
      EndSection

      =================

      Reference:

      2010-06-22

      Downgrade Package in Debian

      To downgrade the package to old version, you need to download the old package and install it by
      >sudo dpkg --install package.deb

      Show Column of File by cat + cut

      Do test as following:

      >dpkg-query -l > package.txt
      >cat package.txt | cut -d " " -f3

      =============
      ....
      xserver-xorg-video-r128
      xserver-xorg-video-radeon
      xserver-xorg-video-radeonhd
      xserver-xorg-video-rendition
      xserver-xorg-video-s3
      xterm
      .....

      2010-06-21

      Define Font in QML

      Due to the bug QTBUG-11611, you should avoid to use relative path to define font file in qml code. Otherwise if you load the qml file by QDeclarativeView in c++ code, you will get a error message like "Cannot load font: QUrl( "file:///D:/work/projects/qt/fonts-build/fonts/tarzenau-ocr-a.ttf" )".


      //bad example
      FontLoader { id: localFont; source: "fonts/tarzenau-ocr-a.ttf" }
      Text {
         text: myText; color: "lightsteelblue"
         font.family: localFont.name; font.pointSize: 42
      }
      

      //good example
      //but you need to copy tarzenau-ocr-a.ttf to ~/.fonts 
      //or $WINDOWS/Fonts in windows
      Text {
         text: myText; color: "lightsteelblue"
         font.family: "tarzenau-ocr-a"; font.pointSize: 42
      }
      
      You can reuse this script to install your font to ~/.font.
      #!/bin/sh
      # This script install the ttf files in source to ~./fonts
      
      SOURCEDIR=../fonts
      TARGETDIR=~/.fonts
      
      #=====================
      # check font dir
      #=====================
      
      if [ ! -d $TARGETDIR ]; then
         echo "$TARGETDIR does not exist! => create it."
         mkdir $TARGETDIR
      fi
      
      if [ ! -d $TARGETDIR ]; then
         echo "Error: Fail to create $TARGETDIR!"
         exit 1
      fi
      
      #=====================
      # check source font dir
      #=====================
      if [ ! -d $SOURCEDIR ]; then
          echo "Error: source font dir '$SOURCEDIR' does not exist!"
          exit 1
      fi
      
      #================
      # copy start
      #================
      
      cp -f $SOURCEDIR/*.ttf $TARGETDIR/
      echo "ttf files in '$SOURCEDIR' have been copy to '$TARGETDIR'"
      echo "Success."
      

      2010-06-18

      Build Qt with support of png, jpeg, tiff

      Strongly recommanded to build Qt with his own library of png, jpeg, tiff by
      ./configure -qt-libtiff -qt-libpng -qt-libjpeg


      Actually, these options are not default (marked with +). See "configure Options (Qt)": 

      
              -no-zlib ........... Do not compile in ZLIB support. Implies -no-libpng.
              -qt-zlib ........... Use the zlib bundled with Qt.
           +  -system-zlib ....... Use zlib from the operating system.
                                   See http://www.gzip.org/zlib
      
              -no-gif ............ Do not compile the plugin for GIF reading support.
           *  -qt-gif ............ Compile the plugin for GIF reading support.
                                   See also src/plugins/imageformats/gif/qgifhandler.h
      
              -no-libtiff ........ Do not compile the plugin for TIFF support.
              -qt-libtiff ........ Use the libtiff bundled with Qt.
           +  -system-libtiff .... Use libtiff from the operating system.
                                   See http://www.libtiff.org
      
              -no-libpng ......... Do not compile in PNG support.
              -qt-libpng ......... Use the libpng bundled with Qt.
           +  -system-libpng ..... Use libpng from the operating system.
                                   See http://www.libpng.org/pub/png
      
              -no-libmng ......... Do not compile the plugin for MNG support.
              -qt-libmng ......... Use the libmng bundled with Qt.
           +  -system-libmng ..... Use libmng from the operating system.
                                   See http://www.libmng.com
      
              -no-libjpeg ........ Do not compile the plugin for JPEG support.
              -qt-libjpeg ........ Use the libjpeg bundled with Qt.
           +  -system-libjpeg .... Use libjpeg from the operating system.
                                   See http://www.ijg.org
      
              -no-openssl ........ Do not compile support for OpenSSL.
           +  -openssl ........... Use OpenSSL from the operating system.

      If Qt is not built with these options. sometime images cannot be correctly displayed. See this QTBUG-11453.

      Change Keyboard Layout in Xterm

      Change "XkbLayout" in /etc/X11/xorg.conf


      ===================== 
      Section "InputDevice"
          Identifier  "Keyboard1"
          Driver      "Keyboard"
          Option "AutoRepeat" "500 30"
          Option "XkbRules"   "xfree86"
          Option "XkbModel"   "pc105"
          Option "XkbLayout"  "de"
      EndSection
      =====================
       
      Switch of beep at xterm
      Add "xset b off" into .bashrc or /etc/profile

      
      

      2010-06-15

      Observe Linux Process

      • >ps aux | less
      • >top
      • >htop
      • >atop

      Reference:
      Show All Running Processes in Linux

      'man' Section Number

      The manuals in Linux have been grouped into several sections.

             1   Executable programs or shell commands
             2   System calls (functions provided by the kernel)
             3   Library calls (functions within program libraries)
             4   Special files (usually found in /dev)
             5   File formats and conventions eg /etc/passwd
             6   Games
             7   Miscellaneous (including macro  packages  and  convenâ
                 tions), e.g. man(7), groff(7)
             8   System administration commands (usually only for root)
             9   Kernel routines [Non standard]

      The default action is to search in all of the available sections, following a pre-defined order and to show only the first page found, even if page exists in several sections. For example, if you want to see the explicit description of /etc/exports ( a configuration file of nfs server) in section 5,
      >man 5 export

      You can check the table in above simply by
      >man man

      2010-06-14

      Set Base Url of QML Files

      You may deploy all qml file to a fold called qml in the same place of main.exe file. For example

      debian:~/project/tmp/release# tree
      .
      |-- main.exe
      `-- qml
          |-- BasicButton.qml
          |-- Battery.qml
          |-- Calendar.qml
          |-- main.qml

      In the main.cpp, you have to specifiy the base url of qml. See the sampe:

      #include <QApplication>
      #include <QDeclarativeView>
      #include <QDeclarativeContext>
      #include <QDeclarativeEngine>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QDeclarativeView view;
      
          view.engine()->setBaseUrl(QUrl("./qml/"));
          view.setSource(QUrl("main.qml"));
          view.show();
      
          return app.exec();
      }
      

      Qt Quick will not be officially release with Qt creator 2.0

      Qt blog: Qt Creator 2.0: It’s a Release Candidate! reports that the nice Qt Quick will not be released in Qt creator 2.0 this summer. Too bad. Maybe guys need more time for code stablization. But user can still enable the Qt Quick feature in Qt Creator 2.0 by build the Qt creator source code.
      "Also, if you desperately want it back for 2.0 already, you can build Qt Creator yourself and enable the QML support by exporting QTCREATOR_WITH_QML before running qmake. "

      Some Terms of VoIP


      VoIP: voice over IP network.
      SIP: Session Initiation Protocol
      miniSipServer: a VOIP server for Microsoft windows system

      2010-06-12

      Switch between Background and Foreground Process

      > ${software} & (run in background)
      > ${software} (run in foreground)
      ctrl+Z (suspend)
      ctrl+Z then bg (bring the suspend process to background)
      fg (bring the background process back to foreground)

      2010-06-10

      Recursively Change All Files Mode

      When people copy a hg repository from Windows to linux, he may meet a annoying problem: All the files have x mode linux. You can check this by
      >hg st
      all the files are modified
      >hg diff
      no context difference.

      A simple solution is to recursively remove the x mode of all files by
      >find . -type f | xargs chmod a-x

      In mercurial, you can use 'hg revert ${changed-file}' to restore the mode of file, but you need to make it sure that except of mode, the file is nothing changed.

      2010-06-04

      Best Practice of Mercurial Teamwork

      1. If you haven’t done so in a while, get the latest version that everyone else is working off of:
        • hg pull
        • hg up
      2. Make some changes
      3. Commit them (locally)
      4. Repeat steps 2-3 until you’ve got some nice code that you’re willing to inflict on everyone else
      5. When you’re ready to share:
        • hg pull to get everyone else’s changes (if there are any)
        • hg merge to merge them into yours
        • test! to make sure the merge didn’t screw anything up
        • hg commit (the merge)
        • hg push

      Reference:

      2010-06-01

      SVG Color Keyword Names

      QML in Qt can use the color keyword in SVG definition. See Recognized color keyword names.

      scp Examples

      Copy the file "foobar.txt" from a remote host to the local host
      $ scp your_username@remotehost.edu:foobar.txt /some/local/directory

      Copy the file "foobar.txt" from the local host to a remote host
      $ scp foobar.txt your_username@remotehost.edu:/some/remote/directory

      Copy the directory "foo" from the local host to a remote host's directory "bar"
      $ scp -r foo your_username@remotehost.edu:/some/remote/directory/bar 

      Reference:

      2010-05-31

      md5sum

      md5sum is a wide-used tool for checking the integrity of files after data transfers. Especially, when you download some big files (such as image of system), you may want to ensure that the huge files have been fully correctly download to your local disk. Usually, data privider will offer a md file to let user check the integrity. See the example in http://downloads.openwrt.org/backfire/10.03/rb532/. After download all the data files,  you also need to download the md5sums file into the same directory and run
      >md5sum -c md5sum

      About how to create a md file is shown below:
      >md5sum file > file.md5 (single file)
      >find directory -type f -print0 | xargs -0 md5sum >> file.md5 (all file in a directory)

      Reference:

      2010-05-28

      nfs-kernel-server vs. nfs-user-server

      Max tried to install nfs-server on his Debian machine.
      >sudo apt-get install nfs-kernel-server
      Everything looks fine, except of this warning message:
       
      Not starting NFS kernel daemon: no support in current kernel. (warning)
       
      It seems that the current kernel doesn't support nfs kernel daemon. After googling for sometime, I found that rebuild the kernel is the solution for the problem (http://computingplugs.com/index.php/NFS_server). It is funny that my self-built kernel 2.6.34 has no the option

      [*] Root file system on NFS

      in 'make menuconfig'.

      The other solution is to install nfs-user-server, which runs in the user-mode, not in kernel-model.

      >sudo apt-get install nfs-user-server
      >/etc/init.d/nfs-user-server restart

      Reference:

       
       

      Difference between Virtualbox and Virtualbox-ose

      The full VirtualBox package is available in binary (executable) form free of charge from the Downloads page. This version is free for personal use and evaluation under the terms of the VirtualBox Personal Use and Evaluation License.

      The VirtualBox Open Source Edition (OSE) is the one that has been released under the GPL and comes with complete source code. It is functionally equivalent to the full VirtualBox package, except for a few features that primarily target enterprise customers. This gives us a chance to generate revenue to fund further development of VirtualBox.


      Reference:

      Description of /apt/etc/sources.list

      #####################
      deb http://ftp.de.debian.org/debian/ lenny main non-free contrib
      deb-src http://ftp.de.debian.org/debian/ lenny main non-free contrib
      #####################

      deb/deb-src, indicates the type of archive: whether it contains binary packages (deb) or source packages (deb-src)
      http://ftp.de.debian.org/debian/: repository of packages, it can be ftp, http, file and so on.
      lenny: distribution, e.g. stable, testing sid...
      main non-free contri: different licence sections in the package repository.
      • main: the official Debian distribution, full free use and redistribution.
      • contri: Packages in this area are freely licensed by the copyright holder but depend on other software that is not free.
      • non-free:  Packages in this area have some onerous license condition restricting use or redistribution of the software.

      A Short Summary of Debian Package Management

      # apt-get update (update local database using newest sources.list)
      # apt-cache search string (search all packages contain the string)
      # apt-get install package (install package)
      # apt-get remove package (remove package)
      # apt-get --purge remove package (remove package and config files)
      # apt-cache show abcde (show info of package, e.g. dependency..)
      # apt-get dist-upgrade (upgrade the installed package to latest version)

      Reference
      

      2010-05-25

      2010-05-24

      Full Screen Mode of Virtualbox

      Left-Ctrl + F is the shortcut to switch between full screen and normal screen modes for virtualbox.

      Error "cannot find -lXrender" at Build of QT

      Reason: missing package of libxrender-dev.
      >sudo apt-get update
      >sudo apt-get install libxrender-dev

      2010-05-20

      Data Share in Virtualbox

      1. Host: Debian
      2. Guest: WindowXP
      3. Virtual Machine Software: Virtualbox -1.6.6_OSE
      4. Share fold: ~/shared
      5. Fold name: shared
      6. AdditionGuestIso: http://www.genunix.org/dist/vbox/VBoxGuestAdditions_1.6.6.iso. Note that don't use the item "Devie->Install Guest Addition", but mount the downloaded iso directly and run the setup.exe.
      7. map to shared fold on Guest: net use x: \\vboxsvr\shared

        Reference:

        Loading and Unloading Modules

        insmod: load module to kernel
        modprobe: load module. But Modprobe loads the modules that a module depends on, "insmod" does not.
        rmmod: remove module from kernel.
        lsmod: list the modules currently loaded in kernel.

        Downgrade to Kernel 2.6.26.686 to Install Virtualbox-ose

        In order to install virtualbox-ose, Max have to downgrade from 2.6.34.4 back to 2.6.26.686. The detail installation steps see Debian Wiki Virtualbox.

        # aptitude install virtualbox-ose virtualbox-ose-modules-$(uname -r)
        # invoke-rc.d udev reload
        # modprobe vboxdrv
        # adduser yourusername vboxusers

        To load the vboxdrv module at system startup, edit /etc/default/virtualbox-ose and set LOAD_VBOXDRV_MODULE to 1.

        2010-05-19

        FVWM-Crystal Shortcuts

        Mouse buttons:
        • Right mouse button click on desktop – opens up a terminal
        • Middle mouse button click on desktop – turns on and off the feature to switch desktops by moving the mouse cursor to the edge of the screen
        Keyboard:
        • ALT+TAB
        • ALT+F1ALT+F10 – switching between virtual desktops 1-10
        • ALT+Escape – switching between the two recently used desktops (cool stuff)
        • Num-5 – change of focus between the two recent apps (even cooler stuff!)
        • ALT+` – opens and closes QuakeConsole window - a nice virtual terminal (which can be xterm, aterm or mrxvt, depending on our choice) - the terminal comes out of nowhere and shows up in the top part of the desktop
        • ALT+Shift+` – opens up a new terminal window (xterm, aterm, mrxvt, Eterm or gnome-terminal)
        • ALT+; – opens up and closes FvwmConsole - a place where we can watch FVWM logs, as well as issue commands and FVWM scripts - I usually use it for launching custom apps
        • ALT+Menu – triggers a menu show up (the Diamond menu with all the applications, etc)
        • ALT+= maximizes current window (back and forth)
        • ALT+Backspace minimizes the current window to a desktop icon
        • ALT+Shift+Backspace closes the current window
        • ALT+Shift+= – full screen (and back to normal size)
        • ALT+z/b – previous/next track in the music player
        • ALT+x/c/v – start/pause/stop playing
        • ALT+./, – mixer volume up/down
        Reference:

        Kernel Compression Mode

        KERNEL_GZIP
        The old and tried gzip compression. Its compression ratio is
        the poorest among the 3 choices; however its speed (both
        compression and decompression) is the fastest.
        KERNEL_BZIP2
        Its compression ratio and speed is intermediate.
        Decompression speed is slowest among the three. The kernel
        size is about 10% smaller with bzip2, in comparison to gzip.
        Bzip2 uses a large amount of memory. For modern kernels you
        will need at least 8MB RAM or more for booting.
         KERNEL_LZMA
        The most recent compression algorithm.
        Its ratio is best, decompression speed is between the other
        two. Compression is slowest. The kernel size is about 33%
        smaller with LZMA in comparison to gzip.

        Reference:

        2010-05-17

        Walkthought of QML Calculator Example

        CalcButton.qml
        import Qt 4.7
        import Qt 4.7
        
        Rectangle {
            /*  The property button.operation, exposed ouside, is connect to the property of inner item label.text. See 'Property aliases' (http://doc.qt.nokia.com/4.7-snapshot/qml-extending-types.html#property-aliases) */
            property alias operation: label.text
            /*  Toggle behavior of button, default is not toggable. The property of button 'Advanced Mode' is set true. */
            property bool toggable: false
            /*  Porperty to tracking the toggle state of button. */
            property bool toggled: false
        
            /*  We want the button has a signal called clicked. */
            signal clicked
        
            id: button; width: 50; height: 30
            /*  border.color is a item among grouped property border. See 'Grouped property'(http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeintroduction.html#grouped-properties) palette gives access to the system Qt color. e.g dark, light mid and so forth. See 'QML SystemPalette Element Reference'(http://doc.qt.nokia.com/4.7-snapshot/qml-systempalette.html#mid-prop) */
            border.color: palette.mid
            /*  This property holds the corner radius used to draw a rounded rectangle. See 'Rectangle.radius' (http://doc.qt.nokia.com/4.7-snapshot/qml-rectangle.html#radius-prop) */
            radius: 6
            /*  1) The gradient to use to fill the rectangle. Here gradientStop1 is the start color from upper boundary, while gradientStop2 is the end color at the bottom. See 'Gradient' (http://doc.qt.nokia.com/4.7-snapshot/qml-rectangle.html#gradient-prop)
                2) Qt.lighter is a global function return a color lighter than given color. See 'Global Function' (http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeglobalobject.html)
                */
            gradient: Gradient {
                GradientStop { id: gradientStop1; position: 0.0; color: Qt.lighter(palette.button) }
                GradientStop { id: gradientStop2; position: 1.0; color: palette.button }
            }
        
            /*  Button text is located at enter of button and use system default buttonText*/
            Text { id: label; anchors.centerIn: parent; color: palette.buttonText }
        
            /*  The MouseArea item enables simple mouse handling.*/
            MouseArea {
                id: clickRegion
                /*  Area covers entire button.*/
                anchors.fill: parent
                /*  Signal Handlers for click on MouseArea. */
                onClicked: {
                    /*???*/
                    doOp(operation);
                    /*  A 'clicked' signal of parent is emitted.*/
                    button.clicked();
                    /*  For toggle behavior of button.*/
                    if (!button.toggable) return;
                    button.toggled ? button.toggled = false : button.toggled = true
                }
            }
        
            /*  Beside of default state, the button has the other action states: Pressed and Toggled. Notice they have own condition to enter the state. In these two actions states, the starting gredient changes to palette.dark to distinguish from default appearance. */
            states: [
        
                State {
                    name: "Pressed"; when: clickRegion.pressed == true
                    PropertyChanges { target: gradientStop1; color: palette.dark }
                    PropertyChanges { target: gradientStop2; color: palette.button }
                },
                State {
                    name: "Toggled"; when: button.toggled == true
                    PropertyChanges { target: gradientStop1; color: palette.dark }
                    PropertyChanges { target: gradientStop2; color: palette.button }
                }
            ]
        }
        


        calculator.qml
        import Qt 4.7
        
        import Qt 4.7
        
        Rectangle {
            /*  The property button.operation, exposed ouside, is connect to the property of inner item label.text. See 'Property aliases' (http://doc.qt.nokia.com/4.7-snapshot/qml-extending-types.html#property-aliases) */
            property alias operation: label.text
            /*  Toggle behavior of button, default is not toggable. The property of button 'Advanced Mode' is set true. */
            property bool toggable: false
            /*  Porperty to tracking the toggle state of button. */
            property bool toggled: false
        
            /*  We want the button has a signal called clicked. */
            signal clicked
        
            id: button; width: 50; height: 30
            /*  border.color is a item among grouped property border. See 'Grouped property'(http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeintroduction.html#grouped-properties) palette gives access to the system Qt color. e.g dark, light mid and so forth. See 'QML SystemPalette Element Reference'(http://doc.qt.nokia.com/4.7-snapshot/qml-systempalette.html#mid-prop) */
            border.color: palette.mid
            /*  This property holds the corner radius used to draw a rounded rectangle. See 'Rectangle.radius' (http://doc.qt.nokia.com/4.7-snapshot/qml-rectangle.html#radius-prop) */
            radius: 6
            /*  1) The gradient to use to fill the rectangle. Here gradientStop1 is the start color from upper boundary, while gradientStop2 is the end color at the bottom. See 'Gradient' (http://doc.qt.nokia.com/4.7-snapshot/qml-rectangle.html#gradient-prop)
                2) Qt.lighter is a global function return a color lighter than given color. See 'Global Function' (http://doc.qt.nokia.com/4.7-snapshot/qdeclarativeglobalobject.html)
                */
            gradient: Gradient {
                GradientStop { id: gradientStop1; position: 0.0; color: Qt.lighter(palette.button) }
                GradientStop { id: gradientStop2; position: 1.0; color: palette.button }
            }
        
            /*  Button text is located at enter of button and use system default buttonText*/
            Text { id: label; anchors.centerIn: parent; color: palette.buttonText }
        
            /*  The MouseArea item enables simple mouse handling.*/
            MouseArea {
                id: clickRegion
                /*  Area covers entire button.*/
                anchors.fill: parent
                /*  Signal Handlers for click on MouseArea. */
                onClicked: {
                    /*???*/
                    doOp(operation);
                    /*  A 'clicked' signal of parent is emitted.*/
                    button.clicked();
                    /*  For toggle behavior of button.*/
                    if (!button.toggable) return;
                    button.toggled ? button.toggled = false : button.toggled = true
                }
            }
        
            /*  Beside of default state, the button has the other action states: Pressed and Toggled. Notice they have own condition to enter the state. In these two actions states, the starting gredient changes to palette.dark to distinguish from default appearance. */
            states: [
        
                State {
                    name: "Pressed"; when: clickRegion.pressed == true
                    PropertyChanges { target: gradientStop1; color: palette.dark }
                    PropertyChanges { target: gradientStop2; color: palette.button }
                },
                State {
                    name: "Toggled"; when: button.toggled == true
                    PropertyChanges { target: gradientStop1; color: palette.dark }
                    PropertyChanges { target: gradientStop2; color: palette.button }
                }
            ]
        }
        

        2010-05-16

        How To Compile A Kernel

        Max updated the kernel from 2.6.32-bpo.3-686 to 2.6.33,
        Download the kernel source from www.kernel.org and
        following the tutorial [1] and [2].

        make CONFIG_DEBUG_SECTION_MISMATCH=y???
        Reference:

        2010-05-15

        Start a Program as FVWM-Crystal Startup

        > cp /usr/share/fvwm-crystal/fvwm/preferences/Startup ~/.fvwm/preferences/Startup

        and edit as needed.

        Reference:
        How do i make things run at fvwm-crystal startup?

        Setup Wireless of ThinkPad SL510 in Debian

        Thinkpad sl510 has a intel wireless card:
        ==============
        Intel(R) WiFi Link 1000 BGN
        ==============

        Unfortunately, Debian Lenny with kernel  2.6.26 cannot support this card. You could install a 2.6.32 kernel image from backport. Follow the ref [1].
        Or, you could directly compile a 2.6.33 kernel from source code. According to [3], the Intel Wireless WiFi Link 1000 is supported since 2.6.33. Follow the tutorial in [4]

        Afterwards, Max installed a gui-based network manager software wicd-client.
        Follow the ref [2].

        Reference:

        2010-05-14

        QWidget vs QML

        "QWidgets are a better choice if your UI is comprised of a small number of complex and static elements, and QML is a better choice if your UI is comprised of a large number of simple and dynamic elements."
        Reference:

        2010-05-13

        Configure Sound for Debian

        See the artical in Germany

        Konfigurieren der Soundkarte mit alsaconf und amixer

        Show Hareware in Linux

        There are three commands are very useful to show hardware in Linux
        > lspci (pci device)
        > lsusb (usb device)
        > lshw (general hardware)
        > dsmeg (prints the message buffer of the kernel)

        Chinese Debian

        A good explained doc on setting update mini chinese Debian.


        http://isis.poly.edu/~qiming/chinese-debian-mini-howto.html

        2010-05-11

        Use Intel Graphic Driver for Debian Lenny onThinkpad SL510

        Thinkpad SL510 has a display adapter "mobile intel 4 series express chipset family".  Debian Lenny with kernel 2.6.26-2-686 is installed. In order to use inter driver, you need to following steps



        1)Modifiy /boot/grub/menu.lst, to set vga=871.

        2) Reconfigure /etc/X11/xorg.conf to use the intel driver:
        ==============
        Section "Device"
        Identifier "Configured Video Device"

        # Add this line to force the driver
        Driver "intel"
        EndSection
        ==============
        3) Reboot

        Reference:

        FVWM-Crystal upon Debian — speed and transparency

        Under Debian Lenny you need to install the following packages:

        >apt-get install fvwm
        >apt-get install fvwm-crystal
        >apt-get install x-window-system

        Add configuration file
        >vim ~/.xinitrc
        type in "exec fvwm-crystal"
        >reboot


        Reference:

         

        2010-05-08

        A Blue-screen Problem during Installation of WindowsXP at ThinkPad

        When Max tried to install WindowsXp on a fresh now ThnikPad, he encountered a blue-screen problem as the system boot from WindowsXP CD. More specifically speaking, after the scanning of hardware and before loading the windows setup program. From the inform on the blue-screen, it seems that something related with hard drive is wrong.

        After some googling, it is found out that XP CD cannot recognize Serial ATA in ACHI. The solution is change the configuration in BIOS.
        Config -> Serial ATA (SATA) > Set AHCI to Compatibility


        Reference:

        2010-05-06

        QML Tutorials (Qt 4.7 snapshot)

        QML is a declarative language designed to describe the user interface of a program: both what it looks like, and how it behaves. QML is an extension to JavaScript, that provides a mechanism to declaratively build an object tree of QML elements. 

        QML improves the integration between JavaScript and Qt's existing QObject based type system, adds support for automatic property bindings and provides network transparency at the language level.


        Reference:



          Qt 4.7 and Qt Creator 2.0

          The first try of Qt Creator 2.0 + Qt 4.7, both of them are in beta phase.
          1. Download them from http://qt.nokia.com/developer/qt-qtcreator-prerelease#download.
          2. Installation
          3. Configuration. Tools->Options->Qt4->Manual.Give correct path of qmake and mingw. e.g. qmake location: c:\qt\4.7.0-beta1\bin\qmake.exe; MinGW directory: c:\Qt\qtcreator-1.3.83\mingw\
          4. Import qml demo. See the video

          2010-05-05

          What is BSP?

          "I think you're referring to the 'Board Support Package'. This usually refers to the OS, and the board-specific drivers in the OS. The BSP is the first thing that must be built in order for an embedded system to work."

          PsTools

          "PsExec is a light-weight telnet-replacement that lets you execute processes on other systems, complete with full interactivity for console applications, without having to manually install client software. PsExec's most powerful uses include launching interactive command-prompts on remote systems and remote-enabling tools like IpConfig that otherwise do not have the ability to show information about remote systems. "
           Reference
          http://technet.microsoft.com/en-gb/sysinternals/bb897553.aspx

          2010-05-04

          Patch on Wrong Version Kernel

          Reversed (or previously applied) patch detected!  Assume -R? [n]

          Above is a common error message when people tried to patch the kernel source. The reason is that you applied the patch on a kernel of wrong version.
          Here is a patched version of linux kernel published by www.kernel.org. For instance, you are going to download 2.6.33.3 kernel source. You have two choices,
          1. Download Full Source. No extra patching is required.
          2. Download Patch und patch on your 2.6.33

          For the second choice, if you try to run patch on the other version. for example 2.6.33.3.  The error shown above will appear. Correct commands are below.

          >tar xzfv linux-2.6.33.tar.gz
          >bunzip2 patch-2.6.33.3.bz2
          >cd linux-2.6.33
          >patch -p1<../patch-2.6.33.3

          Reference:

          2010-05-03

          Window Manager

          Tiling window manager is a window manager with an organization of the screen into mutually non-overlapping frames.
           awesome



          Stacking window manager is a window manager that draws all windows in a specific order, allowing them to overlap, using a technique called painter's algorithm.
          FVWM

          Compositing window manager differentiate from other window managers is that instead of outputting to a common screen, programs each output first to a separate and independent buffer, or temporary location inside the computer, where they can be manipulated before they are shown.
           Compiz

          Reference

          2010-05-02

          Link error during build Qt 4.6.2

          Max encounter the following link error, as he tried to build Qt 4.6.2 with a angstrom toolchain for mini2440 ARM9 board:

          /usr/bin/ld: .obj/release-shared/harfbuzz-buffer.o: Relocations in generic ELF (EM: 40)
          .obj/release-shared/harfbuzz-buffer.o: could not read symbols: File in wrong format
          collect2: ld returned 1 exit status

          After a short analysis, he found out that it supports to be the problem of crossing compiler toolchain.

          >ls -al /usr/bin/gcc
          lrwxrwxrwx 1 root root 63 2009-10-27 20:35 /usr/bin/gcc -> /usr/bin/gcc-4.1
          Here is quick solution, but there may exists better solution.
          >rm /usr/bin/gcc
          >ln -s /opt/toolchains/arm920t-eabi/arm-angstrom-linux-gnueabi/bin/gcc /usr/bin/gcc
          The reconfigure and build everything
          >make confclean
          >./configure -embedded arm -xplatform qws/linux-arm-g++ -depths 16 -qt-mouse-tslib
          >make
          >make install