Skip to content

Instantly share code, notes, and snippets.

@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
class ApplicationController < ActionController::Base
...
# FORCE to implement content_for in controller
def view_context
super.tap do |view|
(@_content_for || {}).each do |name,content|
view.content_for name, content
end
end
end
參考xdite's blog http://blog.xdite.net/?p=1839
建立一個名為railsc的執行檔,以monkey patch的方式啟用wirble及hirb
將railsc存到你PATH下,並設定可執行(chmod 755)
執行railsc取代rails c,即可載入wirble及hirb,不用修改project directory下的東西
P.S.
ActiveRecord::Base.logger = Logger.new(STDOUT)
這個我還是寫在.irbrc裡(事實上我是用show_log和hide_log開關)
@azu
azu / OAuth for Greasemonkey sample.user.js
Created May 29, 2010 13:28
GreasemonkeyでOAuth認証を手助けするライブラリとそのサンプル
// ==UserScript==
// @name OAuth for Greasemonkey sample
// @namespace http://efcl.info/
// @include http://*
// @require http://userscripts.org/scripts/source/78102.user.js
// ==/UserScript==
// http://userscripts.org/scripts/show/78102
/*認証手順
tw.getRequestToken
consumerKeyとconsumerSecretを使って、OAuth認証のページURLに必要なRequestTokenを取得。
class Users::SessionsController < Devise::SessionsController
# Have to reimplement :recall => "failure"
# for warden to redirect to some action that will return what I want
def create
resource = warden.authenticate!(:scope => resource_name, :recall => "failure")
# set_flash_message :notice, :signed_in
sign_in_and_redirect(resource_name, resource)
end