Skip to content

Instantly share code, notes, and snippets.

View JohannSuarez's full-sized avatar

Johann Suarez JohannSuarez

View GitHub Profile
@JohannSuarez
JohannSuarez / dur.sh
Created June 14, 2023 01:18
Get total duration of .wav and .mp3 files in a directory
#!/bin/bash
# Function to calculate the total duration
calculate_total_duration() {
local dir="$1"
local total_duration=0
# Loop through each audio file
while IFS= read -r -d '' file; do
# Check if the file is a .wav or .mp3 file
@JohannSuarez
JohannSuarez / unsilence.py
Created June 14, 2023 00:48
Unsilence ( removes silent parts of an audio file )
#! /usr/bin/python3
import argparse
import subprocess
import os
def remove_silence(filename, noise_tolerance='-30dB', silence_duration='0.5'):
# Extract the base filename and extension
base_filename, extension = os.path.splitext(filename)
@JohannSuarez
JohannSuarez / split_song.sh
Created June 14, 2023 00:36
Split Audio Into Smaller Files
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Usage: $0 <input_song>"
exit 1
fi
input_song="$1"
extension="${input_song##*.}"
@JohannSuarez
JohannSuarez / example.service
Created February 18, 2022 02:39
Very basic SystemD Unit
# Put this on /etc/systemd/system
[Unit]
Description=A very simple service
After=network-up.target
[Service]
ExecStart=/usr/bin/buckle
[Install]
WantedBy=multi-user.target
@JohannSuarez
JohannSuarez / client_upload.py
Created January 24, 2022 09:47
Post Image to FastAPI endpoint
import requests
file_name: str = "hope_sandoval.jpg"
headers = {
'accept': 'application/json',
'Content-Type': 'multipart/form-data',
}
file = {
@JohannSuarez
JohannSuarez / ytapi.py
Created November 29, 2021 02:19
Harvest YouTube Playlist Videos
"""
A python script that uses YouTube's API to
harvest a private playlist list.
It grabs video titles, publish dates, uploader information, etc.
You'll need a client_secret.json, which can be obtained here:
https://console.cloud.google.com/
(OAuth 2.0 Client IDs)
@JohannSuarez
JohannSuarez / icci.py
Created November 9, 2021 02:12
Incrementing Continuous Compound Interest
'''
Suppose I spend $20,000 on a mining rig, and it mines $120 worth of crypto each day.
We then consistently stake its daily revenue into a yield farming platform at a rate of 12% per year,
with the yield immediately claimed and restaked.
How much money would we make after n days?
At what day do we break even? (Assuming we're not paying for maintenance or electric bill)
'''
@JohannSuarez
JohannSuarez / faraday.js
Created October 28, 2021 17:44
Iterate Through a Github Org and Download Each Repo ( Assuming has private repo access )
/*
IMPORTANT:
You must have a .env file in the same directory as this script
that contains your personal access token.
Get one here: https://github.com/settings/tokens
In the .env , put your access token like so:
GH_TOKEN='ACCESS_TOKEN'