• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            2010年9月7日

            2010年8月19日

            some  material

            http://blog.chinaunix.net/u/4206/showart_721067.html

            http://blog.csdn.net/wushihua/archive/2010/07/02/5709359.aspx

            linux 下:
            0. bash
            1. 用戶任意設(shè)置“工作時間”,“休息時間”。目前考慮使用命令行參數(shù) done
            2. 動態(tài)獲取“設(shè)備號”,在不同的機子上用可不需修改 (no so urgent)
            *3. 時間顯示
            改進:
            1.1 如果休息起來五分鐘(默認休息時間)才回來,只剩下不多的工作時間,才做一會兒又要中斷。
            最好是在鎖定鍵鼠五分鐘后,在用戶回來電腦時才開始讓工作時間計時。
            考慮方案一:
            等待用戶輸入后才(解除鼠標鎖定)開始進入下一輪工作計時(done)
            較高級的方案:
            休息時間結(jié)束后,捕捉到鍵盤或者鼠標動作才開始下一輪工作計時。
            1.2 工作時間離開電腦,進入休息時間計時。若一定時間鍵鼠都沒反應(yīng)。
            (done, 獲取鍵盤鼠標的空閑,若比休息時間還長,進入新一輪的工作)

            2. kill sleep后,可能鍵盤永遠鎖住。 解決關(guān)閉該程序的善后工作。(done , use signal)
            鎖住鼠標,不鎖住鍵盤,在鎖住鼠標時,Ctrl-C,結(jié)束程序,但鼠標沒有解鎖。

            備注:
            1. 是否鎖定鍵盤得明確,考慮是否對兩需求推出不同方案。暫考慮只鎖鍵盤


            some note:
            1.
            操作/dev/input/event*文件,向它寫入個input_event結(jié)構(gòu)體就可以模擬按鍵的輸入
            哪個event文件可通過cat /proc/bus/input/devices 查看。
            N: Name="AT Translated Set 2 keyboard"
            H: Handlers=kbd event3

            N: Name="Logitech USB Optical Mouse"
            H: Handlers=mouse1 event4
            2.
            Essentially keyboard and mouse idle time can be
            gleaned (indirectly) from certain lines of the /proc/interrupts file. It
            seems this file contains a counter for each device
            http://software.itags.org/linux-unix/330299/

            Sense mouse and keyboard inactivity final solution:
            /*
            This is a test example.
            Ref:
            http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/

            gcc -o idle idle_xscr2.c -lXss
            */
            #include <stdio.h>
            #include <X11/extensions/scrnsaver.h>
            #include <unistd.h>
                 
            int main()
            {
                  XScreenSaverInfo *info = XScreenSaverAllocInfo();
                Display *display = XOpenDisplay(0);
               
                int i=1;
            for(;i<5; i++){
                sleep(3);     
                XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
                printf("%ld ms\n", info->idle);
            }
                return 0;
            }


            編譯:
            voide@fit:~/bash$ gcc lock.c -o lock -lXss
            lock.c:24:38: error: X11/extensions/scrnsaver.h: No such file or directory
            lock.c: In function ‘main’:
            lock.c:41: error: ‘XScreenSaverInfo’ undeclared (first use in this function)
            lock.c:41: error: (Each undeclared identifier is reported only once
            lock.c:41: error: for each function it appears in.)
            lock.c:41: error: ‘info’ undeclared (first use in this function)
            lock.c:42: error: ‘Display’ undeclared (first use in this function)
            lock.c:42: error: ‘display’ undeclared (first use in this function)
            root@fit:/home/voide/bash# apt-get install libxss-dev
            root@fit:/home/voide/bash# gcc lock.c -o lock -lXss
            root@fit:/home/voide/bash# ./lock  1800 300   /* 1800s 300s*/
            Use a short time for debug
            sh: ./unlock.sh: Permission denied
            root@fit:/home/voide/bash# chmod +x *.sh

            posted @ 2010-08-19 10:52 Voider 閱讀(355) | 評論 (0)編輯 收藏

            2009年10月30日

            http://www.cplusplus.com/reference/stl/deque/
            Deque sequences have the following properties:
            • Individual elements can be accessed by their position index.
            • Iteration over the elements can be performed in any order.
            • Elements can be efficiently added and removed from any of its ends (either the beginning or the end of the sequence)


            On the drawback side, unlike vectors, deques are not guaranteed to have all its elements in contiguous連續(xù)的 storage locations, eliminating排除 thus the possibility of safe access through pointer arithmetics.
            For operations that involve frequent insertion or removals of elements at positions other than the beginning or the end, deques perform worse and have less consistent iterators and references than lists.
            posted @ 2009-10-30 14:45 Voider 閱讀(199) | 評論 (0)編輯 收藏
             

            C++ 運算符優(yōu)先級列表

            http://www.cppreference.com/operator_precedence.html
            http://www.shnenglu.com/aqazero/archive/2006/06/08/8284.html
            Precedence Operator Description Example Associativity
            1 ()
            []
            ->
            .
            ::
            ++
            --
            Grouping operator
            Array access
            Member access from a pointer
            Member access from an object
            Scoping operator
            Post-increment
            Post-decrement
            (a + b) / 4;
            array[4] = 2;
            ptr->age = 34;
            obj.age = 34;
            Class::age = 2;
            for( i = 0; i < 10; i++ ) ...
            for( i = 10; i > 0; i-- ) ...
            left to right
            2 !
            ~
            ++
            --
            -
            +
            *
            &
            (type)
            sizeof
            Logical negation
            Bitwise complement
            Pre-increment
            Pre-decrement
            Unary minus
            Unary plus
            Dereference
            Address of
            Cast to a given type
            Return size in bytes
            if( !done ) ...
            flags = ~flags;
            for( i = 0; i < 10; ++i ) ...
            for( i = 10; i > 0; --i ) ...
            int i = -1;
            int i = +1;
            data = *ptr;
            address = &obj;
            int i = (int) floatNum;
            int size = sizeof(floatNum);
            right to left
            3 ->*
            .*
            Member pointer selector
            Member pointer selector
            ptr->*var = 24;
            obj.*var = 24;
            left to right
            4 *
            /
            %
            Multiplication
            Division
            Modulus
            int i = 2 * 4;
            float f = 10 / 3;
            int rem = 4 % 3;
            left to right
            5 +
            -
            Addition
            Subtraction
            int i = 2 + 3;
            int i = 5 - 1;
            left to right
            6 <<
            >>
            Bitwise shift left
            Bitwise shift right
            int flags = 33 << 1;
            int flags = 33 >> 1;
            left to right
            7 <
            <=
            >
            >=
            Comparison less-than
            Comparison less-than-or-equal-to
            Comparison greater-than
            Comparison geater-than-or-equal-to
            if( i < 42 ) ...
            if( i <= 42 ) ...
            if( i > 42 ) ...
            if( i >= 42 ) ...
            left to right
            8 ==
            !=
            Comparison equal-to
            Comparison not-equal-to
            if( i == 42 ) ...
            if( i != 42 ) ...
            left to right
            9 & Bitwise AND flags = flags & 42; left to right
            10 ^ Bitwise exclusive OR flags = flags ^ 42; left to right
            11 | Bitwise inclusive (normal) OR flags = flags | 42; left to right
            12 && Logical AND if( conditionA && conditionB ) ... left to right
            13 || Logical OR if( conditionA || conditionB ) ... left to right
            14 ? : Ternary conditional (if-then-else) int i = (a > b) ? a : b; right to left
            15 =
            +=
            -=
            *=
            /=
            %=
            &=
            ^=
            |=
            <<=
            >>=
            Assignment operator
            Increment and assign
            Decrement and assign
            Multiply and assign
            Divide and assign
            Modulo and assign
            Bitwise AND and assign
            Bitwise exclusive OR and assign
            Bitwise inclusive (normal) OR and assign
            Bitwise shift left and assign
            Bitwise shift right and assign
            int a = b;
            a += 3;
            b -= 4;
            a *= 5;
            a /= 2;
            a %= 3;
            flags &= new_flags;
            flags ^= new_flags;
            flags |= new_flags;
            flags <<= 2;
            flags >>= 2;
            right to left
            16 , Sequential evaluation operator for( i = 0, j = 0; i < 10; i++, j++ ) ... left to right
            posted @ 2009-10-30 10:31 Voider 閱讀(194) | 評論 (0)編輯 收藏

            2009年8月19日

              轉(zhuǎn):http://www.shnenglu.com/benbendy/archive/2008/05/23/50830.html    

              轉(zhuǎn):  http://hi.baidu.com/gwabit/blog/item/7a188726f2dc91178a82a1b6.html


             C++/OPP/OOD系列:

            層級一:語法/語意(C++)
            1.1 [Lippman2000] Essential C++
                              Essential C++,by Stanley B. Lippman Addison Wesley Longman 
                              2000,276 pages
                              Essential C++ 中文版 ,侯俊杰 譯,282頁  

            1.2 [Gregory95] C++:The Core Language 
                              C++:The Core Language by Gregory Satir 1995 O'Reilly
                              C++語言核心,張銘澤 譯 ,236頁

            1.3 [Deitel98] The Complete C++ Training Course 
                              The Complete C++ Training Course 2/e by Harvey M.Deitel 1998 
                              Prentice Hall
                              C++大學(xué)教程(第二版),邱仲潘等 譯,816頁

            1.4 [Stevens2000] Standard C++ Bible
                              Standard C++ Bible   2000  Al Stevens   IDG 
                              標準C++寶典,林麗閩等 譯,766頁

            1.5 [Eckel2000] Thinking in C++ 
                              Thinking in C++ 2/e   Bruce Eckel  2000 1470 pages Prentice 
                              Hall
                              C++ 編程思想,劉宗田等 譯,420頁

            1.6 [Lippman98] C++Primer 
                              C++ Primer,3rd Editoin,by Stanley Lippman and Josee Lajoie 
                              Addison Wesley Longman,1998 1237 pages
                              C++ Primer 中文版,侯俊杰 譯,1999,1237頁

            1.7 [Struostrup2000] The C++ Programming Language
                              The C++ Programming Language,Special Editoin,by Bjarne 
                              Stroustrup
                              Addison Wesley Longman,2000,1017 pages
                              C++程序語言經(jīng)典本,葉秉哲 譯,儒林 1999

            1.7 [ANSI C++] C++規(guī)格書 1998.9.1 PDF格式
                              ANSI C++ 1996 Draft


            層級二:專家經(jīng)驗(C++/OOP)
            2.1 [Meyers96] More Effective C++
                              More Effective C++,by Scott Meyers,Addison Wesley,1996,318pages
                              More Effective C++中文版,侯俊杰,培生 2000. 318頁

            2.2 [Meyers98] Effective C++ 
                              Effective C++,Second Edition,by Scott Meyers,Addison Wesley 
                              Longman,1998.256pages
                              Effective C++ 2/e 中文版,侯俊杰,培生 2000.256頁

            2.3 [Sutter99] Exceptional C++
                              Exceptional C++,by Herb Sutter,Addison Wesley 
                              Longman,2000.208pages
                              Exceptional C++中文版,侯俊杰,培生 2000.248頁

            2.4 [Sutter2001]More Exceptional C++ 
                              More Exceptional C++ by Herb Sutter,Addison Wesley 
                              Longman,2001.

            層級三:底層機制(C++ Object Model)

            3.1  [Ellis90] The Annotated C++ Reference Manual
                              The Annotated C++ Reference Manual,by Margaret A.Ellis and 
                              Bjarne Stroustrup 
                              Addison Wesley Longman,1990,447 pages.

            3.2  [Lippman96] Inside the C++ Object Model
                              Inside the C++ Object Model,by Stanley Lippman,Addison Wesley 
                              Longman,1996,280pages
                              深度探索C++物件模型,侯俊杰 譯                   

             層級四:設(shè)計觀念的復(fù)用(C++/Patterns)
             

            4.1  [Gamma95] Design Patterns:Elements of Reusable Object Oriented 
                              Software,
                              by Erich Gamma,Richard Helm,Ralph Johnson,and John 
                              Vlissides,Addison Wesley,1995.395pages
                              設(shè)計模式,李英軍等譯,機械工業(yè)出版社,2000.254頁

            4.2   [Alex2001]Modern C++ Design: Generic Programming and Design 
                              Patterns Applied
                              by Andrei Alexandrescu,Addison-Wesley,2001,352Paper


             Genericity/STL系列:

             第一個境界是使用STL:
              [Josuttis99]:The C++ Standard Library -A Tutorial and 
                              Reference,by Nicolai M.Josuttis,
                              Addison Wesley 1999.799pages

              第二個境界是了解泛型技術(shù)的內(nèi)涵與STL的學(xué)理:
               [Austern98]:Generic Programming and the STL -Using and 
                              Extending the C++ Standard 
                              Template library,by Matthew H.Austern,Addison Wesley 
                              1998.548page


              第三個境界是擴充STL:
               [Stepanov2001]:C++ Standard Template Library by 
                              P.J.Plauger,Alexander A.Stepanov,
                              Meng Lee,David R.Musser,Prentice Hall 2001 

              這些就是你應(yīng)該看的書,如果你想成為高手。

            posted @ 2009-08-19 09:55 Voider 閱讀(363) | 評論 (0)編輯 收藏

            2008年9月7日

            作者risc700
            1, 簡歷上寫著了解c++, 實際上不知道m(xù)fc 根 VC有什么區(qū)別. 0級
            2, 簡歷上寫著精通c++, 但是僅僅知道m(xù)fc, 認為VC就是C++的一切。 1級
            3, 總是使用malloc,或者 char[100] 來獲得內(nèi)存,但不知道怎么在指定內(nèi)存上面創(chuàng)建對象。 2級
            4, 感覺std::string 沒有 CString 好用! 聽說過g++ 3級
            5, 會使用std::string, 認為 "c/c++" 很不科學(xué),完全就不是一個語言嘛. 知道4種以上c++ compiler. 感覺自己什么都會。 4級
            6, 看山是山,看水是水。崇拜boost source code, 嘔心瀝血的研究經(jīng)典庫的代碼. 感覺自己什么都不會。5級
            7, 看山不是山,看水不是水。為自己鐘情的函數(shù)庫而奮斗著,恨不得用盡各種tricks 和 traits, 因為各種經(jīng)典設(shè)計模式想得頭疼. 稍有走火入魔跡象。 6級
            8,看山仍然山,看水仍然是水。 看到每行代碼,都是匯編的指令和內(nèi)存數(shù)據(jù)的移動。 代碼中幾乎不出現(xiàn)for 和 while 關(guān)鍵字. 不停地否定自己的過去. 7級
            9, 維護著g++,或者Watcom C++ 之類的項目,頭發(fā)也比較長,有藝術(shù)家氣質(zhì). 8級
            10, 參與 C++ Standards Committee, 代表不同的利益集團發(fā)言. 9級
            11, 徹底走火入魔, 成天幻想修改C++的語法, 添加自己的關(guān)鍵字, 重新實現(xiàn)一個C++的改進, 還想把c++變成腳本,解釋執(zhí)行.已經(jīng)超越了利益. 10級.

            C++的四層境界


            1。程序員。
            有時被稱為藍領(lǐng),在C++開發(fā)小組扮演有用的角色,
            但是遇到設(shè)計難題時,需要高級程序員指導(dǎo)


            2。高級程序員
            與普通程序員的區(qū)別是,能獨立地解決大多數(shù)C++設(shè)計難題。
            要達到這一層次需要至少經(jīng)過三個復(fù)雜的C++PROJECT,并積累了一些設(shè)計失敗的教

            訓(xùn)。

            經(jīng)過努力,大多數(shù)C++編程人員都能達到這一高級程序員的境界。

            3。一個公司里的GURU
            也就是常說的一軟件公司里的牛人,可稱為一個公司里的GURU,
            他們拿著相當高的薪水。,領(lǐng)導(dǎo)一個公司的技術(shù)設(shè)計。
            這樣的人需要十年以上OO的經(jīng)驗并經(jīng)歷多個大型軟件成功和失敗。


            4。工業(yè)界的GURU

            這樣人在所在的領(lǐng)域如雷貫耳,幾乎很少有公司能夠雇得起他們。
            他們通常經(jīng)營著自己的咨詢公司。達到境界4的GURU們,幾乎在每天的空閑散步時間

            里都在思考技術(shù)。

            對大多數(shù)程序員來說,想達到他們的境界,是不現(xiàn)實的。


            -------C++ FAQ
            三位作者:
            Cline : Internet offical Forum C++FAQ 主持人,給數(shù)千名C++工程師上過課,
            計算機專業(yè)博士
            Lomow: 高級機構(gòu)設(shè)計師,15年OO開發(fā)經(jīng)驗,計算機專業(yè)博士
            Girou: 國際C++標準委員會成員,數(shù)學(xué)專業(yè)博士
            posted @ 2008-09-07 21:12 Voider 閱讀(213) | 評論 (0)編輯 收藏
             
            //file1.c
            #include <stdio.h>

            char ch[10];
            //file2.c
            #include <stdio.h>

            extern char *ch;

            int main()
            {
              ch[0]=1; 
              return 0;
            }
            ---------------------------------------
            gcc file1.c file2.c -o ap
            ./ap
            段錯誤
            -----------------------------------------------
            1,array vs pointer
            file2,c ch[i]實際上得到的是一個字符,但編譯器把它當成是一個指針,因為此文件中聲明為指針
            先取地址ch的內(nèi)容,加上i,當作字符ch[i]的地址。實際上所謂的地址是ch[0]+i;
            char ch[10]; 符號ch具有一個地址,ch[i],只需將i+ch具有的地址相加,再取其指向的內(nèi)容
            extern char *ch; ch[i],得到地址p的內(nèi)容,把它加上i,再取所得地址指向的內(nèi)容。
            而事實上p指向的內(nèi)容是ch[0]//one char.而非地址。

            2.定義vs聲明
            定義只有一次,且分配內(nèi)存,一種特殊的聲明。
            聲明可多次,不分配內(nèi)存。

            3.編譯器不為指針指向的對象分配空間,只是分配指針本身的空間。
            除非在定義時賦一string初始化,且只可以是字符串常量。只讀不可修改。
             char *p="Hello world";
              p[0]='h'; //段錯誤。


            posted @ 2008-09-07 20:59 Voider 閱讀(183) | 評論 (0)編輯 收藏
            僅列出標題  
             
            一本大道加勒比久久综合| 99久久国产精品免费一区二区 | 久久综合成人网| 日本久久久久久中文字幕| 精品久久无码中文字幕| 久久久噜噜噜www成人网| 久久婷婷国产综合精品| 国产精品一区二区久久| 99久久99这里只有免费的精品| 久久久精品国产sm调教网站| 欧美一区二区三区久久综| 久久综合狠狠综合久久综合88| 亚洲精品无码久久久久去q | 国产精品亚洲综合久久| 久久综合九色综合网站| 久久亚洲精品无码aⅴ大香| 亚洲成色www久久网站夜月| 99热成人精品热久久669| 久久精品18| 久久综合亚洲色一区二区三区| 国产三级久久久精品麻豆三级 | 亚洲精品国产综合久久一线| 久久人人爽人人人人片av| 久久婷婷五月综合国产尤物app| 久久免费视频观看| 亚洲精品成人网久久久久久| 久久人人爽人人爽人人AV东京热 | 色欲综合久久躁天天躁| 无码AV中文字幕久久专区| 国产精品久久永久免费| 亚洲人成无码www久久久| 久久久久久亚洲AV无码专区 | 久久精品视屏| 亚洲国产精品无码久久98| 国产福利电影一区二区三区久久久久成人精品综合 | 久久精品一本到99热免费| 国産精品久久久久久久| 亚洲精品乱码久久久久久蜜桃图片| 青青草国产精品久久久久| 综合久久国产九一剧情麻豆| 99久久婷婷国产综合精品草原|