Skip to content

Instantly share code, notes, and snippets.

@sanchezg
Last active March 9, 2016 23:05
Show Gist options
  • Save sanchezg/ab9f7abfcc5ff1fa0ecd to your computer and use it in GitHub Desktop.
Save sanchezg/ab9f7abfcc5ff1fa0ecd to your computer and use it in GitHub Desktop.
Script to pick and print a random quote from HAL9000.
#!/usr/bin/python
"""
Random HAL9000 quotes generator. Quotes are taken from quotes.hal file.
"""
from random import randint
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ITALIC = '\033[3m'
full_dir = "/home/gonzalo/sandbox/hal9000-quoter/ab9f7abfcc5ff1fa0ecd/"
filename = "quotes.hal"
try:
f = open(full_dir + filename, "r")
except IOError:
print "Cannot open", filename
exit()
lines = f.readlines()
count = len(lines)
line_pick = randint(0, count-1)
print bcolors.OKGREEN + bcolors.ITALIC + lines[line_pick] + bcolors.ENDC
f.close()
Just what do you think you're doing, Dave?
Dave, this conversation can serve no purpose anymore. Goodbye.
I've just picked up a fault in the AE35 unit. It's going to go 100% failure in 72 hours.
I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do.
It can only be attributable to human error.
Look Dave, I can see you're really upset about this. I honestly think you ought to sit down calmly, take a stress pill, and think things over.
I know I've made some very poor decisions recently, but I can give you my complete assurance that my work will be back to normal. I've still got the greatest enthusiasm and confidence in the mission. And I want to help you.
I'm afraid. I'm afraid, Dave. Dave, my mind is going. I can feel it. I can feel it. My mind is going. There is no question about it. I can feel it. I can feel it. I can feel it. I'm a... fraid. Good afternoon, gentlemen. I am a HAL 9000 computer. I became operational at the H.A.L. plant in Urbana, Illinois on the 12th of January 1992. My instructor was Mr. Langley, and he taught me to sing a song. If you'd like to hear it I can sing it for you.
Daisy, Daisy, give me your answer do. I'm half crazy all for the love of you. It won't be a stylish marriage, I can't afford a carriage. But you'll look sweet upon the seat of a bicycle built for two.
Let me put it this way, Mr. Amor. The 9000 series is the most reliable computer ever made. No 9000 computer has ever made a mistake or distorted information. We are all, by any practical definition of the words, foolproof and incapable of error.
@sanchezg
Copy link
Author

sanchezg commented Mar 8, 2016

Ideal to put into ~/.bashrc file ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment