This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# list profile paths loading variables | |
sudo bash -c "echo exit|dtruss bash -li|& less|grep '^open'" | |
# .bash_profile is for login shell, whereas .bashrc is for non-login shell (SSH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add a new default shell | |
sudo vim /etc/shells | |
chsh -s <path to shell> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
t = np.linspace(0, 4*np.pi, 100) | |
y1 = np.sin(t) | |
randomizer = lambda x: x + np.random.choice([-1, 1])*np.random.rand() | |
# y2 = np.apply_along_axis(randomizer, 0, y1) # applies once on whole array instead of per element of array | |
vRandomizer = np.vectorize(randomizer) | |
y2 = vRandomizer(y1) | |
corr = np.corrcoef(y1, y2)[0, 1] # choose a value from the left --> right diagonal; either [0, 1] or [1, 0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def grad_n(y, x, n, edge_order=2): | |
g = np.gradient(y, x, edge_order=edge_order) | |
for _ in range(n-1): | |
g = grad_n(g, x, 1, edge_order=edge_order) | |
return g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
x1 = np.ma.array([0, 1, 2, 3, 4]) | |
x1.mask # --> [False] | |
x2 = np.ma.array([0, 1, 2, 3, 4], mask=[False]) # triggers mask expansion | |
x2.mask # --> [False, False, False, False, False] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def drop_tracker(curArr, rmIndxs, dropTracker): | |
""" | |
Track values that are removed from an array. | |
dropTracker is a MaskedArray that curArr has derived from and slightly changed. | |
Requires curArr pts to be closer to their complimentary dropTracker pts more than any other dropTracker pts. | |
""" | |
assert type(dropTracker) is np.ma.MaskedArray | |
newArr = np.delete(curArr, rmIndxs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# https://github.com/estysdesu/dotFiles/blob/master/bash/.bash_profile | |
alias ppPATH="echo $PATH | tr -s ':' '\n'" # each path member gets it's own line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateSize() { | |
var projectTile = document.querySelectorAll("#projects .tile.is-child"); | |
projectTile.forEach( function(tile, index) { | |
if (window.innerWidth > 768) { | |
tile.style.height = getComputedStyle(tile).width; | |
} else { | |
tile.style.height = null; | |
} | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import window # https://gist.github.com/estysdesu/af7301fa17817c0d0ac7b5f8952c9bfe | |
def median_filt_1d(data, w_size): | |
""" Median filter for 1d data. Edges are handled with a window shift. """ | |
windowed_data = window(data, w_size) | |
w_half_size = w_size//2 | |
for i, w_data in enumerate(windowed_data): | |
w_data_sort = sorted(w_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
def window(data, w_size): | |
""" Get all windows for a list with an odd window size. """ | |
if not getattr(data, '__iter__', False): | |
raise ValueError("data must be an iterable") | |
if w_size%2 != 1: | |
raise ValueError("window size must be odd") | |
if w_size > len(data): | |
raise ValueError("window size must be less than the data size") |
OlderNewer