- 編輯器設定 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
private | |
def current_user? | |
if session[:user_id] | |
return session[:user_id] == @gist.user_id | |
end | |
return false | |
end | |
def ddd | |
ed | |
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
#用ruby看糗百 | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
url = "http://www.qiushibaike.com" | |
doc = Nokogiri::HTML(open(url)) | |
doc.css(".qiushi_body").each do |article| | |
puts "---------------------------------------------------------------" |
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
require 'rubygems' | |
require 'rufus/scheduler' | |
scheduler = Rufus::Scheduler.start_new | |
scheduler.in '20m' do | |
puts "order ristretto" | |
end | |
scheduler.at 'Thu Mar 26 07:31:43 +0900 2009' do |
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
// create a new store | |
var store = new Lawnchair({adaptor:'dom', table:'people'}); | |
// saving documents | |
store.save({name:'brian'}); | |
// optionally pass a key | |
store.save({key:'config', settings:{color:'blue'}}); | |
// updating a document in place is the same syntax |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8"> | |
<title>COLORFUL</title> | |
<script src="/jquery-1.js" type="text/javascript" charset="utf-8"></script> | |
<script src="/modernizr.js" type="text/javascript" charset="utf-8"></script> | |
<script src="/mustache.js" type="text/javascript" charset="utf-8"></script> | |
<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
if(isie){ | |
if($.browser.version==6.0){ | |
image.onreadystatechange = function () { | |
if (image.readyState == "complete"){ | |
dothing(); | |
} | |
}; | |
}else{ | |
ie7imagetime = window.setInterval(function(){ | |
var rs = image.readyState; |
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
$.fn.textResizer = function(options) { | |
var el = $(this), h; | |
var settings = { | |
minHeight: el.height(), | |
maxHeight: 300, | |
duration: 100 | |
} | |
if (options) { | |
$.extend(settings, options); | |
} |
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
/** | |
* Define a module along with a payload | |
* @param module a name for the payload | |
* @param payload a function to call with (require, exports, module) params | |
*/ | |
(function() { | |
var global = (function() { | |
return this; |
OlderNewer