Skip to content

Instantly share code, notes, and snippets.

View npyoung's full-sized avatar

Noah Young npyoung

  • IndustrialNext
  • San Francisco
View GitHub Profile
@npyoung
npyoung / rl.py
Last active April 6, 2018 19:55
Simple Richardson-Lucy 3D on the CPU for testing purposes.
#!/usr/bin/env python3
import numpy as np
def centered(arr, newshape):
# Return the center newshape portion of the array.
newshape = np.asarray(newshape)
currshape = np.array(arr.shape)
startind = (currshape - newshape) // 2
endind = startind + newshape
myslice = [slice(startind[k], endind[k]) for k in range(len(endind))]
@npyoung
npyoung / cauchy_eq.py
Created February 22, 2018 18:55
Refractive index of cured IP-S
def n_IPS(lam):
# Cauchy equation
A, B, C = 1.4915, 4.8486e3, 1.3694e8
return A + B / lam**2 + C / lam**4
@npyoung
npyoung / init.sh
Last active November 5, 2019 02:12
AWS Ubuntu 16.04 CUDA box setup
#!/usr/bin/env bash
# Screen settings
wget https://gist.githubusercontent.com/npyoung/4d44b0700d743231ab82396be3ff242c/raw/36ad6447b43f3ca927cdb0a80b268ddbfc914ce5/.screenrc
# Get NVIDIA drivers
echo "Getting NVIDIA drivers"
wget http://us.download.nvidia.com/titan/linux/387.34/nvidia-driver-local-repo-ubuntu1604-387.34_1.0-1_amd64.deb &&
sudo dpkg -i nvidia-driver-local-repo-ubuntu1604-387.34_1.0-1_amd64.deb &&
sudo apt-key add /var/nvidia-driver-local-repo-387.34/7fa2af80.pub &&
@npyoung
npyoung / .screenrc
Created February 2, 2018 01:15
Simple screenrc setup
# Detach instead of dying if we disconnect
autodetach on
# Don't waste my time
startup_message off
# Keep scroll up history
defscrollback 30000
termcapinfo xterm* ti@:te@
@npyoung
npyoung / flycaptest.py
Created December 21, 2017 07:34
Testing FlyCapture (Point Grey camera)
import numpy as np
import PyCapture2
from sys import exit
if __name__ == '__main__':
# Ensure sufficient cameras are found
bus = PyCapture2.BusManager()
camInfos = bus.discoverGigECameras()
if not len(camInfos):
@npyoung
npyoung / fstab
Last active April 25, 2020 03:15
Sync Gamin Edge 500 to Dropbox
# Garmin
LABEL="GARMIN" /media/noah/GARMIN vfat noauto,sudo 0 0
@npyoung
npyoung / psth.py
Created September 14, 2017 21:10
Triggered selection from a Numpy array
def pst(x, triggers, window, axis=-1):
"""Extract windows along an axis centered around a list of indices.
Args:
x: Array from which windows should be extracted.
triggers: Indices in signal where the extracted sequences should be aligned to.
window: (before, after) tuple specifying the number of samples around
the trigger to extract.
axis: Axis along which to compute the PSTH.
@npyoung
npyoung / butterfilter.m
Created September 8, 2017 22:13
MATLAB utils
function [ y ] = butterfilter( x, cut, fs, type )
%BUTTEFILTER Apply a Butterworth filter
nyq = fs / 2;
cutf = cut / nyq;
if nargin == 4
[b, a] = butter(5, cutf, type);
elseif nargin == 3
[b, a] = butter(5, cutf);
@npyoung
npyoung / hashpass.py
Last active June 1, 2021 21:51
Hashpass recovery script
#!/usr/bin/env python
import base64, getpass, hashlib, argparse, pyperclip
ENCODING = 'utf-8'
def get_pass(domain, key):
bits = (domain + '/' + key).encode(ENCODING)
for i in range(2 ** 16):
@npyoung
npyoung / subplot_label.py
Created July 11, 2017 08:35
Automatically label subplots in a figure
def label_subplots(axes):
import string
for idx, ax in enumerate(axes):
ax.text(-0.1, 1.05, string.ascii_uppercase[idx], transform=ax.transAxes,
size=20, weight='bold')