Skip to content

Instantly share code, notes, and snippets.

View wildjcrt's full-sized avatar
🦀
have a nice day!

Jerry Lee wildjcrt

🦀
have a nice day!
View GitHub Profile
@wildjcrt
wildjcrt / gist:2246377
Created March 30, 2012 04:01 — forked from Truesun/html
test
<body style="color:#fff; font-family:Verdana, Geneva, sans-serif;">
<h3 style="font-weight:bold; font-size:13px; border-bottom:solid 1px #eee; padding:2px 0;">名稱:測試投票</h3>
<p style="margin-bottom:8px; padding:5px 0;">
宗旨:com'ono<br>
此次投票你可以投 <span id="remain-votes">2</span> 票。
</p>
<div class="grid">
<ul style="padding:0 0 0 5px; margin-bottom:8px;">
<li><input name="" value="" type="checkbox"> a</li>
<li><input name="" value="" type="checkbox"> bcd</li>

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add:

@wildjcrt
wildjcrt / workers.rake
Created January 30, 2012 08:58 — forked from karmi/workers.rake
Rake taks to launch multiple Resque workers in development/production with simple management included
# Rake task to launch multiple Resque workers in development/production with simple management included
require 'resque/tasks' # Require Resque tasks
namespace :workers do
# = $ rake workers:start
#
# Launch multiple Resque workers with the Rails environment loaded,
# so they have access to your models, etc.
@wildjcrt
wildjcrt / gist:1601405
Created January 12, 2012 16:21 — forked from xdite/gist:1599619
Debian DRBD + MySQL + HeartBeat
# before
## model
class User
after_create : call_3rd_api
def call_3rd_api
xxx
end
end
@wildjcrt
wildjcrt / irb3.rb
Created September 26, 2011 02:48 — forked from peterc/irb3.rb
irb3 - Run an IRB-esque prompt over multiple Ruby implementations at once using RVM
#!/usr/bin/env ruby
# encoding: utf-8
# irb3 - Runs an IRB-esque prompt (but it's NOT really IRB!) over multiple
# versions of Ruby at once (using RVM)
#
# By Peter Cooper, BSD licensed
#
# Main dependency is term-ansicolor for each impl:
# rvm exec gem install term-ansicolor
@wildjcrt
wildjcrt / Gemfile
Created September 1, 2011 01:50 — forked from chriseppstein/readme.md
How to integrate Compass with Rails 3.1 asset pipeline
group :assets do
gem 'sass-rails', '~> 3.1.0'
gem 'coffee-rails', '~> 3.1.0'
gem 'uglifier'
gem 'compass', '~> 0.12.alpha'
end
@wildjcrt
wildjcrt / list
Created August 23, 2011 11:17 — forked from anonymous/list
Demos
http://animatable.com/demos/madmanimation/
http://www.mozillademos.org/demos/planetarium/demo.html
http://www.chrysaora.com/
http://mozillademos.org/demos/remixingreality/demo.html
http://playbiolab.com
http://chrome.angrybirds.com
http://helloracer.com/webgl/
http://videos.mozilla.org/serv/blizzard/audio-slideshow/
http://paulrouget.com/TheSanbox
http://hacks.mozilla.org/2011/08/speak-js-text-to-speech-on-the-web/
@wildjcrt
wildjcrt / gist:760859
Created December 31, 2010 08:27 — forked from xdite/gist:758319

Rails 開發注意要點

About Ruby Syntax

  • 編輯器設定 soft tab (space=2),以 2 格空白符號做為程式內縮距離(不分語言)。
  • 函式如果只有一個參數,就不強制打()
  • 函式如果有二個以上的參數,通通都要有 ()
    • (避免發生奇怪的paser bug跟保持專案一致性)
  • 字串限定用雙引號包覆
  • 善用 "#{str1} #{str3} " 等字串改寫技巧取代不需要的字串加法。
wget http://hackmysql.com/scripts/mysqlsla
chmod +x mysqlsla-2.03
sudo ./mysqlsla-2.03 /var/log/mysql/mysql-slow.log
# 預設會列出 top 10 的 slow quires
# 可以帶參數 --top 13 修改列出的項目數量
# 通常網路上都說從 top 1, 2, 3 的 slow quires 去修
# 是對增進效能最有幫助的!