add link to the original quote
made some coffee Increasing DRYness housekeeping The hangover script corrected missing import error housekeeping Remove duplicated file Kumar's script housekeeping send messages to wife Fix text for wife alert Your wife is not your boss, she don't care if you work at home today, but she worries of the hour at which you come tonight. housekeeping
This commit is contained in:
parent
88259a6f67
commit
dea529dcff
|
|
@ -19,6 +19,7 @@ story](https://www.jitbit.com/alexblog/249-now-thats-what-i-call-a-hacker/)_:
|
|||
|
||||
> xxx: holy sh*t I'm keeping those
|
||||
|
||||
Original: http://bash.im/quote/436725 (in Russian)
|
||||
Pull requests with other implementations (Python, Perl, Shell, etc) are welcome.
|
||||
|
||||
## Usage
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import datetime
|
||||
import sys
|
||||
import subprocess
|
||||
import telnetlib
|
||||
import time
|
||||
|
||||
today = datetime.date.today()
|
||||
|
||||
# skip weekends
|
||||
if today.strftime('%A') in ('Saturday', 'Sunday'):
|
||||
sys.exit()
|
||||
|
||||
# exit if no sessions with my username are found
|
||||
output = subprocess.check_output('who')
|
||||
if 'my_username' not in output:
|
||||
sys.exit()
|
||||
|
||||
coffee_machine_ip = '10.10.42.42'
|
||||
password = '1234'
|
||||
password_prompt = 'Password: '
|
||||
|
||||
con = telnetlib.Telnet(coffee_machine_ip)
|
||||
con.read_until(password_prompt)
|
||||
con.write(password + "\n")
|
||||
|
||||
# Make some coffee!
|
||||
con.write("sys brew\n")
|
||||
time.sleep(64)
|
||||
|
||||
# love the smell!
|
||||
con.write("sys pour\n")
|
||||
con.close()
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import random
|
||||
from twilio.rest import TwilioRestClient
|
||||
from time import strftime
|
||||
import subprocess
|
||||
|
||||
today = datetime.date.today()
|
||||
|
||||
# skip weekends
|
||||
if today.strftime('%A') == 'Saturday' || today('%A') == 'Sunday':
|
||||
sys.exit()
|
||||
|
||||
# exit if no sessions with my username are found
|
||||
output = subprocess.check_output('who')
|
||||
if 'my_username' not in output:
|
||||
sys.exit()
|
||||
|
||||
# returns 'None' if the key doesn't exist
|
||||
TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID')
|
||||
TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
|
||||
|
||||
# Phone numbers
|
||||
my_number = '+xxx'
|
||||
number_of_boss = '+xxx'
|
||||
|
||||
excuses = [
|
||||
'Locked out',
|
||||
'Pipes broke',
|
||||
'Food poisoning',
|
||||
'Not feeling well'
|
||||
]
|
||||
|
||||
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
|
||||
client.messages.create(
|
||||
to=number_of_boss,
|
||||
from=my_number,
|
||||
body="Gonna work from home. " + random.choice(excuses)
|
||||
)
|
||||
|
||||
try:
|
||||
f = open('logs/file.txt', 'a')
|
||||
except IOError as e:
|
||||
# dir & file don't exist; create them
|
||||
os.mkdir('logs')
|
||||
f = open('logs/file.txt', 'a')
|
||||
except Exception as e:
|
||||
print e
|
||||
else:
|
||||
pass
|
||||
|
||||
# log it
|
||||
f.write("Message sent at " + strftime("%a, %d %b %Y %H:%M:%S") + "\n")
|
||||
f.close()
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import gmail
|
||||
import sys
|
||||
import re
|
||||
|
||||
GMAIL_USERNAME = ENV['GMAIL_USERNAME']
|
||||
GMAIL_PASSWORD = ENV['GMAIL_PASSWORD']
|
||||
|
||||
g = gmail.login(GMAIL_USERNAME, GMAIL_PASSWORD)
|
||||
|
||||
if not g.logged_in:
|
||||
sys.exit()
|
||||
|
||||
msgs = g.inbox().mail(sender="kumar.a@example.com", unread=True)
|
||||
|
||||
pattern = re.compile("\bsorry\b | \bhelp\b | \bwrong\b ", flags=re.I)
|
||||
|
||||
for msg in msgs:
|
||||
if pattern.match(msg.body):
|
||||
msg.label("Database fixes")
|
||||
msg.reply("No problem. I've fixed it. \n\n Please be careful next time.")
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import datetime
|
||||
import os
|
||||
import random
|
||||
from twilio.rest import TwilioRestClient
|
||||
import subprocess
|
||||
import sys
|
||||
from time import strftime
|
||||
|
||||
|
||||
today = datetime.date.today()
|
||||
|
||||
# skip weekends
|
||||
if today.strftime('%A') == 'Saturday' || today('%A') == 'Sunday':
|
||||
sys.exit()
|
||||
|
||||
# exit if no sessions with my username are found
|
||||
output = subprocess.check_output('who')
|
||||
if 'my_username' not in output:
|
||||
sys.exit()
|
||||
|
||||
# returns 'None' if the key doesn't exist
|
||||
TWILIO_ACCOUNT_SID = os.environ.get('TWILIO_ACCOUNT_SID')
|
||||
TWILIO_AUTH_TOKEN = os.environ.get('TWILIO_AUTH_TOKEN')
|
||||
|
||||
# Phone numbers
|
||||
my_number = '+xxx'
|
||||
her_number = '+xxx'
|
||||
|
||||
reasons = [
|
||||
'Working hard',
|
||||
'Gotta ship this feature',
|
||||
'Someone fucked the system again'
|
||||
]
|
||||
|
||||
client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN)
|
||||
|
||||
client.messages.create(
|
||||
to=her_number,
|
||||
from=my_number,
|
||||
body="Late at work. " + random.choice(reasons)
|
||||
)
|
||||
|
||||
try:
|
||||
f = open('logs/file.txt', 'a')
|
||||
except IOError as e:
|
||||
# dir & file don't exist; create them
|
||||
os.mkdir('logs')
|
||||
f = open('logs/file.txt', 'a')
|
||||
except Exception as e:
|
||||
print e
|
||||
else:
|
||||
pass
|
||||
|
||||
# log it
|
||||
f.write("Message sent at " + strftime("%a, %d %b %Y %H:%M:%S") + "\n")
|
||||
f.close()
|
||||
Loading…
Reference in New Issue