透明思考


Transparent Thoughts


  1. svlogd- runit's service logging daemon

    After installrunit, you’ll get /usr/bin/svlogd in yoursystem, which is runit’s service logging daemon. Although there’s amanual, it took me a while to figure ourhow to use it …

    (BTW, runit package in Ubuntu Feisty official repository isbroken…)

    svlogd accepts input from itsSTDINand write it to log files. For example you can do following:

    ls / | svlogd -v ./log

    There will be a “log/current” file, which includes the output of “ls /”.

    Tolog a runit’s service,you need create a “log” subdirectory within the service directory,thenrun svlogd in the subdirectory. Given I have a “mongrel_3002”service, I’ll create following stuff:

    /var/service/mongrel_3002/log/var/service/mongrel_3002/log/run

    Put following script in “log/run”, and make it executable:

    #!/bin/shexec svlogd -tt /path/to/log # /path/to/log must be writable

    Mongrel(in non-daemon mode, i.e. without “-d” option) makes it morecomplicated: it outputs log to log file of itself (such as”#{RAILS_ROOT}/log/production.log”), or outputs log toSTDERRif thelog file is not writable. In order to collect Mongrel’s log withsvlogd, I first make “production.log” not writable, then redirectSTDERRtoSTDOUTin Mongrel starting script:

    gigix@gigix-laptop:~$ cat /var/service/mongrel_3002/run#!/bin/sh/usr/bin/mongrel_rails -c /path/to/rails/app -C /path/to/mongrel/config 2&1

    Dirty, but it works …


  2. FOR(Finance on Rails)第一步:铁道上选基金

    http://for.thoughtworkers.org/funds/show

    想法很简单:我一直根据晨星评级选基金,不过每次看晨星报表要翻来翻去的排序,还要和以前的旧表对比参考。把这些动作简化,就对我有价值了。

    第一步是列出最近的晨星报表,根据几个重要字段排序(已经做好了);加上高亮标记的功能,在排序时就不会忘记自己前面看中的基金。

    第二步是自定义基金筛选条件,例如“年度排名前10,并且在6月1日、6月8日和6月22日这三周的收益率都在-0.2%以上”。可以分享别人的筛选条件,可以看到哪个筛选条件得到的效果比较好。

    更多的需求,还没想清楚。反馈欢迎中。


  3. 敏捷|认证|随便联想

    JavaEye的一个讨论,不幸已经被隐掉了。Scrum Master认证培训,4500~6000RMB。

    InfoQ:超越CSM的敏捷认证
    ScottAmbler说:“从几个邮件中的讨论来看,很明显,那些没有拿CSM的人认为那只是个噱头,拿了CSM的人也认为那只是个噱头,甚至CSM培训者也这么认为。然而,CSM课程还是照样进行着……只要通过两天的培训课程就可以宣称是通过认证的ScrumMaster了,这明显就是欺诈。”

    敏捷中国的另一个讨论。敏捷是一种“过程体系”吗?敏捷的过程是可以被认证的吗?

    全世界都在讲泰勒制管理。泰勒究竟发明了什么?是挥动煤铲的最佳动作,还是“借助高速摄影机去发现最佳动作”这一实践?


  4. RubyWorks迈出第二步:Production Stack on Ubuntu

    RubyWorks Production Stack今天发布0.0.2版本。

    虽然只是千分位上的进展,不过也可以说是比前一个版本进步了一倍——事实也差不多正是这样:除了Redhat/CentOS以外,我们现在开始支持Debian4 Etch和Ubuntu7.04 Feisty Fawn。此外我们还用runit替换了monit来负责管理所有的服务器进程,从而避免了由于非正常退出而留下PID文件、导致服务无法启动的问题。monit仍然可以提供监控服务器进程的功能。

    我们还全面重写了文档。Alexey和我,两个“外国人”写出的文档,文采就不敢说了,但愿对用户有所帮助就行。

    下一步我们将支持x64架构的服务器,进一步加强安全性和可管理性,以及增加对Capistrano的支持。下一次的发布——如果一切顺利的话——应该在“敏捷中国”技术大会之前出来。


  5. (抄书)Erlang的接口库

    However, several libraries included in the Erlang distribution simplifythe job of interfacingErlang to external programs; these include the following:

    http://www.erlang.org/doc/pdf/erl_interface.pdf

    Erl interface (ei) is a set of C routines and macros for encoding and decoding the Erlang externalformat. On the Erlang side, an Erlang program uses term_to_binary to serialize an Erlang term, andon the C side the routines in ei can be used to unpack this binary. ei can also be used to constructa binary, which the Erlang side can unpack with binary_to_term.

    http://www.erlang.org/doc/pdf/ic.pdf

    The ErlangIDLCompiler (ic). The ic application is an Erlang implementation of anOMG IDLcomplier.

    http://www.erlang.org/doc/pdf/jinterface.pdf

    Jinteface is a set of tools for interfacing Java to Erlang. It provides a full mapping of Erlangtypes to Java objects, encoding and decoding Erlang terms, linking to Erlang processes, and so on,as well as a wide range of additional features.


  6. (抄书)Erlang如何使用外部程序

    Many programming languages allow code in foreign languages to be linked into the applicationexecutable. In Erlang, we don’t allow this for reasons of safety.1 If we were to link an externalprogram into the Erlang executable, then a mistake in the external program could easily crash theErlang system. For this reason, all foreign language code must be run outside the Erlang system inan external operating system process. The Erlang system and the external process communicate througha byte stream.


  7. 塑造敏捷企业:第二届“敏捷中国”技术大会

    软件项目需要敏捷,企业同样需要敏捷。一支敏捷的团队能够在项目中收获成功,而一家敏捷的企业能够在市场的风雨中屹立不倒。

    本次“敏捷中国”技术大会将会集中展现塑造敏捷企业所需的方方面面:业界领先的敏捷项目管理工具;极大提升软件开发效率的新语言和新框架;数据库领域的敏捷实践;全方位的敏捷项目管理指导;还有身临其境的亲身体验。来自开源社区和ThoughtWorks公司的技术领导者们将带领听众全面感受敏捷企业。

    塑造敏捷企业,就从第二届“敏捷中国”技术大会开始。

    • 时 间:2007年7月14日 星期六
    • 地 址:北京市海淀区知春路25号 北京丽亭华苑酒店(原天鸿科园) 鸿运厅
    • 联系方式

    .现在即可在线报名。流火七月,我们相约北京。


  8. Erlang继续学习中……

    Programming Erlang读到第9章,错误处理。把多个进程link起来,监控或者错误恢复或者后备。记得以前看到过一句很牛的话:Erlang is not reliable—Java is reliable,Erlang just rocks.

    不过疑问仍然存在:什么时候才需要这样“rocks”的进程管理能力?什么时候才需要如此清晰的进程建模?当然高性能服务器需要。但高性能服务器不是谁都会拿着玩玩的。Ruby onRails会走红,因为谁都可以拿它做个网站然后做创业梦。那么Erlang呢?它带来的联想是什么?


  9. Erlang Exercise- Ring Benchmark

    Ring benchmark:创建N个进程,把它们组合成环状;把一条消息在环上传递M圈,这样总共有N*M次消息传递。对于不同的N和M值,记录所需的时间。

    + erl -noshell -s ring benchmark 3000 1000 -s init stopBenchmark starting: ring with 3000 nodes, send message around 1000 timesBenchmark doneTime=750000 (827000) microseconds

    第二问:用你熟悉的其他语言编写类似的程序,比较结果。

    首先,0.8秒完成三百万次进程间消息传递,这足以说明问题。其次(也更重要的),我很怀疑自己是否能用别的语言写出同样功能的程序——Erlang的程序共计41行。


  10. Escript- Running Erlang As Scripts

    (以下摘抄自Programming Erlang第六章)

    Using escript you can run your programs directly as scripts—there’s no need to compile them first.

    Warning:escript is included in Erlang versionsR11B-4 and onward. If you havean earlier version of Erlang, then you should upgrade to the latestversion of Erlang.

    To run hello as an escript, we create the following file:

    #!/usr/bin/env escriptmain(_) -gt;nbsp;io:format(“Hello world\n” ).

    On a Unix system,we can run this immediately and without compilation as follows:

    $ chmod u+x hello$ ./helloHello world$