Search

11/18/2006

Using DOM Scripting to Plug the Holes in CSS

Using DOM Scripting to Plug the Holes in CSS

HTML: Structure
CSS: Presentation
DOM Scripting: Behaviour


document.getElementsByClassName = function(name) {
var results = new Array();
var elems = document.getElementsByTagName("*");
for (var i=0; i<elems.length; i++) {
if (elems[i].className.indexOf(name) != -1) {
results[results.length] = elems[i];
}
}
return results;
};

function stripeLists() {
var lists = document.getElementsByTagName("ol");
for (var i=0; i<lists.length; i++) {
if (lists[i].className.match("striped")) {
var items = lists[i].getElementsByTagName("li");
for (var j=0; j<items.length; j=j+2) {
addClass(items[j],"odd");
}
}
}
}

tr:nth-child(2n+1) 
/* represents every odd row of an HTML table */
tr:nth-child(odd) /* same */
tr:nth-child(2n) /* represents every even row of an HTML table */
tr:nth-child(even) /* same */

本週閱讀2006.11.08-2006.11.15

“书记员”──穷人的TextMate?
免费的 Windows Vista 桌面背景
What causes the noise when you crack a joint?

11/13/2006

Java Is Free

Java Is Free

Unmodified GPL2 for our SE, ME, and EE code. GPL2 + Classpath exception for the SE libraries. Javac and HotSpot and JavaHelp code drops today. The libraries to follow, with pain expected fighting through the encumbrances. Governance TBD, but external committers are a design goal. No short-term changes in the TCK or JCP. There are a ton of presentations and an (excellent) FAQ and so on, all to show up at sun.com/opensource/java sometime in the next few hours. I wanted to add a couple of remarks on areas that stuff doesn’t highlight.

Dojo Charting Engine Released

Dojo Charting Engine Released

11/08/2006

Comet: Low Latency Data for the Browser

比較有印象的例子就是整合在Gamil裡面的Gtalk,看起來很不錯阿。

本週閱讀2006.11.08-2006.11.15

Scott Meyers - The Most Important C++

駭客與畫家 Hackers & Painters Big Ideas from the Computer Age

  • 作者的Paul Graham的home page
  • Paul Graham - Wikipedia, the free encyclopedia
  • 作者的著作: ANSI Common Lisp
  • Ch06. How to Make Wealth
  • Ch11. The Hundred-Year Language - 駭客與畫家第11章 - 百年語言。
  • Ch13. Revenge of the nerds - 駭客與畫家第13章 - 書呆的復仇。
    "We were after the C++ programmers. We managed to drag a lot of them about halfway to Lisp."
    - Guy Steele, co-author of the Java spec

  • Functional VS Imperative (未完)
  • 说说动态语言
  • 动态语言,别再说不
  • 漫談 lisp、scheme、ML
    嘻嘻,有一個LISP的笑話:某人自稱hack進了NASA的AI Lab,偷盜了不少程式。
    為了證明,它列出某個LISP程式的最後一頁:
    ......))))))))))))))))))))))))))))))))
    )))))))))))))))))))))
    一整頁的右括號。:)

  • Type system - Wikipedia, the free encyclopedia

    var x = 5;     // (1)
    var y = "hi"; // (2)
    var z = x + y; // (3)

    • In this code fragment, (1) binds the value 5 to x; (2) binds the value "hi" to y; and (3) attempts to add x to y. In a dynamically typed language, the value bound to x might be a pair (integer, 5), and the value bound to y might be a pair (string, "hi"). When the program attempts to execute line 3, the language implementation checks the type tags integer and string, and if the operation + (addition) is not defined over these two types it signals an error.
    • In dynamic typing, type checking often takes place at runtime because variables can acquire different types depending on the execution path.
    • C static weak unsafe nominative


  • Greenspun's Tenth Rule - Wikipedia, the free encyclopedia
    Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp.

  • Occam's razor - Wikipedia, the free encyclopedia
    All things being equal, the simplest solution tends to be the best one.

  • ANSI Common Lisp Ch2 - Welcome to Lisp

    When we evaluate a pure Lisp expression like (+ 1 2), there are no side-effects; it just returns a value. But when we call format, as well as returning a value, it prints something. That's one kind of side-effect.

    Functional programming means writing programs that work by returning values, instead of by modifying things. It is the dominant paradigm in Lisp. Most built-in Lisp functions are meant to be called for the values they return, not for side-effects.

    Just as we can use ' as an abbreviation for quote, we can use \#'
    as an abbreviation for function.

    The defun macro creates a function and gives it a name. But
    functions don't have to have names, and we don't need defun to
    define them. Like most other kinds of Lisp objects, we can refer
    to functions literally.

    To refer literally to an integer, we use a series of digits; to
    refer literally to a function, we use what's called a lambda
    expression. A lambda expression is a list containing the symbol
    lambda, followed by a list of parameters, followed by a body of
    zero or more expressions.

  • Common Lisp - Wikipedia, the free encyclopedia

    (sort (list 5 2 6 3 1 4) #'>)
    ; Sorts the list using the > function as the comparison operator.
    ; Returns (6 5 4 3 2 1).

    (sort (list '(9 a) '(3 b) '(4 c))
    #'(lambda (x y) (< (car x) (car y))))
    ; Sorts the list according to the first element (car) of each sub-list.
    ; Returns ((3 b) (4 c) (9 a)).


Articles from Thinker

Thinker, 很多都是用台語寫的
AJAX 如何傳送資料到不同 host?
登入 Yahoo! 奇摩
簡單的藝術
軟體元件的使用
Functional VS Imperative (未完)
動態 load javascript file
Javascript 和後臺的配合
計算 DOM 物件位置

11/03/2006

Firefox 2.0 Tunning Options

about:config

  • browser.tabs.closeButtons -> 改為0
    說明: 開很多tab的時候,預設的方式會常按到不該案的close button,另一個原因是我都用mouse gestures
    0 Display a close button on the active tab only
    1 Display close buttons on all tabs (Default)
    2 Don’t display any close buttons
    3 Display a single close button at the end of the tab strip (Firefox 1.x behavior)

  • network.http.pipelining -> 改為true
    參考 網頁瀏覽加速法
  • keyword.URL -> 改為 http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q=
    預設是yahoo,改成google好手氣
  • network.dns.disableIPv6 -> 改為true
    雖然官方說這樣是probably a placebo effect,不過等到有用到再開起來就好了。

11/01/2006

本週閱讀2006.11.01-2006.11.07

pointer pointer pointer


void GetMemory( char *p ){
p = (char *) malloc( 100 );
}

void Test( void ) {
char *str = NULL;
GetMemory( str );
strcpy( str, "hello world" );
printf( str );
}

在GetMemory中, p是local variable, 所以GetMemory( str )後,str仍然是NULL.
應改為

void GetMemory( char **p ){
p = (char *) malloc( 100 );
}

void Test( void ) {
char *str = NULL;
GetMemory( &str );
strcpy( str, "hello world" );
printf( str );
}

bit manipulation

int I,J;
I = 257 /8;
J = 456 % 32;

int I,J;
I = 257 >>3;
J = 456 - (456 >> 4 << 4);