Skip to content

Instantly share code, notes, and snippets.

View matthewraaff's full-sized avatar
🖥️

Matthew Raaff matthewraaff

🖥️
View GitHub Profile
@matthewraaff
matthewraaff / jevons.py
Created February 26, 2024 23:29
find multiple quick (solve Jevons's number) - python
def findMulti(num: int) -> tuple:
limit = int(num ** 0.5) + 1
for a in range(1, limit):
if num % a == 0:
b = num // a
if not 1 in (a, b):
return a, b
return False
print(findMulti(8616460799))
@matthewraaff
matthewraaff / data.py
Created January 1, 2024 15:00
Interpreting the "semi-raw" mode-s data file, and finding which downlink format comes up the most often
import pyModeS as pm
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
def openFile(filename: str="log.txt") -> list:
_f = open("log.txt", "r")
_ls = []
for _i in _f.readlines():
_ls.append(_i)
@matthewraaff
matthewraaff / haversine.py
Created December 11, 2023 14:31
Haversine function written in Python 3.12
from math import radians, sin, cos, tan, sqrt, atan2
RADIUS = 6356.752
class Coordinate():
def __init__(self, point_a: float, point_b: float):
self.a = point_a
self.b = point_b
def __repr__(self) -> str:
@matthewraaff
matthewraaff / music.py
Last active December 18, 2023 14:18
youtube music downloader
from pytube import YouTube, Playlist
import os
from datetime import timedelta
def download_audio(video_url, output_path='music'):
yt = YouTube(video_url)
audio_stream = yt.streams.filter(only_audio=True, file_extension='mp4').first()
os.makedirs(output_path, exist_ok=True)
audio_stream.download(output_path)
print("Download complete!")