Skip to content

Instantly share code, notes, and snippets.

View Mason-McGough's full-sized avatar
⛰️
Living in the right balance

Mason McGough Mason-McGough

⛰️
Living in the right balance
View GitHub Profile
@Mason-McGough
Mason-McGough / matplotlib_utils.py
Last active March 15, 2019 03:33
A collection of functions for plotting using Matplotlib
from .numpy_utils import subsample
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
def scatter_3d(X, sample_size=None, fig=None, subplot=None, title='X', xlabel='X',
ylabel='Y', zlabel='Z'):
"""
Create 3d scatterplot of N-by-3 array.
Inputs:
@Mason-McGough
Mason-McGough / numpy_utils.py
Created March 6, 2019 03:54
A collection of functions for examining and using Numpy arrays
import numpy as np
def subsample(x, n_samples, return_choices=False, replace=False):
"""
Randomly sample a subset of x.
Inputs:
x - The array to sample from.
n_samples - The number of samples to select from x.
return_choices - If True, returns an array of the random indices used to
@Mason-McGough
Mason-McGough / file_utils.py
Created March 6, 2019 03:53
Several functions for finding and copying files and folders
from os import listdir
from os.path import join, isdir, isfile
from re import sub
from shutil import copy
def list_files(loc, return_dirs=False, return_files=True, recursive=False, valid_exts=None):
"""
Return a list of all filenames within a directory loc.
Inputs:
@Mason-McGough
Mason-McGough / tensorflow_utils.py
Created March 6, 2019 03:51
Several helpful functions for creating, saving, and loading TensorFlow models
import os
import tensorflow as tf
from tensorflow import keras as K
from tensorflow.keras.layers import Input, Conv2D, MaxPooling2D, UpSampling2D, concatenate
from tensorflow.keras.layers import LeakyReLU as LReLU
# for python2
try:
FileNotFoundError
except NameError:
@Mason-McGough
Mason-McGough / vue-delimiters.js
Created September 19, 2018 01:59
How to override delimiters in Vue.js
// if using Vue as standalone / script tag
Vue.options.delimiters = ['V{', '}V'];
// if using Vue with in-browser compilation / full-build
var instance = new Vue({
el: '#id',
delimiters: ['V{', '}V'],
...
})
@Mason-McGough
Mason-McGough / nodejs-tips.md
Created September 15, 2018 22:48
NodeJS Tips

NodeJS Tips

Node Version Manager (nvm)

Install nvm

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
@Mason-McGough
Mason-McGough / nvm-ssl-certs.txt
Created September 15, 2018 22:35
`nvm ls-remote` fails due to out-of-date SSL certificate store on system
# After installing npm, using the following command:
nvm ls-remote
# This returned `N/A` for me, indicating that it could not pull any valid versions of `node` from the remote
# server. This was likely due to it trying to access https urls without valid certificates.
# After adding the following to `.bashrc`:
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
@Mason-McGough
Mason-McGough / tensorflow.txt
Created August 16, 2018 18:54
Tensorflow Tips
# list all devices
from tensorflow.python.client import device_lib
device_lib.list_local_devices()
@Mason-McGough
Mason-McGough / stripe_effect.html
Last active August 16, 2018 18:56
HTML Stripe Effect With Easy CSS/JS Variables
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<title>Stripe Effect</title>
<style>
body {
padding: 25px;
}
@Mason-McGough
Mason-McGough / anaconda_kernel.txt
Last active August 16, 2018 18:56
Add Anaconda Environment to Jupyter Notebook as Kernel
// Add Anaconda Environment to Jupyter Notebook as Kernel
conda install ipykernel
python -m ipykernel install --user --name myenv --display-name "Python (myenv)"
// Actually, just install this and be done with it https://github.com/Anaconda-Platform/nb_conda_kernels
conda install -c conda-forge nb_conda_kernels