- http://rack.rubyforge.org/doc/classes/Rack/Response.html
- http://www.ruby-doc.org/stdlib-1.9.3/libdoc/open3/rdoc/Open3.html
- http://api.rubyonrails.org/classes/ActiveSupport/SafeBuffer.html
- http://apidock.com/ruby/Module/module_function
- http://markdalgleish.com/2011/03/self-executing-anonymous-functions/
- http://stackoverflow.com/questions/5764005/what-is-return-function-used-for-in-javascript
- http://stackoverflow.com/questions/3360858/why-use-in-the-name-of-javascript-variables
- http://stackoverflow.com/questions/1051782/jquery-this-vs-this
- http://api.jquery.com/is/
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
// reference : http://stackoverflow.com/questions/7203304/warning-cant-verify-csrf-token-authenticity-rails | |
// : http://stackoverflow.com/questions/8511695/rails-render-json-session-lost | |
$.ajax({ url: 'YOUR URL HERE', | |
type: 'POST', | |
beforeSend: function(xhr) { | |
xhr.setRequestHeader('X-CSRF-Token', $('meta[name="csrf-token"]').attr('content')) | |
}, | |
data: 'someData=' + someData, | |
success: function(response) { |
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
# base on ruby 1.9 | |
# Reference : | |
# http://stackoverflow.com/questions/185947/ruby-define-method-vs-def | |
# define_method is a (private) method of the object Class. You are calling it from an instance. There is no instance method called define_method, so it recurses to your method_missing, this time with :define_method (the name of the missing method), and :screech (the sole argument you passed to define_method). | |
# http://stackoverflow.com/questions/752717/how-do-i-use-define-method-to-create-class-methods | |
class Base | |
def self.meta_instance_method &block | |
define_method "ins", block | |
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
git config --global user.name "ilake" | |
git config --global user.email "iamilake@gmail.com" | |
git config --global alias.co checkout | |
git config --global apply.whitespace nowarn | |
git commit -v | |
git commit -v -a | |
git branch -a |
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
/** | |
* http://github.com/Valums-File-Uploader/file-uploader | |
* | |
* Multiple file upload component with progress-bar, drag-and-drop. | |
* | |
* Have ideas for improving this JS for the general community? | |
* Submit your changes at: https://github.com/Valums-File-Uploader/file-uploader | |
* | |
* VERSION 2.0 beta | |
* Original version 1.0 © 2010 Andrew Valums ( andrew(at)valums.com ) |
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
作者: iincho (..) 看板: Soft_Job | |
標題: [翻譯] 圖形計算機的故事 | |
時間: Tue Mar 4 12:04:50 2008 | |
Copyright (c) 2004 Ron Avitzur. | |
============================================================ | |
本文譯自 http://www.pacifict.com/Story/ | |
已獲得作者授權翻譯並同意於 PTT 發布 |
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
# config/initializers/devise.rb | |
# for web | |
config.omniauth :google_oauth2, ENV['GOOGLE_CLIENT_ID'], ENV['GOOGLE_CLIENT_SECRET'], | |
{ access_type: "offline", | |
prompt: "consent", | |
select_account: true, | |
provider_ignores_state: true, | |
scope: "plus.profile.emails.read,calendar,contacts" } | |
# for api |
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
let result = await fetch({ | |
api: "http://localhost:3000/users/auth/google_oauth2_for_api/callback", | |
method: 'get', | |
params: { | |
code: response.params.code, | |
redirect_uri: redirectUrl | |
} | |
}) | |
// The result is from rails side. |
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
let redirectUrl = Expo.AuthSession.getRedirectUrl(); | |
let response = await Expo.AuthSession.startAsync({ | |
authUrl: | |
`https://accounts.google.com/o/oauth2/v2/auth?` + | |
`&client_id=${GOOGLE_WEB_APP_ID}` + | |
`&redirect_uri=${encodeURIComponent(redirectUrl)}` + | |
`&response_type=code` + | |
`&access_type=offline` + | |
`&prompt=consent` + | |
`&scope=${encodeURIComponent('https://www.googleapis.com/auth/plus.profile.emails.read https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/contacts')}`, |
NewerOlder