Search
11/27/2006
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 */
11/13/2006
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.
11/08/2006
本週閱讀2006.11.08-2006.11.15
- Fear, uncertainty and doubt - Wikipedia, the free encyclopediaFear, uncertainty, and doubt (FUD) is a sales or marketing strategy of disseminating negative (and vague) information on a competitor's product. The term originated to describe misinformation tactics in the computer hardware industry and has since been used more broadly. FUD is a manifestation of the appeal to fear.
- Language Wars
- Ruby Performance Revisited
- White & Nerdy 中文字幕版
- White & Nerdy - Wikipedia, the free encyclopedia
- SYN Flood 攻擊的基本原理及防禦
- 張凱雅談Keith Jarrett~
- Dive Into Accessibility
- 為什麼30歲了還沒有汽車?
- 凌群電腦取得國內第一張 CMMI Level5評鑑認證
- 程式語言的效率: 本日最中肯效能最佳化的態度應該是保持一個「可最佳化」的架構,但不先試著做最佳化。等到效能瓶頸浮現時,在這個「可最佳化」的架構上,輕鬆的進行最佳化。而不是試著在每個環節都進行最佳化,最後影響了開發的時程,也不見得真的享受到該有的效能。
Scott Meyers - The Most Important C++
- Scott Meyers最近的一次Aha!时刻
- Scott Meyers 从5个方面回顾和反思 C++ 历史
- A Pause to Reflect: Five Lists of Five, Part I - The Most Important C++ Books...Ever
- A Pause to Reflect: Five Lists of Five, Part II - The Most Important C++ Non-Book Publications...Ever
- A Pause to Reflect: Five Lists of Five, Part III - The Most Important C++ Software...Ever
- A Pause to Reflect: Five Lists of Five, Part IV - The Most Important C++ People...Ever
- A Pause to Reflect: Five Lists of Five, Part V - My Most Important C++ Aha! Moments...Ever
- A Pause to Reflect: Five Lists of Five, Part I - The Most Important C++ Books...Ever
駭客與畫家 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
- 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.
- Greenspun's Tenth Rule - Wikipedia, the free encyclopediaAny 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 encyclopediaAll 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)).
11/03/2006
Firefox 2.0 Tunning Options
about:config
- browser.tabs.closeButtons -> 改為0
說明: 開很多tab的時候,預設的方式會常按到不該案的close button,另一個原因是我都用mouse gestures0 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
- Use Thunar as default Gnome file manager,不過照著改了之後thunar呈現水土不服,頻頻當掉,只好作罷。
- Windows CE 6 arrives with 100% kernel source
- Microsoft WinCE 6 的 100% shared source
- Pay for Hesitate
- Wikipedia - Esoteric programming
- Wikipedia - Brainfuck
- 玩转flickr del.icio.us Digg 之完全攻略
- 找出Java程式吃掉CPU的元兇
- Microsoft Habu Laser Gaming Mouse
- Bulletproof HTML: 37 Steps to Perfect Markup
- This meta element will be ignored if the real HTTP header contains encoding information. It can be useful anyway, though, because it will be used if a visitor saves our page to the hard drive and looks at it locally. In that situation, there's no web server to send HTTP headers, so the meta element will be used instead.
- There is no default encoding for HTML, so we should always make sure to specify it.
- The purpose of HTML is to mark up the semantics of a document, and -- to some extent -- to show the structure of its content. HTML has nothing at all to do with the way this document looks in a browser (although browsers have a default style for each element type).
- It is semantically wrong to mark up non-tabular information as a table.
- This meta element will be ignored if the real HTTP header contains encoding information. It can be useful anyway, though, because it will be used if a visitor saves our page to the hard drive and looks at it locally. In that situation, there's no web server to send HTTP headers, so the meta element will be used instead.
- Novemberborn: JavaScript Terminology
var msg = "hello world";
function foo(){
alert(msg);
};
foo();
Now, if you call foo, it’ll alert hello world! But how does it know the value of msg, which wasn’t defined in the function body foo? It turns out that if the JavaScript interpreter can’t find a variable in it’s current scope, it’ll go up the scope chain and searches the parent scope until it finds the variable. In our case it finds msg in global scope. - [PORTER勸敗網站] Cool Cat購物流程~~想入手日本PORTER必看
- self-improvement對於新手而言,我建議往以下這三個方向發展:Toolsmith, Language Lawyer,Chief programmer
- lilURL - A Free/Open Source Clone of TinyURL
- Debian 和 Mozilla® 在 Firefox 的 LOGO 和 名稱 上的爭議
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 );
}
訂閱:
文章 (Atom)