Skip to content

Commit

Permalink
log to stdout
Browse files Browse the repository at this point in the history
  • Loading branch information
NARKOZ committed Nov 25, 2015
1 parent 12c4f2d commit f9321f0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
16 changes: 4 additions & 12 deletions hangover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
# Skip on weekends
exit if Time.now.saturday? || Time.now.sunday?

log_file_name = File.dirname(__FILE__) + '/logs/hangover.txt'

# Be sure that logs dir always exists
Dir.mkdir('logs') unless File.exists?(log_file_name)

LOG_FILE = File.open(log_file_name, 'a+')

# Exit early if sessions with my username are found
exit if `who -q`.include? ENV['USER']

Expand All @@ -27,19 +20,18 @@
my_number = '+xxx'
number_of_boss = '+xxx'

excuses = [
excuse = [
'Locked out',
'Pipes broke',
'Food poisoning',
'Not feeling well'
]
].sample

# Send a text message
@twilio.messages.create(
from: my_number, to: number_of_boss,
body: 'Gonna work from home. ' + excuses.sample
body: "Gonna work from home. #{excuse}"
)

# Log this
LOG_FILE.puts("Message sent at: #{Time.now}")
LOG_FILE.close
puts "Message sent at: #{Time.now} | Excuse: #{excuse}"
19 changes: 4 additions & 15 deletions smack_my_bitch_up.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
# Skip on weekends
exit if Time.now.saturday? || Time.now.sunday?

log_file_name = File.dirname(__FILE__) + '/logs/smack_my_bitch_up.txt'

# Be sure that logs dir always exists
Dir.mkdir('logs') unless File.exists?(log_file_name)

LOG_FILE = File.open(log_file_name, 'a+')

# Exit early if no sessions with my username are found
exit if `who -q`.include? ENV['USER']

Expand All @@ -27,20 +20,16 @@
my_number = '+xxx'
her_number = '+xxx'

reasons = [
reason = [
'Working hard',
'Gotta ship this feature',
'Someone fucked the system again'
]

sample = reasons.sample
].sample

# Send a text message
@twilio.messages.create(
from: my_number, to: her_number, body: 'Late at work. ' + sample
from: my_number, to: her_number, body: "Late at work. #{reason}"
)

# Log this
LOG_FILE.puts("Message sent at: #{Time.now}")
LOG_FILE.puts("Reason: #{sample}")
LOG_FILE.close
puts "Message sent at: #{Time.now} | Reason: #{reason}"

0 comments on commit f9321f0

Please sign in to comment.