diff --git a/Computing Pi.py b/Computing Pi.py new file mode 100644 index 0000000..6f6e08c --- /dev/null +++ b/Computing Pi.py @@ -0,0 +1,45 @@ +import time +def calculate_next_square_root(number, square_root): + next_square_root = ((number / square_root) + square_root) / 2 + return next_square_root + +def calculate_square_root(number, digits, add): + square_root = 1 * (10 ** (digits + add)) + next_square_root = calculate_next_square_root(number=number, square_root=square_root) + while (next_square_root != square_root): + square_root = next_square_root + next_square_root = calculate_next_square_root(number=number, square_root=square_root) + return square_root +def calculate_next_pi(a, b, t, digits, add): + next_pi = ((10 ** (digits + add)) * ((a + b) ** 2)) / (4 * t) + return next_pi +digits = int(input('How many digits of pi? ')) +add = digits +a = 10 ** (digits + add) +b = calculate_square_root(number=(10 ** ((digits + add) * 2)) / 2, digits=digits, add=add) +t = (10 ** ((digits + add) * 2)) / 4 +p = 1 +pi = -1 +n = 0 +next_pi = calculate_next_pi(a=a, b=b, t=t, digits=digits, add=add) +while True: + try: + while (next_pi != pi): + pi = next_pi + next_a = (a + b) / 2 + next_b = calculate_square_root(number=a * b, digits=digits, add=add) + next_t = t - (p * ((a - next_a) ** 2)) + next_p = 2 * p + a = next_a + b = next_b + t = next_t + p = next_p + next_pi = calculate_next_pi(a=a, b=b, t=t, digits=digits, add=add) + n += 1 + pi /= (10 ** add) + pi = [int(i) for i in str(pi)] + + + except KeyboardInterrupt: + print ('\n',pi) + quit() diff --git a/Cubing.zip b/Cubing.zip new file mode 100644 index 0000000..9f6bddf Binary files /dev/null and b/Cubing.zip differ diff --git a/Meme Email Sender.zip b/Meme Email Sender.zip new file mode 100644 index 0000000..059bb81 Binary files /dev/null and b/Meme Email Sender.zip differ diff --git a/SCAN0002.JPG b/SCAN0002.JPG new file mode 100644 index 0000000..5050336 Binary files /dev/null and b/SCAN0002.JPG differ diff --git a/SCAN0003.JPG b/SCAN0003.JPG new file mode 100644 index 0000000..795b4e5 Binary files /dev/null and b/SCAN0003.JPG differ diff --git a/TicTacToe.py b/TicTacToe.py new file mode 100644 index 0000000..4bfc0ae --- /dev/null +++ b/TicTacToe.py @@ -0,0 +1,58 @@ +class TicTacToe: + def __init__(self): + self.board = {'a3':' ','b3': ' ','c3': ' ','a2' : ' ','b2':' ','c2' : ' ', 'a1': ' ', 'b1' : ' ','c1' : ' '} + self.turn = 'X' + self.turns = 0 + def flipTurn(self,turn): + return {'X':'O','O':'X'}[turn] + def printBoard(self): + print('\n'*200, + ''' + {} | {} | {} 3 + ---------- + {} | {} | {} 2 + ---------- + {} | {} | {} 1 + a b c + '''.format(self.board['a3'],self.board['b3'],self.board['c3'],self.board['a2'],self.board['b2'],self.board['c2'],self.board['a1'],self.board['b1'],self.board['c1'])) + def getWin (self,space1,space2,space3): + if(self.board[space1] == 'X' and self.board[space2] == 'X' and self.board[space3] == 'X' or self.board[space1] == 'O' and self.board[space2] == 'O' and self.board[space3] == 'O'): + input('{} won! Ctrl+C to quit, enter to start a new game'.format(self.flipTurn(self.turn))) + win = True + import TicTacToe + quit() + def testers(self): + self.getWin('a3','b3','c3') + self.getWin('a2','b2','c2') + self.getWin('a1','b1','c1') + self.getWin('a3','a2','a1') + self.getWin('b2','b3','b1') + self.getWin('c1','c2','c3') + self.getWin('a1','b2','c3') + self.getWin('a3','b2','c1') + def gameLoop(self): + self.win = False + while True: + if self.turns == 9: + input('Enter to play again, CTRL + C to quit') + import TicTacToe + quit() + self.printBoard() + self.testers() + self.turns += 1 + print('It is ',self.turn,"'s turn. Put in move: ") + invalid = True + while(invalid): + place = input() + if(place in self.board.keys()): + if(self.board[place] == ' '): + invalid = False + if not self.win: + if self.turns == 9: + print('Cat') + else: + print('That move is invalid. Try again!') + self.board[place] = self.turn + self.turn = self.flipTurn(self.turn) +board = TicTacToe() +board.gameLoop() diff --git a/cloud.html b/cloud.html new file mode 100644 index 0000000..267ca54 --- /dev/null +++ b/cloud.html @@ -0,0 +1,17 @@ + + + +
+ + + + + + +I don't know if any of these run outside of Unix-based systems. Most programs work best in the terminal. You must have all dependencies.
+ Send Random Memes to Friends Via Gmail + + Tic Tac Toe in Python + + Random Password Word Generator That Somewhat Makes Sense + + Cubing Timer and PLL trainer! + + Pi to the Nth Digit + + A programmable voice assistant in Python! Keep this in a file, as all the extra mp3s generate a alot. +Hello! My name is Logan Hunt! I love to program, even though I'm not that good at it. I made this website so I could share my programs, have some games, and share files. Some other interests of mine are speedcubing, speedrunning SM64, Super Metroid, Super Meat Boy, and Portal. I love to play violin, science bowl, and video games. +
+ + + +Hello! My name is Logan Hunt! I love to program, even though I'm not that good at it. I made this website so I could share my programs, have some games, and share files. Some other interests of mine are speedcubing, speedrunning SM64, Super Metroid, Super Meat Boy, and Portal. I love to play violin, science bowl, and video games. +
+ + + + + + + + +Click the button to display a random number.
+ + + + + + + + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..aa9af4d --- /dev/null +++ b/style.css @@ -0,0 +1,38 @@ +{ + padding: 0; + margin: 0; +} +body { + overflow-x: hidden; +} +canvas { + width: 100vw; + height: 100vh; + display: block; + position: fixed; + top: 0; + left: 0; + z-index: -9999; +} +#textbox { + margin: 10vh auto 0 auto; + background: rgba(255, 0, 0,0.8); + border-radius: 30px/50px; + padding: 5vh 2vw; + width: 30vw; +} +h1 { + text-align: center; + font-family: 'Open Sans Condensed', sans-serif; + font-size: 300%; + color: rgba(0, 255, 0,0.5); +} +p,ul { + font-family: 'Asar', serif; +} +a { + text-decoration: none; +} +a:visited { + color: blue; +} diff --git a/voiceassistant.py b/voiceassistant.py new file mode 100644 index 0000000..95e2af0 --- /dev/null +++ b/voiceassistant.py @@ -0,0 +1,124 @@ +import speech_recognition as sr +import subprocess +import time +import os +import pyowm +import urllib.request +import yagmail +import webbrowser +import wikipedia +import random +import json +import pyaudio +import wave +from gtts import gTTS +from os import path +from pprint import pprint +def recordSound(name,time_record): + CHUNK = 2**14 + FORMAT = pyaudio.paInt16 + SHORT_NORMALIZE = (1.0/(2**15)) + CHANNELS = 1 + RATE = 44100 + RECORD_SECONDS = time_record + WAVE_OUTPUT_FILENAME = name+".wav" + p = pyaudio.PyAudio() + stream = p.open(format=FORMAT,channels=CHANNELS,rate=RATE,input=True,frames_per_buffer=CHUNK) + os.system('aplay sound.wav') + print("Recording") + frames = [] + for i in range(0, int(RATE / CHUNK * RECORD_SECONDS)): + data = stream.read(CHUNK) + frames.append(data) + print("Done recording") + stream.stop_stream() + stream.close() + p.terminate() + wf = wave.open(WAVE_OUTPUT_FILENAME, 'wb') + wf.setnchannels(CHANNELS) + wf.setsampwidth(p.get_sample_size(FORMAT)) + wf.setframerate(RATE) + wf.writeframes(b''.join(frames)) + wf.close() + time.sleep(3) +recordSound('output',5) +loctime = time.localtime() +email = '' #<-------- GMAIL ADRESS MUST BE GMAIL +pwd = '' #<-------- Password +yag = yagmail.SMTP(email, pwd) +contacts = {"YOUR CONTACT'S NAME GOES IN THESE QUOTES":"THE CONTACT'S EMAIL GOES IN THESE QUOTES","YOUR SECOND CONTACT'S NAME GOES IN THESE QUOTES":"THE 2ND CONTACT'S EMAIL GOES IN THESE QUOTES"} +#<----------- CHANGE THIS DICTIONARY TO YOUR EMAIL CONTACTS, YOU CAN ADD AS MANY CONTACTS AS YOU WANT USING THIS DICT +AUDIO_FILE = path.join(path.dirname(path.realpath(__file__)), "output.wav") +r = sr.Recognizer() +with sr.AudioFile(AUDIO_FILE) as source: + audio = r.record(source) +var = r.recognize_google(audio).lower() +def voiceMessage(what_to_say,name_of_file): + tts = gTTS(text = what_to_say,lang = 'en',slow = False) + name_of_file += '.mp3' + tts.save(name_of_file) + os.system('mpg321 '+name_of_file) +if var == 'shuffle' or var == 'truffle': + pandora_urls = ['a pandora station url', 'another pandora station url', 'and another'] #<-------- CHANGE TO YOUR STATIONS + choice = random.choice(pandora_urls) + webbrowser.open(choice) + time.sleep(600) + pyautogui.hotkey('ctrl','shift','q') +elif var.count('email') == 1: + recipient_contact = var.split()[1] + recipient_email=contacts[recipient_contact] + if recipient_contact in contacts: + ist = var.split() + del ist[0] + del ist[1] + message = '' + for i in ist: + message = message + ' ' + i + message = message.replace(recipient_contact,'') + newmsg = message.title() + yag.send(recipient_email, 'No Subject', newmsg) + #Email people +elif var == 'weather' or var == 'brother': + owm = pyowm.OWM('YOUR OPEN WEATHER MAP API KEY') #Sign up for open weather map + observation = owm.weather_at_place("Redding,us")# <----------CHANGE THIS TO YOUR CITY!!! + w = observation.get_weather() + temperature = w.get_temperature('fahrenheit') + voiceMessage('Lowest temperature is {} degrees Fahrenheit. Current temperature is {} degrees Fahrenheit. Highest temperature is {} degrees Fahrenheit'.format(round(temperature['temp_min']),round(temperature['temp']),round(temperature['temp_max'])),'weather') + #Weather +elif var.count('wikipedia') >=1: + var = var.replace('wikipedia','') + tts = gTTS(wikipedia.summary(var),'wiki') + #Wikipedia stuff +elif var == 'quote': + try: + os.remove('qod.json') + except OSError: + pass + os.system('wget http://quotes.rest/qod.json') + with open('qod.json') as opened_data: + json_data = json.load(opened_data) + talk = json_data['contents']['quotes'][0]['quote'] + talk = talk.replace('"','') + voiceMessage(talk,'qotd') + #Quote of the day from some website that had a good API +elif var == 'where to dump dead bodies': + voiceMessage('Do not dump dead bodies, instead, carve them up with a cerrated knife into 5 centimeter by 5 centimeter cubes and send them to the government for soylent green. Thank you for helping the future!','dead') +elif var == 'time': + voiceMessage('The time is {} hours and {} minutes'.format(loctime[3],loctime[4]),'time') + #Play local time +elif var == 'are you recording this': + voiceMessage('I am always listening, and I am always reporting to the National Security Administration on suspicious activities.','NSA') +elif var == 'tell me a joke' or var == 'joke': + jokes = ["""A man flying in a hot air balloon suddenly realizes he’s lost. He reduces height and spots a man down below. He lowers the balloon further and shouts to get directions, "Excuse me, can you tell me where I am?" The man below says: "Yes. You're in a hot air balloon, hovering 30 feet above this field." "You must work in Information Technology," says the balloonist. "I do" replies the man. "How did you know?" "Well," says the balloonist, "everything you have told me is technically correct, but It's of no use to anyone." The man below replies, "You must work in management." "I do," replies the balloonist, *"But how'd you know?"** "Well", says the man, "you don’t know where you are or where you’re going, but you expect me to be able to help. You’re in the same position you were before we met, but now it’s my fault.""",'When your hammer is C++, everything begins to look like a thumb.',"What's the object oriented way of becoming wealthy? Inheritance","What's a computer scientists favorite place to hangout? Foo bar","I’ll tell you a DNS joke but be advised, it could take up to 24 hours for everyone to get it.","So I want to dress up as a UDP packet for Halloween, but I don’t know if anyone will get it.","I could tell you an ICMP joke but it would probably be repetitive.","Linux geek started working at McDonalds. A customer asked him for a Big Mac and he gave him a bit of paper with FF:FF:FF:FF:FF:FF written on it."] + #You can change these jokes if you wish + voiceMessage(random.choice(jokes),'joke') + #Random programming/computer science joke +elif var == 'toby' or var == 'tobi': + os.system('mpg321 Toby.mp3') + #Play Heyeayeayea +elif var.count('record me as') == 1: + print(var) + recordSound(var.split()[3],int(var.split()[4])) + #e.g. record me as foobarbaz 20 this will record you as foobarbaz.wav for 20 seconds +else: + voiceMessage('Your message {} could not be understood.'.format(var),'error') diff --git a/webcomic.html b/webcomic.html new file mode 100644 index 0000000..20810f3 --- /dev/null +++ b/webcomic.html @@ -0,0 +1,133 @@ + + +Comic about computer science, chess, and more.
ML
Paul and Timmy.
+Sketches of Jeff, Timmy, Shaun, Mason, Paul.
+ML comics, founded by Miranda and Logan Hunt, is a webcomic with much inspiration from xkcd.
+Miranda is a creative young woman wtih a lot of talent. She is a great artist, is very good at playing the piano, and loves hanging out with her friends.
+
+
+