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 rails_admin_error.log
Completed 500 Internal Server Error in 193ms (ActiveRecord: 3.7ms)
I18n::ArgumentError - Object must be a Date, DateTime or Time object. "" given.:
i18n (0.7.0) lib/i18n/backend/base.rb:53:in `localize'
i18n (0.7.0) lib/i18n.rb:247:in `localize'
rails_admin (0.8.1) lib/rails_admin/config/fields/types/datetime.rb:65:in `block in <class:Datetime>'
rails_admin (0.8.1) lib/rails_admin/config/configurable.rb:66:in `block in register_instance_option'
rails_admin (0.8.1) lib/rails_admin/config/fields/base.rb:113:in `block in <class:Base>'
rails_admin (0.8.1) lib/rails_admin/config/configurable.rb:66:in `block in register_instance_option'
rails_admin (0.8.1) lib/rails_admin/config/proxyable/proxy.rb:27:in `method_missing'
View minitest_assert.rb
require "rubocop"
module RuboCop
module Cop
module Lint
# This cop checks bad use of the Minitest `assert` method
#
# `assert` method's second argument is the error message when the
# first argument evals to false.
#
View initializer_instrumentation.rb
# Backport patch made on Rails 4.1 , to add instrumentation around the
# initializer load code. see https://github.com/rails/rails/pull/12859
# Remove this patch once we are on Rails 4.1+
Rails::Engine.class_eval do
if method_defined? :load_config_initializer
warn "[DEPRECATION] load_config_initializer patch can now be removed."
else
def load_config_initializer(initializer)
ActiveSupport::Notifications.instrument('load_config_initializer.railties', initializer: initializer) do
load(initializer)
@arthurnn
arthurnn / console.rb
Created May 20, 2016
Constant leaking on class_eval
View console.rb
[arthurnn@snowball ~]$ irb
irb(main):001:0> class Foo
irb(main):002:1> FOO = "foo"
irb(main):003:1> end
=> "foo"
irb(main):005:0> Foo.class_eval { BAR = "bar" }
=> "bar"
irb(main):006:0> BAR
=> "bar"
irb(main):007:0> FOO
View pg_test.rb
require 'pg'
class Context
attr_reader :connections
def initialize
@connections = {}
end
def connection
@connections.fetch(Process.pid) { @connections[Process.pid] = PG.connect( dbname: 'test' ) }
end
View pg_test.rb
require 'pg'
class Context
attr_reader :connections
def initialize
@connections = {}
end
def connection
@connections.fetch(Process.pid) { @connections[Process.pid] = PG.connect( dbname: 'test' ) }
end
View mysql_test.rb
require 'mysql2'
connection = Mysql2::Client.new(host: "127.0.0.1", port: 3306, username: "root", database: "test")
connection.automatic_close = false
p connection.query( "SELECT database();" ).to_a
fork { }
Process.wait
p connection.query( "SELECT database();" ).to_a
View pg_test.rb
require 'pg'
class Context
attr_reader :connections
def initialize
@connections = {}
end
def connection
@connections.fetch(Process.pid) { @connections[Process.pid] = PG.connect( dbname: 'test' ) }
end
View Gemfile
# A sample Gemfile
source "https://rubygems.org"
gem 'ruby-prof'
View test_conn.rb
require 'active_support/all'
require 'active_record'
require 'logger'
ActiveRecord::Base.logger = Logger.new(STDOUT)
spec = { 'test' => {adapter: 'sqlite3', database: ':memory:'},
'test_readonly' => {adapter: 'sqlite3', database: ':memory:'},
'shared_test' => {adapter: 'sqlite3', database: ':memory:'},
'shared_test_readonly' => {adapter: 'sqlite3', database: ':memory:'}
You can’t perform that action at this time.