Skip to content

Instantly share code, notes, and snippets.

View numbcoder's full-sized avatar
🎯
Focusing

Seekr Wang numbcoder

🎯
Focusing
View GitHub Profile
private
def current_user?
if session[:user_id]
return session[:user_id] == @gist.user_id
end
return false
end
def ddd
ed
end
#用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 "---------------------------------------------------------------"
@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
@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 / 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
<!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>
@numbcoder
numbcoder / image_load.js
Created July 5, 2011 09:31
js image load
if(isie){
if($.browser.version==6.0){
image.onreadystatechange = function () {
if (image.readyState == "complete"){
dothing();
}
};
}else{
ie7imagetime = window.setInterval(function(){
var rs = image.readyState;
@numbcoder
numbcoder / gist:1287356
Created October 14, 2011 14:59 — forked from xdite/gist:758319
Ruby / Rails Convention of Techbang

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
@numbcoder
numbcoder / testResize.js
Created November 22, 2011 10:21
Textarea auto resize
$.fn.textResizer = function(options) {
var el = $(this), h;
var settings = {
minHeight: el.height(),
maxHeight: 300,
duration: 100
}
if (options) {
$.extend(settings, options);
}
@numbcoder
numbcoder / require.js
Created December 20, 2011 07:21
CommonJS Module simple implemention
/**
* 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;