跳至主要内容

博文

目前显示的是 五月, 2008的博文

关于代码缩进的思考

在 PEP8 读到了关于代码缩进的指导建议: Code lay-out Indentation Use 4 spaces per indentation level. For really old code that you don't want to mess up, you can continue to use 8-space tabs. Tabs or Spaces? Never mix tabs and spaces. The most popular way of indenting Python is with spaces only. The second-most popular way is with tabs only. Code indented with a mixture of tabs and spaces should be converted to using spaces exclusively. When invoking the Python command line interpreter with the -t option, it issues warnings about code that illegally mixes tabs and spaces. When using -tt these warnings become errors. These options are highly recommended! For new projects, spaces-only are strongly recommended over tabs. Most editors have features that make this easy to do. 在此之前我也仔细考虑过缩进应该使用哪个比较好——tab vs. white space.最终我觉得使用tab比较适合我,主要是基于以下几点考虑: 在行首的所有缩进都是用tab,在行内和行末只适用white space,这样无论代码使用哪一种IDE或是editor打开,无论设置的tab width是4或是8或是其他什么奇怪的数,每一行的缩进关系都可以正确的显示出来,差别只是宽度而已,不影响可读性。 我使...

Fixed width within display:inline

根据老板的需求修改web page中的footer的时候发现了<span>的宽度有问题,HTML的结构大致如下: <div style="margin: 0pt 260px; width: 380px;">     <span class="footTag">About</span>     <span class="footTag">Partners</span>     <span class="footTag">Advertise</span> </div> <div style="margin: 6px 0pt; clear: left;">   © 2008 Company-Name </div> 其中样式footTag指定了width,但是尝试了很久发现span的宽度无论如何也不能按照CSS的定义显示…… 但是如果换成DIV或是用 display: block 就可以。在Google了不少keyword之后终于发现了一篇 相关的解释 。到W3C的CSS 2.1规范里具体找了一下,果然发现: 10.3.1 Inline, non-replaced elements The 'width' property does not apply. A computed value of 'auto' for 'left' , 'right' , 'margin-left' or 'margin-right' becomes a used value of '0'. 有空一定要仔细看看规范~做WEB开发的至少先将CSS、JavaScript和DOM混个脸熟,然后再研究不同browser的特性。

Ubuntu下的nvidia硬件加速

在老PC里装上Ubuntu 7.10已经有一段日子了,平时上班主要用ACER的laptop,回家有时候开着PC下aMule或是Azureus。本来也曾经试着用PC来看片,可惜有时候CPU占用率偏高,遇到解码率较高的片子,如HD的片子就会卡…… 今晚在google是否有linux的土豆加速器版本,无意中看见了一个安装nvidia驱动的帖子——打开菜单『系统』|『系统管理』|『受限驱动管理器』,启用nvidia驱动程序即可。打开了nvidia驱动之后的视频果然强悍了不少:Firefox里头的控件多了shade;Flash看土豆的CPU使用率降低了不少;整个desktop的view变得更细致了,估计是抗锯齿打开了的好处。 看来以后买硬件还是大牌比较好,至少linux下面驱动的支持找得到~