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: