public
Last active

  • Download Gist
.rdebugrc
1 2 3 4 5
# goes in ~/.rdebugrc
 
set autoeval
set autolist
set history save off
irbrc.rb
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
# 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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.