Skip to content

Instantly share code, notes, and snippets.

View Tremus's full-sized avatar
👻
Focusing

Trémus Tremus

👻
Focusing
View GitHub Profile
import numpy as np
# CONSTANTS
WT_SIZE = 2048
PLAYBACK_FREQ = 440
MAX_HARMONIC = 20000
# saw WT, -1 - 1.0
SAW = np.arange(-1.0, 1.0, 2 / WT_SIZE)
# usually this would be cached so we can keep
# reading the partials any time we need to generate
# a new WT
#!/bin/bash
# Author: Trémus
# Simply loops through the files in the directory you call this script
# that will normalise the 'integrated loudness' of your music files to
# settings similar to the default Platinum Notes settings.
# Results are saved in ./output.
# Change the bitrate from 128k if you need a higher one, this was intended
# to be used in conjuction with SoundCloud rips, and SC streams at 128kbps.
#!/bin/bash
# Author: Trémus
# Description: Downloads mp3s from YouTube & Soundcloud, adds metadata incl. BPM and album art
# Originally made for OSX. May fail on linux (probably 'sed' commands)
# Dependencies:
# - python
# - pip packages:
# - youtube-dl (downloads music)
# - aubio (calculates bpm)
@Tremus
Tremus / html_parser.py
Created February 12, 2020 10:31
Recreated some get functions used in JS by 'document'
import re
from html.parser import HTMLParser
# https://docs.python.org/3.6/library/html.parser.html#module-html.parser
SELF_CLOSING_TAGS = {
'area',
'base',
'br',
'col',
'embed',
@Tremus
Tremus / handle_bad_connection.py
Last active June 26, 2018 09:43
Ever find yourself scraping data on bad internet connection? Then you need to relaunch your whole sequence again, possibly from the start. Or maybe you shut and reopened your laptop. This is a simply retry wrapper
from time import sleep
import socket
def internet_connection(host="8.8.8.8", port=53, timeout=3):
"""
Host: 8.8.8.8 (google-public-dns-a.google.com)
OpenPort: 53/tcp
Service: domain (DNS/TCP)
Source: https://stackoverflow.com/questions/3764291/checking-network-connection