Skip to content

Instantly share code, notes, and snippets.

@tiburona
tiburona / sameStructureAs.js
Last active November 12, 2017 17:19
a modification to the JS array prototype to test whether two arrays have the same nesting structure
//a solution to this CodeWars kata: https://www.codewars.com/kata/nesting-structure-comparison/javascript
Array.prototype.sameStructureAs = function (other) {
// Return 'true' if and only if 'other' has the same
// nesting structure as 'this'.
const isArray = Array.isArray
var equal = true
@tiburona
tiburona / generate_AST.py
Created November 19, 2017 00:17
Lisp AST generator
def generate_AST(string):
# my implementation is currently supporting negative numbers and decimals,
# but not exponentiation
number_symbols = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '-']
ind = 1
arr_to_return = []
@tiburona
tiburona / lisp_ast.py
Last active November 19, 2017 16:13
a function to generate an AST from Lisp and another to interpret addition
def generate_AST(string):
# my implementation is currently supporting negative numbers and decimals,
# but not exponentiation
number_symbols = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', '-']
ind = 1
arr_to_return = []
@tiburona
tiburona / gist:a9b5d44b1a0e3305139f6bee0a597603
Created December 5, 2022 21:00
removeLineNoise_SpectrumEstimation.m
function [wave] = removeLineNoise_SpectrumEstimation(wave, fs, opts)
% [wave] = removeLineNoise_SpectrumEstimation(wave, [fs], [opts])
% removeLineNoise_SpectrumEstimation removes line noise (50/60 Hz) from a
% (chans/trials x samples) matrix, wave, which is samplel at fs Hz, and
% returns the de-noised matrix, wave.
% The behaviour of the line noise removal algorithm can be controlled by
% an optional input string, 'opts'. The following options are defined:
% NH = number of harmonics. (default: 1)
% LF = line frequency. (default: 50 Hz)
% TOL = error tolerence. (default: 1% tol)