Skip to content

Instantly share code, notes, and snippets.

View endolith's full-sized avatar
😑

endolith

😑
View GitHub Profile
@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
"""
@endolith
endolith / peakdet.m
Last active February 14, 2024 21:27
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 / FIR_filter_NN.py
Last active February 6, 2024 19:15
Neural network learning FIR filter
"""
Train a neural network to learn an FIR filter.
Created on Fri Aug 3 15:00:40 2018
"""
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.callbacks import Callback
import numpy as np
from scipy import signal
@endolith
endolith / README.md
Last active February 6, 2024 19:13
Single neuron experiments

My first keras experiments:

  1. simplest.py — A single neuron with no activation function and no bias (so just input→weight→output, can learn y=mx functions only). Show the function for a few random weights. (Doesn't learn anything.)
  2. linear with bias.py — A single neuron with no activation function but with bias (so it can learn y=mx+b functions, such as relationship between Celsius and Fahrenheit).
  3. single_neuron_buffer.py — A single neuron with sigmoid activation and no bias, trained to learn a digital logic buffer.
  4. single_neuron_inverter.py — A single neuron with sigmoid activation and no bias, trained to learn an inverting analog amplifier.
@endolith
endolith / AutoCorrect.ahk
Last active January 31, 2024 14:02
AutoCorrect AutoHotkey spelling script
; c = case sensitive
; c1 = ignore the case that was typed, always use the same case for output
; * = immediate change (no need for space, period, or enter)
; ? = triggered even when the character typed immediately before it is alphanumeric
; r = raw output
;------------------------------------------------------------------------------
; CHANGELOG:
;
; 2011-03-21 and after: See readme.md
@endolith
endolith / LICENSE.txt
Last active January 14, 2024 07:37
Arduino hardware true random number generator
MIT License
Copyright (c) 2012 endolith
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@endolith
endolith / finite_scroll.txt
Last active January 8, 2024 12:31
Adblock ublock kill infinite scrolling
! Title: Finite Scroll (kills infinite scrolling)
! Last modified: 2017-10-24
! Homepage: https://gist.github.com/endolith/72ac5e69e037be02b118adbedcdeac59
! This URL: https://gist.githubusercontent.com/endolith/72ac5e69e037be02b118adbedcdeac59/raw/finite_scroll.txt
! TODO: Add these scripts: https://infinite-scroll.com/
! Forbes infinite scroll (and all other AJAX)
@endolith
endolith / chirpz.py
Last active January 7, 2024 11:29
Chirp Z-transforms in Python (by Paul Kienzle, Nadav Horesh, Stefan van der Walt)
"""Chirp z-Transform.
As described in
Rabiner, L.R., R.W. Schafer and C.M. Rader.
The Chirp z-Transform Algorithm.
IEEE Transactions on Audio and Electroacoustics, AU-17(2):86--92, 1969
"""
import numpy as np
@endolith
endolith / zfft.py
Created August 14, 2021 18:36 — forked from aluchies/zfft.py
Zoom FFT functionality. Includes implementation of chirpz transform.
""" Zoom FFT function"""
import numpy as np
from time import time
from scipy.fftpack import fft, ifft
from numpy import swapaxes
def chirpz(x, A=None, W=None, M=None):
"""chirpz(x, A, W, M) - Chirp z-transform of variable x
@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);