Skip to content

Instantly share code, notes, and snippets.

Arthur Nogueira Neves arthurnn

Block or report user

Report or block arthurnn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ar_relation.rb
require 'active_record'
require 'mysql2'
require 'minitest/autorun'
require 'logger'
puts "ActiveRecord: #{ActiveRecord::VERSION::STRING}"
ActiveRecord::Base.establish_connection(adapter: "mysql2", host: "localhost", database: "test")
ActiveRecord::Base.logger = Logger.new(STDOUT)
class Author < ActiveRecord::Base
View arel_rails_issue.rb
require 'active_record'
require 'minitest/autorun'
require 'logger'
puts "ActiveRecord: #{ActiveRecord::VERSION::STRING}"
case ARGV[0]
when 'pg'
require 'pg'
ActiveRecord::Base.establish_connection(adapter: "postgresql", host: "localhost", user: "postgres", database: "test")
when 'mysql'
View eager_load.rb
require 'mongoid'
require 'mongoid/support/query_counter'
Mongoid.configure.connect_to("mongoid_test")
logger = Logger.new $stdout
logger.level = 0
class Post
include Mongoid::Document
belongs_to :person
end
View sprockets.rake
require 'sprockets/rails/task'
Rake::Task["assets:environment"].clear
Rake::Task["assets:precompile"].clear
Rake::Task["assets:clean"].clear
Rake::Task["assets:clobber"].clear
Sprockets::Rails::Task.new(Rails.application) do |t|
t.manifest = lambda do
app = Rails.application
Sprockets::Manifest.new(app.assets, File.join(app.root, 'public', app.config.assets.prefix, 'manifest.json'))
View gist12566.rb
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
p ActiveRecord.version
class Foo < ActiveRecord::Base
View each_with_index.rb
require 'benchmark'
arr = (1..100).to_a
Benchmark.bm(20) do |x|
x.report("each.with_index") do
100_000.times do
arr.each_with_index do |v, i|
end
View gist:8981360
require 'active_record'
require 'benchmark'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.integer :comments_count
end
create_table :comments, force: true do |t|
View gist:9012245
require 'active_record'
require 'benchmark'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.integer :comments_count
end
View gist:9012248
require 'active_record'
require 'benchmark'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.integer :comments_count
end
View issue.rb
require 'active_record'
require 'benchmark'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.integer :comments_count
end
You can’t perform that action at this time.