一些linux和OpenGL的笔记

本来希望能通过google notebook的share功能来分享的,不知什么原因无法使用该功能。

所以只能这样了,内容比较杂

Google Notebook
a bit per day

Last edited January 14, 2011 
要对Nvidia的glew赶尽杀绝(Windows)
之前系统中的OpenGL环境已配置正常,glut, glu, glew都正常,但突然有一天发现Link时会出问题,错误是 unresolved __glewDeleteRenderbuffers
一肚子火,后来想到以前出现过一次,是因为NV的Opengl SDK和gpucomputing sdk都带有glew库,并且it还把它的环境变量设到vs里面了,系统path里面也有,所以编译的时候会使用nv的glew,
但那个glew可能不完整,于是会出问题。 解决方法很简单,删之。如果之前你的OpenGL环境正常,对nv的sdk不会有大的影响,opengl sdk中个别project需要指定在Link的input中glew.lib
今天再次遇到此问题,特意记下,以后遇到同样问题的可以看下是不是这个问题
for atoi, strlen ,etc. if a NULL argument is passed, the behavior is undefined, I got segment fault on linux from atoi(NULL), what's more if you simple wrote
atoi(p); //p == NULL
nothing goes wrong, I think this is because that the compiler optimized the code and remove the line
if you use atoi(p) in some expression, then you got segment fault
解决kubuntu字体偏小的问题
设置Use anti-aliasing 为 System Settings
设置fonts DPI为120DPI
In linux, Alt+F2 shortcut is actually associated with krunner, so when it's gone, you can added it by yourself
in KDE, System Settings->Shortcuts and Gestures->Custom Shortcuts->Preset Actions, 
right click on Preset Action: New->Global Shortcut->Command/URL, name it as Run Application, or any other name your prefer,
set the Trigger to Alt+F2, and Action to krunner
Grub2 - Community Ubuntu Documentation
https://help.ubuntu.com/community/Grub2

Changing the Ubuntu boot splash screen

Post by BIT0103-Ovid on Sat Jun 19, 2010 1:12 am

I am sure most of us doesn't like the color purple [You must be registered and logged in to see this image.] . But unfortunately the Ubuntu boot time splash screen is a purple one [You must be registered and logged in to see this image.] . One to get rid of that [You must be registered and logged in to see this image.] just follow the step mentioned below:

Ubuntu uses the Plymouth theme for the boot up splash screen. In order to get a new look you need to install some new themes. 

1. Go to synaptic package manager. 

2. Search by typing plymouth and you will find some new themes . Install some of those.

3. Now open the terminal and paste the following:

Code: Select All


sudo update-alternatives --config default.plymouth



4. Choose your theme and then restart the PC.

5. Have fun [You must be registered and logged in to see this image.]
HowTo Mount NTFS Filesystem Partition Read Write Access in openSUSE
http://opensuse.swerdna.org/susentfs.html

Permissions and Ownership on NTFS Partitions

The NTFS filesystem does not support Linux permissions or ownership per se. You can't successfully change ownership with the Linux command chown and you can't successfully change permissions with the Linux command chmod. Ownership and permissions are set only in the mount command.

The permissions and ownership properties that are available for NTFS under Linux are not written into the individual files to be retained when the filesystem is unmounted or the computer is turned off. Permissions and ownership obtained under Linux are temporary artifices imposed via the mount command and maintained temporarily by the operating system. They are transient properties that last only until the NTFS partition is unmounted.

1. Create a Repository

svnadmin create /svnrepos

 

2. Create a SVN User

vi /svnrepos/conf/svnserve.conf

In that file add these three lines:

anon-access = none
auth-access = write
password-db = passwd

Create a password file:

vi /svnrepos/conf/passwd

In that file add a line for your user:

# add users in the format : user = password
tony = mypassword

3. Import Your Project

(assuming you’ve put your project files in /projects/myrailsproject)

svn import /projects/myrailsproject file:///svnrepos/myrailsproject

4. Start the SVN Server as Daemon

svnserve -d

Done! You should now have a svn server running with one project named myrailsproject.

Try checking it out of the repository:

svn co svn://192.168.0.2/svnrepos/myyrailsproject

the import step is not really necessary
 
 client&server, linux&windows

Display current label

If the optional argument new-label is not present, e2label will simply display the current filesystem label.
$ sudo e2label /dev/sda1
or
# e2label /dev/sda1
Sample output:

/boot

Set a new label

If the optional argument new-label is present, then e2label will set the filesystem label to be new-label. Ext2 filesystem labels can be at most 16 characters long; if new-label is longer than 16 characters, e2label will truncate it and print a warning message. To set a new label, enter:
# e2label /dev/sdb2 usbstroage
It is also possible to set the filesystem label using the -L option of tune2fs, enter:
# tune2fs -L usbstroage /dev/sdb2

another problem emerged, when i try to update, there's an error message: the package list need to be rebuilt ...
I run : sudo apt-get update, error occurred, then i deleted all the files under /var/lib/apt/lists/
then run: sudo apt-get update, again, the problem fixed
today i upgraded my kubuntu 10.10 to 11.04, but the upgraded kernel can't work, so i uninstalled them, but this lead to a problem
the old kernel 2.6.35-22 can't start too, after hours of tossing I got it right by doing the following:
1. install linux-headers-2.6.35-22
2. install linux-headers-2.6.35-22-generic
3. install nvidia driver
the header packages are downloaded from http://packages.ubuntu.com/
分享:Linux 下压缩与解压.zip和.rar及.7z文件 百度空间_应用平台
http://apps.hi.baidu.com/share/detail/32415223
2)对于.7z

支持 7Z,ZIP,Zip64,CAB,RAR,ARJ,GZIP,BZIP2,TAR,CPIO,RPM,ISO,DEB 压缩文件格式

安装: sudo apt-get install p7zip p7zip-full p7zip-rar
在Linux下开启Chrome Flash的方法 - Chrome使用交流 - Chrome迷论坛
http://bbs.chromi.org/thread-6829-1-1.html
  • sudo mkdir -p /opt/google/chrome/plugins
  • sudo cp /usr/lib/flashplugin-installer/libflashplayer.so /opt/google/chrome/plugins/
  • /opt/google/chrome/google-chrome --enable-plugins
  • 安装texlive 2010及中文 配置
    1. 下载texlive 2010.iso
    2. 安装 perl-tk, 如果命令行安装则不用
         sudo apt-get install perl-tk
    3. 安装 
        a. sudo mount -o loop texlive 2010.iso /media/iso
        b. cd /media/iso
        c. sudo ./install-tl -gui
        d. Language collections中language support只选中文和英文,language-specific documentation 只选英文
            Create symlinks in system directories 改成yes
        e. 开始安装
    4. 配置环境变量
    sudo gedit /etc/bash.bashrc
    在此文件末尾添加
    PATH=/usr/local/texlive/2010/bin/i386-linux:$PATH; export PATH
    MANPATH=/usr/local/texlive/2010/texmf/doc/man:$MANPATH; export MANPATH
    INFOPATH=/usr/local/texlive/2010/texmf/doc/info:$INFOPATH; export INFOPATH
    在 /etc/manpath.config 文件的
    # set up PATH to MANPATH mapping
    这行下面的列表后增加一条:
    MANPATH_MAP /usr/local/texlive/2010/bin/i386-linux /usr/local/texlive/2010/texmf/doc/man
    至此安装过程结束。
    对于64位系统,上速i386-linux应改为x86_64-linux
    5. 配置中文
        a. 安装所需的宏包,命令中xeCJK可写为xecjk:
            sudo tlmgr install xeCJK ctex
        b. Copy the /usr/local/texlive/2010/texmf-var/fonts/conf/texlive-fontconfig.conf file to /etc/fonts/conf.d/10-texlive.conf.
            Run fc-cache -fsv.
    b. 获取中文字体:simfang.ttf simhei.ttf simkai.ttf simli.ttf simsun.ttc simyou.ttf 
            AdobeFangsongStd-Regular.otf 
            AdobeHeitiStd-Regular.otf 
            AdobeKaitiStd-Regular.otf 
            AdobeMingStd-Light.otf 
             AdobeMyungjoStd-Medium.otf 
             AdobeSongStd-Light.otf
        c. 在/usr/share/fonts下创建zh_CN目录(也可是fonts目录下的其他目录),将以上字体复制到zh_CN目录
            cd /usr/share/fonts/zh_CN
            chmod 777 *
            sudo mkfontscale
            sudo mkfontdir
            sudo fc-cache -fsv
            可以通过fc-list :lang=zh-cn查看字体添加是否成功
    or fc-list :lang=zh-cns
            
        d. 修改/usr/local/texlive/2010/texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.def内容为
    % ctex-xecjk-winfonts.def: Windows 的 xeCJK 字体设置,默认为六种中易字体
    % vim:ft=tex

    \setCJKmainfont[BoldFont={SimHei},ItalicFont={KaiTi}] {SimSun}
    \setCJKsansfont{SimHei}
    \setCJKmonofont{FangSong}
    \setCJKfamilyfont{zhsong}{SimSun}
    \setCJKfamilyfont{zhhei}{SimHei}
    \setCJKfamilyfont{zhkai}{KaiTi}
    \setCJKfamilyfont{zhfs}{FangSong}
    \setCJKfamilyfont{zhli}{LiSu}
    \setCJKfamilyfont{zhyou}{YouYuan}

    \newcommand*{\songti}{\CJKfamily{zhsong}} % 宋体
    \newcommand*{\heiti}{\CJKfamily{zhhei}}   % 黑体
    \newcommand*{\kaishu}{\CJKfamily{zhkai}}  % 楷书
    \newcommand*{\fangsong}{\CJKfamily{zhfs}} % 仿宋
    \newcommand*{\lishu}{\CJKfamily{zhli}}    % 隶书
    \newcommand*{\youyuan}{\CJKfamily{zhyou}} % 幼圆

    \endinput

        修改/usr/local/texlive/2010/texmf-dist/tex/latex/ctex/fontset/ctex-xecjk-winfonts.def内容为
    % ctex-xecjk-adobefonts.def: Adobe 的 xeCJK 字体设置,为 Adobe 的四套字体
    % vim:ft=tex

    \setCJKmainfont[BoldFont=Adobe Heiti Std,ItalicFont=Adobe Kaiti Std] {Adobe Song Std}
    \setCJKsansfont{Adobe Heiti Std}
    \setCJKmonofont{Adobe Fangsong Std}

    \setCJKfamilyfont{zhsong}{Adobe Song Std}
    \setCJKfamilyfont{zhhei}{Adobe Heiti Std}
    \setCJKfamilyfont{zhfs}{Adobe Fangsong Std}
    \setCJKfamilyfont{zhkai}{Adobe Kaiti Std}

    \newcommand*{\songti}{\CJKfamily{zhsong}} % 宋体
    \newcommand*{\heiti}{\CJKfamily{zhhei}}   % 黑体
    \newcommand*{\kaishu}{\CJKfamily{zhkai}}  % 楷书
    \newcommand*{\fangsong}{\CJKfamily{zhfs}} % 仿宋
    \newcommand*{\lishu}{\CJKfamily{zhli}}    % 隶书
    \newcommand*{\youyuan}{\CJKfamily{zhyou}} % 幼圆

    \endinput
    OK!以上在Kubuntu 10.04和10.10上均试过,能通过以下测试
    1. test1.tex
    \documentclass{article}
    \usepackage{xeCJK}
    \setCJKmainfont{SimSun}
    \begin{document}
    你好,TeX Live 2009!
    \end{document}
    $ xelatex test1

    2. test2.tex
    \documentclass{ctexart}
    \begin{document}
    你好,TeX Live 2010!\\
    {\songti 这是宋体}\\
    {\heiti 这是黑体}\\
    {\fangsong 这是仿宋}\\
    {\kaishu 这是楷书}\\
    {\lishu 这是隶书}\\
    {\youyuan 这是幼圆}\\
    \end{document}


    $xelatex test2
    Windows 7下硬盘安装Ubuntu 10.04简明教程(非Wubi安装)
    http://www.linuxidc.com/Linux/2010-05/25875.htm

    1、在Windows7中下载并安装EasyBCD_1.7.2

    2、将 Ubuntu-10.04-desktop-i386.iso文件复制到C盘根目录,用压缩软件打开,再打开casper目录,把initrd.lz、 vmlinuz二个文件解压到C盘根目录下。

    3、运行EasyBCD_1.7.2进入操作窗口后,
    点Add/Remove Entries
    再点右下边的NeoGrub
    再点Install NeoGrub
    再点Save
    选中NeoGrub Bootloader,再点Configure

     

    4、在出现menu.lst记事本窗口中输入以下内容并保存:

    root
    kernel /vmlinuz iso-scan/filename=/Ubuntu-10.04-desktop-i386.iso boot=casper splash
    initrd /initrd.lz
    boot

    5、电脑重启后,就会发现启动菜单会多了一项NeoGrub Bootloader,选择后会进入Ubuntu 10.04光盘系统。按快捷键运行(Alt+F2),在运行框内输入:

    sudo umount -l /isodevice

    最后点桌面上的Ubuntu安装图标及可开始正常安装

    加快ubuntu开机速度_E Wind Studio_百度空间
    http://hi.baidu.com/xlf5563/blog/item/c26748d90820216dd1164ef3.html
    加快ubuntu开机速度
    2010年01月22日 星期五 14:30
    加快开机速度
    删除开机画面: sudo apt-get remove ubuntu-xsplash-artwork libusplash0
    设置开机不扫描硬盘: sudo gedit /etc/fstab 寻找所有的UUID=开头的语句把结尾部分的数字全部改成 0 0
    系统减肥
    删除游戏: sudo apt-get remove gnome-games-common
    删除蓝牙装备: sudo apt-get remove libbluetooth3
    删除IDE硬盘支持: sudo apt-get remove hdparm
    未知组件: sudo apt-get remove cron anacron rsync
    删除打印机: sudo apt-get remove cups hplip system-config-printer-common
    删除brasero刻录: sudo apt-get remove libbrasero-media0
    删除扫描仪: sudo apt-get remove xsane-common
    删除E-mail: sudo apt-get remove empathy-doc evolution-common
    删除声音冲突组件: sudo apt-get remove pulseaudio
    删除openoffice: sudo apt-get remove openoffice.org-draw openoffice.org-math openoffice.org-impress openoffice.org-calc openoffice.org-writer
    删除孤立组件: dpkg -l |grep ^rc|awk '{print $2}' |tr ["\n"] [" "]|sudo xargs dpkg -P -
    Keyboard Shortcuts for Bash ( Command Shell for Ubuntu, Debian, Suse, Redhat, Linux, etc) - How-To
    http://www.howtogeek.com/howto/ubuntu/keyboard-shortcuts-for-bash-command-shell-for-ubuntu-debian-suse-redhat-linux-etc/
    Ctrl + A Go to the beginning of the line you are currently typing on
    Ctrl + E Go to the end of the line you are currently typing on
    Ctrl + L               Clears the Screen, similar to the clear command
    Ctrl + U Clears the line before the cursor position. If you are at the end of the line, clears the entire line.
    Ctrl + H Same as backspace
    Ctrl + R Let’s you search through previously used commands
    Ctrl + C Kill whatever you are running
    Ctrl + D Exit the current shell
    Ctrl + Z Puts whatever you are running into a suspended background process. fg restores it.
    Ctrl + W Delete the word before the cursor
    Ctrl + K Clear the line after the cursor
    Ctrl + T Swap the last two characters before the cursor
    Esc + T Swap the last two words before the cursor
    Alt + F Move cursor forward one word on the current line
    Alt + B Move cursor backward one word on the current line
    Tab Auto-complete files and folder names
    C语言的数组初始化 - Lance的专栏 - CSDN博客
    http://blog.csdn.net/sibylle/archive/2008/01/05/2026915.aspx
    5.2.1   数组初始化 
    数组可以用一个列值来初始化,例如
             int v1[] ={1,2,3,4};
             char v2[]={'a','b','c',0};
    当数组定义时没有指定大小,当初始化采用列表初始化了,那么数组的大小由初始化时列表元素个数决定。所以v1和v2分别为 int[4] 和char[4]类型。如果明确指定了数组大小,当在初始化时指定的元素个数超过这个大小就会产生错误。例如:
             char   v3[2] ={'a','b',0};   //错误:太多的初始化值了
             char   v3[3] ={'a','b',0};   //正确

    如果初始化时指定的的元素个数比数组大小少,剩下的元素都回被初始化为   0。例如
             int   v5[8]={1,2,3,4};
    等价于
              int   v5[8]={1,2,3,4,0,0,0,0};
    Linux 文件、内容查找(递归) ,grep ,find - LaoChai的专栏 - CSDN博客
    http://blog.csdn.net/chaiqi/archive/2007/03/05/1521276.aspx

    内容查找(递归)

    grep /etc/httpd/modules/ -lr '51ditu' *

    文件名查找(递归,不适合查找modules)

    find /etc/httpd/ -name httpd.conf 

    LaTex中注释大段文字--慎思 明辨 笃行
    http://harddisc.bokee.com/5277954.html

    在LaTex中的注释有3种:

    1. 用%注释一行文字, 在%后的文字都不予编译;

    2. 用\iffalse .... \fi 包含一段文字, 被包含的文字被注释掉了;

    3. 用\begin{comment} ... \end{comment} 包含被注释的文字, 但是需要在引言区包括相应的宏包, 即 \usepackage{verbatim}.

    LaTeX中注释大块代码的方法 at 男单 618
    http://www.ai7.org/wp/html/24.html

    LaTeX中注释大块代码的方法

    with 3 comments

      在LaTeX中,因为只有行注释符“%”,所以,当有大块代码需要注释时,就比较麻烦。可以采用如下的方法:

    \iffalse  %注释开始
    %需要注释掉的内容
    ……..
    \fi   %注释结束

    其实是条件语句,只不过把条件设置成总是假,当然就等于注释掉了。

    Debian下的pdflatex中文解决方案 - 红联Linux门户 - 中国领先的Linux技术网站 - 网站导航 - Linux发行版技术 - Debian
    http://www.linuxdiyf.com/viewarticle.php?id=55053
    一、首先,安装这些东西吧:apt-get install tetex-bin tetex-base tetex-extra cjk-latex

      dvipdfm-cjk-cmap dvipdfm-cjk dvipdfm texmf-zh gbkfonts gs-cjk-resource,最好还有texlive的那一部分,反正我是装了的。

      二、然后是那几个sim的字体,最好把它安装在你的Debian里面(我的Debian安了好几个漂亮的字体,当然包括这几个基本的sim字体)。

      接下来,去王垠那下载gbkfonts,主要是那个静态链接文件,直接把它放在/usr/bin里面,然后你就可以生成字体了:

      $mkdir texmf-local
      $cd texmf-local
      $gbkfonts /usr/share/fonts/truetype/microsoft/simsun.ttf song
      $gbkfonts /usr/share/fonts/truetype/microsoft/simhei.ttf hei
      ...

      那几个sim字体都这样处理,这个过程最好是普通用户的权限来执行。

      三、下面为dvips设置字体
      $mkdir dvips/config
      $mv cjk.map dvips/
      $cp /usr/share/texmf/dvips/config/config.* dvips/config/

      添加一个文件config.cjk,内容是p +cjk.map

      四、pdftex设置字体
      这时,我的pdftex字体已经可以了,如果你的还不行的话,按下面的做:

      $cp /usr/share/texmf/pdftex/config/pdftex.cfg pdftex/config/
      $cat pdftex.cfg >> pdftex/config/pdftex.cfg

      五、更新字体数据库
      换root来做:
      #cp -r texmf-local /usr/local/share/texmf
      #mkdir /usr/local/share/texmf/fonts/truetype
      #cd /usr/local/share/texmf/fonts/truetype
      #cp /usr/share/fonts/truetype/microsoft/sim* ./

      当然,这里的最后一步,你也可以用软链接来做,ln -s 。

      这时我的字体已经解决了,如果你还没有解决,那么继续:

      把刚才产生的字体目录移动到配置文件(/etc/texmf/texmf.cnf)指定的字体目录下,如果需要放在别的路径下,也可以修改配置文件。另一个默认的路径是 $HOME/texmf。

      最后,这一步是必须的,用root执行mktexlsr,更新字体数据库。

      六、开始测试吧。
    • 創建一個掛載點(目錄),你將通過這個掛載點訪問windows分區。Ubuntu缺省在/media目錄下創建所有文件系統的掛在點。
    mkdir /media/partitionname
    • 掛載相應的分區到這個掛載點。所有的分區可以在/dev下查看, 每一個分區都有一個唯一的標號,普通硬盤以"hd"開頭,SCSI或SATA硬盤以"sd"開頭,後面跟着字母a,b等標示該分區位於第幾個硬盤上,最後面是數字1,2等表示該分區是第幾個分區。 (例如:第一個IDE接口的主硬盤表示為hda,它的第一個分區表示為hda1;第一個IDE口的從盤表示為hdb)。在多重啟動的系統里,windows的C分區一般為/dev/hda1。
      • FAT 分區可以像下面一樣掛載
    sudo mount /dev/hda1 /media/partitionname -t vfat -o iocharset=utf8,umask=000
      • NTFS 分區可以像下面一樣掛載
    sudo mount /dev/hda1 /media/partitionname -t ntfs -o nls=utf8,umask=0222
        • 注意:你只能從NTFS分區上讀數據,不能進行寫操作。
      • 若要在系統啟動的時候自動掛載分區,可以編輯文件/etc/fstab,為你想掛載的分區添加一行代碼,內容如下:
      • FAT 分區:
    /dev/hda1       /media/partitionname  vfat    iocharset=utf8,umask=000   0       0
      • NTFS 分區:
    /dev/hda1       /media/partitionname  ntfs    nls=utf8,umask=0222 0       0

    安装Fcitx输入法

    sudo apt-get remove ibus
    sudo add-apt-repository ppa:wengxt/fcitx-nightly
    sudo apt-get update
    sudo apt-get install fcitx
    im-switch -s fcitx -z default

    使用软件管理安装的是3.6版本,有些问题,这里安装的是4.0版本,五笔输入法可以用软件管理安装相应table,新手可以选wbpy,熟练者可以选wubi

    Cool Solutions: Gnome / KDE Keyboard Shortcuts
    http://www.novell.com/coolsolutions/tip/2289.html

    FOR GNOME:

    General Shortcut Keys

    Alt F1

    Opens the Applicantions Menu .

    Alt F2

    Displays the Run Application dialog.

    Print Screen

    Takes a screenshot.

    Alt Print Screen

    Takes a screenshot of the window that has focus.

    Ctrl Alt right arrow

    Switches to the workspace to the right of the current workspace.

    Ctrl Alt left arrow

    Switches to the workspace to the left of the current workspace.

    Ctrl Alt up arrow

    Switches to the workspace above the current workspace.

    Ctrl Alt down arrow

    Switches to the workspace below the current workspace.

    Ctrl Alt d

    Minimizes all windows, and gives focus to the desktop.

    F1

    Starts the online help browser, and displays appropriate online Help.

    Window Shortcut Keys

    Alt Tab

    Switches between windows. When you use these shortcut keys, a list of windows that you can select is displayed. Release the keys to select a window.

    Alt Esc

    Switches between windows in reverse order. Release the keys to select a window.

    F10

    Opens the first menu on the left side of the menubar.

    Alt spacebar

    Opens the Window Menu .

    Arrow keys

    Moves the focus between items in a menu.

    Return

    Chooses a menu item.

    Esc

    Closes an open menu.

    Ctrl Alt right arrow

    Switches to the workspace to the right of the current workspace.

    Ctrl Alt left arrow

    Switches to the workspace to the left of the current workspace.

    Ctrl Alt up arrow

    Switches to the workspace above the current workspace.

    Ctrl Alt down arrow

    Switches to the workspace below the current workspace.

    Ctrl Alt d

    Minimizes all windows, and gives focus to the desktop.

    Panel Shortcut Keys

    Ctrl Alt Tab

    Switches the focus between the panels and the desktop. When you use these shortcut keys, a list of items that you can select is displayed. Release the keys to select an item.

    Ctrl Alt Esc

    Switches the focus between the panels and the desktop. Release the keys to select an item.

    Ctrl F10

    Opens the popup menu for the selected panel.

    Tab

    Switches the focus between objects on a panel.

    Return

    Chooses the selected panel object or menu item.

    Shift F10

    Opens the popup menu for the selected panel object.

    Arrow keys

    Moves the focus between items in a menu. Moves the focus between interface items in an applet also.

    Esc

    Closes an open menu.

    F10

    Opens the Applications menu from the Menu Bar , if the Menu Bar is in a panel.

    Application Shortcut Keys

    Shortcut Keys

    Command

    Ctrl N

    New

    Ctrl X

    Cut

    Ctrl C

    Copy

    Ctrl V

    Paste

    Ctrl Z

    Undo

    Ctrl S

    Save

    Ctrl Q

    Quit


    FOR KDE:

    Alt-F2

    Execute Command

    Ctrl - B

    Add Bookmark

    Ctrl-Esc

    List of running applications.

    Ctrl - W

    Close

    Alt-Tab

    Switch forward among windows

    Ctrl - C

    Copy

    Alt-Shift-Tab

    Switch backward among windows

    Ctrl - End

    End

    Ctrl - F1 to F12

    Switch to Desktop 1 - 12

    Ctrl - F

    Find

    Shift-Ctrl-F1 to F4

    Switch to Desktop 13 to 16

    F3

    Find Next

    Ctrl-Alt-Esc

    Kill Window (Click on the window to action the kill.)

    Ctrl - F3

    Find Prev

    Ctrl-Alt-Delete

    Logout (To complete logout process, Tab & Enter)

    F1

    Help

    F12

    Toggle cursor key mouse emulation

    Ctrl - Home

    Home

    Alt - F1

    Popup KDE launch menu

    Ctrl - Insert

    Insert

    Ctrl-Tab

    Switch forward one desktop

    Ctrl - N

    New

    Ctrl-Shift-Tab

    Switch back one desktop

    Ctrl - Down

    Next Complete Match

    Alt - F4

    Window close

    Down

    Next Item in List

    Alt - F3

    Window open menu

    Ctrl - O

    Open

    Ctrl - V

    Paste

    "Windows" Menu

    Popup Menu Context

    Ctrl - Up

    Previous Complete Match

    Up

    Previous Item in list

    Ctrl - P

    Print

    Page Up

    Prior

    Ctrl - Q

    Quit

    Ctrl-Shift-Z

    Redo

    F5

    Reload

    Ctrl - R

    Replace

    Ctrl - S

    Save

    Ctrl - A

    Select All

    Ctrl - E

    Text Completion

    Ctrl - Z

    Undo

    Shift - F1

    What's this

    Ctrl - Plus (+)

    Zoom In

    Ctrl - Minus (-)

    Zoom Out

  • ,ca,在可选的注释方式之间切换,比如C/C++ 的块注释/* */和行注释//
  • ,cc,注释当前行
  • ,c ,切换注释/非注释状态
  • ,cs,以”性感”的方式注释
  • ,cA,在当前行尾添加注释符,并进入Insert模式
  • ,cu,取消注释
  • Normal模式下,几乎所有命令前面都可以指定行数
  • Visual模式下执行命令,会对选中的特定区块进行注释/反注释
  • [转]经典vim插件功能说明、安装方法和使用方法介绍 - SUN's Cabin - 博客园
    http://www.cnblogs.com/jianyungsun/archive/2011/02/14/1954033.html
    手把手教你把Vim改装成一个IDE编程环境(图文) - 吴垠的专栏 - CSDN博客
    http://blog.csdn.net/wooin/archive/2007/10/31/1858917.aspx
    手把手教你把Vim改装成一个IDE编程环境(图文)
    linux下批量修改文件名 - Linux - chinawanglun
    http://blogold.chinaunix.net/u2/80377/showart_2235899.html

    rename 的典型应用:
    0. 批量更改文件扩展名
    $ rename ’s/\.txt/\.ext/’ *

    1. 批量删除文件扩展名
    $ rename ’s/\.txt//’ *

    2. 批量添加文件扩展名
    $ rename ’s/$/\.txt/’ *

    3. 按自己的方式批量重命名文件
    $ rename ’s/(\d)/第$1 章/’ *
    $ rename s/_/-/ *.jpg  #修改所有的包含_的.jpg文件中的_为-

    Vertical Maximize - Ubuntu Forums
    http://ubuntuforums.org/showthread.php?t=62687
    You can assign keyboard shortcut for this action.

    Code:
    gnome-keybinding-properties
    Navigate to Window Management subsection and there is the Maximize Window Vertically action. Assign keyboard shortcut for it.
    Linux文件或目录的读,写,执行权限 - cc的脚印 - CSDN博客
    http://blog.csdn.net/omohe/archive/2007/11/23/1899910.aspx
    文件或目录的存取权限
    Template + Inheritance - Ubuntu Forums
    http://ubuntuforums.org/showthread.php?t=218626
    No, it's a name scoping rule that strictly-confirming compilers flag (and MSVC does if you turn off extensions via /Za).

    Anyway, due to specialization rules, the compiler can't actually assume that any inherited memebers exist in a templated base class. 

    I could do something like this:
    Code:
    template <typename T>
    class Base {
    public:
       bool isFoo() const { // something about foo }
       bool isBar() const { // something about bar }
    };
    
    template<>
    class Base<MyType> {
    public:
       // don't define isFoo
       bool isBar() const { // something about bar }
    };
    Now, if I define an class inheriting base like so:
    Code:
    template<typename T>
    class Child : public Base<T> {
    public:
       bool doTest() const { isFoo(); }
    }
    it's obvious that this won't work if the template parameter for Child is 'MyType', because Base<MyType> doesn't have a definition for 'isFoo()'. 

    As such, all names in a templatized base class are hidden. There are three solutions:
    1. Use this-> to implicitly note that the member is inherited
    2. Use a using declaration to import the function from the base class scope
    3. Use an explict scope declaration. This is undesirible for virtuals because it kills dynamic binding but is mandatory in a few situations, mainly accessing the base constructor in an initialization list.
    使用 MinGW 编译含 glut 的 opengl 程序 - 独木专栏 - CSDN博客
    http://blog.csdn.net/fox000002/archive/2008/04/08/2260949.aspx
    默认 mingw 不包含 glut 相关的头文件。下面一步步进行添加。

    (1) 下载 glut 库。

    http://www.xmission.com/~nate/glut.html

    (2) 将 glut.h 添加到 /path/to/mingw/inclu
    de/GL/ 目录下。

    这里使用 mingw 自带的 libglut32.a,所以只需要添加头文件就可以了。

    (3) 设定编译选项。

    a 连接到需要的库文件

    -lopengl32 -lglu32 -lglut32

    b 修正 
    undefined reference 错误

    错误提示为:
    ... ...
    xxx: undefined reference to `__glutInitWithExit@12'
    xxx: undefined reference to `__glutCreateWindowWithExit@8'
    xxx: undefined reference t
    o `__glutCreateMenuWithExit@8'
    ... ...
    解决方法:


    完整的编译命令如下:


     
    gcc -o demo demo.c -D_STDCALL_SUPPORTED -D_M_IX86 \
    -DGLUT_DISABLE_ATEXIT_HACK -lopengl32 -lglu32 -lglut32


    命令太长,写成 Makefile 就可以方便很多了。

    当然,你也可以在源代码中添加

    #define _STDCALL_SUPPORTED 

    #define _M_IX86 

    #define GLUT_DISABLE_ATEXIT_HACK


    -enable-auto-import may needed in the command line for correct compiling

    Converting tabs to spaces - Vim Tips Wiki
    http://vim.wikia.com/wiki/Converting_tabs_to_spaces

    To insert space characters whenever the tab key is pressed, set the 'expandtab' option:

    :set expandtab
    

    With this option set, if you want to enter a real tab character use Ctrl-V<Tab> key sequence.

    To control the number of space characters that will be inserted when the tab key is pressed, set the 'tabstop' option. For example, to insert 4 spaces for a tab, use:

    :set tabstop=4
    

    After the 'expandtab' option is set, all the new tab characters entered will be changed to spaces. This will not affect the existing tab characters. To change all the existing tab characters to match the current tab settings, use:

    :retab
    

    To change the number of space characters inserted for indentation, use the 'shiftwidth' option:

    :set shiftwidth=4
    

    For example, to get the following coding style,

    • No tabs in the source file.
    • All tab characters are 4 space characters.

    use the following set of options:

    :set tabstop=4
    :set shiftwidth=4
    :set expandtab
    

    Add the above settings to your vimrc.

    Unix/Linux下一般比如想让某个程序在后台运行,很多都是使用 & 在程序结尾来让程序自动运行。比如我们要运行mysql在后台:

    /usr/local/mysql/bin/mysqld_safe --user=mysql &

    但是加入我们很多程序并不象mysqld一样做成守护进程,可能我们的程序只是普通程序而已,一般这种程序使用 & 结尾,

    但是如果终端关闭,那么程序也会被关闭。

    但是为了能够后台运行,那么我们就可以使用nohup这个命令,比如我们有个test.php需要在后台运行,并且希望在后台能够定期运行,

    那么就使用nohup:

    nohup /root/test.php &

    提示:

    [1] 54470

    [~]$ appending output to nohup.out

    嗯,证明运行成功,同时把程序运行的输出信息放到当前目录的 nohup.out 文件中去。

    Linux系统攻略 用UUID在Fstab中挂载分区 - Linux教程 - 新客网
    http://www.xker.com/page/e2007/1018/36318.html

    在 fstab 中用 UUID 挂载分区,看起来向这样:

    UUID=1234-5678 /mnt/usb vfat utf8,umask=0 0 0

    在 UUID= 后面填入分区相应的 UUID 值,就可以正确挂载分区了。

    那么,我们如何知道一个分区的 UUID 呢?

    有 3 种方法:

    1. 通过浏览 /dev/disk/by-uuid/ 下的设备文件信息。

    # ls -l /dev/disk/by-uuid/

    ------

    lrwxrwxrwx 1 root root 10 10-13 09:14 0909-090B -> http://www.cnblogs.com/sdb5

    lrwxrwxrwx 1 root root 10 10-13 09:13 7c627a81-7a6b-4806-987b-b5a8a0a93645 -> http://www.cnblogs.com/sda4

    .....

    2. 通过 vol_id 命令。

    # vol_id /dev/sdb5

    ID_FS_USAGE=filesystem

    ID_FS_TYPE=vfat

    ID_FS_VERSION=FAT32

    ID_FS_UUID=0909-090B

    ID_FS_UUID_ENC=0909-090B

    ID_FS_LABEL=SWAP

    ID_FS_LABEL_ENC=SWAP

    ID_FS_LABEL_SAFE=SWAP

    3. 通过 blkid 命令

    # blkid /dev/sdb5

    /dev/sdb5: LABEL="SWAP" UUID="0909-090B" TYPE="vfat"

    通过这三种方法都可以获得分区的 UUID,UUID 依据分区不同,长度和格式都不相同。

    for gnome: eog for imgs, evince for pdfs
    Linux change my hostname / computer system name
    http://www.cyberciti.biz/faq/howto-change-my-hostname-machine-name/

    Linux change my hostname / computer system name

    by Vivek Gite on July 26, 2007 · 2 comments

    Q. I’m using Ubuntu Linux. How do I change my hostname or the machine name?

    A.. You need to use hostname command, which is used to either set or display the current host or domain name of the system. This name is used by many of the networking programs to identify the machine.

    Following instructions should work on both Debian and Ubuntu Linux systems.

    Task: Display current hostname

    Just type hostname command print the name of the system:
    $ hostname
    Output:

    vivek-desktop.gite.in

    Task: Change hostname

    Set hostname to desktop.nixcraft.com:
    # hostname desktop.nixcraft.com
    # hostname 

    Output:

    desktop.nixcraft.com

    Task: Change hostname permanently

    You need to edit a file called /etc/hostname:
    # vi /etc/hostname
    Set new hostname:

    desktop.nixcraft.com

    Save and close the file.

    中国建设银行取消短信服务_星影庄蝶的空间_百度空间
    http://hi.baidu.com/%D0%C7%D3%B0%D7%AF%B5%FB/blog/item/e70fc355a6cf9b58574e0072.html

    短信注销:

                 1、注销指定账户短信服务:编辑短信”QXZH#账户后四位“发送到95533;

                 2、注销本手机所有账户短信服务:编辑短信”QXFW“发送到95533;

    表 27.1. 基本 gdb 命令.
     
    命   令 描  述
    file 装入想要调试的可执行文件.
    kill 终止正在调试的程序.
    list 列出产生执行文件的源代码的一部分.
    next 执行一行源代码但不进入函数内部.
    step 执行一行源代码而且进入函数内部.
    run 执行当前被调试的程序
    quit 终止 gdb
    watch 使你能监视一个变量的值而不管它何时被改变.
    break 在代码里设置断点, 这将使程序执行到这里时被挂起.
    make 使你能不退出 gdb 就可以重新产生可执行文件.
    shell 使你能不离开 gdb 就执行 UNIX shell 命令. 
    For anyone else who comes across this post in future, the 'Revprop change blocked by pre-revprop-change hook (exit code 255) with no output.' error can be caused by not having execute permissions on the pre-revprop-change script.

    在linux中,最简单的截屏工具莫过于import了。

    几个常用的import命令介绍给大家:

    1 import mypicture.jpg

    然后可以使用鼠标选择的范围

    2 sleep 5; import mypicture.jpg

    等待5秒钟后,截取鼠标选择的范围

    3 import -frame mypicture.jpg

    截取鼠标所点击的窗口

    4 import -window root mypicture.jpg

    截取整个屏幕,作用相当于Print Screen键

    5 import -frame -window 0xe00003 mypicture.jpg

    用于截取window ID为0xe00003的窗口。

    你可以使用xwininfo命令获取到特定窗口的window ID

    ps:截取完成的图片,如果你想了解它的各项参数,可以使用identify命令加图片文件名称就可以了。

    Linux GNOME桌面快捷键 - 就介个 - 博客大巴
    http://leenmax.blogbus.com/logs/10652724.html

    通用快捷键

    Alt + F1 类似Windows下的Win键,在GNOME中打开"应用程序"菜单(Applications)

    Alt + F2 类似Windows下的Win + R组合键,在GNOME中运行应用程序

    Ctrl + Alt + D 类似Windows下的Win + D组合键,显示桌面

    Ctrl + Alt + L 启动屏幕保护程序

    Alt + Tab 同Windows下的Alt + Tab组合键,在不同程序窗口间切换

    PrintScreen 全屏抓图

    Alt + PrintScreen 当前窗口抓图

    Ctrl + Alt + → / ← 在不同工作台间切换

    Ctrl + Alt + Shift + → / ← 移动当前窗口到不同工作台

    窗口操作快捷键

    Alt + F4 关闭窗口

    Alt + F5 取消最大化窗口 (恢复窗口原来的大小)

    Alt + F7 移动窗口 (注: 在窗口最大化的状态下无效)

    Alt + F8 改变窗口大小 (注: 在窗口最大化的状态下无效)

    Alt + F9 最小化窗口

    Alt + F10 最大化窗口

    Alt + Space 打开窗口的控制菜单 (点击窗口左上角图标出现的菜单)

    Svn 常用命令指南 - 我的文章 - yjg2008
    http://blogold.chinaunix.net/u/30699/showart_1970102.html

    Subversion常用命令指南


      Svn在实际操作时非常简单,结合图形化客户端工具(如:TortoiseSVN),为我们的工作带来了很多方便。下面介绍Svn常用命令及简单用法,使你更加地喜欢上Subversion。

    1、将文件Checkout到本地目录

     svn checkout PATH(PATH是服务器上的目录)
       例如:svn checkout svn:
    //10.123.456.789/test/DEMO
        简写:svn co

    2、往版本库中添加新的文件

     svn add file
       例如:svn 
    add test.java(添加test.java)
        svn 
    add *.java(添加当前目录下所有的java文件)

    3、将改动的文件提交到版本库

     svn commit -m "LogMessage" [-N] [--no-unlock] PATH(如果选择了保持锁,就使用--no-unlock开关)
       例如:svn commit -m 
    "add test file for my test" test.java
        简写:svn ci

    4、加锁/解锁

     svn lock -m "LockMessage" [--force] PATH
       例如:svn lock -m 
    "lock test file" test.java
         svn unlock PATH

    5、更新到某个版本

     svn update -r m PATH
       例如:svn update如果后面没有目录,默认将当前目录以及子目录下的所有文件都更新到最新版本。
        svn update -r 
    200 test.java(将版本库中的文件test.java还原到版本200)
         svn update test.java(更新,于版本库同步。如果在提交的时候提示过期的话,是因为冲突,需要先update,修改文件,然后清除svn resolved,最后再提交commit)
       简写:svn up

    6、查看文件或者目录状态

      1)svn status PATH(目录下的文件和子目录的状态,正常状态不显示)
       【?:不在svn的控制中;M:内容被修改;C:发生冲突;A:预定加入到版本库;K:被锁定】
      
    2)svn status -v PATH(显示文件和子目录状态)
       第一列保持相同,第二列显示工作版本号,第三和第四列显示最后一次修改的版本号和修改人。
       注:svn status、svn diff和 svn revert这三条命令在没有网络的情况下也可以执行的,原因是svn在本地的.svn中保留了本地版本的原始拷贝。
    简写:svn st

    7、删除文件

      svn delete PATH -m "delete test fle"
       例如:svn delete svn://10.123.456.789
    /test/DEMO/test.java -m "delete test file"
        或者直接svn delete test.java 然后再svn ci -m 'delete test file‘,推荐使用这种
    简写:svn (del, remove, rm)

    8、查看日志

     svn log PATH
      例如:svn log test.java 显示这个文件的所有修改记录,及其版本号的变化

    9、查看文件详细信息

     svn info PATH
      例如:svn info test.java

    10、比较差异

     svn diff PATH(将修改的文件与基础版本比较)
      例如:svn diff test.java
        svn diff -r m:n PATH(对版本m和版本n比较差异)
         例如:svn diff -r 200:201 test.java
          简写:svn di

    11、将两个版本之间的差异合并到当前文件

     svn merge -r m:n PATH
       例如:svn merge -r 
    200:205 test.java(将版本200与205之间的差异合并到当前文件,但是一般都会产生冲突,需要处理一下)

    12、SVN 帮助

     svn help
       svn help ci
    svn 服务器镜像方式同步备份 - 淡泊明志,宁静致远 - 博客园
    http://www.cnblogs.com/zhouxiuquan/archive/2010/04/22/1912373.html

    6、常见问题解决:
    svnsync init file:///data/svnroot/repository/products http://10.10.10.150/svn/products
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
     从目标版本库获得锁失败,当前被“rhel500:284ff204-e16b-457f-933c-03d1c26c314b”持有
    svnsync: Couldn't get lock on destination repos after 10 attempts

    解决方法,执行以下命令:
    svn propdel svn:sync-lock --revprop -r 0 http://10.10.10.130/svn/products
    删除属性 “svn:sync-lock” 于版本库版本 0

    用svnsync 同步备份任意两个svn版本库 - 软件配置管理 - 博客园
    http://www.cnblogs.com/xbsoft/archive/2010/04/14/1711809.html
    试验下来,SVNSync除了目标库为只读之外,其它功能都很强大,实现也相对简单。
    如用svnsync 同步备份linux 下svn版本库到Windows
    要同步的项目名称:MU
    svn版本库1。4以上
    源目录:svn://192.168.1.196/mu
    目标目录:svn://192.168.1.205/mu
     
    方法:
    1.如果目标目录存在相同的项目,请先清除,重新建立空项目
    svnadmin create mu
    2.在mu目录下hooks目录下,建立
    pre_revprop-change.bat 全部内容只有一行:exit 0
    如果用拷贝同目录下的pre_revprop-change.tmpl 则必须删除最后三行的内容或替换为只有一行:exit 0
    不然下面初始化同步的时候,将停顿
     
    3. 执行 初始化
    svnsync init svn://192.168.1.205/mu svn://192.168.1.196/mu
    即svnsync init 目标库 源库
    将向你询问登录目标库和源库的用户名和密码,建议为两个库设置相同的用户名及相同的密码
    正确后,显示
    Copied properties for revision 0.
    4.执行同步
    svnsync sync svn://192.168.1.205/mu
    即svnsync sync 目标库
    正确执行后,显示
    Committed revision 1.
    Copied properties for revision 1.
    Committed revision 2.
    Copied properties for revision 2.
    Committed revision 3.
    Copied properties for revision 3.
    Committed revision 4.
    Copied properties for revision 4.
    Committed revision 5.
    Copied properties for revision 5.
    Committed revision 6.
    Copied properties for revision 6.
    Committed revision 7.
    Copied properties for revision 7.
    Committed revision 8.
    ...
    5.更新同步
    在源库的hooks下面,添加post-commit 脚本
    可拷贝post-commit.tmpl
     
    cp post-commit.tmpl post-commit
    然后
    把 post-commit 中,最后两行替换为
     
    svnsync sync  --non-interactive svn://192.168.1.205/mu --sync-username user --sync-password user
    即提交更新后,即执行同步命令,不进行交互
    把post-commit 设为755权限。
     
    ps:
    如果post-commit脚本出错,或者无可执行权限,在提交更新时会报错
    用Parallel_For进行并行快速排序 - 海边夕阳 - JavaEye技术网站
    http://bjxagu.javaeye.com/blog/400003
    用Parallel_For进行并行快速排序
    并行排序算法 - 编酷 - JavaEye技术网站
    http://bianku.javaeye.com/blog/401495
    并行排序算法
    The boot configuration data store could not be opened. - The NeoSmart Forums
    http://neosmart.net/forums/showthread.php?t=5073
    If EasyBCD can't find the BCD, its usually a problem with the hidden "system" partition which a W7 install creates. Otherwise, it could be because you're using a 3rd party boot manager (like me), and are hiding the partition containing the BCD from the OS you are running EasybCD from.
    the glm_avl has some problem with normal computing.
     function can be defined in header file if decorated with __inline or inline
    C++ 嵌入汇编 获取CPU信息_不走冤枉路_百度空间
    http://hi.baidu.com/ctralt/blog/item/2aae98ef7e3bd11bfdfa3cf2.html
    C++ 嵌入汇编 获取CPU信息
    2010年06月25日 星期五 11:53

    #include "windows.h" 
    #include "iostream"
    #include "string"

    using namespace std;

    //用来存储信息
    DWORD deax;
    DWORD debx;
    DWORD decx;
    DWORD dedx;

    void ExeCPUID(DWORD veax)//初始化CPU
    {
    __asm
    {
       mov eax,veax
        cpuid
        mov deax,eax
        mov debx,ebx
        mov decx,ecx
        mov dedx,edx
    }
    }

    long GetCPUFreq()//获取CPU频率,单位: MHZ
    {
    int start1,start2;
    _asm rdtsc
       _asm mov start1,eax
       Sleep(50);
    _asm rdtsc
       _asm mov start2,eax
       return (start2-start1)/50000;
    }

    string GetManID()//获取制造商信息
    {
    char ID[25];//存储制造商信息
    memset(ID,0,sizeof(ID));//先清空数组 ID
    ExeCPUID(0);//初始化
    memcpy(ID+0,&debx,4);//制造商信息前四个字符复制到数组
    memcpy(ID+4,&dedx,4);//中间四个
    memcpy(ID+8,&decx,4);//最后四个
    //如果返回 char * ,会出现乱码;故返回 string 值
    return string(ID);
    }

    string GetCPUType()
    {
    const DWORD id = 0x80000002; //从0x80000002开始,到0x80000004结束
    char CPUType[49];//用来存储CPU型号信息
    memset(CPUType,0,sizeof(CPUType));//初始化数组

    for(DWORD t = 0 ; t < 3 ; t++ )
    {
       ExeCPUID(id+t);
       //每次循环结束,保存信息到数组
       memcpy(CPUType+16*t+ 0,&deax,4);
       memcpy(CPUType+16*t+ 4,&debx,4);
       memcpy(CPUType+16*t+ 8,&decx,4);
       memcpy(CPUType+16*t+12,&dedx,4);
    }

    return string(CPUType);
    }

    void main() 

    cout<<"本机CPU信息如下:"<<endl;
    cout<<"CPU 主 频: "<<GetCPUFreq()<<" MHZ"<<endl;
    cout<<"CPU 制造商: "<<GetManID()<<endl;
    cout<<"CPU 型 号: "<<GetCPUType()<<endl;
    cin.get();

    }

    gettimeofday - get the date and time
    QueryPerformanceCounter - daoyuly的专栏 - CSDN博客
    http://blog.csdn.net/daoyuly/archive/2009/03/01/3947918.aspx

    ueryPerformanceCounter 收藏

    精确的时间计时,有时候是非常必要的。比如播放多媒体时视频与音频的时间同步,还有在测试代码的性能时,也需要使用到非常精确的时间计时。还有测试硬件的性能时,也需要精确的时间计时。这时就需要使用QueryPerformanceCounter来查询定时器的计数值,如果硬件里有定时器,它就会启动这个定时器,并且不断获取定时器的值,这样的定时器精度,就跟硬件时钟的晶振一样精确的。

    QueryPerformanceCounter            查询性能计数器

    C/C++利用CPU时钟计数器精确计时 - 芳草天涯,编程,c,lijs,
    http://www.lijs.net/show-149-1.html

    C/C++利用CPU时钟计数器精确计时

    Submitted by lijs on 2008, September 30, 10:23 PM. 芳草天涯

    C++代码
    1. __inline unsigned __int64 GetCycleCount()      
    2. {   
    3.     __asm   _emit   0x0F   
    4.     __asm   _emit   0x31   
    5. }  

    经测试,C/C++都可用。

    似乎只有intel的CPU可以。

    使用

    unsigned __int64 mytime=GetCycleCount();

    即可获得CPU至加电以来的时钟周期数,除以CPU时钟频率即可得时间。

    小技巧:

    1.CPU时钟频率通常很大,所以除以(CPU时钟频率/1000000)得到微秒级时间,以此类推。

    2.如果要想转为double做除法运算,先要转为signed __int64。

    for linux:

    static inline unsigned long long int GetCycleCount(){

         unsigned long long int res = 0;

         // Use the assembly instruction rdtsc, which gets the current

        // cycle count (since the process started) and puts it in edx:eax.

         asm volatile ("rdtsc" : "=A" (res));

         return res;

    }

    __int64 is actually long long

    void   CWatch::init()   
    {   
              INT64   start   =   GetCycleCount();   
              Sleep(1000);   //等待1秒钟,提高等待的时间,可以提高标定的精度   
              INT64   end   =   GetCycleCount();   
              count_per_second   =   end   -   start;   
        
              double   currTime   =   (double)GetCycleCount()   /   count_per_second;   
              time_t   realTime   =   time(   NULL   );   //当前时间,精度只有1s   
              startTime   =   realTime   -   currTime;   //CPU上电时的时间   
    }   

    most errors about memory access or allocation are due to out of range usage
    problem: xxx is not located in xxx.dll
    for such a problem, it's very possible that the .lib file you used while compiling is not compatible with your .dll file while running the program
    you can check which .dll is used by debug(VS), and you can also check you environment path, the first .dll found is used, and the system
    searches for the dll in the order of the paths.
    Intel® C++ Compiler for Windows* - Fatal link error LNK1104 when using Intel® C++ Compiler with
    http://software.intel.com/en-us/articles/intel-c-compiler-for-windows-fatal-link-error-lnk1104-when-using-intel-c-compiler-with-boost-libraries/

    When building an application that uses the Boost Libraries with the Intel® C++ Compiler, you may get linker errors like the ones shown below due to incorrect libraries being linked to the application:

    fatal error LNK1104: cannot open file 'libboost_thread-iw-mt-1_33_1.lib'
    or 
    fatal error LNK1104: cannot open file 'libboost_thread-iw-1_33_1.lib'

    Perform the following steps to correct the problem:

    1. Open " boostconfigauto_link.hpp."
    2. Search for " __ICL" to find the following entries:

      #elif defined(__ICL)

      // Intel C++, no version number: 
      # define BOOST_LIB_TOOLSET "iw"

    3. Change " iw" to:

      vc7" - if you are using Microsoft* Visual Studio* .NET 
      vc71" - if you are using Microsoft Visual Studio .NET 2003 
      vc80" - if you are using Microsoft Visual Studio 2005 
      vc90" - if you are using Microsoft Visual Studio 2008.

    4. Rebuild your application to resolve the link errors.
    在LINUX中如何查找文件内容中含有某字符串的文件。 - Linux/Unix社区 / 系统维护与使用区
    http://topic.csdn.net/t/20020117/01/482547.html
    grep   /usr/local/*   -e   who
    SCIM输入启动遭遇“Failed to load x11 FrontEnd module. ”错误 - 听雨轩 - JavaEye技术网站
    http://sheng.javaeye.com/blog/716921

    今天把我的一个Linux系统重启了一下,想输入中文,却发现中文输入法打不开,应该是SCIM没启动,于是

    # scim -d

    启动之,却发现报错如下:

    Linux信息代码
    1. [root@sheng ~]# scim -d  
    2. Smart Common Input Method 1.4.4  
    3.   
    4. Launching a SCIM process with x11...  
    5. Loading socket Config module ...  
    6. Creating backend ...  
    7. Loading x11 FrontEnd module ...  
    8. Failed to load x11 FrontEnd module.  
    9. Failed to launch SCIM.  
    10. [root@sheng ~]#   
    [root@sheng ~]# scim -d
    Smart Common Input Method 1.4.4
    
    Launching a SCIM process with x11...
    Loading socket Config module ...
    Creating backend ...
    Loading x11 FrontEnd module ...
    Failed to load x11 FrontEnd module.
    Failed to launch SCIM.
    [root@sheng ~]# 
    

    很自然地上网去搜一下“Failed to load x11 FrontEnd module.”,发现有很多人遇到这个问题,但没找到有效的解决办法。用

    # ps -ef | grep scim

    看了一下,发现有四个scim相关的进程在运行:

    Linux信息代码
    1. [root@sheng ~]# ps -ef | grep scim  
    2. root      4706     1  0 13:59 ?        00:00:00 /usr/lib/scim-1.0/scim-launcher -d -c simple -e all -f socket --no-stay  
    3. root      4710     1  0 13:59 ?        00:00:00 /usr/lib/scim-1.0/scim-helper-manager  
    4. root      4711     1  0 13:59 ?        00:00:01 /usr/lib/scim-1.0/scim-panel-gtk --display :0.0 -c socket -d --no-stay  
    5. root      4713     1  0 13:59 ?        00:00:00 /usr/lib/scim-1.0/scim-launcher -d -c socket -e socket -f x11  
    6. root      4779     1  0 14:01 ?        00:00:00 scim-bridge  
    7. root      5349  5275  0 14:10 pts/2    00:00:00 grep scim  
    [root@sheng ~]# ps -ef | grep scim
    root      4706     1  0 13:59 ?        00:00:00 /usr/lib/scim-1.0/scim-launcher -d -c simple -e all -f socket --no-stay
    root      4710     1  0 13:59 ?        00:00:00 /usr/lib/scim-1.0/scim-helper-manager
    root      4711     1  0 13:59 ?        00:00:01 /usr/lib/scim-1.0/scim-panel-gtk --display :0.0 -c socket -d --no-stay
    root      4713     1  0 13:59 ?        00:00:00 /usr/lib/scim-1.0/scim-launcher -d -c socket -e socket -f x11
    root      4779     1  0 14:01 ?        00:00:00 scim-bridge
    root      5349  5275  0 14:10 pts/2    00:00:00 grep scim
    

    于是把这四个进程全部杀掉,然后再重启scim:

    Linux信息代码
    1. [root@sheng ~]# scim -d  
    2. Smart Common Input Method 1.4.4  
    3.   
    4. Launching a SCIM daemon with Socket FrontEnd...  
    5. Loading simple Config module ...  
    6. Creating backend ...  
    7. Reading pinyin phrase lib failed  
    8. Loading socket FrontEnd module ...  
    9. Starting SCIM as daemon ...  
    10. Launching a SCIM process with x11...  
    11. Loading socket Config module ...  
    12. Creating backend ...  
    13. Loading x11 FrontEnd module ...  
    14. GTK Panel of SCIM 1.4.4  
    15.   
    16. Starting SCIM as daemon ...  
    17. SCIM has been successfully launched.  
    18. [root@sheng ~]#   
    [root@sheng ~]# scim -d
    Smart Common Input Method 1.4.4
    
    Launching a SCIM daemon with Socket FrontEnd...
    Loading simple Config module ...
    Creating backend ...
    Reading pinyin phrase lib failed
    Loading socket FrontEnd module ...
    Starting SCIM as daemon ...
    Launching a SCIM process with x11...
    Loading socket Config module ...
    Creating backend ...
    Loading x11 FrontEnd module ...
    GTK Panel of SCIM 1.4.4
    
    Starting SCIM as daemon ...
    SCIM has been successfully launched.
    [root@sheng ~]# 
    

     启动正常了,原来刚开始启动不了是因为SCIM已经启动了,才报那个错。可是为什么无法调出输入法呢?打开SCIM配置界面一看,原来我为了在我的WinXP上的XServer上使用SCIM时,避免打开输入法的快捷方式与WinXP的的快捷方式冲突,把启动快捷键改成了“Shift+Ctrl+Z”,难怪无法调出输入法。

    在此留个记号,免得下次再在这个坑上摔跟斗。

    linux opengl环境配置_Bellgrade_百度空间
    http://hi.baidu.com/bellgrade/blog/item/4cceff5975d19089800a18a1.html
    linux opengl环境配置
    2009-06-11 16:40
    $yum install mesa*
    Glut有很多种实现,在这里我用的是freeglut
    $yum install freeglut*
    编译
    $gcc -lglut -o test test.c
    linux下应用程序的位置?_百度知道
    http://zhidao.baidu.com/question/115962897.html
    which vim
    /usr/bin/vim
     
    Linux下rpm命令的基本用法 - 楠楠 - JavaEye技术网站
    http://hunan.javaeye.com/blog/741119
    rpm基本用法   
       1.安装一个包 
         # rpm -ivh  
       2.升级一个包 
         # rpm -Uvh  
       3.移走一个包 
         # rpm -e  
       4.安装参数 
        --force  即使覆盖属于其它包的文件也强迫安装 
        --nodeps 如果该RPM包的安装依赖其它包,即使其它包没装,也强迫安装或卸载。 
       5.查询一个包是否被安装 
         # rpm -q  
       6.得到被安装的包的信息 
         # rpm -qi  
       7.列出该包中有哪些文件 
         # rpm -ql  
       8.列出服务器上的一个文件属于哪一个RPM包 
         # rpm -qf  
       9.可综合好几个参数一起用 
         # rpm -qil  
      10.列出所有被安装的rpm package 
         # rpm -qa  
      11.列出一个未被安装进系统的RPM包文件中包含有哪些文件? 
         # rpm -qilp
    用什么命令可以查看文件夹大小? - 系统管理 - Linux论坛 - ChinaUnix.net
    http://bbs.chinaunix.net/viewthread.php?tid=313251

    用什么命令可以查看文件夹大小?

    du -sh dirname
    MonoDevelop设置openGL开发环境 - 读百家之书 成一家之言 - 博客园
    http://www.cnblogs.com/yanzisoft/archive/2010/07/25/1784573.html
     
    opensuse 下设置opengl环境
    # fuser -m /dev/sdc1
    /dev/sdc1: 538
    # ps auxw|grep 538
    donncha 538 0.4 2.7 219212 56792 ? SLl Feb11 11:25 rhythmbox
    umount,device is busy解决办法 - Forzw-冷关茗诗
    http://www.forzw.com/archives/189
    在Centos 5.2上我挂着一个新硬盘,命令如下:
      #mount /dev/sdb1 /home/soft
      之后想卸载掉,但在输入:
      #umount /home/soft
      提示device is busy,无法卸载,在网上查找,方法如下
      #fuser -m /home/soft
      提示出进程号码 4573,之后执行如下命令:
      #kill -9 4573 成功后就可以卸载掉了
    ubuntu系统下texlive 2009的安装配置 - Ubuntu - 爪 杉
    http://blogold.chinaunix.net/u3/109488/showart_2222797.html

    Procedure to mount ISO images under Linux

    1) You must login as a root user, if not root user then switch to root user using following command:
    $ su -

    2) Create the directory i.e. mount point:
    # mkdir -p /mnt/disk

    3) Use mount command as follows to mount iso file called disk1.iso:
    # mount -o loop disk1.iso /mnt/disk

    4) Change directory to list files stored inside an ISO image:
    # cd /mnt/disk
    # ls -l

    $sudo add-apt-repository ppa:shawn-p-huang/ppa
    $sudo apt-get update
    $sudo apt-get dist-upgrade
    linux下安装boost - 自己的记录 - thunder54007
    http://blogold.chinaunix.net/u3/104108/showart_2075589.html
    boost最新版本下载地址:
    http://sourceforge.net/project/showfiles.php?group_id=7586&amp;package_id=8041

    下载boost_1_39_0.tar.gz    
    tar -zxvf boost_1_39_0.tar.gz  

    然后进入解压缩后的文件夹编译boost的编译器jam
    cd boost_1_39_0\tools\jam
    ./build_dist.sh 

    编译完后在这个目录下有编译出的bjam文件
    boost_1_39_0\tools\jam\stage\bin.linuxx86

    把它copy到boost_1_39_0 然后在这个目录下运行命令编译:
    ./bjam "-sTOOLS=gcc" "--includedir=/usr/include" "--libdir=/usr/lib/boost" install

    开始编译,等待编译完成,需很长时间。
    关于bjam的后面的参数的设置:
    -sTOOLS=gcc  指定编译器为GCC
    --includedir=/usr/include/  指定头文件的安装目录,我安装在/usr/include下。如果安装成功,将在/usr/include/生成目录boost_1_33,该目录下就是boost的头文件目录
    --libdir=/usr/lib/boost  指定boost的库文件的存放位置, 生成的 .a .so 文件将放在该目录下
    install 编译并安装boost
     
    最基本的测试程序:
    (1)autotest.cpp
    #define BOOST_AUTO_TEST_MAIN
    #include<boost/test/auto_unit_test.hpp>
    BOOST_AUTO_TEST_CASE(test)
    {
    BOOST_CHECK(true);
    }
    编译autotest.cpp
    g++ autotest.cpp -L/usr/lib/boost -lboost_unit_test_framework -lboost_test_exec_monitor-gcc41-mt-1_39
     
    (2)unitest.cpp
     
    #include<iostream>
    #include<boost/test/unit_test.hpp>
    using namespace std;
    using boost::unit_test::test_suite;
    void force_division_by_zero()
    {
     BOOST_CHECKPOINT("About to force division by zero");
     int i =1, j = 0;
     i = i / j;
    }
    void infinite_loop()
    {
    #ifdef __unix
     BOOST_CHECKPOINT("About to enter infinite loop");
     while(1);
    #else
     BOOST_MESSAGE("Timeout support is not implemented on your platform");
    #endif
    }
    test_suite* init_unit_test_suite(int argc,char* argv[])
    {
     test_suite* test = BOOST_TEST_SUITE("unit test example");
     test->add(BOOST_TEST_CASE(&force_division_by_zero));
     test->add(BOOST_TEST_CASE(&infinite_loop),0,2);
     return test;
    }
    编译:
    g++ unitest.cpp -L/usr/lib/boost/ -lboost_unit_test_framework
    ubuntu Eclipse 配置好环境变量后, 双击错误,解决办法 - 网络协议学习 - rainblue - 和讯博客
    http://wamp.blog.hexun.com/35196077_d.html
    Eclipse 3.3.2 在 Ubuntu 8.04 下会出现一个很奇怪的现象,我没有经过测试,无法确定是Ubuntu 8.04 还是 JDK 还是 Eclipse本身造成的。 这个现象是:
    可以在终端顺利启动Eclipse,但是鼠标双击,或者用起动器启动就会出现如下的内容:
    Java RunTime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No javavirtual machine was found after searching the following locations:…
    解决办法是在终端进入你的eclipse目录,然后输入:
    mkdir jre
    cd jre
    ln -s 你的JDK目录/bin
    linux如何查看磁盘剩余空间_百度知道
    http://zhidao.baidu.com/question/19422643.html
    root@Linux var]# df -hl 文件系统 容量 已用 可用 已用% 挂载点 /dev/hdb2 75G 75G 0 100% / /dev/hdb1 99M 9.2M 85M 10% /boot none 251M 0 251M 0% /dev/shm
    Ubuntu Linux安装 CUDA 开发环境_/*蜉游天地*/_百度空间
    http://hi.baidu.com/mudgao/blog/item/20f5d46332f15b6c0d33fabb.html/cmtid/43a8e94e77b9bd07b2de0589
    ubuntu PATH 变量在 /etc/environment中设 
    查看系统发行版本:cat /etc/issue
    use #include in .cl files, you need to specify the directory to search for the header file, refer smallptGPU for detail( . refers to current directory)
    posted @ 2011-05-11 16:05  Aldrich  阅读(2592)  评论(0编辑  收藏  举报