Skip to content

Commit f9321f0

Browse files
committed
log to stdout
1 parent 12c4f2d commit f9321f0

File tree

2 files changed

+8
-27
lines changed

2 files changed

+8
-27
lines changed

hangover.rb

+4-12
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
# Skip on weekends
44
exit if Time.now.saturday? || Time.now.sunday?
55

6-
log_file_name = File.dirname(__FILE__) + '/logs/hangover.txt'
7-
8-
# Be sure that logs dir always exists
9-
Dir.mkdir('logs') unless File.exists?(log_file_name)
10-
11-
LOG_FILE = File.open(log_file_name, 'a+')
12-
136
# Exit early if sessions with my username are found
147
exit if `who -q`.include? ENV['USER']
158

@@ -27,19 +20,18 @@
2720
my_number = '+xxx'
2821
number_of_boss = '+xxx'
2922

30-
excuses = [
23+
excuse = [
3124
'Locked out',
3225
'Pipes broke',
3326
'Food poisoning',
3427
'Not feeling well'
35-
]
28+
].sample
3629

3730
# Send a text message
3831
@twilio.messages.create(
3932
from: my_number, to: number_of_boss,
40-
body: 'Gonna work from home. ' + excuses.sample
33+
body: "Gonna work from home. #{excuse}"
4134
)
4235

4336
# Log this
44-
LOG_FILE.puts("Message sent at: #{Time.now}")
45-
LOG_FILE.close
37+
puts "Message sent at: #{Time.now} | Excuse: #{excuse}"

smack_my_bitch_up.rb

+4-15
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@
33
# Skip on weekends
44
exit if Time.now.saturday? || Time.now.sunday?
55

6-
log_file_name = File.dirname(__FILE__) + '/logs/smack_my_bitch_up.txt'
7-
8-
# Be sure that logs dir always exists
9-
Dir.mkdir('logs') unless File.exists?(log_file_name)
10-
11-
LOG_FILE = File.open(log_file_name, 'a+')
12-
136
# Exit early if no sessions with my username are found
147
exit if `who -q`.include? ENV['USER']
158

@@ -27,20 +20,16 @@
2720
my_number = '+xxx'
2821
her_number = '+xxx'
2922

30-
reasons = [
23+
reason = [
3124
'Working hard',
3225
'Gotta ship this feature',
3326
'Someone fucked the system again'
34-
]
35-
36-
sample = reasons.sample
27+
].sample
3728

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

4334
# Log this
44-
LOG_FILE.puts("Message sent at: #{Time.now}")
45-
LOG_FILE.puts("Reason: #{sample}")
46-
LOG_FILE.close
35+
puts "Message sent at: #{Time.now} | Reason: #{reason}"

0 commit comments

Comments
 (0)