From f7b7f6e7ad882188e4075c5aab9755d573bfb20c Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 13:14:09 +0300 Subject: [PATCH 01/12] made some coffee --- fucking_coffee.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 fucking_coffee.py diff --git a/fucking_coffee.py b/fucking_coffee.py new file mode 100644 index 0000000..8e28860 --- /dev/null +++ b/fucking_coffee.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python +import datetime +import sys +import subprocess +import telnetlib +import time + +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() + +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() + + + + + + + + + From c23f11a822cf10f7de94876fb63960d2cf79d6a6 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 16:19:32 +0300 Subject: [PATCH 02/12] Increasing DRYness --- fucking_coffee.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fucking_coffee.py b/fucking_coffee.py index 8e28860..7dea915 100644 --- a/fucking_coffee.py +++ b/fucking_coffee.py @@ -8,7 +8,7 @@ import time today = datetime.date.today() # skip weekends -if today.strftime('%A') == 'Saturday' || today('%A') == 'Sunday': +if today.strftime('%A') in ('Saturday', 'Sunday'): sys.exit() # exit if no sessions with my username are found From dbc4f125b9e3d519c9c8b7ff8e0b8af7502433c8 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 20:07:56 +0300 Subject: [PATCH 03/12] housekeeping --- fucking_coffee.py => python/fucking_coffee.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) rename fucking_coffee.py => python/fucking_coffee.py (96%) mode change 100644 => 100755 diff --git a/fucking_coffee.py b/python/fucking_coffee.py old mode 100644 new mode 100755 similarity index 96% rename from fucking_coffee.py rename to python/fucking_coffee.py index 7dea915..a510b02 --- a/fucking_coffee.py +++ b/python/fucking_coffee.py @@ -1,4 +1,5 @@ #!/usr/bin/env python + import datetime import sys import subprocess @@ -30,13 +31,4 @@ time.sleep(64) # love the smell! con.write("sys pour\n") -con.close() - - - - - - - - - +con.close() From f3c9c2d2edf4e29749c3f2183d3ce9e0e7d9e799 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 14:00:01 +0300 Subject: [PATCH 04/12] The hangover script --- hangover.py | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 hangover.py diff --git a/hangover.py b/hangover.py new file mode 100644 index 0000000..3e552a0 --- /dev/null +++ b/hangover.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python + +import datetime +import os +import random +from twilio.rest import TwilioRestClient +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' +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() From 87fbe643c9bd8277e3c51468cf1f7f1b193b2af1 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 15:47:17 +0300 Subject: [PATCH 05/12] corrected missing import error --- hangover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hangover.py b/hangover.py index 3e552a0..676429a 100644 --- a/hangover.py +++ b/hangover.py @@ -5,7 +5,7 @@ import os import random from twilio.rest import TwilioRestClient from time import strftime - +import subprocess today = datetime.date.today() From 95931ff7be7d0664d463e49ce27cc2763ddd3433 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 20:11:06 +0300 Subject: [PATCH 06/12] housekeeping --- python/hangover.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 python/hangover.py diff --git a/python/hangover.py b/python/hangover.py new file mode 100755 index 0000000..676429a --- /dev/null +++ b/python/hangover.py @@ -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() From be7539418c62a15da76754733d8fe861c8806a98 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 21:38:27 +0300 Subject: [PATCH 07/12] Remove duplicated file --- hangover.py | 57 ----------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 hangover.py diff --git a/hangover.py b/hangover.py deleted file mode 100644 index 676429a..0000000 --- a/hangover.py +++ /dev/null @@ -1,57 +0,0 @@ -#!/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() From 77e936387fff6751d2e1e415101d8eddd8c3b636 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 15:16:18 +0300 Subject: [PATCH 08/12] Kumar's script --- kumar_asshole.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 kumar_asshole.py diff --git a/kumar_asshole.py b/kumar_asshole.py new file mode 100644 index 0000000..36f5f67 --- /dev/null +++ b/kumar_asshole.py @@ -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.") From dbeecdb4a5bc649217af4c568cc41302d82817c7 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 20:13:58 +0300 Subject: [PATCH 09/12] housekeeping --- kumar_asshole.py => python/kumar_asshole.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename kumar_asshole.py => python/kumar_asshole.py (100%) mode change 100644 => 100755 diff --git a/kumar_asshole.py b/python/kumar_asshole.py old mode 100644 new mode 100755 similarity index 100% rename from kumar_asshole.py rename to python/kumar_asshole.py From d2285f93d315454620b161e67993f74f482788e3 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 15:44:59 +0300 Subject: [PATCH 10/12] send messages to wife --- wife.py | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 wife.py diff --git a/wife.py b/wife.py new file mode 100644 index 0000000..79a8de9 --- /dev/null +++ b/wife.py @@ -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="Gonna work from home. " + 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() From c7bc32a0183f1e7ef38720fd29e48e8a257101e2 Mon Sep 17 00:00:00 2001 From: Yann Guineau Date: Mon, 23 Nov 2015 15:48:06 +0100 Subject: [PATCH 11/12] 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. --- wife.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wife.py b/wife.py index 79a8de9..398c881 100644 --- a/wife.py +++ b/wife.py @@ -39,7 +39,7 @@ client = TwilioRestClient(TWILIO_ACCOUNT_SID, TWILIO_AUTH_TOKEN) client.messages.create( to=her_number, from=my_number, - body="Gonna work from home. " + random.choice(reasons) + body="Late at work. " + random.choice(reasons) ) try: From 607d7b121c908bc055a86a1bd4e50189deaea2d1 Mon Sep 17 00:00:00 2001 From: EL Date: Mon, 23 Nov 2015 20:16:05 +0300 Subject: [PATCH 12/12] housekeeping --- wife.py => python/wife.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename wife.py => python/wife.py (100%) mode change 100644 => 100755 diff --git a/wife.py b/python/wife.py old mode 100644 new mode 100755 similarity index 100% rename from wife.py rename to python/wife.py