Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gabrielbissey/8a726a5891945f771676c2e724b32d1a to your computer and use it in GitHub Desktop.
Save gabrielbissey/8a726a5891945f771676c2e724b32d1a to your computer and use it in GitHub Desktop.
Take a break every hour
import time
import webbrowser
import random
#Feel Good Inc.
a = "https://www.youtube.com/watch?v=NxxjLD2pmlk"
#When You Were Young
b = "https://www.youtube.com/watch?v=0k-v9cp9Fxc"
#Burnin' For You
c = "https://www.youtube.com/watch?v=ipqqEFoJPL4"
#Changes
d = "https://www.youtube.com/watch?v=omhNnvX3Sx0"
#Rock the Casbah
e = "https://www.youtube.com/watch?v=0pCFVX6lzHU"
#Down Under
f = "https://www.youtube.com/watch?v=hfmxO-HQ5rU"
#Take Me Out
g = "https://www.youtube.com/watch?v=RMmRac5wYv4"
#Ruby
h = "https://www.youtube.com/watch?v=XioruVM0pU8"
#Here I Drempt I Was an Architect
i = "https://www.youtube.com/watch?v=Sy0NySwzDzY"
#Enjoy the Silence
j = "https://www.youtube.com/watch?v=6bYKZbWxKoQ"
#The Promise
k = "https://www.youtube.com/watch?v=vyLtOeT-5vY"
#Hold Me Now
l = "https://www.youtube.com/watch?v=FxvbED6gTBI"
#Bring Me to Life
m = "https://www.youtube.com/watch?v=6CA-8OSX5U0"
#Kryptonite
n = "https://www.youtube.com/watch?v=tQ-EM6DbFQk"
#All Star
o = "https://www.youtube.com/watch?v=Je_8A5hurSY"
#Africa
p = "https://www.youtube.com/watch?v=QAo_Ycocl1E"
#Viva la Vida
q = "https://www.youtube.com/watch?v=zOQ4ld6NsXE"
#Over the Hills and Far Away
r = "https://www.youtube.com/watch?v=60iwmyhV8pQ"
#Seasons Change
s = "https://www.youtube.com/watch?v=zJD2jLjXsls"
#I Can't Wait
t = "https://www.youtube.com/watch?v=UJ1tBVtYOBc"
#Rocketeer
u = "https://www.youtube.com/watch?v=hnK5sv9mWeo"
#Sit Next to Me
v = "https://www.youtube.com/watch?v=uypLTcMfwHE"
#Stylo
w = "https://www.youtube.com/watch?v=OmwZtFwFj94"
#Stand by Me
x = "https://www.youtube.com/watch?v=xICj8-Psl5A"
#Zion and Babylon
y = "https://www.youtube.com/watch?v=O7mgzsZOnoI"
#Lean on
z = "https://www.youtube.com/watch?v=rn9AQoI7mYU"
foo = [a,b,c,d,e,f,g,h,i,j,k,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
# 'l' is omitted from list foo becasue the algorythm that selects numbers at random seems to favor 'l'
def take_a_break():
for i in range (1,1000*1000):
time.sleep(1)
print(i + 1)
if i % 3600 == 0:
webbrowser.open(random.choice(foo))
take_a_break()
@CHBaker
Copy link

CHBaker commented Jan 9, 2018

Hey @Pfuufy, Nice program! I remember writing this one. I tried to make mine into a fork bomb so i could blast my friends with youtube videos. It looks good, there are a few ways you can improve it, but it's relatively simple and not a whole lot of optimization will make much of a difference here. As far as omitting 'l', check out this post about randomness and the birthday paradox.

One thing you can do, if you want to create more of a human sense of randomness or keep songs from repeating, is store the random choice in an array (like a cache) and the next time it chooses that song, make it keep choosing until it is a different song. Maybe your cache could store even 3 songs, bumping out the last in the list and adding the newest addition, to keep your playlist fresh to death.

Good choice using random.choice though, it's a bit faster than randint (randing produces a random integer but has another layer of function calls, that integer can be used to access a random list number, say foo[i])

But it looks good man, keep up the good work!

@gabrielbissey
Copy link
Author

gabrielbissey commented Jan 10, 2018

Thanks for the input! Is there a way you know of to assign variables to songs in a more efficient way? That's where I feel this code was the weakest. The only other way I could think of is to instead open a link to a youtube playlist with the songs set on random. But that wouldn't be as much of a challenge to code ;)

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