Category: 未分类

  • 祸兮,福之所倚

    一周前,我的校友信箱被发垃圾邮件的盯上了,发得那个疯狂,过了一天,系统就发出警告信,说容量超过警戒线了。毕竟校友信箱不是Gmail。

    我一直是将其中的信件自动转发到Gmail中的,已经好久没登录过了。这一警告,赶紧去邮箱里删信,删完了发现还有许多空间被使用,就到发件箱去看。意外收获,大三时图像处理的作业乖乖地躺在那里呢!其时我正在被一门选修课的作业所困扰。把它放到Linux里,touch一下再拿回来,写个报告交上去,完事了。

    多么宝贵的人生经验,平凡的生活中蕴含着这么深奥的哲理。

    Update: 发现里面还有详尽的文档,但遗憾的是当时不知道为什么转成了PDF还加了密。。。不过省得动脑筋了,打字还是很快的。

  • IE float元素的一个恶心Bug

    这种问题不好Google,也许已经有许多人知道怎么解决了,不过我没有搜索到,为解决这问题,加起来花了应该有半天时间。我大致知道了一个重现的过程。

    在一个比较窄的元素中,我想把几个词排成两列。用如下的代码(容器宽度是在外面的元素限制的):


    <div style="width:250px">
    <div style="border:1px solid #0066CC;padding:10px;font-size:14px;text-align:left;">
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="clear:both"></div>
    </div>
    </div>

    但效果是这样:

    Test
    Test
    Test
    Test
    Test
    Test
    Test
    Test

    显然我想边框把这几个条目全部包起来(而且行间距也不应该那么大!)。最初的时候这几个词是相等字数即等宽的,于是我把”Test”的float属性去掉,加上display:inline。这时,宽度就无效了,但因为字符串等长,我就给它加了固定的margin,可以实现两列了,而且IE的border也把它们都包起来了。

    不过最近需求变了,这几个词的长度不等了,用display:inline再加margin的办法不行了。该面对的问题还是要面对,尽管IE很垃圾,用它的人还是太多。仔细看上面代码显示的效果,IE似乎是认为那个框里只有三行(在我的应用里,它是认为只有一行),显然是处理float的高度有问题。知道这点后,我就在那些float元素的前面加了一个空的div,NND,这就没事了。

    代码:


    <div style="width:250px">
    <div style="border:1px solid #0066CC;padding:10px;font-size:14px;text-align:left;">
    <div></div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="margin-left:10px;float:left;width:100px">Test</div>
    <div style="clear:both"></div>
    </div>
    </div>

    效果:

    Test
    Test
    Test
    Test
    Test
    Test
    Test
    Test

  • request.getParameter返回null

    用GET方法传递过去的参数,在某些情况下用request.getParameter只能取得null,而apache确实得到了完整的URL,且Debug时URL也是完整的,就是取不出来。

    参数是一大段文字,其中可能有中文,我在客户端是用Javascript编码过的,为了避免URL过长,截断过,在以前的PHP里用得很好,就是偶尔会把一个中文字的编码给切断,造成末尾乱码,但影响不大。这次出了这个问题,我一直怀疑是不是Tomcat不能接受这么长的URL,或者是struts/JSP. 结果找到最后,发现就是编码不完整的问题。

    在request.getParameter这个调用里,会对percent encode过的参数值进行解码,但解码时遇到不正确的码就会返回null. 这不正确的码就是我截断的。

    以前编码是把所有的文字编码,组成URL后截断长度到6000。于是改了一下编码的策略,每100个字符作为一个块编码一次,直到字符串结束或剩下的空间不能容纳一个块为止。目前看来,这是一个好办法。

  • bbPress做菜单

    在公司用bbPress架了个小论坛,交流经验、灌水,一个主要的功能是点菜。

    这个版面每天一个sticky主题,吃饭时间大家都把自己要点的东西作为回复发上去,专人统计好后打电话点。

    前些天都是把各家的菜单置顶,但仍然很不方便,每次发贴都得看着其它的页面点。今天花了一点时间,把菜单做到了这个版面的发贴框下面,而且点击一样饭菜时它就会自动加入输入框,舒服多了。

    如果再把每次点的菜加入tag列表,那么就可以利用bbPress的Tag系统统计各样菜的popularity了。可惜我0.81的版本还不支持中文Tag,据说是支持的。。。可以想见,首页的tag cloud将会变成一个menu cloud. menu cloud? 将来开饭馆一定要做一个:) 这样服务员就不用给人介绍哪个菜卖得最好了。

    做一个简单的点菜系统也不难,不过在论坛上点菜更有乐趣。今天就有人滥用key master职能,改了好多人点的菜,哈哈。

  • 奇怪的错误

    刚才调试一个日记页面时,突然看见tomcat打出的异常,整页的stacktrace,吓了一跳。仔细看,跟这个页面一点关系都没有。

    后来老大过来看,原来是他刚才把一个出错页面信息保存下来记到日记里了。。。

    愚人节还有一件趣事,有时间再记。

  • 精彩评论

    Quoted from IEBlog:

    http://blogs.msdn.com/ie/archive/2006/11/30/ie6-and-ie7-running-on-a-single-
    machine.aspx#1186820

    This “solution” shows the utter lack of talent at Microsoft. An application
    shouldn’t be so ingrained into an operating system that an entire virtual
    environment is needed to use different versions. I used to believe it was a
    pain testing web applications for quirks in IE6, Mozilla, Opera, Safari, etc,
    but now, thanks to the dolts at MS, I have to run a virtual environment in
    addition to my normal rounds of testing, and I guess I can forget about
    supporting IE6 users after April 1st. Because the Software Engineers at
    Microsoft are clearly lacking in their ability to produce a well written
    operating system, I’ve provided a diagram below to prevent mistakes like this
    from happening again, courtesy of my undergraduate OS class:

    The right way to write an operating system:

    [hardware]

    [kernel]

    [applications]

    Notice how the applications sit entirely on their own level. Ingenuous!

    The wrong way to write an operating system:

    [hardware]

    [kernel+GUI+Browser+Mr.Clippy+…]

    [3rd party applications]

    Notice how the applications, like Internet Explorer, are integrated with the
    OS. While this may be good for protecting monopolies, it’s bad for every one
    of your users. So please avoid it in the future!

    • One unhappy customer

    http://blogs.msdn.com/ie/archive/2006/11/30/ie6-and-ie7-running-on-a-single-
    machine.aspx#1186839

    Damn, i see so many “well” trained people here. You call yourselves
    developers ? You are coding machines, have you ever developed something real
    in your life? Something that works on every noticeable browser at least on the
    market ? MS did a good think for themselves to keep you locked in in IE, but
    you see how many problems it created? I lay my hat down for IE, at the
    beginning of its age, it was a tool FOR developers, a tool that because of
    ignorance to the new wave of web features or because of too much bugfixes
    suddenly transformed itself in tool against developers, and i actually mean
    AGAINST(<– font-weight:bold;font-size:8em;) developers, or at least good
    ones, that are preocupied to run their software for all of their clients. You
    people at MS, at least the ones that are developing IE, should make a
    partnership or quit doing browsers, give support to Mozilla or Opera to create
    a damn standards friendly browser. And create something like Apollo from Adobe
    for your own platform taste. IE is now a mess, progress has been made with IE7
    but it is far from being or at least trying to be as standards friendly as FF
    or Opera or Safari. You could even start concentrating on doing good, quality
    software as a plugin for FF (like .net integration). Active-X is a mess. No
    serious company still sees it as a common choice over java(if you want low
    level stuff, not possible with flash). You have lost the plugin war, and the
    browser war is still won by you, but only by inertia. I repeat it again, i bet
    you have great programmers there, but because you are a company “for the
    money”, they will always have pressure on them from above and never finish a
    good quality product, they will always have to switch focus on something else
    than browsers.Dont tell me that your browser team, in 7 years has developed
    only and only IE7. The so crazy “developers, developers” is something like a
    Jabba roar when i kill my mind hacking IE to make my client or my boss happy.
    And this thing of not being possible to run two versions of IE on the same
    machine is quite a blow. IE is only damn renderer, and i bet the part that
    breaks is the one that made windows so integrable with it. You’ve got sued for
    this, and you also got sued for the Eolas issue.And even your own plugin
    architecture got broken.We have to rely on crazy JS hacks to insert a
    MediaPlayer plugin, not making our content possilbe to multiple devices, or
    having to overwork to avoid this. Problems that the Opensource Mozilla Gecko
    engine will never have. I finish my rant here, but probably Adobe’s Apolo will
    be the wave of the future with Internet Applications, or might that be
    ExpresionSuite with .net ? Or the browser will maintain forever its might.

    http://blogs.msdn.com/ie/archive/2006/11/30/ie6-and-ie7-running-on-a-single-
    machine.aspx#1187334

    Its funny I was just thinking about how messed up Windows had done things
    and how simple the logic would be. If it where me developing an OS (Which I
    realize is a lot of work) that I wouldnt want anyone being able to mess around
    with the core of the OS itself and that to create a folder like the windows
    folder that is not writable to period and have another folder for all 3rd
    party applications including there own so that the end user would have full
    control but not have to worry about any program / user from removing files
    that make the os work. you could have a layer overtop of the core os that
    could be modified to look like it was modified but not actually changing it so
    if you didnt want it you could remove it. Another method of working with IE 6
    and IE 7 that no one has mentioned is to have access to another pc and using
    vnc or something of the like, thats what I do for all my web dev. For app dev
    I use vmware cause I dont want to blow up my os lol (again because its so
    unstable) I think developers should just say to hell with older browser
    versions and force an update lol 🙂 if all websites wouldnt work with IE6
    people would have to upgrade. Yes I realize there are cases where you cant
    upgrade but still (thats no excuse)

  • IE,无比垃圾

    对于开发者来说,使自己的界面在IE下显示正常,需要花费数倍于在Firefox中下的功夫。

    人们可以为Firefox开发出Firebug这样强大的东西,而IE的开发者们自己也仅仅只能做出一个跟Firebug比起来基本上没用的toolbar.

    时无英雄,竟使竖子称雄!希望IE早日安息。

  • 动物园

    前天下午去的。

    1. 熊猫,这只很活跃,跑到玻璃前面好奇地看着外面的人们(所有图片):

    熊猫

    下面两个视频是它在玩一根竹子,这叫竹马。还有一个好玩的视频,相机上正常,电脑上看很暗。

    1. 熊喝奶,没有一点威风。我建议抓住那些投食的,重罚,或者扔下去喂熊,提高中华民族种群素质,为中华民族伟大复兴做贡献。

    棕熊

    1. 这只巨大的猫:

    巨大的猫,注意耳朵上的毛

    1. 这鸟肯定是不死族的,注意左边那只的眼神。它拧着脖子到那样的角度不是看天,是看我!

    undead

  • 自然规律

    上次LMS就提醒我要小心,这次果然最先出局了。看来已经形成自然规律了,以后一定要注意,差不多就可以了,千万不做赢家。

    2007-3-16 Texas Hold'em

    哪个比较空,被别人的钱占满了的地方就曾经是我的阵地。

  • 办公室

    我的角落:

    我的小角落

    健身球,这个比较小,今天又买来一个大的,很爽

    健身球