Skip to content

Instantly share code, notes, and snippets.

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
@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を取得。
參考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開關)
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
@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' '*';
#
@jcsrb
jcsrb / gist:1081548
Created July 13, 2011 23:05
get avatar from google profiles, facebook, gravatar, twitter, tumblr
function get_avatar_from_service(service, userid, size) {
// this return the url that redirects to the according user image/avatar/profile picture
// implemented services: google profiles, facebook, gravatar, twitter, tumblr, default fallback
// for google use get_avatar_from_service('google', profile-name or user-id , size-in-px )
// for facebook use get_avatar_from_service('facebook', vanity url or user-id , size-in-px or size-as-word )
// for gravatar use get_avatar_from_service('gravatar', md5 hash email@adress, size-in-px )
// for twitter use get_avatar_from_service('twitter', username, size-in-px or size-as-word )
// for tumblr use get_avatar_from_service('tumblr', blog-url, size-in-px )
// everything else will go to the fallback
// google and gravatar scale the avatar to any site, others will guided to the next best version
@jeffhung
jeffhung / gist:1160862
Created August 21, 2011 17:12
IRC Log for #coscup in Aug, 2011.
--- Log opened Mon Aug 01 00:00:23 2011
--- Day changed Wed Aug 03 2011
[20110803T091729+0800]< sanyuan> w
--- Log closed Thu Aug 04 07:52:01 2011
--- Log opened Thu Aug 04 07:52:07 2011
[20110804T075207+0800]-!- Irssi: #coscup: Total of 27 nicks [3 ops, 0 halfops, 0 voices, 24 normal]
[20110804T075320+0800]-!- Irssi: Join to #coscup was synced in 77 secs
--- Day changed Mon Aug 08 2011
[20110808T130743+0800]-!- kyu is now known as kengyu
--- Day changed Tue Aug 09 2011
@bentruyman
bentruyman / Custom.css
Created August 22, 2011 19:35
Tomorrow Theme for Chrome Developer Tools
/**********************************************/
/*
/* Tomorrow Skin by Ben Truyman - 2011
/*
/* Based on Chris Kempson's Tomorrow Theme:
/* https://github.com/ChrisKempson/Tomorrow-Theme
/*
/* Inspired by Darcy Clarke's blog post:
/* http://darcyclarke.me/design/skin-your-chrome-inspector/
/*