关注开源技术(黑龙江。哈尔滨) 倡导企业级开源应用,探索信息化方案标准; 集成开源众多新成果,消除开源方案忧与患; 力推低成本开源战车,笑纳八方来客叙开源; 普及开源知识助推力,喜迎开源企业展宏图;
  • shell脚本的编缉、存储、执行 *

    2008-05-27 13:50:57

    编缉工具:vi  gedit  ee  leafpad  vim很多
    存储为*.sh文件
    执行:$ sh  *.sh  # sh *.sh
    chmod permission your-scrīpt-name

    Examples:
    $ chmod +x your-scrīpt-name
    $ chmod 755 your-scrīpt-name
    例子:
    ######ginfo.sh   start#########
    #
    #
    # scrīpt to print user information who currently login , current date & time
    #
    clear
    echo "Hello $USER"
    echo "Today is \c ";date
    echo "Number of user login : \c" ; who | wc -l
    echo "calendar"
    cal
    exit 0
    #######end##############
    fuqiang@fuqiang-laptop:~/桌面$ sh ginfo.sh
    Hello fuqiang
    Today is 2008年 05月 27日 星期二 16:00:48 CST
    Number of user login : 2
    calendar
         五月 2008     
    一 二 三 四 五 六 日
              1  2  3  4
    5  6  7  8  9 10 11
    12 13 14 15 16 17 18
    19 20 21 22 23 24 25
    26 27 28 29 30 31 
  • ETAPS 2008 *

    2008-04-25 22:25:30

      researchers working on topics relating to Software Science. ETAPS, established in 1998, is a confederation of five main annual conferences, accompanied by satellite workshops and other events. ETAPS 2008 is the eleventh event in the series.
      ETAPS 2008 will be hosted by Budapest, the capital of Hungary, which was founded in 1873 as the unification of the separate historic towns of Buda (the royal capital since the 15th century), Pest (the cultural centre) and Óbuda (built on the ancient Roman settlement of Aquincum). The city is bisected by the River Danube, which makes Budapest a natural geographical centre and a major international transport hub. Budapest has a rich and fascinating history, a vibrant cultural heritage, yet it managed to maintain its magic and charm. It has also been called the City of Spas with a dozen thermal bath complexes served by over a hundred natural thermal springs.
    http://etaps08.mit.bme.hu/


  • gcov—a Test Coverage Program *

    2008-04-21 12:40:15

    gcov is a tool you can use in conjunction with GCC to test code coverage in your programs.
    http://gcc.gnu.org/onlinedocs/gcc/Gcov.html
    覆盖率(白盒测试)
    一、安装工作:
        ubuntu7.10源中有,但还要装libbfd-2.17.50.20070426.so,把它放到/usr/lib下。
    二、功能应用:
        [gcov命令行式的,ggcov(GTK图形式的)]
    fuqiang@fuqiang-laptop:~/linuxcexample/time/gcovex$ gcov
    用法:gconv [选项]... 源文件

    显示代码覆盖信息。

      -h, --help                      打印此帮助并退出
      -v, --version                    打印版本号并退出
      -a, --all-blocks                显示每个基本块的信息
      -b, --branch-probabilities      输出包含分支概率
      -c, --branch-counts             给出跳转的分支数,而不是百分比
      -n, --no-output                 不创建输出文件
      -l, --long-file-names           为包含进来的源文件使用长输出文件名
      -f, --function-summaries        输出每个函数的小结信息
      -o, --object-directory DIR|FILE 在 DIR 中搜索目标文件,或搜索名为 FILE 的目标文件
      -p, --preserve-paths            保留所有路径名
      -u, --unconditional-branches    同时显示无条件跳转数

    提交错误报告的具体步骤请参见:
    <URL:http://gcc.gnu.org/bugs.html>。

    For Debian GNU/Linux specific bug reporting instructions, please see:
    <URL:file:///usr/share/doc/gcc-4.1/README.Bugs>.
    fuqiang@fuqiang-laptop:~/linuxcexample/time/gcovex$ ls
    timeex.c
    fuqiang@fuqiang-laptop:~/linuxcexample/time/gcovex$ gcc -fprofile-arcs -ftest-coverage timeex.c
    fuqiang@fuqiang-laptop:~/linuxcexample/time/gcovex$ ls
    a.out  timeex.c  timeex.gcno
    fuqiang@fuqiang-laptop:~/linuxcexample/time/gcovex$ ./a.out
    biggest = Tue Jan 19 03:14:07 2038
    fuqiang@fuqiang-laptop:~/linuxcexample/time/gcovex$ ls
    a.out  timeex.c  timeex.gcda  timeex.gcno
    fuqiang@fuqiang-laptop:~/linuxcexample/time/gcovex$ ggcov timeex.c



  • 最基本linux c编程基础 *

    2008-03-15 19:24:32

    例子文件:
    /*
    this is bill.c
    */
    #include  <stdio.h>
    void  bill(char *argv)
    {
        printf("bill:  %s\n",argv);
    }
    /*
    this is linus.c
    */
    #include  <stdio.h>
    void  linus(char *argv)
    {
        printf("linus:  %s\n",argv);
    }
    /*
    this is mylib.h
    */
    void bill(char  *);
    void linus(char *);
    /*
    this is main program
    */
    #include  "mylib.h"
    int main()
    {
        linus("Hello Word");
        exit(0);
    }
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ gcc -c bill.c linus.c
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ ls *.o
    bill.o  linus.o
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ ls
    bill.c  bill.o  linus.c  linus.o  main.c  mylib.h
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ gcc -c main.c
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ ls
    bill.c  bill.o  linus.c  linus.o  main.c  main.o  mylib.h
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ gcc -o main main.o linus.o
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ ./main
    linus:  Hello Word
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ ar crv libmy.a  bill.o linus.o
    a - bill.o
    a - linus.o
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ ls
    bill.c  bill.o  libmy.a  linus.c  linus.o  main  main.c  main.o  mylib.h
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ ls libmy.a
    libmy.a
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ nm main
    080494dc d _DYNAMIC
    080495b0 d _GLOBAL_OFFSET_TABLE_
    080484a8 R _IO_stdin_used
            w _Jv_RegisterClasses
    080494cc d __CTOR_END__
    080494c8 d __CTOR_LIST__
    080494d4 d __DTOR_END__
    080494d0 d __DTOR_LIST__
    080484c4 r __FRAME_END__
    080494d8 d __JCR_END__
    080494d8 d __JCR_LIST__
    080495d8 A __bss_start
    080495cc D __data_start
    08048460 t __do_global_ctors_aux
    08048350 t __do_global_dtors_aux
    080495d0 D __dso_handle
            w __gmon_start__
    0804845a T __i686.get_pc_thunk.bx
    080494c8 d __init_array_end
    080494c8 d __init_array_start
    080483f0 T __libc_csu_fini
    08048400 T __libc_csu_init
            U __libc_start_main@@GLIBC_2.0
    080495d8 A _edata
    080495dc A _end
    08048488 T _fini
    080484a4 R _fp_hw
    0804829c T _init
    08048320 T _start
    080495d8 b completed.5982
    080495cc W data_start
            U exit@@GLIBC_2.0
    08048380 t frame_dummy
    080483d0 T linus
    080483a4 T main
    080495d4 d p.5980
            U printf@@GLIBC_2.0
    fuqiang@fuqiang-laptop:~/linuxcexample/ch1$ nm libmy.a

    bill.o:
    00000000 T bill
            U printf

    linus.o:
    00000000 T linus
            U printf
  • python数据结构--->set(集合) *

    2008-01-29 11:34:53

    主要了解集合的语义、组成、操作集、比较运算、集合的指令集、集合的内置函数与方法等信息。
    集合:相关数据对象集.

    Set Semantics

    A set is, perhaps the simplest possible container, since it contains objects in no particular order with no particular identification. Objects stand for themselves. With a sequence, objects are identified by position. With a mapping, objects are identified by some key. With a set, objects stand for themselves.

    Since each object stands for itself, elements of a set cannot be duplicated. A list or tuple, for example, can have any number of duplicate objects. For example, the tuple ( 1, 1, 2, 3 ) has four elements, which includes two copies of the integer 1; if we create a set from this tuple, the set will only have three elements.

    A set has large number of operations for unions, intersections, and differences. A common need is to examine a set to see if a particular object is a member of that set, or if one set is contained within another set.

    A set is mutable, which means that it cannot be used as a key for a dict for more information.) In order to use a set as a dict key, we can create a frozenset, which is an immutable copy of the original set. This allows us to accumulate a set of values to create a dict key.


    Set Literal Values

    frozenset (iterable) → set
    set( iterable) → set
    >>> set( ("hello", "world", "of", "words", "of", "world") )
    set(['world', 'hello', 'words', 'of'])

    Set Operations


    >>> fib=set( (1,1,2,3,5,8,13) )
    >>> prime=set( (2,3,5,7,11,13) )
    >>> fib | prime
    set([1, 2, 3, 5, 7, 8, 11, 13])
    >>> fib & prime
    set([2, 3, 5, 13])
    >>> fib - prime
    set([8, 1])
    >>> prime - fib
    set([11, 7])
    >>> fib ^ prime
    set([8, 1, 11, 7])

    Set Comparison Operators

    All of the standard comparisons (<, <=, >, >=, ==, !=, in, not in) work with sets
    >>> craps= set( [ (1,1), (2,1), (1,2), (6,6) ] )
    >>> (1,2) in craps
    True
    >>> (3,4) in craps
    False

    >>> three= set( [ (2,1), (1,2) ] )
    >>> three < craps
    True
    >>> three <= craps
    True
    >>> craps <= craps
    True
    >>> craps < craps
    False

    Set Statements


    >>> even= set( range(2,38,2) )
    >>> ōdd= set( range(1,37,2) )
    >>> zero= set( (0,'00') )
    >>> for n in even|odd|zero:
    print n
    0
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    00

    Set Built-in Functions

    A number of built-in functions create or process sets.

    len(object ) → integer

    Return the number of items of a set.

    max(set ) → value

    With a set, return its largest item

    min(set ) → value

    With a set, return its smallest item.

    Set Methods

    A set object has a number of member methods. In the following definitions, s is a set object.

    The following transformation functions update a set.

    s.clear

    Remove all items from the set.

    s.copy → set

    Copy the set to make a new set. This is a shallow copy. All objects in the new set are references to the same objects as the original set.

    s.pop → object

    Remove an arbitrary object from the set, returning the object. If the set was already empty, this will raise a KeyError exception.

    s.add(new)

    Adds element new to the set. If the object is already in the set, nothing happens.

    s.remove(old)

    Removes element old from the set. If the object old is not in the set, this will raise a KeyError exception.

    s.discard(old)

    Removes element old from the set. If the object old is not in the set, nothing happens.

    s.update(new) → object

    Merge values from the new set into the original set, adding elements as needed. It is equivalent to the following Python statement. s |= new.

    s.intersection_update(new) → object

    Update s to have the intersection of s and new. In effect, this discards elements from s, keeping only elements which are common to new and s. It is equivalent to the following Python statement. s &= new.

    s.difference_update(new) → object

    Update s to have the difference between s and new. In effect, this discards elements from s which are also in new. It is equivalent to the following Python statement. s -= new.

    s.symmetric_difference_update(new) → object

    Update s to have the symmetric difference between s and new. In effect, this both discards elements from s which are common with new and also inserts elements into s which are unique to new. It is equivalent to the following Python statement. s ^= new.

    The following accessor methods provide information about a set.

    s.issubset(set) → boolean

    If s is a subset of set, return True, otherwise return False. Essentially, this is s <= set.

    s.issuperset(set) → boolean

    If s is a superset of set, return True, otherwise return False. Essentially, this is s >= set.

    s.union(new) → set

    If new is a proper set, return s | new. If new is a sequence or other iterable, make a new set from the value of new, then return the union, s | new. This does not update s.

    >>> prime.union( (1, 2, 3, 4, 5) )
    set([1, 2, 3, 4, 5, 7, 11, 13])
    s.intersection(new) → set

    If new is a proper set, return s & new. If new is a sequence or other iterable, make a new set from the value of new, then return the intersection, s & new. This does not update s.

    s.difference(new) → set

    If new is a proper set, return s - new. If new is a sequence or other iterable, make a new set from the value of new, then return the difference, s - new. This does not update s.

    s.symmetric_difference(new) → set

    If new is a proper set, return s ^ new. If new is a sequence or other iterable, make a new set from the value of new, then return the symmetric difference, s ^ new. This does not update s.

    >>>help(set)可查一下
    Help on class set in module __builtin__:

    class set(object)
     |  set(iterable) --> set object
     | 
     |  Build an unordered collection of unique elements.
     | 
     |  Methods defined here:
     | 
     |  __and__(...)
     |      x.__and__(y) <==> x&y
     | 
     |  __cmp__(...)
     |      x.__cmp__(y) <==> cmp(x,y)
     | 
     |  __contains__(...)
     |      x.__contains__(y) <==> y in x.
     | 
     |  __eq__(...)
     |      x.__eq__(y) <==> x==y
     | 
     |  __ge__(...)
     |      x.__ge__(y) <==> x>=y
    .............................




     


  • Graphical tools for ODBC management and browsing *

    2008-01-26 14:17:32

       This package contains three graphical applications for use with
    unixODBC, the Open DataBase Connectivity suite: ODBCConfig, a graphical
    configuration tool for managing database drivers and access to
    individual databases; DataManager, a simple browser and query tool for
    ODBC databases; and odbctest, a tool for testing the ODBC API itself.
  • 关于Python的线程程序设计 *

    2008-01-09 16:41:24

    关于Python的线程程序设计

    一、为什么用线程(Thread)?
        在现阶段应用程序设计技术中,线程扮演很重要的角色,比如好多中间件是基于线程的、JAVA GUI应用等。
        大面积应用采用线程的理由如下:
        1、并行计算
        2、并行I/O处理
        3、异步I/O事件处理
    二、什么是线程(Thread)?
        1、先说一下什么是进程(Process)?
          通过学习操作系统的基本原理你可以了解到它的重要性和有用性,主要是提升CPU的处理效率,主要内容有:什么是进程,进程的状态,进程的调度,进程的结构与标识, 进程的空间,进程的上下文切换,进程的处理方法,进程与程序的区别等。
        2、线程是类似进程的,只有大小、粒度的不同
          线程有时也叫轻量级(lightweight)进程,占有比线程更小的空间,切换的代价小,实际情况下依赖于具体的线程系统,它们都有自己的中断方法,关 于中断的技术要引起关注,因为线程的粒度小,有时要引起极大的关注,都可以创建自己的子线程或子进程,在UNIX/LINUX中用fork()创建子线 程,子共亨父的方法也是类同的。
    三、Python的线程模块
        有两个thread.py和threading.py,前者是早期的,相对来说简单一些。
        用例子说明如下,注意研究lock是如何形成的
          server.py
        # this is the server
    import socket  # networking module
    import sys
    import thread
    # note the globals v and nclnt, and their supporting locks, which are
    #    also global; the standard method of communication between threads is
    #    via globals
    # function for thread to serve a particular client, c
    def serveclient(c):
          global v,nclnt,vlock,nclntlock
          while 1:
                  # receive letter from c, if it is still connected
                  k = c.recv(1)
                  if k == ' ': break
                  # concatenate v with k in an atomic manner, i.e. with protection
                  #    by locks
                  vlock.acquire()
                  v += k
                  vlock.release()
                  # send new v back to client
                  c.send(v)
                  c.close()
                  nclntlock.acquire()
                  nclnt -= 1
                  nclntlock.release()
    # set up Internet TCP socket
    lstn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    port = int(sys.argv[1]) # server port number
    # bind lstn socket to this port
    lstn.bind(('127.0.0.1', 4000))
    # start listening for contacts from clients (at most 2 at a time)
    lstn.listen(5)
    # initialize concatenated string, v
    v = ' '
    # set up a lock to guard v
    vlock = thread.allocate_lock()
    # nclnt will be the number of clients still connected
    nclnt = 2
    # set up a lock to guard nclnt
    nclntlock = thread.allocate_lock()
    # accept calls from the clients
    for i in range(nclnt):
          # wait for call, then get a new socket to use for this client,
          #    and get the client's address/port tuple (though not used)
          (clnt,ap) = lstn.accept()
          # start thread for this client, with serveclient() as the thread's
          #    function, with parameter clnt; note that parameter set must be
          #    a tuple; in this case, the tuple is of length 1, so a comma is
          #    needed
          thread.start_new_thread(serveclient(clnt))
    # shut down the server socket, since it's not needed anymore
    lstn.close()
    # wait for both threads to finish
    while nclnt > 0: pass
    print 'the final value of v is', v
      client1.py
    # simple illustration of thread module
    # two clients connect to server; each client repeatedly sends a letter,
    # stored in the variable k, which the server appends to a global string
    # v, and reports v to the client; k = ' 'means the client is dropping out; when all clients are gone, server prints the final string v
    # this is the client; usage is
    #    python clnt.py server_address port_number
    import socket  # networking module
    import sys
    # create Internet TCP socket
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    host = sys.argv[1] # server address
    port = int(sys.argv[2]) # server port
    # connect to server
    s.connect((host,port ))
    while(1):
    # get letter
            k = raw_input('enter a letter:')
            s.send(k) # send k to server
    # if stop signal, then leave loop
            if k == ' ': break
    v= s.recv(1024)  # receive v from server (up to 1024 bytes)
    print  v
    s.close() # close socket
    下面是threading的,联系java想一下相关方面 srvr如何?
    # simple illustration of threading module
    # multiple clients connect to server; each client repeatedly sends a
    # value k, which the server adds to a global string v and echos back
    # to the client; k = ’’ means the client is dropping out; when all
    # clients are gone, server prints final value of v
    # this is the server
    import socket # networking module
    import sys
    import threading
    # class for threads, subclassed from threading.Thread class
    class srvr(threading.Thread):
            # v and vlock are now class variables
            v = ’’
            vlock = threading.Lock()
            id = 0 # I want to give an ID number to each thread, starting at 0
            def __init__(self,clntsock):
                  # invoke constructor of parent class
                  threading.Thread.__init__(self)
                  # add instance variables
                  self.myid = srvr.id
                  srvr.id += 1
                  self.myclntsock = clntsock
          # this function is what the thread actually runs; the required name
          #    is run(); threading.Thread.start() calls threading.Thread.run(),
          #    which is always overridden, as we are doing here
          def run(self):
                  while 1:
                        # receive letter from client, if it is still connected
                        k = self.myclntsock.recv(1)
                        if k == ’’: break
                        # update v in an atomic manner
                        srvr.vlock.acquire()
                        srvr.v += k
                        srvr.vlock.release()
                        # send new v back to client
                        self.myclntsock.send(srvr.v)
                self.myclntsock.close()
    # set up Internet TCP socket
    lstn = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    port = int(sys.argv[1]) # server port number
    # bind lstn socket to this port
    lstn.bind((’’, port))
    # start listening for contacts from clients (at most 2 at a time)
    lstn.listen(5)
    nclnt = int(sys.argv[2])  # number of clients
    mythreads = [] # list of all the threads
    # accept calls from the clients
    for i in range(nclnt):
          # wait for call, then get a new socket to use for this client,
          #    and get the client’s address/port tuple (though not used)
            (clnt,ap) = lstn.accept()
          # make a new instance of the class srvr
          s = srvr(clnt)
          # keep a list all threads
          mythreads.append(s)
          # threading.Thread.start calls threading.Thread.run(), which we
          #    overrode in our definition of the class srvr
          s.start()
    # shut down the server socket, since it’s not needed anymore
    lstn.close()
    # wait for all threads to finish
    for s in mythreads:
          s.join()
    print ’the final value of v is’, srvr.v
  • The Erlang Shell *

    2008-01-02 15:37:20

    Most operating systems have a command interpreter or shell, Unix and Linux have many, Windows has the Command Prompt. Erlang has its own shell where you can directly write bits of Erlang code and evaluate (run) them to see what happens. Start the Erlang shell (in Linux or UNIX) by starting a shell or command interpreter in your operating system and typing erl, you will see something.
    tut.erl
    code--start
    -module(tut).
    -export([double/1]).
    double(X) ->
            2 * X.
    code--end
    fuqiang@fuqiang-laptop:~$ erl
    Erlang (BEAM) emulator version 5.5.5 [source] [async-threads:0] [kernel-poll:false]

    Eshell V5.5.5  (abort with ^G)
    1> c(tut).
    {ok,tut}
    2> tut:double(10).
    20
    3>
    ubuntu 7.10
    c(tut).--->{ok,tut}代表编译成功;
    tut:double(10).--->调用tut中的double;
    erlang源文件*.erl.


  • python数据结构---List *

    2007-12-31 10:25:10

    操作类型:
    insert(i, x)
    extend(L)--a[len(a):] = L
    append(x)
    remove(x)
    pop()
    index(x)
    count(x)
    sort( )
    reverse( )
    >>> a=[3434,234,6768,900]
    >>> print a.count(3434),a.count(234),a.count(6768),a.count(900)
    1 1 1 1
    >>> print a.count(0)
    0
    >>> a.insert(2,-1)>>> a.append(333)
    >>> a
    [3434, 234, -1, 6768, 900, 333]

    >>> a.index(333)
    5
    >>> a.remove(333)
    >>> a
    [3434, 234, -1, 6768, 900]
    >>> a.reverse()
    >>> a
    [900, 6768, -1, 234, 3434]
    >>> a.sort()
    >>> a
    [-1, 234, 900, 3434, 6768]
    >>> m=[23,56]
    >>> a[len(a):]=m
    >>> a
    [-1, 234, 900, 3434, 6768, 23, 56]
    >>> a.pop()
    56
    >>>
    标注:有些工作由python语言处理程序作了内化处理,这可以使程序员的工作减少,但又不失语言的功用,从而达到简单的目的,有时也提高了程序的安全性,提倡安全程序设计,数据结构由三方面组成:
    数据元素、关系、操作,当然也可以通过python提供的第三方库实现数据结构支持扩展,比如python可用科学计算、并行程序设计等,可以说它是动态语言的典范。
  • Layout management(Tkinter)布局管理

    2007-12-28 18:01:15

    GUI application
    widgets get arranged in a window?
    Although there are three different “geometry managers” in Tkinter, the author strongly
    prefers the Grid geometry manager for pretty much everything. This manager treats every window or frame as a table—a gridwork of rows and columns.
    A cell is the area at the intersection of one row and one column.
    The width of each column is the width of the widest cell in that column.
    The height of each row is the height of the largest cell in that row.
    For widgets that do not fill the entire cell, you can specify what happens to the extra
    space. You can either leave the extra space outside the widget, or stretch the widget
    to fit it, in either the horizontal or vertical dimension.
    You can combine multiple cells into one larger area, a process called spanning.
    When you create a widget, it does not appear until you register it with a geometry
    manager. Hence, construction and placing of a widget is a two-step process that goes
    something like this:
            thing = Constructor(master, ...)
            thing.grid(...)
    where Constructor is one of the widget classes like Button, Frame, and so on. All
    widgets have a .grid() method that you can use to tell the geometry manager where to
    put it.

Open Toolbar