Skip to content

Instantly share code, notes, and snippets.

View josevalim's full-sized avatar

José Valim josevalim

View GitHub Profile
@josevalim
josevalim / 0_rails.2.3.yml
Created January 4, 2010 10:02
I18n yml format proposal for Rails 3
# This a sample YML file from Rails 2.3. The objective is to propose a yml based on this
# one which will reduce error messsages duplication, as outline in this post:
#
# http://groups.google.com/group/rails-i18n/browse_thread/thread/3085a78831ed8fae
#
# Proposals are available below and also check the forks at the right.
en:
activerecord:
models:
admin: "Admin"
module ActiveSupport
module Notifications
autoload :Instrumenter, 'active_support/notifications/instrumenter'
autoload :Event, 'active_support/notifications/instrumenter'
autoload :Fanout, 'active_support/notifications/fanout'
class << self
attr_writer :notifier
delegate :publish, :subscribe, :to => :notifier
delegate :instrument, :to => :instrumenter
class Bubble::Cli::Add < Base
class_option :force, :aliases => "-f", :type => :boolean, :default => false,
:desc => "Force"
def first_step
end
def second_step
end
[ Carlhuda ]
actionmailer/lib/action_mailer/railtie.rb:17 (was actionmailer/lib/action_mailer/rails.rb)
actionmailer/lib/action_mailer/railtie.rb:23 (was actionmailer/lib/action_mailer/rails.rb)
actionpack/lib/action_controller/railtie.rb:17 (was actionpack/lib/action_controller/rails.rb)
actionpack/lib/action_controller/railtie.rb:37 (was actionpack/lib/action_controller/rails.rb)
actionpack/lib/action_view/template/handlers.rb:13
activerecord/lib/active_record/railtie.rb:74 (was activerecord/lib/active_record/rails.rb)
activesupport/lib/active_support/testing/performance.rb:321
class <%= class_name %> < ActionMailer::Base
delivers_from "mail@<%= Rails.application.name %>.com"
<% for action in actions -%>
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.actionmailer.<%= file_name %>.<%= action_name %>.subject
#
def <%= action %>
class Notifier < ActionMailer::Base
delivers_from "[email protected]"
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
# en.actionmailer.notifier.foo.subject
#
def foo
@greeting = "Hi"
Host gitproxy
User git
HostName ssh.github.com
Port 443
@josevalim
josevalim / _yerb.rb
Created March 18, 2010 16:41
Who needs HAML when you have YAML + ERB?
# = YERB
#
# Who needs HAML when you have YAML + ERB? ;)
#
# See example.yaml below for an example. You can run this code
# by cloning this gist and then `ruby _yerb.rb example.yaml`.
#
# Notice that you need Ruby 1.9 so the hash order is preserved.
# Obviously, this is just for fun. Definitely slow as hell.
#
# require "rack/openid"
require 'devise/strategies/base'
require 'uri'
module Devise
module Strategies
# Default strategy for signing in a user, based on openid
# Redirects to sign_in page if it's not authenticated
class OpenId < Warden::Strategies::Base
include Devise::Strategies::Base
Warden::Strategies.add(:openid) do
def valid?
!params["openid_identifier"].blank?
end
def authenticate!
if resp = env[Rack::OpenID::RESPONSE]
RAILS_DEFAULT_LOGGER.info "Attempting OpenID auth: #{env["rack.openid.response"].inspect}"
case resp.status
when :success