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 pull origin master | |
% ant dist | |
% tar zxvf dist/jruby-bin-1.7.0.dev.tar.gz -C ~/.rbenv/versions | |
% cd ~/.rbenv/versions/jruby-1.7.0.dev/bin | |
% rm -f *.exe *.dll *.bat jruby.sh | |
% sed -i "" 's/^#!\/bin\/bash/#!\/usr\/bin\/env bash/' jruby | |
% ln -fs jruby ruby |
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
if Rails.env.production? | |
PAYPAL_ACCOUNT = 'production@gmail.com' | |
else | |
PAYPAL_ACCOUNT = 'development@gmail.com' | |
ActiveMerchant::Billing::Base.mode = :test | |
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
<?php | |
/* | |
Plugin Name: A Plugin Name | |
Plugin URI: http://somadesign.ca/ | |
Description: Be descriptive. | |
Version: 0.1 | |
Author: Soma Design | |
Author URI: http://somadesign.ca/ | |
License: GPL v2 |
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
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb | |
# Maps logical Rails types to MySQL-specific data types. | |
def type_to_sql(type, limit = nil, precision = nil, scale = nil) | |
return super unless type.to_s == 'integer' | |
case limit | |
when 1; 'tinyint' | |
when 2; 'smallint' | |
when 3; 'mediumint' | |
when nil, 4, 11; 'int(11)' # compatibility with MySQL default |
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/routes.rb | |
resources :documents do | |
scope module: 'documents' do | |
resources :versions do | |
post :restore, on: :member | |
end | |
resource :lock | |
end | |
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
<!-- | |
Easily creates something like: | |
class Object | |
attr_reader :attr1, :attr2, :attr3 | |
def initialize attr1, attr2, attr3 | |
@attr1 = attr1 | |
@attr2 = attr2 | |
@attr3 = attr3 |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
- Rails 7.0.1 is compatible with Ruby 3.1.0.
- Rails 7.0.1 addes net-smtp, net-imap and net-pop gems as Action Mailbox and Action Mailer dependency, you do not need to add them explicitly in your application Gemfile anymore.
- thor 1.2.1 has been released. You will not see
DidYouMean::SPELL_CHECKERS.merge
deprecate warnings anymore.
- Use Rails 6.1.5 to support
database.yml
with aliases andsecrets.yml
with aliases.