Skip to content

Instantly share code, notes, and snippets.

View endolith's full-sized avatar
😑

endolith

😑
View GitHub Profile
@endolith
endolith / thesaurus.js
Created July 20, 2009 17:28
My test commands
// Search for synonyms of a word using thesaurus.com
// Should probably create an actual list of words and remove any duplicates, alphabetize them, etc.
CmdUtils.CreateCommand({
names: ["thesaurus", "synonyms of"],
homepage: "http://www.zacharyspencer.com/",
author: { name: "Zachary Spencer", email: "[email protected]"},
contributors: ["Zachary Spencer"],
license: "MPL",
arguments: [{role: "object",
@endolith
endolith / Has weird right-to-left characters.txt
Last active April 29, 2025 03:07
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@endolith
endolith / bedtime.py
Created July 29, 2009 03:11
Reverse alarm clock
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Use the Gnome screensaver to enforce bedtime or otherwise lock out the computer, and set an away message in Pidgin
# Note that the actual time it warns the user is whenever you call the script,
# so you can use more granularity than an hour, can set it for different times
# on different days, etc.
# You can enter your password and log back in if you want, but it will repeatedly lock you back out.
@endolith
endolith / bansheeserver.py
Created October 11, 2009 20:03
Banshee remote server (by Nikitas Stamatopoulos)
#!/usr/bin/env python
#Copyright (C) 2009 Nikitas Stamatopoulos
# Modified by [email protected] 2009-10
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
@endolith
endolith / maxima-init.mac
Created October 27, 2009 18:48
Maxima shortcuts for audio and electronics
/* Decibel conversion and inverse */
db(x) := float(20 * log(abs(x)) / log(10));
idb(x) := float(10^(x / 20));
/* For calculating components in parallel */
infix("||", 119, 119)$ "||"(x, y) := x * y / (x + y);
/* log(x) is always ambiguous from one language to the next. Now it's not. */
log10(x) := log(x) / log(10);
@endolith
endolith / Perfect_FFT.py
Last active June 16, 2023 08:25
Perfect FFT
from numpy import linspace, cos, pi, absolute
from numpy.fft import fft, fftfreq, fftshift
import matplotlib.pyplot as plt
# Sampling rate
fs = 64 # Hz
# Time is from 0 to 1 seconds, but leave off the endpoint, so
# that 1.0 seconds is the first sample of the *next* chunk
length = 1 # second
@endolith
endolith / readme.md
Last active October 18, 2024 13:16
THD+N calculator

Unfortunately, there are 2 versions of this. The other is here: https://github.com/endolith/waveform-analyzer I intend to either completely combine them or completely separate them, eventually.

Somewhat crude THD+N calculator in Python

Measures the total harmonic distortion plus noise (THD+N) for a given input signal, by guessing the fundamental frequency (finding the peak in the FFT), and notching it out in the frequency domain. This is a THDR

@endolith
endolith / peakdet.m
Last active February 10, 2025 19:45
Peak detection in Python [Eli Billauer]
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.
@endolith
endolith / frequency_estimator.py
Last active February 26, 2025 04:36
Frequency estimation methods in Python
from __future__ import division
from numpy.fft import rfft
from numpy import argmax, mean, diff, log, nonzero
from scipy.signal import blackmanharris, correlate
from time import time
import sys
try:
import soundfile as sf
except ImportError:
from scikits.audiolab import flacread
@endolith
endolith / location_codes.py
Created January 24, 2010 17:45
State and country code mappings for Python
#!/usr/bin/env python
"""
See http://opencountrycodes.appspot.com/python/
state_names returns a state name for a state code, like 'AK': 'Alaska'
country_names returns a country name for a country code, like 'AD': 'Andorra'
state_codes and country_codes are just the reverse
"""