快要去找工作了

想找轻松一点的工作,身体是革命的本钱
富士康都11跳了今天。。。
算法类工作不知道轻松不
不想coding as a job
只想coding for fun


--
l5g
功可强成,名可强立。后面还可以加...
http://l5g.blogspot.com

查找 time_t 的定义

又读expert c programming.

/usr/include$ grep time_t time.h


typedef __time_t time_t;


/usr/include$ grep __time_t time.h

# include /* This defines __time_t for us.  */ (这个注释的好处...)


/usr/include$ grep __time_t bits/types.h 
__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch.  */

__STD_TYPE 其实就是typedef


l5g@desktop:/usr/include$ grep include bits/types.h
 * Never include this file directly; use instead.
#include
#include
#include /* Defines __*_T_TYPE macros.  */






l5g@desktop:/usr/include$ grep __TIMER_T_TYPE bits/typesizes.h
#define __TIMER_T_TYPE void *


终于到最后了 其实就是一个 void *


strsep.c

unix 源代码里的strsep.c 与 gnu/linux 里的不一样,觉得后者的代码写的清晰明了一点.

http://www.koders.com/c/fid4F16A5D73313ADA4FFFEEBA99BE639FEC82DD20D.aspx

里面的代码风格也是我喜欢的类型, 在那些小地方优化一些感觉好一点.

看这个函数的头文件还以为delimiter会作为一个整体的...

http://blog.wu-boy.com/2010/04/28/2136/

XML-RPC SOAP 与 REST

简单对象访问协议(Simple Object Access Protocol,SOAP)、代表性状态传输(Representational State Transfer,REST)以及 XML 远程过程调用协议(XML Remote Procedure Call,XML-RPC)

用于将本地程序向web程序集成


http://www.ibm.com/developerworks/cn/webservices/ws-xml-rpc/
http://www.tldp.org/HOWTO/XML-RPC-HOWTO/index.html
http://www.ibm.com/developerworks/cn/webservices/ws-pyth/part5/index.html

用c为apache开发cgi应用

以前没有这么多脚本语言的时候应该很流行.

安装apache

启用模块 userdir, 就是每个用户目录一个public_html


sudo vim /etc/apache2/mods-enabled/userdir.conf


/*****************************************************************
* C Programming in Linux (c) David Haskins 2008
* chapter1_3.c                                 *
*****************************************************************/
#include
int main(int argc, char *argv[])
{
          int i=0;
     printf("Content-type:text/plain\n\n");
     printf("Hello, you are still learning C!!\n");
     printf("Number of arguments to the main function:%d\n", argc);
          for(i=0;i
          {
          printf("argument number %d is %s\n", i, argv[i]);
          }
      return 0;
}






启用对每个用户都有效的cgi目录

指令可以指定每个用户主目录中的一个特定的目录为"允许cgi"的目录,使每个用户都可以拥有自己的cgi-bin目录。

Options ExecCGI
SetHandler cgi-script

Python 的代码风格

有两个供参考

1.PEP 8 http://www.python.org/dev/peps/pep-0008/
            http://www.python.org/dev/peps/pep-0257/

2. Google Python Style Guide http://google-styleguide.googlecode.com/svn/trunk/pyguide.html

代码风格的一致性很重要, 更重要的是在某些情况下为了可读性要灵活变通

缩进用4个空格
不要混用 tab 和空格, python -t / -tt 检查是否混用
限制所有行最长79个字符, 长的块最长72个字符, 换行在二元运算符后面
最上层的函数和类的定义用两个空行分隔
类里的方法用一个空行分隔, python 接受 control-L 作为空格


import 分成几行, from ... import 例外
import 的顺序
Imports should be grouped in the following order:


1. standard library imports
      2. related third party imports
      3. local application/library specific imports
用空行分隔
使用package的绝对路径导入
避免下面这种多余的空格
- Immediately inside parentheses, brackets or braces.


Yes: spam(ham[1], {eggs: 2})
      No:  spam( ham[ 1 ], { eggs: 2 } )

    - Immediately before a comma, semicolon, or colon:

      Yes: if x == 4: print x, y; x, y = y, x
      No:  if x == 4 : print x , y ; x , y = y , x

    - Immediately before the open parenthesis that starts the argument
      list of a function call:

      Yes: spam(1)
      No:  spam (1)

    - Immediately before the open parenthesis that starts an indexing or
      slicing:

      Yes: dict['key'] = list[index]
      No:  dict ['key'] = list [index]

    - More than one space around an assignment (or other) operator to
      align it with another.

      Yes:

          x = 1
          y = 2
          long_variable = 3

      No:

          x             = 1
          y             = 2
          long_variable = 3
算术操作符前后用空格, 二元运算符


Yes:

          i = i + 1
          submitted += 1
          x = x * 2 - 1
          hypot2 = x * x + y * y
          c = (a + b) * (a - b)

      No:

          i=i+1
          submitted +=1
          x = x*2 - 1
          hypot2 = x*x + y*y
          c = (a+b) * (a-b)
当'='用来指明关键字参数或默认参数的时候,两边不要用空格
最好不要把多行语句下在一行里,尤其是if/for/while
错误的注释别没有注释更糟糕.
用英文注释除非120%的确信其它种类的人不会读你的代码
# 后面加个空格
行内注释与表达式之间空至少两格,避免无意义的注释
为所有的公开的modules, functions, classes, methods 写 docstrings


__version__ = "$Revision: 68852 $"
        # $Source$


- Comparisons to singletons like None should always be done with
      'is' or 'is not', never the equality operators.


beware of writing "if x" when you really mean "if x is not None"


Use ''.startswith() and ''.endswith() instead of string slicing to check
      for prefixes or suffixes.


Yes: if foo.startswith('bar'):

        No:  if foo[:3] == 'bar':


For sequences, (strings, lists, tuples), use the fact that empty
      sequences are false.

      Yes: if not seq:
           if seq:

      No: if len(seq)
          if not len(seq)