Skip to content

Instantly share code, notes, and snippets.

@endolith
endolith / spectral_centroid.py
Created April 8, 2010 02:53
spectral centroid calculation
# http://en.wikipedia.org/wiki/Spectral_centroid
from __future__ import division
from numpy import abs, sum, linspace
from numpy.fft import rfft
spectrum = abs(rfft(signal))
normalized_spectrum = spectrum / sum(spectrum) # like a probability mass function
normalized_frequencies = linspace(0, 1, len(spectrum))
spectral_centroid = sum(normalized_frequencies * normalized_spectrum)
@endolith
endolith / delay.py
Last active February 22, 2026 01:48
Distance between two microphones from delay of collinear source
"""
Measure the distance between two microphones based on the delay of a
clap from a point that is collinear with the two microphones.
Make sure your signal isn't clipping.
First test:
2 electrets 26 cm apart, hand clap
Distance: -25.72 cm
Sub-sample distance: -26.02 cm
@endolith
endolith / google translated.txt
Created April 26, 2010 01:00
Transistor data
Comment availability in January 2004, Sato has been based on electricity.
● J-FET (measurement environment | Vds | = 10V)
Manufacturer, model number, voltage, V, current, A, Power, W, M, IDSS, Ciss, Crss, Yfs, Remarks
日電, (K68A), 50, V, -, A, 0.25, W, y, 0.5-12mA, 13p, 2.6p, 4.0-12 - mS, waste, low noise, high gm, difficulties in obtaining (Suzusho .)
日電, (J44/K163), 40, V, -, A, 0.4, W, y, 1.0-18mA, 50p/13p, 10p/3.2p, 7.0 ----- mS, waste, low noise, high gm, hard to obtain
日電, (K523), 50, V, -, A, 0.4, W, y, 1.0-18mA, 13p, 3.2p, 7.0 ----- mS, garbage, pin care DSG, low noise, high gm get difficult (Suzusho)
日電, (K533), 50, V, -, A, 0.4, W, y, 1.0-18mA, 13p, 3.2p, 7.0 ----- mS, K523 through the difficulty of obtaining for industrial (commercial bell)
Mitsubishi, J498/K2880, 50, V, -, A, 0.45, W, y, 0.6-12mA, 18p/8p, --/1.5p, 1.5-4.0-mS, J40/K381 hard to obtain
Toshiba, J109/K389, 30, V, -, A, 0.2, W, y, 2.6-20mA, 95p/25p, 25p/5.5p, 8.0-20 - mS, Dual
@endolith
endolith / gist:400494
Created May 13, 2010 21:42
Unicode cheatsheet
arrows ← ↑ → ↓ ↔ ↵ ⇐ ⇑ ⇒ ⇓ ⇔
pipes | ¦
math ± ∞ ×
greek Αα Ββ Γγ Δδ Εε Ζζ Ηη Θθ Ιι Κκ Λλ Μμ Νν Ξξ Οο Ππ Ρρ ΣσςΤτ Υυ Φφ Χχ Ψψ Ωω
misc ♥ •
@endolith
endolith / event_logger.py
Created May 15, 2010 00:46
Log datestamped strings to a .csv file
#!/usr/bin/env python
"""
Event logger
The basic idea is just to provide an interface dedicated to manual data
logging. It will log the exact date and time that the user enters strings,
and allow it to be formatted for output in various ways.
Should be able to prompt the user to enter something at a given interval.
@endolith
endolith / bl_waveforms.py
Last active April 1, 2025 17:22
Band-limited waveform generation in Python/SciPy
"""
Bandlimited versions of scipy.signal.waveforms.
Intent is mathematical perfection over performance;
these use additive synthesis, so they are slow, but exact.
Less ideal methods using BLIT:
Sawtooth can be made by integrating BLIT minus a DC value to prevent integrator wandering off
Square can be made by integrating bipolar BLIT
Triangle can be made by integrating square
@endolith
endolith / duration.ny
Created July 6, 2010 21:44
Audacity selection duration plug-in
;nyquist plug-in
;version 2
;type analyze
;name "Selection Duration..."
;action "Getting selection duration..."
;info "by David R. Sky, Steven Jones, Dominic Mazzoni\nReleased under terms of GNU Public License"
; Selection Duration by David R. Sky
; Code help from Steven jones, Dominic Mazzoni
; updated January 2, 2006
@endolith
endolith / measurement.ny
Created August 8, 2010 14:20
Audacity waveform analyzer plug-in
;nyquist plug-in
;version 1
;type analyze
;name "Amplitude statistics..."
;action "Calculate amplitude statistics..."
; [email protected]
; 2010-08
; Set the output format (example: 53.3 dB)
@endolith
endolith / livefilter.js
Created January 23, 2011 04:18
failed attempt at craigslist live filter
// ==UserScript==
// @name Craiglist Live Filter
// @namespace srawlins
// @description Filter out listings with given words on Craigslist
// @include http://*.craigslist.org/search/*
// ==/UserScript==
// v1.2
var clfDiv = document.createElement('div');
@endolith
endolith / AutoHotkey.ahk
Last active May 7, 2025 19:53
AutoHotkey_L Hotstrings and other utilities
;------------------------------------------------------------------------------
; Disable Insert key
;------------------------------------------------------------------------------
$Insert::return
!Insert::Send, {Insert} ; Use Alt+Insert to toggle the 'Insert mode'
;------------------------------------------------------------------------------
; Hand tool with middle button in Adobe Reader
;------------------------------------------------------------------------------
#IfWinActive ahk_class AdobeAcrobat