Skip to content

Instantly share code, notes, and snippets.

View zperk13's full-sized avatar

Zachary Perkins zperk13

View GitHub Profile
@zperk13
zperk13 / look_and_say.rs
Created September 22, 2022 20:22
Just some code I wrote when watching https://youtu.be/EGoRJePORHs
#![allow(clippy::collapsible_else_if, dead_code)]
// Just some code I wrote when watching https://youtu.be/EGoRJePORHs
fn main() {
let start = 1;
let mut current = int_to_vec_of_binary_digits(start);
for _ in 0..1_000 {
let mut zeroes = 0;
@zperk13
zperk13 / animal_cousin.py
Created November 28, 2021 18:10
Find out how closely related two animals are in the Scientific Classification
# I wrote this code a long time ago lol
import requests
import re
from pprint import pprint
class Animal(object):
def __init__(self, name):
self.name = name
self.url_1 = f'https://en.wikipedia.org/wiki/{name.replace(" ", "_")}'
@zperk13
zperk13 / nws_weather_api.py
Last active August 22, 2021 23:20
Class for accessing NWS API
import requests
import typing
class NWSWeatherAPI:
def __init__(self, user_agent: str, longitude: str, latitude: str, ignore_test_alerts: bool = True, max_alert_cache_size: int = 256):
# Read about User-Agents here: https://www.weather.gov/documentation/services-web-api
self._user_agent_header = {'User-Agent': user_agent}
self._long_lat = f'{longitude},{latitude}'
self._api_url = 'https://api.weather.gov'
import os
from os.path import isdir
indent_amount = 4
collapse_amount = 10
indent_char = ' '
# indent_amount = 1
# collapse_amount = 5
# indent_char = '-'
@zperk13
zperk13 / imdb_cast_overlap_finder.py
Last active August 7, 2019 22:34
You give it multiple imdb title id's (eg: tt4154796) and it will look at the full cast and crew and find people who were in all of them
import re
import requests
from time import sleep
def unique(iter):
result = []
for x in iter:
if x not in result:
result.append(x)
@zperk13
zperk13 / color_namer.py
Last active December 30, 2019 00:19
Calculates the distance between colors, treating the rgb value as xyz in a 3 dimensional space, then finds the color with the shortest distance.
def abs(x):
if x < 0:
return 0 - x
else:
return x
def calculate_distance(rgb1, rgb2):
r1 = rgb1[0]
b1 = rgb1[1]