This commit is contained in:
Daniel Vinciguerra 2017-05-09 16:55:51 +00:00 committed by GitHub
commit 5bccf1cbdc
4 changed files with 130 additions and 0 deletions

33
perl5/fucking-coffee.pl Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
use DateTime;
use Net::Telnet ();
# Skip on weekends
my $day_of_week = DateTime->now->day_of_week();
exit if $day_of_week == 6 || $day_of_week == 7;
# Exit early if no sessions with my username are found
exit unless `who | grep $ENV{USER}`;
#my $coffee_machine_ip = '10.10.42.42';
my $coffee_machine_ip = 'localhost';
my $password = '1234';
my $delay = 24;
my $con = Net::Telnet->new(
-host => $coffee_machine_ip, -timeout => 30
);
$con->waitfor('/password: $/i');
$con->print($password);
$con->cmd('sys brew');
sleep $delay;
$con->cmd('sys pour');
$con->close;

46
perl5/hangover.pl Normal file
View File

@ -0,0 +1,46 @@
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
use DateTime;
use SMS::Send::Twilio;
# Skip on weekends
my $day_of_week = DateTime->now->day_of_week();
exit if $day_of_week == 6 || $day_of_week == 7;
# Exit early if no sessions with my username are found
exit unless `who | grep $ENV{USER}`;
# Phone numbers
my $MY_NUMBER = '+xxx';
my $NUMBER_OF_BOSS = '+xxx';
my $EXCUSES = [
'Locked out',
'Pipes broke',
'Food poisoning',
'Not feeling well',
];
my $rand = int(rand(scalar(@$EXCUSES)));
my $random_excuse = $EXCUSES->[$rand];
my $message = "Gonna work from home. ${random_excuse}";
# Send a text message
my $twilio = SMS::Send->new('Twilio',
_accountsid => $ENV{TWILIO_ACCOUNT_SID},
_authtoken => $ENV{TWILIO_AUTH_TOKEN},
_from => $MY_NUMBER,
);
my $sent = $sender->send_sms(
text => $message, to => $NUMBER_OF_BOSS
);
# Log errors
die "Failed to send SMS" if not $sent;

6
perl5/kumar-asshole.pl Normal file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;

View File

@ -0,0 +1,45 @@
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
use DateTime;
use SMS::Send::Twilio;
# Skip on weekends
my $day_of_week = DateTime->now->day_of_week();
exit if $day_of_week == 6 || $day_of_week == 7;
# Exit early if no sessions with my username are found
exit unless `who | grep $ENV{USER}`;
# Phone numbers
my $MY_NUMBER = '+xxx';
my $HER_NUMBER = '+xxx';
my $REASONS = [
'Working hard',
'Gotta ship this feature',
'Someone fucked the system again',
];
my $rand = int(rand(scalar(@$REASONS)));
my $random_reason = $REASONS->[$rand];
my $message = "Late at work. ${random_reason}";
# Send a text message
my $twilio = SMS::Send->new('Twilio',
_accountsid => $ENV{TWILIO_ACCOUNT_SID},
_authtoken => $ENV{TWILIO_AUTH_TOKEN},
_from => $MY_NUMBER,
);
my $sent = $sender->send_sms(
text => $message, to => $HER_NUMBER
);
# Log errors
die "Failed to send SMS" if not $sent;