clearance
Class Rails::Generator::Commands::Create
2009年10月16日 星期五
JavaScript 中的 document.createDocumentFragment
JavaScript 中的 document.createDocumentFragment
在這段程式碼中,使用了 document.createDocumentFragment() 這個函式產生一個 document fragment,你可以把它想作是一個處理 DOM element 的 buffer,把欲生成的 DOM element 先加入到這個 fragment 中,最後再一次加到頁面的 DOM 結構中,這樣的作法比起在迴圈中一直 appendChild 來得快上許多,當然更重要的是,問題也被解決了 :)
在這段程式碼中,使用了 document.createDocumentFragment() 這個函式產生一個 document fragment,你可以把它想作是一個處理 DOM element 的 buffer,把欲生成的 DOM element 先加入到這個 fragment 中,最後再一次加到頁面的 DOM 結構中,這樣的作法比起在迴圈中一直 appendChild 來得快上許多,當然更重要的是,問題也被解決了 :)
2009年10月6日 星期二
2009年10月5日 星期一
has_many , time now, assocation
Do you know when your code runs?
有時候你時候你會發現你在你下的conditions 有關於時間的, 跑起來有點怪怪的
在development 沒問題, 在production 卻不正常
仔細看會發現時間統統都是static 的了, 因為production 並不會每次都去reload class
這時候只要換個寫法
有時候你時候你會發現你在你下的conditions 有關於時間的, 跑起來有點怪怪的
在development 沒問題, 在production 卻不正常
仔細看會發現時間統統都是static 的了, 因為production 並不會每次都去reload class
這時候只要換個寫法
2009年10月2日 星期五
2009年10月1日 星期四
Facebook app memo
Facebook development: choosing FBML or iframe as your application type
http://apps.new.facebook.com/facebooker_tutorial/
1. Set up New application
http://www.facebook.com/developers/
2. remember your api key and serect key
3. Canvas/畫布 setting
api key, serect key
they let our application verify that requests are coming from Facebook.
Facebook sends us the ID of the current user and their whole list of friends on
every request. That makes our life quite a bit easier. It also can cause
some security problems.
All requests come from Facebook. To make sure this is the case, we can
verify the signature that is sent by Facebook on every request. A digital
signature is a way to use cryptography to verify that something actually
came from the person who it appears to be from.4 Facebook sends a
number of parameters that start with fb_sig. All these parameters are
used in the signature validation.
When Facebook sends our applications a request, it builds a string
that includes all the fb_sig parameters in alphabetical order. It then
adds our secret key to the end of that string and calculates the MD5 sum.
When Facebooker receives a request, it goes through the
same steps to recalculate the signature. If the value that Facebooker
calculates matches the one in our request, it proves that the request
came from somebody who knows our secret key.
Rails included a feature to stop cross-site forgery
attacks. Unfortunately, this feature doesn’t play well with Facebook.
We’ll need to disable it by editing environment.rb and setting allow_forgery_
protection to false,
http://apps.new.facebook.com/facebooker_tutorial/
1. Set up New application
http://www.facebook.com/developers/
2. remember your api key and serect key
3. Canvas/畫布 setting
api key, serect key
they let our application verify that requests are coming from Facebook.
Facebook sends us the ID of the current user and their whole list of friends on
every request. That makes our life quite a bit easier. It also can cause
some security problems.
All requests come from Facebook. To make sure this is the case, we can
verify the signature that is sent by Facebook on every request. A digital
signature is a way to use cryptography to verify that something actually
came from the person who it appears to be from.4 Facebook sends a
number of parameters that start with fb_sig. All these parameters are
used in the signature validation.
When Facebook sends our applications a request, it builds a string
that includes all the fb_sig parameters in alphabetical order. It then
adds our secret key to the end of that string and calculates the MD5 sum.
When Facebooker receives a request, it goes through the
same steps to recalculate the signature. If the value that Facebooker
calculates matches the one in our request, it proves that the request
came from somebody who knows our secret key.
Rails included a feature to stop cross-site forgery
attacks. Unfortunately, this feature doesn’t play well with Facebook.
We’ll need to disable it by editing environment.rb and setting allow_forgery_
protection to false,
訂閱:
文章 (Atom)