Skip to content

Instantly share code, notes, and snippets.

@StuntsPT
Created September 29, 2015 15:53
Show Gist options
  • Save StuntsPT/e307f1855d7c8aabde53 to your computer and use it in GitHub Desktop.
Save StuntsPT/e307f1855d7c8aabde53 to your computer and use it in GitHub Desktop.
Randomatic_3000.pl patched to work on linux too.
#!/usr/bin/env perl
#
# randomatic_3000.pl
#
# Copyright (c) 2015 Keith Bradnam
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software,
# and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
# OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
use strict;
use warnings FATAL => 'all';
use List::Util qw(shuffle);
############################################################################################################
#
# Note: this script needs to be run on a computer running OS X ~~(sorry Mick Watson)~~ or linux.
#
############################################################################################################
# change Apple voice from default
my $voice = 'Samantha';
my $talk = "";
if ($^O eq "linux"){
$talk = "espeak";
}
else {
$talk = "say -v ".$voice
}
# Read twitter names of entrants from DATA section and store in array
my @entries;
while(<DATA>){
chomp();
push(@entries, $_);
}
# shuffle names 100 times (this is very pointless)
print "\n\n";
print "###################################################################################\n";
print "## ##\n";
print "## W E L C O M E T O T H E R A N D O M A T I C 3 0 0 0 ##\n";
print "## ##\n";
print "## Shuffling, scrambling, and otherwise randomizing names since 2015-09-28 ##\n";
print "## ##\n";
print "###################################################################################\n\n";
sleep 1;
print "DISCLAIMER: This Perl script contains small parts and may present a choking hazard.\n\n";
sleep 3;
print "INITIATING: Randomizing array of 65 contestant names.\n\n";
for (my $i = 1; $i <= 100; $i++){
@entries = shuffle(@entries);
}
# wait 3 seconds
sleep 2;
# build up array of possible farewell messages
my @messages;
push(@messages, "goodbye", "farewell", "adios", "sayonara", "adieu", "ciao", "cheerio", "shalom");
push(@messages, "so long", "toodle pip", "go directly to jail, do not pass go, do not collect 200 dollars", "bon voyage", "parting is such sweet sorrow", "catch you later", "laters");
push(@messages, "later dude", "dont forget your coat", "peace out", "see you soon", "you are fired", "take it easy");
push(@messages, "Nice knowing you", "peace out", "get out of here", "may the Force be with you", "keep it real", "it has been real");
push(@messages, "so long and thanks for all the fish", "was that the best you could do?", "keep living the dream", "have a good one");
push(@messages, "You came, you saw, you lost ", "liv long, and prosper", "Till we meet again, half naked and swinging from trees");
push(@messages, "Time to hit the road", "time to make tracks", "I will be back, but you wont be", "hasta la vista, baby");
push(@messages, "all the best", "smell you later", "this is the end", "bye!!!", "your time is over", "game over man, game over");
push(@messages, "see you later alligator", "the end is nigh", "just go. walk out the door. turn around now. you are not welcome any more");
push(@messages, "you say hello and I say goodbye. goodbye goodbye. I dont know why you say hello I say goodbye");
push(@messages, "you know where the door is", "well it was nice to know you", "i feel we had something special", "i wont forget you");
push(@messages, "this is the end of the line", "you want me to open the pod bay doors? I am afraid I cannot do that");
push(@messages, "this is our last goodbye", "goodbye stranger, it has been nice");
# Introduce the selection process
print "SELECTING: Time to implement natural selection! The weak will perish. Only the strong will survive!\n\n";
sleep 3;
system($talk." Testing, testing, is this thing on?");
system($talk." I will now proceed with the eliminations.");
sleep 2;
############################################
#
# main loop for selecting entries
#
############################################
while (@entries){
my $message;
# there are a few messages that I want to appear at particular times
if(scalar(@entries) == 65){
$message = "you are the weakest link, goodbye";
} elsif(scalar(@entries) == 64){
$message = "leaving so soon?";
}elsif(scalar(@entries) == 63){
$message = "were you even trying?";
}elsif(scalar(@entries) == 62){
$message = "sunk without a trace";
}elsif(scalar(@entries) == 61){
$message = "was it worth it?";
}elsif(scalar(@entries) == 60){
$message = "please close the door on the way out";
}elsif(scalar(@entries) == 3){
$message = "a podium finish! not too shabby";
}elsif(scalar(@entries) == 2){
$message = "close, but no cigar";
}else{
$message = splice(@messages, rand(@messages), 1)
}
# randomly choose entrant
my $random_pos = int(rand(@entries));
my $name = $entries[$random_pos];
# modify their name for easier pronunciation
my $spoken_name = $name;
$spoken_name =~ s/^@/at /;
system("$talk $message $spoken_name");
print "Eliminating $name\n";
splice(@entries, $random_pos, 1);
last if (scalar(@entries) == 1);
}
# announce winner!
print "\n\nOPENING GOLDEN ENVELOPE: a winner has been chosen\n\n";
sleep 3;
system("$talk the winner");
sleep 1;
system("$talk of the competition");
sleep 1;
system("$talk to win a signed copy of");
sleep 1;
system("$talk Bioinformatics Data skills");
sleep 1;
system("$talk by Vince Buffalo, sometimes known as Buffalo Vince");
sleep 1;
system("$talk is as follows ");
sleep 2;
system("$talk drum roll please");
sleep 3;
my $spoken_name = $entries[0];
$spoken_name =~ s/^@/at /;
system("$talk $spoken_name");
print "$entries[0]!\n\n\n";
sleep 1;
system("$talk Congratulations! Not only have you won a copy of a fantastic book, you are also the first ever person to have been selected by the randomatic 3000");
system("$talk This script will now self destruct in 10 seconds");
sleep 5;
exit;
# all contestant names stored here
__DATA__
@1234jc4321
@a5hi5h
@aggodbout
@alexeome
@alipirani88
@BaCh_mira
@BiochemPhD
@CiaranOFlynn
@copypasteusa
@D_Cassatella
@davetang31
@DjekNad
@dna_puzzles
@dnatimes
@FeThalen
@fgblanch
@flobosg
@Fomightez
@FPinaMartins
@Geek_y
@genomepandit
@grmunjal
@guamfr
@idjoly
@ismailud
@jasdumas
@jnfass
@JoDaub
@kutchko
@leprevostfv
@lexnederbragt
@Limenian
@madhubioinfo
@MarisolAMtz
@Mattagenomics
@MColebrook
@mdperry
@mekossack
@MicroTolo
@minisciencegirl
@monsterbashseq
@Natasha___P
@neilfws
@OmicsOmicsBlog
@pdiakumis
@peter1402
@pheadtony
@pimbongaerts
@pseudonym_cp
@psmaldino
@rmflight
@RnDries
@robin_andersson
@robsyme
@sentausa
@shoemakah
@showalterdn
@sjackman
@smurali89
@srbehera11
@tangming2005
@torstenseemann
@upendra_35
@whiteGenomics
@ZKamvar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment