Skip to content

Instantly share code, notes, and snippets.

@WillKirkmanM
WillKirkmanM / modulus.js
Created December 23, 2023 14:10
How Modulus Works
function modulus(a, b) {
let c = parseInt(a / b)
let d = c * b
return a - d
}
@WillKirkmanM
WillKirkmanM / humanize.js
Created December 23, 2023 13:50
Turn Minutes into Human Time (Cinema)
function humanize(minutes) {
return `${(minutes / 60).toFixed(0)} Hours ${minutes % 60} Minutes`
}
@WillKirkmanM
WillKirkmanM / streaming.rs
Created December 18, 2023 15:42
Media Streaming in Rust (Partial Content 206)
async fn stream_song() -> impl Responder {
let media = "MEDIA PATH"
let bitrate = 1000;
let start = 0;
let end = seconds * bitrate * 1000 / 8; // convert seconds to bytes
let mut file = File::open(media).unwrap();
file.seek(SeekFrom::Start(start)).unwrap();
@WillKirkmanM
WillKirkmanM / reset.sh
Created December 18, 2023 15:40
Undo Last Commit
git reset --soft HEAD~
@WillKirkmanM
WillKirkmanM / linecount.py
Created October 12, 2023 09:56
Lines of Code Counter
import os
import argparse
parser = argparse.ArgumentParser(description="A File Counter")
# Arguments
parser.add_argument("directory", help="The directory that you would like to scan")
args = parser.parse_args()
@WillKirkmanM
WillKirkmanM / IA.py
Last active September 21, 2023 11:30
List of Chemistry IA's (From https://www.clastify.com/ia/chemistry) | BeautifulSoup Parsing (Saves to File "IA.txt")
import requests
from bs4 import BeautifulSoup
def main():
page = requests.get("https://www.clastify.com/ia/chemistry", headers={'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 12_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148'})
soup = BeautifulSoup(page.content, 'html.parser')
elements = soup.find_all(class_="MuiTypography-root MuiTypography-subtitle2 css-ydl03f")
file = open("IA.txt", "w", encoding="utf-8")
for element in elements:
@WillKirkmanM
WillKirkmanM / AudioBook.py
Created September 17, 2023 14:07
Metadata Preserving Audiobook Converter From .m4b -> .mp3
import os
import subprocess
import sys
cwd = os.getcwd()
files = os.listdir(cwd)
for file in files:
extension = os.path.splitext(file)[1]