• 2009-10-10

    技术的本质 – 围观不会设置User-Agent的美国菜鸟

    Views: 19515 | 3 Comments

    最近, 网上盛传一个笑话, 一般名字叫做"围观不会设置Java User-Agent的菜鸟". 讲的是国外一个用Java开发Web爬虫获取网页的菜鸟, 不知道怎么设置自己虫子的User-Agent字段, 该字段可以告诉Web服务器, 对方用的是什么工具或者软件. 这个笑话中的事情确有其事, 见下面URL:

    https://groups.google.com/group/comp.lang.java/browse_thread/thread/6923c024ed392c85

    这个帖子(邮件)的发贴人使用的邮箱后缀是cs.stanford.edu, 他是斯坦福大学的学生. 发贴的时间是1996年1月, 使用的Java是1.0beta2. 当时, Web爬虫技术应该是非常稀有的技术, Java/1.0beta2的HTTP相关库也应该非常难用. 现在看来, 那时的人, 那时的技术, 都像是婴儿. 所以, 这看起来像个笑话.

    但是, "笑话"的笑点在这里吗? 我相信, 大家在看到这个所谓的笑话时, 可能会心里或者面上露出笑, 但应该是感悟的笑, 自嘲的笑, 无奈的笑, 思索的笑...肯定不会有快乐的笑. 为什么? 因为发贴的人是Larray Page, 是Google公司的创始人之一. 他创造了全球许多技术人员的上帝, 他创造了巨大的财富, 他创造了技术和商业神话. 可是, 他曾经做过的事, 使用的技术, 开发出的产品, 遇到的无法逾越的问题, 向人讨教时的心情, 和我们那么接近, 甚至对我们大部分技术人员简直是小菜一碟. 在每一个人心中, 这都是一个历史笑话, 让我们思考技术的本质.

    我把这封邮件引用在这里, 做个留念:

    Jan 7 1996, 4:00 pm

    I have a web robot which is a Java app. I need to be able to set the User-Agent field in the HTTP header in order to be a good net citizen (so people know who is accessing their server). Anyone have any ideas?

    Right now, Java sends a request that includes something like:

    User-Agent: Java/1.0beta2

    I'd rather not rewrite all the HTTP stuff myself. I tried just searching in the JDK for the Java/1.0beta2 figuring I could just change the string, but I couldn't find it. Perhaps it is stored as a unicode string?

    An easy method of setting the User-Agent field should probably be added to Java, so people can properly identify their programs.

    Thanks, Larry Page

    Posted by ideawu at 2009-10-10 14:57:14
  • 2009-09-28

    我学过的编程语言

    Views: 10600 | No Comments

    Basic
    在中学时学习, 为了奥林匹克竞赛.

    Pascal
    在中学时学习, 为了奥林匹克竞赛, 但还是没用上. 后来第一次做了.exe软件, 放在autoexec.bat里, 用做系统登录.

    C Continue reading »

    Posted by ideawu at 2009-09-28 19:27:43
  • 2009-08-21

    CVS笔记

    Views: 9890 | No Comments

    cvs up -p -r1.2 file_name 打文件输出到stdout.

    CVS checkout 模块到当前目录, 结构ps/aos/machine
    cvs -d :pserver:me@ideawu.net:/data/cvsroot checkout -r TAG_1 product/abc

    CVS checkout 模块到当前目录, 结构machine
    cvs -d :pserver:me@ideawu.net:/data/cvsroot checkout -d local_dir -r TAG_1 product/abc

    更新(如果不这样, 被删除的目录不会被更新到本机, 因为默认只更新本机有的文件):
    cvs up -dr 分支号

    查看文件不同版本的区别
    cvs diff -r1.3 -r1.5 file_name

    获取指定版本的文件输出的 stdout
    cvs update -p -r1.2 file_name

    导入一个目录(在要导入的目录内部执行, 把当前目录的内容导入指定的CVS目录):
    cvs -d :pserver:me@ideawu.net:/data/cvsroot -b TAG_1 import product/abc/subdir company TAG_X
    其中, product/abc/subdir 是在 CVS 中的目录.

    获取指定tag的代码:
    错误的方法: cvs up -dr TAG, 其实是给本地代码打上TAG, 算误操作, 可以通过cvs up -A补救.
    正确的方法: 只能用 cvs checkout -r tag_name

    Posted by ideawu at 2009-08-21 17:36:09
  • 2009-08-02

    .Net程序中使用log4net记录日志

    Views: 11358 | No Comments

    记录下这个笔记, 方便以后查阅. log4net使用了控制台输出和文件轮换输出.

    1. 新建工程
    2. 添加对log4net.dll的引用
    3. 在AssemblyInfo.cs中增加[assembly: log4net.Config.XmlConfigurator(Watch = true)]
    4. 增加应用程序配置文件App.config, 完整内容为:

      <?xml version="1.0" encoding="utf-8" ?>
      <configuration>
        <!-- Register a section handler for the log4net section -->
        <configSections>
          <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
        </configSections>
      
        <log4net>
          <appender name="A_CONSOLE" type="log4net.Appender.ConsoleAppender">
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date{HH:mm:ss,fff} [%-5level] %logger{1} - %message%newline" />
            </layout>
          </appender>
      
          <appender name="A_FILE" type="log4net.Appender.RollingFileAppender">
      	  <file value="log.txt" />
      	  <appendToFile value="true" />
      	  <rollingStyle value="Size" />
      	  <maximumFileSize value="1024KB" />
      	  <maxSizeRollBackups value="3" />
            <layout type="log4net.Layout.PatternLayout">
              <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss.fff} [%-5level] %logger{1} - %message%newline" />
            </layout>
          </appender>
      
          <!-- Set root logger level to DEBUG and its only appender to A1 -->
          <root>
            <level value="DEBUG" />
            <appender-ref ref="A_CONSOLE" />
            <appender-ref ref="A_FILE" />
          </root>
      
        </log4net>
      </configuration>
      
    5. 使用:
      log4net.ILog log = log4net.LogManager.GetLogger(
          System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
      log.Debug("ideawu.net");
      
    Posted by ideawu at 2009-08-02 15:03:58
  • 2009-06-17

    重流程还是重工具?

    Views: 9275 | No Comments

    开发一套流程系统, 是把业务的有效性是由系统来判断, 还是由人来判断? 是帮助人操作业务, 还是记录人操作业务的历史? 流程系统是越俎代庖替人搬砖头, 还是记录人搬砖头的经过? 流程系统是一个机械自动化工具吗?

    Posted by ideawu at 2009-06-17 10:15:30
  • 2009-06-13

    “打开方式”里无法选择程序的解决方法

    Views: 11013 | No Comments

    不知道什么原因, 鼠标右键里的"打开方式", 无法选择某个程序, 如果把该程序改名, 就能选择. 经一番搜索, 终于知道注册表里该程序的路径有误.

    HKEY_CLASSES_ROOT\Applications\your app.exe\shell\open\command

    把"command"或者"your app.exe"删除即可.

    Posted by ideawu at 2009-06-13 10:55:30
|<<<123456789>>>| 5/15 Pages, 86 Results.