Search
12/11/2009
AppJet: The Platform behind EtherPad
AppJet: The Platform behind EtherPad
JavaScript execution on both the client and server
This enabled us to be more productive by writing all of EtherPad in the same language, and shuttle data between the client, server, and database all using JavaScript objects.
Scalable, cross-browser persistent client sockets
EtherPad changes show up on everyone's browser in real-time, so we needed to maintain a persistent connection to push data to client at all times. We have client and sever libraries that support "Comet" connections in a scalable and browser-compatible way.
Flexible, memory-cached JavaScript object database
All the objects that the EtherPad application code works with are JavaScript objects, so why on earth would we convert them to and from any other format when storing them in the database? EtherPad stores all its data in the AppJet Database, which automatically scales and caches itself in memory as necessary. This makes it fast to implement EtherPad features, fast to change storage models, and fast to serve requests in production.
Access to the world's biggest collection of libraries: the JVM
There are more high-quality and well-documented libraries written for the Java VM than for any other runtime. We wanted access to all of them when building EtherPad, so we made an easy way to import Java libraries for use in JavaScript, based on Rhino's JavaScript/Java bridge.
Obsessive focus on performance
We named it AppJet for a reason. Part of why AppJet is so fast is that it uses Rhino to compile JavaScript to Java bytecodes, which in turn run on top of the JVM. Many man-decades have gone into optimizing the JVM, and all of that work makes AppJet faster. To make the database fast, we automatically cache frequently used segments in memory. The net result is a full-stack platform for building web apps that supports rapid development and rapid performance in production.
Google Wave Operational Transformation
12/09/2009
你的程式語言可以這樣做嗎? - The Joel on Software Translation Project
你的程式語言可以這樣做嗎? - The Joel on Software Translation Project
當你一想到作為參數的無名函數,你也許想到對某個陣列的元素進行相同動作的程式碼。
var a = [1,2,3];
for (i=0; i<a.length; i++) {
a[i] = a[i] * 2;
}
for (i=0; i<a.length; i++) {
alert(a[i]);
}
常常要對陣列內的所有元素做同一件事,因此你可以寫個這樣的函數來幫忙:
function map(fn, a) {
for (i = 0; i < a.length; i++) {
a[i] = fn(a[i]);
}
}
現在你可以將上面的東西寫成:
map( function(x){return x*2;}, a );
map( alert, a );
另一個常見的工作是將陣列內的所有元素按某種方法合起來:
function sum(a)
{
var s = 0;
for (i = 0; i < a.length; i++)
s += a[i];
return s;
}
function join(a)
{
var s = "";
for (i = 0; i < a.length; i++)
s += a[i];
return s;
}
alert(sum([1,2,3]));
alert(join(["a","b","c"]));
'sum'和'join'長得很像,你也許想將它們抽象化,變成將陣列內所有元素按某種方法合起來的泛型函數:
function reduce(fn, a, init)
{
var s = init;
for (i = 0; i < a.length; i++)
s = fn( s, a[i] );
return s;
}
function sum(a)
{
return reduce( function(a, b){ return a + b; },
a, 0 );
}
function join(a)
{
return reduce( function(a, b){ return a + b; },
a, "" );
}
讓我們回到'map'函數。對陣列內的每個元素做事時,很可能並不在乎哪個元素先做。無論由第一個還是最後一個元素開始,結果都是一樣的,對不對?如果你手頭上有2個CPU,就可以寫段程式碼,使得它們各對一半的元素工作,於是'map'就變快兩倍了。
或者你在全球有千千百百台伺服器(只是假設),還有一個很大很大的陣列,存放整個互聯網的內容(同樣也只是假設)。現在你可以在這些伺服器上執行'map',讓各台伺服器只處理問題很小的一部份。
tag: map reduce mapreduce
12/05/2009
12/04/2009
Using Google Public DNS
The Google Public DNS IP addresses are as follows:
* 8.8.8.8
* 8.8.4.4
OpenDNS创始人:谷歌DNS与
OpenDNS不完全相同_互联网新闻_科技_腾讯网
我们具有最大的DNS缓冲、最快的解析器,而且提供最大的灵活性让你控制DNS体验。举例来说,IT人士希望在DNS中阻挡恶意网站,父母有时希望阻挡孩子访问特定网站。我们的DNS服务可以实现上面这些和更多任务。谷歌DNS做不到这一点。当然,我们不强推这些功能,一切由用户自己选择。让用户选择是我们服务的核心所在。
12/03/2009
DD_roundies: Code-only rounded HTML boxes
DD_roundies: Code-only rounded HTML boxes
http://chunghe.googlecode.com/svn/trunk/project/DD_roundies/index.htm
Quick summary:
This uses Microsoft's implementation of VML for Internet Explorer. For other browsers, this adds simple border-radius styles to the document (IF and only if you specify the third argument in DD_belatedPNG.addRule).
The third argument in addRule defaults to false. This library does focus primarily on IE.
usage:
# addRule can take up to three arguments:
* (REQUIRED) A text string representing a CSS selector
* (REQUIRED) A text string representing a border radius or radii (anywhere from 1 to 4, separated by commas)
* (OPTIONAL) A boolean indicating whether or not you want to make roundies just in IE (set to false), or attempt to make roundies in "all" browsers (set to true).
12/02/2009
Setting Maxlength with javascript
Setting Maxlength with javascript
注意要用input.maxLength而不是input.maxlenth, 只會影響由 createElement('input')長出來的input.
http://chunghe.googlecode.com/svn/trunk/experiment/maxLength.htm
訂閱:
文章 (Atom)