Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
# goes in ~/.rdebugrc
set autoeval
set autolist
set history save off
# Goes in ~/.irbrc
unless defined? IRBRC_LOADED
require 'rubygems'
require 'irb/completion'
require 'pp'
# Use the simple prompt if possible.
IRB.conf[:PROMPT_MODE] = :SIMPLE if IRB.conf[:PROMPT_MODE] == :DEFAULT
# Benchmarking
require 'benchmark'
def bench(n=1_000,&b)
Benchmark.bmbm do |r|
r.report {n.to_i.times(&b)}
end
end
if ENV['RAILS_ENV']
# QUERYING
def scn(klass)
klass.columns.sort_by(&:name).map(&:name)
end
def scd(klass)
klass.columns.sort_by(&:name).each do |column|
puts "#{column.name} - #{column.type}"
end
nil
end
def sql(query)
ActiveRecord::Base.connection.select_all(query)
end
require 'logger'
Object.const_set(:RAILS_DEFAULT_LOGGER, Logger.new(STDOUT))
def loud_logger
set_logger_to Logger.new(STDOUT)
end
def quiet_logger
set_logger_to nil
end
def set_logger_to(logger)
ActiveRecord::Base.logger = logger
ActiveRecord::Base.clear_active_connections!
end
end
# FIXING RUBY'S IRB HISTORY
require "readline"
require 'irb/ext/save-history'
module IRB
module HistorySavingAbility
def load_history
hist = IRB.conf[:HISTORY_FILE]
hist = IRB.rc_file("_history") unless hist
HISTORY << ""
File.foreach(hist) do |line| HISTORY << line.chomp end
rescue Errno::ENOENT # history file doesn't yet exist
end
end
end
#History configuration
IRB.conf[:SAVE_HISTORY] = 1000
IRB.conf[:HISTORY_FILE] = "#{ENV['HOME']}/.irb_history"
IRB.conf[:HISTORY_NO_DUPS] = true
IRBRC_LOADED=true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.