Skip to content

Instantly share code, notes, and snippets.

View elibroftw's full-sized avatar

Elijah Lopez elibroftw

View GitHub Profile
@elibroftw
elibroftw / country_and_currencies.json
Last active June 18, 2023 14:31
A list of countries and the currencies each one uses. Data sourced from three sources.
{
"af": {
"currencyName": "Afghan afghani",
"currencyIso": "AFN",
"countryName": "Afghanistan",
"symbol": "\u060b",
"decimalPoint": ".",
"thousandsSeparator": ",",
"decimalPlaces": 2
},
@elibroftw
elibroftw / removeDuplicates.gs
Created April 23, 2023 22:20
Google Sheets script to remove duplicate rows related to MAC, IP addresses, and Semantic Versioning
function isNewerVersion(oldVer, newVer) {
const oldParts = oldVer.split('.');
const newParts = newVer.split('.');
for (var i = 0; i < newParts.length; i++) {
const a = ~~newParts[i]; // parse int
const b = ~~oldParts[i]; // parse int
if (a > b) return 1;
if (a < b) return -1;
}
return 0
[target.'cfg(target_os = "linux")'.dependencies]
dbus = "0.9"
@elibroftw
elibroftw / cs350_cli.py
Last active April 24, 2023 14:18
A CLI to increase productivity for the CS 350 Operating Systems course. This should sit two levels above the os161-X.Y directory. Script is robust enough to work with the naming convention recommended by the course as well as my own.
#!/usr/bin/python3
import argparse
import subprocess
from subprocess import DEVNULL
import os
import glob
from pathlib import Path
import time
import shutil
import sys
@elibroftw
elibroftw / sound_wave.py
Last active December 20, 2022 21:37
Generate sound waves for any audio file
import soundfile as sf
import numpy as np
import matplotlib.pyplot as plt
import io
from PIL import Image
def get_audio_wave(file):
data, samplerate = sf.read(file)
n = len(data)
@elibroftw
elibroftw / update_monerod.sh
Created April 29, 2022 21:14
Auto update monerod (Linux)
# sudo chmod +x update_monerod.sh
sudo sytemctl stop monerod
mkdir -p ~/Downloads && cd ~/Downloads
echo "Downloading and extracting Monero binaries"
curl -L https://downloads.getmonero.org/cli/linux64 | tar xj
rm -r -f ~/bin/monero && mkdir -p ~/bin
mv monero-*-linux-* monero
mv monero ~/bin
sudo systemctl start monerod
@elibroftw
elibroftw / get_multiple_file_types.py
Created April 4, 2022 05:19
Python get files of multiple extensions
# abstracted from https://github.com/elibroftw/music-caster/blob/master/src/music_caster.py :: get_audio_uris
import glob
import os.path
from pathlib import Path
MY_EXTS = {'.mp3', '.flac', '.m4a', '.mp4', '.aac', '.mpeg', '.ogg', '.opus', '.wma', '.wav'}
def valid_file_ext(uri) -> bool:
"""
@elibroftw
elibroftw / xlsx_to_js.py
Last active March 27, 2022 17:50
Excel file (xlsx) to Javascript array
import pandas as pd
import openpyxl
df = pd.read_excel(r'C:\Users\maste\Downloads\countries.xlsx')
javascript_1 = 'export const countries = [\n'
javascript_2 = 'export const countries_fr = [\n'
for _, row in df.iterrows():
row['EN'] = row['EN'].replace('’', "'")
@elibroftw
elibroftw / single_instance_alt.py
Created February 22, 2022 18:49
Python Single Instance Alternative?
## HELPERS AND CONSTANTS
def is_already_running(look_for='Music Caster', threshold=1):
raise NotImplementedError('https://gist.github.com/elibroftw/44844582287ce7386d1d9d5060e52972')
MUTEX_NAME = 'MusicCasterMutex{{FBE8A652-58D6-482D-B6A9-B3D7931CC9C5}'
PID_FILENAME = 'music_caster.pid'
LOCK_FILENAME = 'music_caster.lock'
@elibroftw
elibroftw / .bashrc
Last active February 11, 2022 02:05
Linux Add Directories to ENV::PATH
# ...
# .env_path format:
# path1
# path2
if [ -f ~/.env_path ]; then
export PATH=$PATH:$(python3 -c "import os; print(':'.join((line.strip() for line in open('.env_path').readlines() if line.strip())))")
fi
# Python code: