晓斌's profile黄晓斌的个人空间BlogLists Tools Help

Blog


    May 08

    欢迎大家通过sabifoo了解我的近况

    MSN Spaces 太慢了, 所以我的一些简短随笔会放在Sabifoo上, 欢迎大家访问.
     
    可惜的是, Sabifoo还不支持留言。
     
    这里会放一些比较长的, Sabifoo放不下的东西。
     
    April 26

    Muttrc, 对付gb.*, utf-8

    mutt? 对付恼火的gb*以及utf-8。

    我的locale:
    LANG=en_US.UTF-8
    LC_CTYPE=zh_CN.UTF-8

    在muttrc中写上:
    charset-hook !(gb.*|utf-8) gb2312 #所有非gb.*标记和非utf-8标记的都当作gb2312
    iconv-hook gb.* utf-8 #再把gb2312转为utf-8

    set locale="zh_CN.UTF-8"
    set send_charset="us-ascii:iso-8859-1:gb2312:utf-8"
    set charset="utf-8"

    前两行是重点...
    如果直接当作utf-8来处理的话,由于编码不同,导致什么都显示不出来...


    April 22

    xfce4 比较像那么回事~

    xfce4众多desktop environment中比较清爽的一个~
    现在我的X中,又多了个xfce4。

    ion3, fvwm, xfce4换着用...
    March 23

    申请到了Google Page Creator

    终于在两个星期后,获得了Google Page Creator的试用许可.
     
     
     
    March 20

    -_-!

    int b,o,_,d;
    b^o^_,_ == -_-b;
    -_-!b ? b+_+d : o^o^o;

    迅雷打算进入Linux平台了

    迅雷招聘广告上看来如此。
     
    迅雷这一套下载系统(所以为系统,因其并不只是下载),点子并不怎么新颖,但是它的确把这个点子做得非常好。
     
    我常用的downloador是小锁myget,最近使用firefox 1.5以后,用的就是firefox的扩展DownloadThem All!
     
    技术特点
    迅雷使用的多资源超线程技术基于网格原理,能够将网络上存在的服务器和计算机资源进行有效的整合,构成独特的迅雷网络,通过迅雷网络各种数据文件能够以最快的速度进行传递。
    多资源超线程技术还具有互联网下载负载均衡功能,在不降低用户体验的前提下,迅雷网络可以对服务器资源进行均衡,有效降低了服务器负载。

    有关CVS的第三方代码追踪

    对于第三方代码,我以前的习惯是,使用本地仓库的main trunk来追踪,而使用vendor branch来开发自己的patch版本。
    昨天阅读了Hellwolf的《实践CVS和Subversion ...》(未完成),他使用vendor branch来进行追踪,而主干用来开发自己的版本。
    仔细想了一下这两种管理方案,对比之下,我觉得hw叙述的方案更加适合。其中最大的好处是: checkout的时候不用使用-r来stick branch tag,trunk的HEAD即是最新修改的代码。
     
    hw现在正在写svn的部分,加油吧!
     

    非常棒的Ion3

    我会因新加入的mod_sp感谢Ion3的作者,它非常完美的让Ion3拥有了一个QuakeConsole,不用我自己动手动脚了。

    一直很欣赏fvwm-crystal的QuakeConsole,想在Ion3下面用脚本实现一个,未果。这次Ion3-20060305-r1,让我十足爽了一把,mod_sp,status_bar的新style,快速的query……

    ps. Ion3Fvwm是我最喜欢的wm。Ion3的简洁,Fvwm随意,正符合我的胃口。
    March 18

    Unicode Mutt

    参照Unicode Mutt将Mutt安装至系统。
    查看html,w3m在Unicode的支持上做得不错(lynx我总没有办法让它显示正确),下载,编译并安装至系统。
    编辑~/.mailcap文件,加入,或者修改text/html一行为:
    text/html; w3m -dump %s; needsterminal; copiousoutput; nametemplate=%s.html
    当然,也可以用任何浏览器打开。

    编辑.muttrc
    加入,或修改charset为:
    set charset="utf-8"

    现在mutt可以非常漂亮的工作了。


    March 15

    Evaluate Order

    在[SICP 1.3]中有如下的规则:

    To evaluate a combination, do the following:
    1.  Evaluate the subexpressions of the combination.
    2.  Apply the procedure that is the value of the leftmost subexpression (the operator) to the arguments that are the values of the other subexpressions (the operands).

    在[R5RS 4.1.3]中说明,Scheme对组合式的求值强调的是未定义的顺序,并且以任何顺序,或者并发执行的结果,与某一特定顺序求值的结果是一样的。

    是否我对[SICP]中,首先求值operator,然后是其他的以任意顺序求值operands的规则理解错了,有待考证。

    About the Sugar

    Syntactic sugar causes cancer of the semicolon.
    --Alan Perlis
    在Lua中,可以找到
    t = {}
    t.f = function(self, params, ...) ... end
    通过语法上的甜头可以写为
    function t:f(params, ...)
    ...
    end
    拥有默认的self参数,作为t的一个引用.
    那么对于t.f的调用
    在使用者看来,就有两种
    t:f(params,...)
    t.f(t, params,...)
    如果没有清楚的文档,不敢保证用户会按照你想的方式来调用。

    自[SICP, footnote.11]:
    语法上的甜头(syntactic sugar)只不过为那些完全可以使用统一形式表述的语法增加另一种表现形式而已。

    如果一个语言的语法上的甜头过多,程序员使用过滥的话,只会白白的增加代码的复杂性而已。
    如上面的Lua代码,使用``:''省略掉一个self参数,如果不写明t是一个对象,或者不指出t.f应该使用t:f进行调用,在不参考代码的情况下,虽然Lua的track back infomation会指出试图引用一个nil元素,也难保不会杀死用户的脑细胞。

    Lisp,hmm,是藐视语法的;^)
    March 03

    Mechanisms of Languages

    [SICP]
    Every powerful language has three mechanisms for accomplishing this:

    • primitive expressions, which represent the simplest entities the language is concerned with,

    • means of combination, by which compound elements are built from simpler ones, and

    • means of abstraction, by which compound elements can be named and manipulated as units.
    February 28

    LUA: Incompatibilities with the Previous Version

    [refman-5.1]

    Here we list the incompatibilities that may be found when moving a program from Lua 5.0 to Lua 5.1. You can avoid most of the incompatibilities compiling Lua with appropriate options (see file luaconf.h). However, all these compatibility options will be removed in the next version of Lua.

    Incompatibilities with version 5.0M

    Changes in the Language

    The vararg system changed from the pseudo-argument arg with a table with the extra arguments to the vararg expression. (Option LUA_COMPAT_VARARG in luaconf.h.)
    There was a subtle change in the scope of the implicit variables of the for statement and for the repeat statement.
    The long string/long comment syntax ([[...]]) does not allow nesting. You can use the new syntax ([=[...]=]) in these cases. (Option LUA_COMPAT_LSTR in luaconf.h.)

    Changes in the Libraries

    Function string.gfind was renamed string.gmatch. (Option LUA_COMPAT_GFIND)
    When string.gsub is called with a function as its third argument, whenever this function returns nil or false the replacement string is the whole match, instead of the empty string.
    Function table.setn was deprecated. Function table.getn corresponds to the new length operator (#); use the operator instead of the function. (Option LUA_COMPAT_GETN)
    Function loadlib was renamed package.loadlib. (Option LUA_COMPAT_LOADLIB)
    Function math.mod was renamed math.fmod. (Option LUA_COMPAT_MOD)
    Functions table.foreach and table.foreachi are deprecated. You can use a for loop with pairs or ipairs instead.
    There were substantial changes in function require due to the new module system. However, the new behavior is mostly compatible with the old, but require gets the path from package.path instead of from LUA_PATH.
    Function collectgarbage has different arguments. Function gcinfo is deprecated; use collectgarbage("count") instead.

    hanges in the API

    The luaopen_* functions (to open libraries) cannot be called directly, like a regular C function. They must be called through Lua, like a Lua function.
    Function lua_open was replaced by lua_newstate to allow the user to set a memory allocation function. You can use luaL_newstate from the standard library to create a state with a standard allocation function (based on realloc).
    Functions luaL_getn and luaL_setn (from the auxiliary library) are deprecated. Use lua_objlen instead of luaL_getn and nothing instead of luaL_setn.
    Function luaL_openlib was replaced by luaL_register.

    基本上看完了refman,不过没发现令人激动的序列化相关的lib或者package(除了chunk外),要序列化一个table,还得自己一个一个的来.上lua-users.org看看,或许会发现一些power patch.

    February 27

    又多了两只仓鼠

    家里又多了两个成员,三线仓鼠 QQ 和 CC
    QQ是肥得像个皮球的GG,CC是只精力旺盛的MM~~ 还好,蛋蛋看着他们不叫唤~好象还挺喜欢这两个小老鼠的。。 再多只猫,《猫和老鼠》演员就凑齐了 ps.蛋蛋是只小巴哥
    February 24

    狗狗的食谱

    这里,我把文章重新整理了,吸取上次的经验,重新做了一次,并加了照片,希望比前面的更好
    一、自己做狗粮的目的:
     1、放心:养狗两年多,买过很多狗粮,也看了很多文章、听了不少评论,有褒有贬;但说实话,我对那包装精美的狗粮是越来越不放心,说明书上说得很悬乎,谁知道那些黑糊糊的颗粒里面究竟包含些什么成分;但我自己做的“狗粮”绝对没有加入任何所谓的“副产品”、玉米麸;保证所有原料狗能吃人也能吃。  
       2、经济:目前市场上的高价“优质”狗粮并不是我们每一个养狗人都能承受得起的;但即便是几百元一包的原装进口狗粮也不见得物有所值,如价格中等的美国原装进口的ANF优质狗粮18KG一包500元,相当于14元一市斤(而且含10%的水份),其主要原料是“鸡肉副产品”(鸡肉副产品的含义我不多解释了,大家应该都知道),想想也是,大老远从美国运来,要经过多少中间环节的抽成?到了我们GG这里还有什么好东西可吃啊。花了大钱,却害了我们心爱的GG。我自己做的狗粮,价格是买来的中等狗粮价格的一半。
     3、品质:我相信,经过不断实践,我的“家产牌”的品质,一定能赶上顶级的“雪山牌”;而且我的狗粮新鲜,没有任何防腐剂和抗氧化剂。
    二、制作过程:
     1、原料采集:
            选料原则:**无玉米、大豆、小麦、鸡蛋、乳制品或葵花籽油**
    这些成份怀疑系引起敏感反应的成因,如脱毛、搔痒、荨麻疹、咬尾、不停咬脚、耳朵感染,所以不会使用。(引自"雪山特级全犬配方"的理论)
            途径:超市方便,但比较贵;菜场更便宜。以下是超市的价格
       品名        数  量        价  格
     脱皮羊后腿肉       3kg         30元
      牛胸肉        0.6kg                              12元
      猪肋排        0.5kg                               10元
      小米         1.5kg         5元
      胡萝卜        3根           0.5元
      卷心菜        半个           1元
      蒜头、紫菜      少许           1元
      大豆卵磷脂      若干           3元
      钙磷粉        若干           5元
      合计         6kg           68元
      平均10元左右1kg,而且没有加水

    脱皮羊后腿肉

    牛胸肉

    猪肋排

    小米饭

    胡萝卜

    卷心菜

    蒜头、紫菜、维生素

    钙磷粉

    大豆卵磷脂
     2、制作流程:  
      工具:高压锅
      先用高压锅单独把小米煮成小米饭,放一边待用(因为小米容易糊)
      其余原料视高压锅的大小分一锅或者若干锅煮:卷心菜切碎;为方便去骨,肋排整根下锅,所有东西加水和少许植物油用高压锅煮烂,标准:胡萝卜、肉用筷子一夹就烂,骨肉自然分离,可轻松把骨头拿掉。煮的时候满屋牛羊肉的香味,自己都忍不住想吃
      去除骨头后(说GG不吸收骨头里的钙,故弃之),将锅里的东西捣烂,与小米饭充分混合再加火煮(不用高压锅)一会儿,注意不要烧糊。出锅冷却装盆放入冰箱保存。
      用的时候取二分之一自制狗粮,四分只一米饭,四分之一的买来的狗粮(考虑到一些其他元素的补充,目前自制狗粮尚无添加其他微量成分,为保险起见,适当用些外购犬粮),混合,煮熟(幼犬可加些IN和发育宝),盛盆,放凉,于是,一碗胡萝卜瘦肉粥成也;这时GG早已经等不及了,于是乎,风卷残云,吃个盆底朝天。
     3、效果:
      我们家拉拉吃了后,大便数量明显比吃狗粮的时候少,质量也好,而且没有以前那么臭。


     
     本狗粮特点:营养丰富,美味可口,经济实惠(不含水相当于5元一斤),GG开心,我也开心

    Lua 5.1

    目前看到的,比较醒目的变化是require, module 函数和 package library,比以前的LUA_PATH清爽多了。
     
    另外,API 和 AuxLib 现在给人的感觉比较清爽,某些kernel api可能会被取消或者转入AuxLib。table.foreach(i)也成了deprecated function。
     
    让人费解的是 operator #
    "len": the # operation.
     function len_event (op)
       if type(op) == "string" then
         return strlen(op)         -- primitive string length
       elseif type(op) == "table" then
         return #op                -- primitive table length
       else
         local h = metatable(op).__len
         if h then
           -- call the handler with the operand
           return h(op)
         else  -- no handler available: default behavior
           error("...")
         end
       end
     end
    不过当看了:
    [5.0.2 refman] Every table and userdata object in Lua may have a metatable.
    [5.1 refman] Every value in Lua may have a metatable.
    就明白了~~
     
    这点算是比较大的变化吧
     
    还有,改变非table的metatable时应该:
    [5.1 refman] You can replace the metatable of tables through the setmetatable function. You cannot change the metatable of other types from Lua (except using the debug library); you must use the C API for that.
     
     
    February 23

    Lua二三事

    一、Lua 5.1 发布了,文档还没有仔细读,看ChangeLog,似乎增加了一些东西
    二、在对Lua element 做 clone 操作时发现:
     
    1.         lua_State* L1 = lua_open();
    2.         lua_State* L2 = lua_open();
    3.        
    4.         lua_pushstring(L1, "test_key");
    5.         lua_newtable(L1);
    6.         lua_pushvalue(L1, -2);
    7.         lua_pushnumber(L1, 10);
    8.         lua_settable(L1, -3);
    9.  
    10.         lua_pushstring(L1, "the_table");
    11.         lua_pushvalue(L1, -2);
    12.         lua_settable(L1, LUA_GLOBALSINDEX);
    13.  
    14.         lua_xmove(L1, L2, 2);
    15.  
    16.         std::cout << lua_typename(L2, lua_type(L2,-2)) << std::endl;
    17.         std::cout << lua_typename(L2, lua_type(L2,-1)) << std::endl;
    18.        
    19.         lua_insert(L2, -2);
    20.         lua_pushstring(L2, "test string");
    21.         lua_settable(L2, -3);
    22.  
    23.         lua_pushstring(L1, "the_table");
    24.         lua_gettable(L1, LUA_GLOBALSINDEX);
    25.         lua_pushstring(L1, "test_key");
    26.         lua_gettable(L1, -2);
    27.  
    28.         std::cout << lua_typename(L1, lua_type(L1,-1)) << std::endl;
    29.         std::cout << lua_tostring(L1, -1) << std::endl;

     

    看来, lua_State只是一个堆栈, 虚拟机还隐藏在背后.

    所有的lua element都携带有虚拟机信息, 跟使用的stack无关.

    xmove也只是copy了ref到新的stack, 并没有复制对象.

     

    如果在20行处,重新lua_pushstring(L2, "test_key")当作key, 这时候key携带的是L2的信息, 对表操作时,将会得到与之关联的nil, 而不是L1中所关联的值.

     

    现在问题变成了,如何简便地复制一个Lua对象.

    在Lua中只有'= 文字量', '{}' (表构造)能创建对象实例, 此外其他的, 都是ref

    February 19

    Python newbie

    开始了解Python

    单从Python tut和Dive into Python来看,跟Lua(由于我是先接触Lua)有很大的相似之处。
    比如closures,对象(如果称Lua的table为类,使用creator返回的table为对象的话)的观点,还有coroutine的 yeild等等。

    def foo():
      x = ...
      def y():
        return x
      return y
    或者
    def foo():
      x = ...
      return lambda : x

    function foo()
       x = ...
       return function() return x end
    end
    January 24

    Man who Sold the World

    -- 不哭的BLOG上贴着这首老歌


    We passed upon the stair,
    we spoke of was and when
    Although I wasn't there,
    he said I was his friend
    Which came as some surprise
    I spoke into his eyes
    I thought you died alone,
    a long long time ago
    Oh no, not me
    We never lost control
    You're face to face
    With The Man Who Sold The World
    I laughed and shook his hand,
    and made my way back home
    I searched for form and land,
    for years and years I roamed
    I gazed a gazley stare
    at all the millions here
    We must have died along,
    a long long time ago
    Who knows? not me
    I never lost control
    You're face to face
    With The Man Who Sold The World
    Who knows? not me
    We never lost control
    You're face to face
    With the Man who Sold the World

    厌烦了Makefile

    写了许久的Makefile,终于厌烦了
    终于通读了一遍info autoconf 和 info automake
    然而又陷入另一个漩涡...

    不过比起M$的那套IDE,AutoTools还是可爱许多。

    M$似乎不知道programmmmmers的需要,以为programer只会点点鼠标,做几个宏,写几个assist。或者,是我太笨不会用的原因。

    M$总是将简单的事情变复杂,复杂的事情变繁琐。(结论自 `Linux is NOT Windoz', 以及我的眼睛和手指头)

    谁来教我用一下VS200x!为自己的代码们贴上.vcproj的标签,耗费了很多精力阿--;

    此外,VS assist,这个东西,不得不特别点名表扬一下,当然,是作为代码粉碎软件。