Last active
August 29, 2015 14:27
-
-
Save kjy00302/600e01a02bb7fbaed210 to your computer and use it in GitHub Desktop.
All work and no play makes Jack a dull boy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import StringIO, time, sys, random | |
#All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. All work and no play makes Jack a dull boy. | |
boy=StringIO.StringIO("All work and no play makes Jack a dull boy.") | |
jack=0 | |
work=0.05 | |
dull=0.2 | |
play=boy.read(1) #All work and no play makes Jack a dull boy. | |
while(play != ""): | |
sys.stdout.write(play) | |
sys.stdout.flush() | |
play=boy.read(1) | |
time.sleep(work) | |
time.sleep(work*10) | |
print("") | |
boy.seek(0) | |
time.sleep(work*40) | |
print("") | |
time.sleep(work*15) | |
while(True): | |
play=boy.read(1) | |
if(play != ""): | |
#All wofk and no pkay mskes Jadk a dull boy. | |
#https://github.com/mmehnert/xscreensaver/blob/master/hacks/xjack.c | |
if((random.random()<jack) & (play == "a")): | |
play = random.choice(["s", "q", "w"]) | |
elif((random.random()<jack) & (play == "A")): | |
play = random.choice(["S", "Q", "W"]) | |
elif((random.random()<jack)&(play == "b")): | |
play = random.choice(["g", "v", "h", "n"]) | |
elif((random.random()<jack)&(play == "c")): | |
play = random.choice(["x", "d", "f", "v"]) | |
elif((random.random()<jack)&(play == "d")): | |
play = random.choice(["s", "e", "r", "f", "c", "x"]) | |
elif((random.random()<jack)&(play == "e")): | |
play = random.choice(["w", "s", "d", "r", "f"]) | |
elif((random.random()<jack)&(play == "J")): | |
play = random.choice(["h", "u", "i", "k", "m", "n"]) | |
elif((random.random()<jack)&(play == "k")): | |
play = random.choice(["j", "i", "o", "l", ",", "m"]) | |
elif((random.random()<jack)&(play == "l")): | |
play = random.choice(["k", "o", "p", ";", ".", ',']) | |
elif((random.random()<jack)&(play == "m")): | |
play = random.choice(["n", "j", "k", ","]) | |
elif((random.random()<jack)&(play == "n")): | |
play = random.choice(["b", "h", "j", "n"]) | |
elif((random.random()<jack)&(play == "o")): | |
play = random.choice(["i", "k", "l", "p", "0", "9"]) | |
elif((random.random()<jack)&(play == "p")): | |
play = random.choice(["o", "l", ";", "[", "-", "0"]) | |
elif((random.random()<jack)&(play == "r")): | |
play = random.choice(["e", "d", "f", "t", "5", "4"]) | |
elif((random.random()<jack)&(play == "s")): | |
play = random.choice(["a", "w", "e", "d", "x", "z"]) | |
elif((random.random()<jack)&(play == "u")): | |
play = random.choice(["y", "h", "j", "i", "8", "7"]) | |
elif((random.random()<jack)&(play == "w")): | |
play = random.choice(["q", "a", "s", "e", "3", "2"]) | |
elif((random.random()<jack)&(play == "y")): | |
play = random.choice(["u", "h", "g", "t", "6", "7"]) | |
elif((random.random()<jack)&(play == ".")): | |
play = random.choice([",", "l", ";", "/"]) | |
# if(random.random()<jack): #all wOrk aNd no pLay mAkes JacK a dUll boY. | |
# play = play.swapcase() | |
if(random.random()<jack*0.01): #A l w rk an no pl y ma es J ck a d ll oy. | |
play = " " | |
sys.stdout.write(play) | |
sys.stdout.flush() | |
else: | |
time.sleep(work*20) | |
print("") | |
time.sleep(work*10) | |
boy.seek(0) | |
work = random.random()*0.2 | |
if(jack < dull): | |
jack = jack + random.random()*0.01 | |
else: | |
jack = jack - random.random()*0.2 | |
time.sleep(work) | |
#W;p 2ptl shs k o.st nslda mqxm s fh,. g0g; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment