-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpryrc
More file actions
41 lines (30 loc) · 667 Bytes
/
pryrc
File metadata and controls
41 lines (30 loc) · 667 Bytes
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
## Pry Config
Pry.config.pager = false
Pry.config.editor = "vim"
Pry.config.prompt = [proc{"? "}, proc{"| "}]
if defined?(ActiveRecord::Base)
# Get random object
class ActiveRecord::Base
def self.random
self.order("rand()").limit(1).first
end
end
end
# Useful collections
def a
(1..20).to_a
end
def h
{:hello => "world", :free => "of charge"}
end
## Benchmarking
# Inspired by <http://stackoverflow.com/questions/123494/whats-your-favourite-irb-trick/123834#123834>.
def time(repetitions = 100, &block)
require 'benchmark'
Benchmark.bm{|b| b.report{repetitions.times(&block)}}
end
## Odds and Ends
def beep
putc ?\a
nil
end