Skip to content

Instantly share code, notes, and snippets.

View numbcoder's full-sized avatar
🎯
Focusing

Seekr Wang numbcoder

🎯
Focusing
View GitHub Profile
@numbcoder
numbcoder / lawnchair-examples.js
Created March 16, 2011 01:16 — forked from brianleroux/lawnchair-examples.js
examples for using lawnchair js
// 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
@numbcoder
numbcoder / gist:764372
Created January 4, 2011 04:02 — forked from xdite/gist:758319
Rails 開發注意要點

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
@numbcoder
numbcoder / rufus-scheduler.rb
Created September 1, 2010 14:39
cron scheduler
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
#用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 "---------------------------------------------------------------"
private
def current_user?
if session[:user_id]
return session[:user_id] == @gist.user_id
end
return false
end
def ddd
ed
end