诗意代码 – PoemCode

These codes, As beautiful as poetry!

harvey

  • Android Application Framework Outside, Service Understanding : 1

    Android

    从2007年11月5日Google首次发布Android以来,这个绿色机器人 Open Source、体系架构卓越、应用开发便捷等亮点日益引起业界的浓厚兴趣,到目前为止陆续发布了1.1、1.5、1.6、2.0、2.1和2.2等版本,日趋完善的进取势头带动了移动互联网一股新的热潮。

    文档名 Android Framework Outside,原本是打算用Inside,但是由于Framework内容繁复,如果用Inside,未免显得自负,况且我也无法做到了如指掌、洞若观火,因此取名Outside,表示这只是一知半解。

    由于无法在短时间内面面俱到,目前优先选择其中的Service部分进行学习,整理成Service Understanding。但尽管Service只是Framework中一个组成部分,仍旧体积庞大,对其内容继续筛选后,选择WindowManagerService和ActivityManagerService进行重点研究。

    阅读全文 →

  • 读《Professional Assembly Language》之移位之谜

    Professional Assembly Language

    《Professional Assembly Language》在第八章第二节讲解了Shift Instruction,在谈到算数左移(SAL)和逻辑左移(SHL)时,作者列举了该指令的三种格式:

    1. sal destination
    2. sal %cl, destination
    3. sal shifter, destination

    其中,第三种格式表述存不清楚,shifter可以是immediate value?是common register?是memory location?下面先用shifter是memory location类型来做个试验。

    .section .data
    val:
            .int 0x1
    count:
            .int 0x21
    .section .text
    .global _start
    _start:
            nop
            sall count, val
            movl $1, %eax
            movl $0, %ebx
            int $0x80
    

    阅读全文 →

  • OS X Lion 接入802.1x

    Apple

    把OS X从Snow Leopard升级Lion,我遇到了两个问题,第一,摄像头找不到;第二,802.1x无线网络无法接入。第一个问题在Apple官方论坛里有用户在讨论(见《Camera not working with Lion》),通过重设SMC(见《Intel-based Macs: Resetting the System Management Controller (SMC)》)得以解决。

    第二个问题,不少用户认为Apple在Snow Leopard能做到的事情,到了Lion反而不能做,认为这是一种倒退。从我的使用经验来看,不能直接接入802.1x实在很有损用户体验。同样在官方论坛,有用户抱怨《802.1x add profile ?》,并且这种抱怨的声音在各个非官方Mac论坛里都能看到。

    阅读全文 →

  • 一波三折的PAC on Mac

    Apple

    由于众所周知的原因,看个facebook也得架个梯子。三年前使用tor,虽然慢,但终究是个不花钱的办法,哪知后来竟然也不能用了。所幸托管网站的服务器开放了ssh,于是采用ssh转发绕过GFW。

    起初我使用浏览器的插件来管理网站列表,但是从firefox到chrome,再到safari,插件虽好,但免不了每个浏览器都设置一番,耗时不说,最大的弊端是无法同步,不仅是浏览器之间,还有操作系统之间,–我要周转在Mac OS X (Lion),Debian (Squeeze),Windows (XP)之间。

    PAC,全称是Proxy Auto-Config,顾名思义是指代理自动配置,由网景公司在上个世纪提出,无法明白创建者们当时的动机,但肯定不是为了方便P民们翻墙的。这项陈旧的技术达成了我的目的,–把pac文件保存在了Google Code上,将URL设置到操作系统的代理配置里,这样同步问题迎刃而解。

    阅读全文 →

  • 读《Professional Assembly Language》之奇怪的if-then-else

    Professional Assembly Language

    在本书英文版第149、150页(中文版第117页),作者展示了一段稍复杂的C语言if语句,以及对应的汇编伪代码:

    Instead of a single conditional jump instruction, there may be several, with each one evaluating a separate part of the if condition. For example, the C language if statment

    if (eax < ebx) || (eax == ecx) then
    

    create the following assembly language code:

    if:
        cmpl %eax, %ebx
        jle else
        cmpl %eax, %ecx
        jne else
    then:
        
        jmp end
    else:
          
    end:
    

    This If statement condition required two separate CMP instructions. Because the logical operator is and OR, if either CMP instruction evaluates to true, the program jumps to the else label.

    阅读全文 →