Created
December 31, 2008 05:39
-
-
Save kneath/41897 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment