kneath (owner)

Revisions

gist: 41897 Download_button fork
public
Public Clone URL: git://gist.github.com/41897.git
Embed All Files: show embed
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
#!/usr/local/bin/ruby
 
# Fun script to see your income potential if you bill hourly
# Calculates how many billable days are in a given month and approximates
# your income potential depending on the input below
#
# To use: save as a file on your system, chmod +x and call it. Example:
# $ ./billable.rb
# $ Week days: 22
# $ 101% of normal
# $ Income potential: $6600..$8800..$13200
 
 
# Customize this hash to set the year, month, billable rate and so on
config = {
  :year => 2009, # year to use
  :month => 1, # month to use
  :rate => 100, # billable rate, in $$
  :high_billable => 6, # most hours per day to expect
  :low_billable => 3, # least hours per day to expect
  :target_billable => 4, # target hours per day to expect
}
 
 
require 'date'
 
class Date
  def self.week_days_in_year(year)
    (Date.new(year,1,1) .. Date.new(year,12,-1)).select{|d|(1..5).include?(d.wday)}
  end
  
  def self.week_days_in_month(year, month)
    (Date.new(year,month,1) .. Date.new(year,month,-1)).select{|d|(1..5).include?(d.wday)}
  end
end
 
wdays = Date.week_days_in_month(config[:year], config[:month]).size
all_wdays = Date.week_days_in_year(config[:year]).size
percent_avg = wdays.to_f/(all_wdays.to_f/12.0)*100
 
income_low = config[:rate]*config[:low_billable]*wdays
income_target = config[:rate]*config[:target_billable]*wdays
income_high = config[:rate]*config[:high_billable]*wdays
 
puts "Week days: #{wdays}\n"
puts "#{percent_avg.to_i}% of normal"
puts "Income potential: $#{income_low}..$#{income_target}..$#{income_high}"