Skip to content

Instantly share code, notes, and snippets.

endolith

View GitHub Profile
@endolith
endolith / DFT_ANN.py
Last active Apr 15, 2019
Training neural network to implement discrete Fourier transform (DFT/FFT)
View DFT_ANN.py
"""
Train a neural network to implement the discrete Fourier transform
"""
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
import matplotlib.pyplot as plt
N = 32
batch = 10000
@endolith
endolith / mzti.m.py
Last active Dec 3, 2017
MZTi Matched Z-Transform improved lowpass example [Matlab→Python translation]
View mzti.m.py
from numpy import pi, exp, tan, sqrt, log10
import numpy as np
from scipy import signal
import matplotlib.pyplot as plt
def lp2_mzti(w0=None, K=None):
"""
Digital 2nd order lowpass filter design using
improved Matched Z transform (MZTi)
@endolith
endolith / finite_scroll.txt
Last active Jun 19, 2018
Adblock ublock kill infinite scrolling
View finite_scroll.txt
! 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)
View bounds_constraints_example.py
import numpy as np
from numpy import exp, sqrt, pi, cos, sin, e
import matplotlib.pyplot as plt
from scipy import optimize
import warnings
warnings.filterwarnings("ignore",".*GUI is implemented.*")
from scipy._lib._util import check_random_state
from scipy.optimize._basinhopping import AdaptiveStepsize, RandomDisplacement
@endolith
endolith / reverse_cmap.py
Last active Jul 26, 2017 — forked from stefanv/reverse_cmap.py
Reverse colormap
View reverse_cmap.py
from skimage import io as sio
import skimage
import numpy as np
import matplotlib.pyplot as plt
filename = 'Lennert jet.png'
img = skimage.img_as_float(sio.imread(filename))[:,:,:3]
jet = plt.cm.jet
@endolith
endolith / image_movie.py
Last active Jul 4, 2017
Display a folder of images very quickly
View image_movie.py
from tkinter import Tk, Label
from PIL import Image, ImageTk
import os
import sys
# Skip every n frames. Use 1 to show all images
skip = 1
try:
root = Tk()
@endolith
endolith / election_simulator.py
Last active Jan 12, 2019
Election simulator
View election_simulator.py
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 17 11:33:35 2016
"""
from __future__ import division, print_function
from numpy.random import multivariate_normal
import matplotlib.pyplot as plt
from scipy.spatial.distance import cdist
import numpy as np
@endolith
endolith / value_parser.py
Created Aug 25, 2016
Parse schematic component values
View value_parser.py
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 24 2016
"""
from __future__ import division, print_function, unicode_literals
prefixes = {
'Y': 1e24,
@endolith
endolith / boinc_temp.py
Last active Sep 16, 2016
Turn off BOINC if it's hot outside
View boinc_temp.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import subprocess
import re
weather = subprocess.check_output(['inxi', '-w'])
temp = int(re.search('\((\D?\d+) C\)', weather).groups()[0])
if temp > 15:
subprocess.call(['systemctl', 'stop', 'boinc-client'])
You can’t perform that action at this time.