- 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
- 函式如果只有一個參數,就不強制打()
- 函式如果有二個以上的參數,通通都要有 ()
- (避免發生奇怪的paser bug跟保持專案一致性)
- 字串限定用雙引號包覆
- 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A | |
def test | |
puts "test" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="gears_init.js"></script> | |
<script type="text/javascript"> | |
var localServer = google.gears.factory.create('beta.localserver'); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="gears_init.js"></script> | |
<script type="text/javascript"> | |
var db = google.gears.factory.create('beta.database'); | |
db.open('database-test'); | |
db.execute('create table if not exists Test' + | |
' (Phrase text, Timestamp int)'); | |
db.execute('insert into Test values (?, ?)', ['Monkey!', new Date().getTime()]); | |
var rs = db.execute('select * from Test order by Timestamp desc'); | |
while (rs.isValidRow()) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2007, Google Inc. | |
// ============= | |
// gears_offline | |
// ============= | |
// Changed by: Alex([email protected]) | |
// Time : 2009.01.23 | |
(function() { | |
jQuery.fn.offline = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright 2007 Google Inc. All Rights Reserved. | |
// ========== | |
// gears_init | |
// ========== | |
// Changed by: Alex([email protected]) | |
// Time : 2009.01.23 | |
(function() { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The ParentWorkerPool of Monitor whether the system is online or offline | |
* | |
* Alex([email protected]) | |
* 2009.3 | |
*/ | |
isOnlie: function(){ | |
workerPool = google.gears.factory.create('beta.workerpool'); | |
workerPool.onmessage = function(a, b, message) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The ChinldWorkerPool of Monitor whether the system is online or offline | |
* | |
* Alex([email protected]) | |
* 2009.3 | |
*/ | |
var POLLING_INTERVAL = 2000; | |
var wp = google.gears.workerPool; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var wp = google.gears.factory.create('beta.workerpool', '1.0'); | |
childCode = String(evalHandler) + | |
'google.gears.workerPool.onmessage = evalHandler;'; | |
wp.onmessage = parentHandler; | |
var childId = wp.createWorker(childCode); | |
wp.sendMessage('2+2', childId); | |
function parentHandler(msg, sender) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
OlderNewer