Skip to content

Instantly share code, notes, and snippets.

View ZhangHanDong's full-sized avatar
🦀
Rustacean

Alex ZhangHanDong

🦀
Rustacean
  • Beijing, China
View GitHub Profile
class A
def test
puts "test"
end
end
<script type="text/javascript" src="gears_init.js"></script>
<script type="text/javascript">
var localServer = google.gears.factory.create('beta.localserver');
</script>
<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()) {
// Copyright 2007, Google Inc.
// =============
// gears_offline
// =============
// Changed by: Alex([email protected])
// Time : 2009.01.23
(function() {
jQuery.fn.offline = {
// Copyright 2007 Google Inc. All Rights Reserved.
// ==========
// gears_init
// ==========
// Changed by: Alex([email protected])
// Time : 2009.01.23
(function() {
/**
* 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) {
/**
* 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;
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) {
# 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")

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。