View authlogic_dont_lockout_api_key_or_http_auth.rb
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
odule Authlogic::Session::Timeout::DontLockoutApiKeyOrHttpAuth | |
def self.included(klass) | |
klass.class_eval do | |
dont_lockout = "single_access? || persist_by_http_auth?" | |
before_persisting_callback_chain.detect {|c| c.method == :reset_stale_state }.options.update(:unless => dont_lockout) | |
after_persisting_callback_chain.detect {|c| c.method == :enforce_timeout }.options.update(:unless => dont_lockout) | |
end | |
end | |
end |
View dateinput_converter.js
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
// Based on http://snipt.net/boriscy/datetime-jquery-formtastic/ | |
$.tools.dateinput.localize("ja", { | |
months: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月', | |
shortMonths: '1月,2月,3月,4月,5月,6月,7月,8月,9月,10月,11月,12月', | |
days: '日曜日,月曜日,火曜日,水曜日,木曜日,金曜日,土曜日', | |
shortDays: '日,月,火,水,木,金,土' | |
}); | |
$.tools.dateinput.conf.format = 'yyyy-mm-dd'; |
View gist:984510
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
# javascript | |
$(function() { | |
var ids = $('//[data-fb-id]').map(function(){ | |
return $(this).data("fb-id"); | |
}) | |
$.unique(ids).each(function(){ | |
FB.api('/' + this, function(r){ | |
$("//[data-fb-id='"+ r["id"] + "']").each(function(){ | |
var attr = $(this).data("fb-attr"); | |
$(this).text(r[attr]); |
View gist:1039790
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
Started GET "/assets/application.js" for 127.0.0.1 at 2011-06-22 18:54:39 +0900 | |
Compiled app/assets/javascripts/application.js (4ms) (pid 65649) | |
Compiled ~/.rvm/gems/ruby-1.9.2-p180/gems/jquery-rails-1.0.11/vendor/assets/javascripts/jquery.js (1ms) (pid 65649) | |
Compiled ~/.rvm/gems/ruby-1.9.2-p180/gems/jquery-rails-1.0.11/vendor/assets/javascripts/jquery_ujs.js (0ms) (pid 65649) | |
Compiled vendor/assets/javascripts/externals.js (2ms) (pid 65649) | |
Compiled vendor/assets/javascripts/jshashtable-2.1.js (0ms) (pid 65649) | |
Compiled vendor/assets/javascripts/jquery.numberformatter-1.2.2.min.js (0ms) (pid 65649) | |
Compiled app/assets/javascripts/invoices.coffee (119ms) (pid 65649) | |
Compiled app/assets/javascripts/application.js (0ms) (pid 65649) | |
Served asset /application.js - 304 Not Modified (150ms) (pid 65649) |
View gist:1042058
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
class Invoice < ActiveRecord::Base | |
belongs_to :sender | |
after_initialize :assign_defaults | |
def assign_defaults | |
if new_record? && sender | |
self.fax ||= sender.fax | |
end | |
end | |
end |
View gist:1188099
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
escaped = CGI.unescape(query) | |
return escaped if escaped.valid_encoding? | |
%w[EUC-JP Shift_JIS].each do |encoding| | |
s = escaped.force_encoding(encoding) | |
return s.encode("UTF-8") if s.valid_encoding? | |
end | |
escaped |
View widget.js
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
//= require getElementsByClassName-1.0.1 | |
//= require domready | |
//= require_tree ./widget |
View globalize_accessors.rb
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
# allows directly accessing the locale specific fields such as text_en and text_ja without using fallbacks | |
module GlobalizeAccessors | |
def translates(*attr_names) | |
super | |
attr_names.each do |attr_name| | |
I18n::AVAILABLE_LOCALES.map(&:to_sym).each do |locale| | |
# writer | |
define_method :"#{attr_name}_#{locale}=" do |value| | |
write_attribute(attr_name, value, :locale => locale) | |
end |
View boundio-example.rb
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
#!/usr/bin/env ruby | |
# encoding: UTF-8 | |
require "boundio" | |
require "csv" | |
include Boundio | |
greeting = AudioFile.create(:convtext => "こんにちは、") | |
message = AudioFile.create(:convtext => "さん。") | |
CSV.parse($stdin) do |row| |
View original.css
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
input#profile_min_age, input#profile_max_age { | |
width: 26px; | |
} | |
input#profile_height, input#profile_min_seek_height, input#profile_max_seek_height { | |
width: 36px; | |
} |
OlderNewer